[{"data":1,"prerenderedAt":640},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Ffleet\u002Flifecycle":3},{"id":4,"title":5,"body":6,"description":16,"extension":634,"meta":635,"navigation":307,"path":636,"seo":637,"stem":638,"__hash__":639},"docs\u002Fdocs\u002Fv2\u002Ffleet\u002Flifecycle.md","Lifecycle",{"type":7,"value":8,"toc":626},"minimark",[9,13,17,28,33,36,129,152,167,201,208,211,215,221,228,231,235,238,249,259,263,266,418,421,425,428,434,437,504,512,519,523,526,601,608,611,614,622],[10,11,5],"h1",{"id":12},"lifecycle",[14,15,16],"p",{},"How a string becomes a running agent, and what happens when the run ends.",[18,19,24],"pre",{"className":20,"code":22,"language":23},[21],"language-text","axon exec review.axon.ts\n  │\n  ├─ resolve every reference     ← fails here if an agent is missing\n  ├─ boot in parallel            ← capsules start, modules connect\n  ├─ run the script              ← your code\n  └─ shut everything down        ← always, including on failure\n","text",[25,26,22],"code",{"__ignoreMap":27},"",[29,30,32],"h2",{"id":31},"resolving-a-reference","Resolving a reference",[14,34,35],{},"Every agent reference is a string, and one resolver turns it into a directory.",[18,37,41],{"className":38,"code":39,"language":40,"meta":27,"style":27},"language-ts shiki shiki-themes dark-plus","await Fleet({\n    barry: \"..\u002Fbarry\",           \u002F\u002F a path, relative to the script\n    dave:  \"~\u002Fagents\u002Fdave\",      \u002F\u002F a path, absolute\n    scout: \"scout\",              \u002F\u002F a name — your profile, then watched paths\n    zeno:  \"@axon\u002Fzeno\",         \u002F\u002F a registry package\n})\n","ts",[25,42,43,60,78,93,108,123],{"__ignoreMap":27},[44,45,48,52,56],"span",{"class":46,"line":47},"line",1,[44,49,51],{"class":50},"sYbnZ","await",[44,53,55],{"class":54},"sCudf"," Fleet",[44,57,59],{"class":58},"sTNBD","({\n",[44,61,63,67,71,74],{"class":46,"line":62},2,[44,64,66],{"class":65},"s3F5K","    barry:",[44,68,70],{"class":69},"sKc5r"," \"..\u002Fbarry\"",[44,72,73],{"class":58},",           ",[44,75,77],{"class":76},"sOLPB","\u002F\u002F a path, relative to the script\n",[44,79,81,84,87,90],{"class":46,"line":80},3,[44,82,83],{"class":65},"    dave:",[44,85,86],{"class":69},"  \"~\u002Fagents\u002Fdave\"",[44,88,89],{"class":58},",      ",[44,91,92],{"class":76},"\u002F\u002F a path, absolute\n",[44,94,96,99,102,105],{"class":46,"line":95},4,[44,97,98],{"class":65},"    scout:",[44,100,101],{"class":69}," \"scout\"",[44,103,104],{"class":58},",              ",[44,106,107],{"class":76},"\u002F\u002F a name — your profile, then watched paths\n",[44,109,111,114,117,120],{"class":46,"line":110},5,[44,112,113],{"class":65},"    zeno:",[44,115,116],{"class":69},"  \"@axon\u002Fzeno\"",[44,118,119],{"class":58},",         ",[44,121,122],{"class":76},"\u002F\u002F a registry package\n",[44,124,126],{"class":46,"line":125},6,[44,127,128],{"class":58},"})\n",[14,130,131,132,135,136,135,139,142,143,147,148,151],{},"A reference starting ",[25,133,134],{},".",", ",[25,137,138],{},"~",[25,140,141],{},"\u002F"," or containing a slash is a ",[144,145,146],"strong",{},"path",", resolved against\n",[144,149,150],{},"the script's own directory"," — not where you invoked from, which is what keeps a script\nportable. If nothing is there it throws: a path states where the agent is, so a miss is a\nmistake, not an invitation to go looking.",[14,153,154,155,158,159,166],{},"Anything else is a ",[144,156,157],{},"name",", resolved in order: your profile's agents, then each\n",[160,161,163],"a",{"href":162},"\u002Fdocs\u002Fv2\u002Fcli\u002Fwatch",[25,164,165],{},"axon watch"," root, then — for a scoped package — the registry, which\nfetches and installs it for next time. First match wins, so a local copy always shadows a\npublished one.",[18,168,172],{"className":169,"code":170,"language":171,"meta":27,"style":27},"language-bash shiki shiki-themes dark-plus","axon watch ~\u002Fagents          # make everything under here addressable by bare name\naxon install @axon\u002Fzeno      # resolve and cache ahead of time, so no run pays for it\n","bash",[25,173,174,188],{"__ignoreMap":27},[44,175,176,179,182,185],{"class":46,"line":47},[44,177,178],{"class":54},"axon",[44,180,181],{"class":69}," watch",[44,183,184],{"class":69}," ~\u002Fagents",[44,186,187],{"class":76},"          # make everything under here addressable by bare name\n",[44,189,190,192,195,198],{"class":46,"line":62},[44,191,178],{"class":54},[44,193,194],{"class":69}," install",[44,196,197],{"class":69}," @axon\u002Fzeno",[44,199,200],{"class":76},"      # resolve and cache ahead of time, so no run pays for it\n",[14,202,203,204,207],{},"Pin a version (",[25,205,206],{},"\"@axon\u002Fzeno@1.4.0\"",") when you need an agent to stay put. Unpinned resolves\nto whatever is installed, and fetches the latest if nothing is.",[14,209,210],{},"Resolution completes for the whole set before anything boots. A fleet comes up whole or\nnot at all — a script holding two working agents and one broken one is the outcome this\nprevents.",[29,212,214],{"id":213},"teardown","Teardown",[14,216,217,220],{},[25,218,219],{},"axon exec"," owns the process. When the script finishes — returns, throws, or is\ninterrupted — every agent it booted is shut down, then it exits.",[14,222,223,224,227],{},"This is why destructuring is safe. ",[25,225,226],{},"const { barry, checker } = await Fleet(...)"," throws\naway the fleet object, which in most APIs would mean throwing away the only way to clean\nup. Here the lifetime belongs to the run.",[14,229,230],{},"Shutdown is error-isolated — one agent failing to close never strands the others — and\nsession logs flush regardless, so a crashed run still leaves a complete trace per agent.",[29,232,234],{"id":233},"what-survives","What survives",[14,236,237],{},"The runtime is ephemeral; the folder is not.",[14,239,240,241,244,245,248],{},"Each agent writes its session to its own ",[25,242,243],{},"data\u002Fsessions\u002F"," as a JSONL trace. Three agents\nleave three traces, in three folders, each readable on its own. Anything written to\n",[25,246,247],{},"data\u002F"," during the run persists on the same terms.",[14,250,251,252,254,255,134],{},"Conversation does not survive. A handle's context lasts as long as the handle: within a\nrun consecutive calls share everything, across runs they share nothing. If an agent needs\nto carry something forward it belongs in ",[25,253,247],{}," — written deliberately, read at boot. See\n",[160,256,258],{"href":257},"\u002Fdocs\u002Fv2\u002Fconcepts\u002Fstate-model","State & Memory",[29,260,262],{"id":261},"long-running-scripts","Long-running scripts",[14,264,265],{},"Nothing stops a script staying up — a loop, a queue consumer, a watcher. Boot once at the\ntop and keep the handles:",[18,267,269],{"className":38,"code":268,"language":40,"meta":27,"style":27},"const { triage } = await Fleet({ triage: \"..\u002Ftriage\" })\n\nfor await (const issue of watchIssues()) {\n    const result = await triage.request(`triage this issue:\\n\\n${issue.body}`)\n    await postComment(issue.number, result.text)\n}\n",[25,270,271,303,309,334,385,413],{"__ignoreMap":27},[44,272,273,277,280,284,287,289,291,294,297,300],{"class":46,"line":47},[44,274,276],{"class":275},"scz_3","const",[44,278,279],{"class":58}," { ",[44,281,283],{"class":282},"s9McN","triage",[44,285,286],{"class":58}," } = ",[44,288,51],{"class":50},[44,290,55],{"class":54},[44,292,293],{"class":58},"({ ",[44,295,296],{"class":65},"triage:",[44,298,299],{"class":69}," \"..\u002Ftriage\"",[44,301,302],{"class":58}," })\n",[44,304,305],{"class":46,"line":62},[44,306,308],{"emptyLinePlaceholder":307},true,"\n",[44,310,311,314,317,320,322,325,328,331],{"class":46,"line":80},[44,312,313],{"class":50},"for",[44,315,316],{"class":50}," await",[44,318,319],{"class":58}," (",[44,321,276],{"class":275},[44,323,324],{"class":282}," issue",[44,326,327],{"class":275}," of",[44,329,330],{"class":54}," watchIssues",[44,332,333],{"class":58},"()) {\n",[44,335,336,339,342,345,347,350,352,355,358,361,365,368,371,373,376,379,382],{"class":46,"line":95},[44,337,338],{"class":275},"    const",[44,340,341],{"class":282}," result",[44,343,344],{"class":58}," = ",[44,346,51],{"class":50},[44,348,349],{"class":65}," triage",[44,351,134],{"class":58},[44,353,354],{"class":54},"request",[44,356,357],{"class":58},"(",[44,359,360],{"class":69},"`triage this issue:",[44,362,364],{"class":363},"svVle","\\n\\n",[44,366,367],{"class":275},"${",[44,369,370],{"class":65},"issue",[44,372,134],{"class":58},[44,374,375],{"class":65},"body",[44,377,378],{"class":275},"}",[44,380,381],{"class":69},"`",[44,383,384],{"class":58},")\n",[44,386,387,390,393,395,397,399,402,404,407,409,411],{"class":46,"line":110},[44,388,389],{"class":50},"    await",[44,391,392],{"class":54}," postComment",[44,394,357],{"class":58},[44,396,370],{"class":65},[44,398,134],{"class":58},[44,400,401],{"class":65},"number",[44,403,135],{"class":58},[44,405,406],{"class":65},"result",[44,408,134],{"class":58},[44,410,23],{"class":65},[44,412,384],{"class":58},[44,414,415],{"class":46,"line":125},[44,416,417],{"class":58},"}\n",[14,419,420],{},"One boot, many requests, one context accumulating across every issue. When that\naccumulation is wrong — issue nine should not be coloured by issue eight — the answer is a\nfresh instance per unit of work, not a longer prompt.",[29,422,424],{"id":423},"when-a-script-becomes-an-agent","When a script becomes an agent",[14,426,427],{},"A global script is disposable by design: no identity, no version, no address. When it\nearns its keep — a teammate wants it, it should run nightly, it needs an HTTP endpoint —\nit becomes an agent whose job is orchestrating other agents.",[18,429,432],{"className":430,"code":431,"language":23},[21],"eslint-manager\u002F\n├── src\u002Fscripts\u002Faudit.ts     # boots a fleet, runs the audit\n├── src\u002Fprompts\u002F\n└── axon.config.ts\n",[25,433,431],{"__ignoreMap":27},[14,435,436],{},"There is no separate workflow artifact, and there doesn't need to be. A manager is an\nordinary agent that happens to delegate, so everything built for agents applies unchanged:",[438,439,440,452],"table",{},[441,442,443],"thead",{},[444,445,446,449],"tr",{},[447,448],"th",{},[447,450,451],{},"How",[453,454,455,469,480,488,496],"tbody",{},[444,456,457,461],{},[458,459,460],"td",{},"Publish \u002F install",[458,462,463,135,466],{},[25,464,465],{},"axon publish",[25,467,468],{},"axon install @cody\u002Feslint-manager",[444,470,471,474],{},[458,472,473],{},"Deploy",[458,475,476,479],{},[25,477,478],{},"axon deploy"," — routes, URL, API key",[444,481,482,485],{},[458,483,484],{},"Schedule",[458,486,487],{},"cron against a script or a route",[444,489,490,493],{},[458,491,492],{},"Trigger",[458,494,495],{},"HTTP routes, hooks, email, the TUI palette",[444,497,498,501],{},[458,499,500],{},"Observe",[458,502,503],{},"its own session trace, like any agent",[14,505,506,507,511],{},"It can also ",[508,509,510],"em",{},"think",". A script routes work by whatever its author hardcoded; a manager can\nask an agent which specialist should handle something, then boot that one. That is the\ncapability a plain script doesn't have.",[14,513,514,515,518],{},"A published manager can't use relative paths — the consumer has no ",[25,516,517],{},"..\u002Flinter"," — so refer\nto members by registry name, pinned.",[29,520,522],{"id":521},"agents-already-running","Agents already running",[14,524,525],{},"A booted agent serves HTTP, and its routes are the same front door for a browser, a\nwebhook, or another agent:",[18,527,529],{"className":38,"code":528,"language":40,"meta":27,"style":27},"const res = await fetch(`${barryUrl}\u002Fapi\u002Fchat`, {\n    method: \"POST\",\n    body: JSON.stringify({ message: \"what's the status of the migration?\" }),\n})\n",[25,530,531,562,573,597],{"__ignoreMap":27},[44,532,533,535,538,540,542,545,547,549,551,554,556,559],{"class":46,"line":47},[44,534,276],{"class":275},[44,536,537],{"class":282}," res",[44,539,344],{"class":58},[44,541,51],{"class":50},[44,543,544],{"class":54}," fetch",[44,546,357],{"class":58},[44,548,381],{"class":69},[44,550,367],{"class":275},[44,552,553],{"class":65},"barryUrl",[44,555,378],{"class":275},[44,557,558],{"class":69},"\u002Fapi\u002Fchat`",[44,560,561],{"class":58},", {\n",[44,563,564,567,570],{"class":46,"line":62},[44,565,566],{"class":65},"    method:",[44,568,569],{"class":69}," \"POST\"",[44,571,572],{"class":58},",\n",[44,574,575,578,581,583,586,588,591,594],{"class":46,"line":80},[44,576,577],{"class":65},"    body:",[44,579,580],{"class":282}," JSON",[44,582,134],{"class":58},[44,584,585],{"class":54},"stringify",[44,587,293],{"class":58},[44,589,590],{"class":65},"message:",[44,592,593],{"class":69}," \"what's the status of the migration?\"",[44,595,596],{"class":58}," }),\n",[44,598,599],{"class":46,"line":95},[44,600,128],{"class":58},[14,602,603,604,134],{},"Because the only way in is the protocol, location is a property of the address: an agent\nyour script booted, one running elsewhere on the machine, and a deployed one are reached\nthe same way. Moving an agent to the cloud changes its address, not the code that talks to\nit. See ",[160,605,607],{"href":606},"\u002Fdocs\u002Fv2\u002Fdeploy\u002Fconnecting","Connecting",[14,609,610],{},"A machine-wide directory of running agents — so an agent can look up where its peers are\nrather than being told — is a natural extension of the state the CLI already tracks. It\nhands out identity and address, not a handle: a directory, not a back door.",[612,613],"hr",{},[14,615,616,617,621],{},"Next: ",[160,618,620],{"href":619},"\u002Fdocs\u002Fv2\u002Ffleet\u002Fmanagement","Managing Agents"," — the same fleet, in the editor.",[623,624,625],"style",{},"html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html pre.shiki code .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}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 .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .svVle, html code.shiki .svVle{--shiki-default:#D7BA7D}",{"title":27,"searchDepth":62,"depth":62,"links":627},[628,629,630,631,632,633],{"id":31,"depth":62,"text":32},{"id":213,"depth":62,"text":214},{"id":233,"depth":62,"text":234},{"id":261,"depth":62,"text":262},{"id":423,"depth":62,"text":424},{"id":521,"depth":62,"text":522},"md",{},"\u002Fdocs\u002Fv2\u002Ffleet\u002Flifecycle",{"title":5,"description":16},"docs\u002Fv2\u002Ffleet\u002Flifecycle","Y-A03ClJhu2bIKBuTo7o_LMwY140bF4jrSNOQn_808U",1786104361083]