[{"data":1,"prerenderedAt":434},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fv2\u002Fcli\u002Fexec":3},{"id":4,"title":5,"body":6,"description":427,"extension":428,"meta":429,"navigation":266,"path":430,"seo":431,"stem":432,"__hash__":433},"docs\u002Fdocs\u002Fv2\u002Fcli\u002Fexec.md","axon exec",{"type":7,"value":8,"toc":417},"minimark",[9,13,22,64,67,75,103,106,146,158,162,169,192,199,210,213,321,332,336,344,368,371,375,382,385,388,392,413],[10,11,5],"h1",{"id":12},"axon-exec",[14,15,16,17,21],"p",{},"Run a global script — a ",[18,19,20],"code",{},"*.axon.ts"," file that boots its own agents.",[23,24,29],"pre",{"className":25,"code":26,"language":27,"meta":28,"style":28},"language-bash shiki shiki-themes dark-plus","axon exec .\u002Freview.axon.ts\naxon exec ~\u002Fscripts\u002Fstandup.axon.ts --since yesterday\n","bash","",[18,30,31,47],{"__ignoreMap":28},[32,33,36,40,44],"span",{"class":34,"line":35},"line",1,[32,37,39],{"class":38},"sCudf","axon",[32,41,43],{"class":42},"sKc5r"," exec",[32,45,46],{"class":42}," .\u002Freview.axon.ts\n",[32,48,50,52,54,57,61],{"class":34,"line":49},2,[32,51,39],{"class":38},[32,53,43],{"class":42},[32,55,56],{"class":42}," ~\u002Fscripts\u002Fstandup.axon.ts",[32,58,60],{"class":59},"scz_3"," --since",[32,62,63],{"class":42}," yesterday\n",[14,65,66],{},"The file runs, and every agent it booted is shut down when it finishes. No agent folder\nis required, and the script does not have to live inside a project.",[68,69,71,72],"h2",{"id":70},"why-not-axon-run","Why not ",[18,73,74],{},"axon run",[14,76,77,83,84,87,88,91,92,95,96,99,100,102],{},[78,79,81],"a",{"href":80},"\u002Fdocs\u002Fv2\u002Fcli\u002Frun",[18,82,74],{}," is agent-first: ",[18,85,86],{},"-a"," names one agent, and ",[18,89,90],{},"-p",", ",[18,93,94],{},"-s"," and\n",[18,97,98],{},"--text"," all resolve against it. A global script names its own agents in its own code,\nso there is nothing for ",[18,101,86],{}," to point at.",[14,104,105],{},"Keeping them apart means neither command has flags that apply to only some of its\ninputs:",[23,107,109],{"className":25,"code":108,"language":27,"meta":28,"style":28},"axon run  -a barry -s close-plan   # this agent, its script\naxon exec .\u002Fclose-plan.axon.ts     # a program; it picks its agents\n",[18,110,111,134],{"__ignoreMap":28},[32,112,113,115,118,121,124,127,130],{"class":34,"line":35},[32,114,39],{"class":38},[32,116,117],{"class":42}," run",[32,119,120],{"class":59},"  -a",[32,122,123],{"class":42}," barry",[32,125,126],{"class":59}," -s",[32,128,129],{"class":42}," close-plan",[32,131,133],{"class":132},"sOLPB","   # this agent, its script\n",[32,135,136,138,140,143],{"class":34,"line":49},[32,137,39],{"class":38},[32,139,43],{"class":42},[32,141,142],{"class":42}," .\u002Fclose-plan.axon.ts",[32,144,145],{"class":132},"     # a program; it picks its agents\n",[14,147,148,150,151,153,154,157],{},[18,149,5],{}," takes no ",[18,152,86],{}," deliberately. A script that wants an agent calls ",[18,155,156],{},"Axon()"," —\nhanding it an ambient one it never asked for is exactly what the global-script form\nexists to avoid.",[68,159,161],{"id":160},"arguments","Arguments",[14,163,164,165,168],{},"Everything after the file reaches the script as ",[18,166,167],{},"process.argv",":",[23,170,172],{"className":25,"code":171,"language":27,"meta":28,"style":28},"axon exec .\u002Freview.axon.ts --file src\u002Findex.ts --verbose\n",[18,173,174],{"__ignoreMap":28},[32,175,176,178,180,183,186,189],{"class":34,"line":35},[32,177,39],{"class":38},[32,179,43],{"class":42},[32,181,182],{"class":42}," .\u002Freview.axon.ts",[32,184,185],{"class":59}," --file",[32,187,188],{"class":42}," src\u002Findex.ts",[32,190,191],{"class":59}," --verbose\n",[14,193,194,195,198],{},"There is no ",[18,196,197],{},"defineArgs"," here — that belongs to agent-scoped scripts, where the runtime\nparses arguments before invoking them. A global script is started by a shell and reads\nits arguments like a shell program does.",[68,200,202,205,206,209],{"id":201},"axon-and-fleet-are-in-scope",[18,203,204],{},"Axon"," and ",[18,207,208],{},"Fleet"," are in scope",[14,211,212],{},"Both are bound for the run, so nothing is imported:",[23,214,218],{"className":215,"code":216,"language":217,"meta":28,"style":28},"language-ts shiki shiki-themes dark-plus","\u002F\u002F standup.axon.ts\nconst { barry } = await Fleet({ barry: \"~\u002Fagents\u002Fbarry\" })\n\nconst summary = await barry.request(\"summarise yesterday's commits\")\nconsole.log(summary.text)\n","ts",[18,219,220,225,261,268,298],{"__ignoreMap":28},[32,221,222],{"class":34,"line":35},[32,223,224],{"class":132},"\u002F\u002F standup.axon.ts\n",[32,226,227,230,234,238,241,245,248,251,255,258],{"class":34,"line":49},[32,228,229],{"class":59},"const",[32,231,233],{"class":232},"sTNBD"," { ",[32,235,237],{"class":236},"s9McN","barry",[32,239,240],{"class":232}," } = ",[32,242,244],{"class":243},"sYbnZ","await",[32,246,247],{"class":38}," Fleet",[32,249,250],{"class":232},"({ ",[32,252,254],{"class":253},"s3F5K","barry:",[32,256,257],{"class":42}," \"~\u002Fagents\u002Fbarry\"",[32,259,260],{"class":232}," })\n",[32,262,264],{"class":34,"line":263},3,[32,265,267],{"emptyLinePlaceholder":266},true,"\n",[32,269,271,273,276,279,281,283,286,289,292,295],{"class":34,"line":270},4,[32,272,229],{"class":59},[32,274,275],{"class":236}," summary",[32,277,278],{"class":232}," = ",[32,280,244],{"class":243},[32,282,123],{"class":253},[32,284,285],{"class":232},".",[32,287,288],{"class":38},"request",[32,290,291],{"class":232},"(",[32,293,294],{"class":42},"\"summarise yesterday's commits\"",[32,296,297],{"class":232},")\n",[32,299,301,304,306,309,311,314,316,319],{"class":34,"line":300},5,[32,302,303],{"class":253},"console",[32,305,285],{"class":232},[32,307,308],{"class":38},"log",[32,310,291],{"class":232},[32,312,313],{"class":253},"summary",[32,315,285],{"class":232},[32,317,318],{"class":253},"text",[32,320,297],{"class":232},[14,322,323,324,327,328,331],{},"This is what lets a global script live anywhere — a repo root, ",[18,325,326],{},"~\u002Fbin",", a scratch\ndirectory — none of which has a ",[18,329,330],{},"node_modules"," to resolve an import from.",[68,333,335],{"id":334},"relative-references","Relative references",[14,337,338,339,343],{},"A relative agent reference inside the script resolves against ",[340,341,342],"strong",{},"the script's own\ndirectory",", not the directory you invoked from:",[23,345,347],{"className":25,"code":346,"language":27,"meta":28,"style":28},"cd ~\u002Fprojects\u002Fapi\naxon exec ~\u002Fscripts\u002Fstandup.axon.ts    # \"..\u002Fbarry\" inside means ~\u002Fbarry\n",[18,348,349,357],{"__ignoreMap":28},[32,350,351,354],{"class":34,"line":35},[32,352,353],{"class":38},"cd",[32,355,356],{"class":42}," ~\u002Fprojects\u002Fapi\n",[32,358,359,361,363,365],{"class":34,"line":49},[32,360,39],{"class":38},[32,362,43],{"class":42},[32,364,56],{"class":42},[32,366,367],{"class":132},"    # \"..\u002Fbarry\" inside means ~\u002Fbarry\n",[14,369,370],{},"This is what makes a script portable: it keeps working wherever you run it from.",[68,372,374],{"id":373},"lifetime","Lifetime",[23,376,380],{"className":377,"code":379,"language":318},[378],"language-text","axon exec review.axon.ts\n  │\n  ├─ resolve every reference     ← fails here if an agent is missing\n  ├─ boot                        ← capsules start, modules connect\n  ├─ run the script              ← your code\n  └─ shut everything down        ← always, including on failure\n",[18,381,379],{"__ignoreMap":28},[14,383,384],{},"Teardown covers every agent the script booted, including when the script throws and\nincluding agents booted before the failure. Shutdown is error-isolated — one agent\nfailing to close never strands the others — and session logs are flushed regardless, so\na crashed run still leaves a complete trace per agent.",[14,386,387],{},"A failing script fails the command: the exit status reflects what happened.",[68,389,391],{"id":390},"see-also","See also",[393,394,395,406],"ul",{},[396,397,398,402,403,405],"li",{},[78,399,401],{"href":400},"\u002Fdocs\u002Fv2\u002Ffleet\u002Fcode","Agents in Code"," — writing one, and what ",[18,404,156],{}," gives you",[396,407,408,412],{},[78,409,411],{"href":410},"\u002Fdocs\u002Fv2\u002Ffleet\u002Flifecycle","Lifecycle"," — boot, teardown, and what survives",[414,415,416],"style",{},"html pre.shiki code .sCudf, html code.shiki .sCudf{--shiki-default:#DCDCAA}html pre.shiki code .sKc5r, html code.shiki .sKc5r{--shiki-default:#CE9178}html pre.shiki code .scz_3, html code.shiki .scz_3{--shiki-default:#569CD6}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 .sOLPB, html code.shiki .sOLPB{--shiki-default:#6A9955}html pre.shiki code .sTNBD, html code.shiki .sTNBD{--shiki-default:#D4D4D4}html pre.shiki code .s9McN, html code.shiki .s9McN{--shiki-default:#4FC1FF}html pre.shiki code .sYbnZ, html code.shiki .sYbnZ{--shiki-default:#C586C0}html pre.shiki code .s3F5K, html code.shiki .s3F5K{--shiki-default:#9CDCFE}",{"title":28,"searchDepth":49,"depth":49,"links":418},[419,421,422,424,425,426],{"id":70,"depth":49,"text":420},"Why not axon run",{"id":160,"depth":49,"text":161},{"id":201,"depth":49,"text":423},"Axon and Fleet are in scope",{"id":334,"depth":49,"text":335},{"id":373,"depth":49,"text":374},{"id":390,"depth":49,"text":391},"Run a global script — a *.axon.ts file that boots its own agents.","md",{},"\u002Fdocs\u002Fv2\u002Fcli\u002Fexec",{"title":5,"description":427},"docs\u002Fv2\u002Fcli\u002Fexec","ss5-SR4HIFfdty2Tv7RRISzeSA5Cf6ktANUL7e3Icq0",1786104359513]