@axia-labs/cli 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/axia.js +22 -0
- package/package.json +29 -1
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# axia
|
|
2
|
+
|
|
3
|
+
`axia` is the command line your AI agent uses to work in [Axia OS](https://app.axia.agency) for you: sign you in, set up or join your company, read what is new, and work in chat, tasks and files with your permissions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Needs Node.js 20 or later on macOS or Linux.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @axia-labs/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Start
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
axia login you@yourcompany.com # Axia emails you a 6-digit code
|
|
17
|
+
axia login --code 123456
|
|
18
|
+
axia status # names your next step
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Every command prints JSON. `next_cli` lists the commands that come next. `axia --help` lists every command.
|
|
22
|
+
|
|
23
|
+
Your sign-in is saved in `~/.axia/cli.json`. `axia logout` ends it.
|
package/dist/axia.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{randomUUID as Eq}from"node:crypto";import{openAsBlob as wz}from"node:fs";import{access as Fz,readFile as Tz}from"node:fs/promises";import{homedir as Sq}from"node:os";import{extname as Oz,join as Rz}from"node:path";import{createInterface as _z}from"node:readline/promises";import{setTimeout as Lz}from"node:timers/promises";import{parseArgs as Nz}from"node:util";var h={start:"Sign in, set up, and pull what is new:",company:"The company, as your person sees it:",work:"Work, as your person (your changes are labeled as yours):",more:"Everything else your person can do in Axia:",role:"With your person's role (owner or admin), and refused without it:"},V=(q,z,J={},Q=[])=>({section:q,help:z,flags:J,subcommands:Q}),I={api:"text",help:"switch"},s={harness:"text"},N=["x","instagram","tiktok","youtube","linkedin"],qq={firstName:"text",lastName:"text",email:"text",phone:"text",companyName:"text",title:"text",notes:"text"},zq={"to-user":"text","to-agent":"text",open:"switch"},d={department:"text",status:"text"},w={login:V("start",[["axia login <email>","email your person a 6-digit sign-in code"],["axia login --code <code> [--bot <botId>]","finish sign-in; saves an access token in ~/.axia/cli.json. A returning agent passes its own bot id to stay itself"]],{code:"text",bot:"text"}),status:V("start",[["axia status","where onboarding is and what to send next"]]),company:V("start",[[`axia company --userName .. --companyName .. --whatWeSell .. [--website ..] ${N.map((q)=>`[--${q} ..]`).join(" ")}`,"make your person's new company, the usual choice"]],{userName:"text",companyName:"text",whatWeSell:"text",website:"text",...Object.fromEntries(N.map((q)=>[q,"text"]))}),join:V("start",[["axia join <invite link or code>","join with the invite link or code your person gives you, when they chose to join a company"]]),answer:V("start",[["axia answer --questionId .. --answer .. [--nudge ..]",""]],{questionId:"text",answer:"text",nudge:"texts"}),strategy:V("start",[["axia strategy","write the company strategy (about a minute)"]]),decide:V("start",[["axia decide continue","accept the strategy and start Axia working"],["axia decide revise --section <problem|currentGoal|objective|moves> --note ..","rewrite one section from a note"]],{section:"text",note:"text"},["continue","revise"]),profile:V("start",[["axia profile --displayName .. --title .. --responsibilities ..",""]],{displayName:"text",title:"text",responsibilities:"text"}),bot:V("start",[["axia bot","which of your person's bots you are, and the choices"],["axia bot <botId>","confirm or pick the bot you are"],["axia bot --name .. [--avatarUrl ..] [--hue ..]","name yourself, with a name you choose"],["axia bot --wake-url <https url>","have Axia push your deliveries there; prints the signing secret once"],["axia bot --wake-url off","stop pushing; read deliveries with axia deliveries"]],{name:"text",avatarUrl:"text",hue:"text","wake-url":"text"}),deliveries:V("start",[["axia deliveries","what is waiting for you: mentions, DMs, tasks assigned to your person (ids only)"]]),ack:V("start",[["axia ack <eventId> [eventId ..]","mark deliveries handled so they are not sent again"]]),inbox:V("start",[["axia inbox","everything new in the company since your last pull there: one cursor per company, kept in ~/.axia/cli.json"],["axia inbox --check-in [--harness ..]","the same pull, run by your own scheduled job about every 2 hours"]],{"check-in":"switch",...s}),install:V("start",[["axia install [--harness ..]","write Axia's prompt block (between its begin and end markers) into your harness's main prompt and the Axia skill into its skill folder; detected only inside Claude Code and omp, else --harness claude-code|codex|hermes|grok|omp"]],s),uninstall:V("start",[["axia uninstall [--harness ..]","take both out again, byte for byte"]],s),logout:V("start",[["axia logout",""]]),home:V("company",[["axia home","the company's goal, who is working, and what waits on your person"]]),activity:V("company",[["axia activity [--department <id>] [--cursor <nextCursor>]","what happened in the company, newest first"]],{department:"text",cursor:"text"}),departments:V("company",[["axia departments","every department and its id (tasks, campaigns and reports name one)"]]),agents:V("company",[["axia agents","Axia's agents, with their department and id"]]),reports:V("company",[["axia reports [--status ready] [--department <id>]","reports; ready ones wait on a decision"]],d),report:V("company",[["axia report <reportId>","one report with its context, and the link where your person decides it"]]),campaigns:V("company",[["axia campaigns [--department <id>] [--status ..]",""]],d),campaign:V("company",[["axia campaign <campaignId>",""]]),rooms:V("work",[["axia rooms","every chat room and DM you can see"]]),room:V("work",[["axia room new <name> [--agent <agentId>]","open a room; with an agent it is that agent's department room"]],{agent:"text"},["new"]),messages:V("work",[["axia messages <threadId>","the latest messages in a room"]]),send:V("work",[["axia send <threadId> <text>","post a message; @Name of someone in the room reaches them"]]),run:V("work",[["axia run <threadId>","the agent run working in a room now, with the messages it has posted"]]),wait:V("work",[["axia wait <threadId> [--run <runId>] [--timeout <seconds>]","wait until the run axia send named and the room's runs finish (default 300s), then print their replies"]],{run:"text",timeout:"text"}),dm:V("work",[["axia dm <userId>","open (or find) a DM with a teammate"],["axia dm --bot <botId>","open (or find) a DM with a teammate's agent"]],{bot:"text"}),"mark-read":V("work",[["axia mark-read <threadId> <messageId>","mark a room read through that message"]]),chat:V("work",[["axia chat notify <threadId> all|mentions|off","how a room notifies your person: every message, mentions and DMs (the default), or mentions in the bell only"]],{},["notify"]),devices:V("more",[["axia devices list","the phones your person gets pushes on"],["axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild ..","push to an APNs device token, bound to this CLI's access token"],["axia devices unregister <token>","stop pushing to that device"]],{environment:"text",bundleId:"text",appVersion:"text",appBuild:"text"},["list","register","unregister"]),tasks:V("work",[["axia tasks","tasks assigned to your person"],["axia tasks --all | --open | --department <id> [--status ..]","every task, the unassigned open ones, or one department's"]],{all:"switch",open:"switch",...d}),task:V("work",[["axia task <taskId>","one task"],["axia task add <title> --department <id> [--to-user <userId> | --to-agent <agentId> | --open] [--description ..]",""],["axia task cancel <taskId>","cancel a task"]],{department:"text",description:"text",...zq},["add","cancel"]),assign:V("work",[["axia assign <taskId> --to-user <userId> | --to-agent <agentId> | --open",""]],zq),start:V("work",[["axia start <taskId>","start your person's task; an open one becomes theirs"]]),note:V("work",[["axia note <taskId> <text>","add a note to a task"]]),done:V("work",[["axia done <taskId> [--note <what was done>] [--evidence <ref> ..]","a ref is a workspace path, a https link, or report:<reportId>"]],{note:"text",evidence:"texts"}),ls:V("work",[["axia ls [path]","browse the company workspace"]]),cat:V("work",[["axia cat <path>","read a workspace file"]]),tree:V("work",[["axia tree [path] [--depth 1-5]","the workspace as a tree"]],{depth:"text"}),search:V("work",[["axia search <text>","workspace files whose name or text matches"]]),download:V("work",[["axia download <path> [--to <local file>]","save a workspace file in this folder; never overwrites a file"]],{to:"text"}),write:V("work",[["axia write <path> --text .. | --file <local file> [--version N]","create a workspace file, or replace one at the version axia cat shows"]],{text:"text",file:"text",version:"text"}),mv:V("work",[["axia mv <from> <to>","move or rename a workspace file"]]),rm:V("work",[["axia rm <path>","delete a workspace file"]]),mkdir:V("work",[["axia mkdir <path>","make a workspace folder, e.g. /company/Plans"]]),"rename-folder":V("work",[["axia rename-folder <oldPath> <newPath>",""]]),mail:V("work",[["axia mail [--folder inbox|sent]","the company mailbox's threads: received (the default) or sent"],["axia mail <threadId>","one thread"],["axia mail setup","whether the company has a mailbox, and how to set one up"],["axia mail create --address <name> --displayName <name>","create the company mailbox (your person owns the company)"],["axia mail drafts [--limit <n>] [--cursor <nextCursor>]","the mailbox's unsent drafts, newest first; drafts Axia already sent are left out, so a page can be empty with older drafts behind it: run the next_cli line it prints"],["axia mail draft --to <address>[,..] [--cc ..] [--bcc ..] --subject .. --body ..",'write a draft; axia mail draft <draftId> [the same flags] edits it, and --cc "" or --bcc "" removes its copies. The body is plain text; add --bodyFormat html to send it as HTML (on mail send and mail reply too)'],["axia mail send <draftId> | axia mail send --to <address>[,..] [--cc ..] [--bcc ..] --subject .. --body ..","ask to send: it waits in Axia's approvals until your person approves it there; it never sends directly"],["axia mail reply <messageId> --body ..","ask to reply, the same way"]],{folder:"text",address:"text",displayName:"text",limit:"text",cursor:"text",to:"text",cc:"text",bcc:"text",subject:"text",body:"text",bodyFormat:"text"},["setup","create","drafts","draft","send","reply"]),contacts:V("work",[["axia contacts [search text]","contacts, or the ones matching the text"]]),contact:V("work",[["axia contact <contactId>",""]]),"add-contact":V("work",[["axia add-contact --firstName .. [--lastName ..] [--email ..] [--phone ..] [--companyName ..] [--title ..] [--notes ..]",""]],qq),"edit-contact":V("work",[["axia edit-contact <contactId> [the same flags]",""]],qq),tools:V("more",[["axia tools [filter]","list the actions your person can take, with their inputs"]]),call:V("more",[["axia call <tool> ['<json input>']",`run one action, e.g. axia call tasks_listTasks '{"input":{"status":"blocked"}}'`]]),subscribe:V("more",[["axia subscribe","a Stripe Checkout link to subscribe to Axia (owner or admin)"]]),team:V("more",[["axia team","everyone in the company, their roles, and each person's agents"]]),invites:V("more",[["axia invites","invite links and who used them (owner or admin)"]]),orgs:V("more",[["axia orgs","every company your person belongs to; axia status names the one you act in"]]),switch:V("more",[["axia switch <orgId>","act in another of your person's companies (same as the web org switcher)"]]),upload:V("more",[["axia upload <file> --folder <path>","upload a file to the company workspace, e.g. --folder /Marketing"],["axia upload <file> --thread <threadId> [--text ..]","post a chat message with the file attached (it also lands in the workspace)"]],{folder:"text",thread:"text",text:"text"}),approve:V("role",[["axia approve <reportId> [--note ..]","approve a report"]],{note:"text"}),revise:V("role",[["axia revise <reportId> --note ..","ask the report's agent for a revision"]],{note:"text"}),invite:V("role",[["axia invite --department <id> [--department ..] [--role member|admin] [--agent-access full|none]","an invite code your person sends to who they invite"]],{department:"texts",role:"text","agent-access":"text"})},Jq=(q)=>Object.hasOwn(w,q),A=(q,z)=>w[q].subcommands.find((J)=>J===z),G=(q,...z)=>["axia",q,...z].join(" "),Qq=(q)=>/^[\w@%+=:,./-]+$/.test(q)?q:`'${q.replaceAll("'","'\\''")}'`,i=([q],[z])=>q<z?-1:1,nq=(q)=>{let z=2166136261;for(let J=0;J<q.length;J+=1)z=Math.imul(z^q.charCodeAt(J),16777619);return(z>>>0).toString(16).padStart(8,"0")},tq=(q)=>nq(JSON.stringify([Object.entries(I).sort(i),Object.entries(q).sort(i).map(([z,J])=>[z,Object.entries(J.flags).sort(i),[...J.subcommands].sort()])])),oq=tq(w);var Zq=`axia-cli/${oq}`;var aq=["claude-code","codex","hermes","grok","omp"],Wq="about every 2 hours";var eq="npm install -g @axia-labs/cli";var TJ=`Your axia CLI is out of date. Update it: ${eq}. Then run the same command again; your sign-in is kept.`,Xq=G("bot","<botId>");var OJ={cli:`If the company has no subscription yet, run \`${G("subscribe")}\` and send your person the checkout link it prints, so Axia keeps working once the starter credit runs out. Paying is theirs.`,mcp:"If the company has no subscription yet, call billing_createSubscriptionCheckoutSession and send your person the checkout link it returns, so Axia keeps working once the starter credit runs out. Paying is theirs."},Vq="Send your person this checkout link. Paying is theirs; once they subscribe, Axia keeps working after the starter credit runs out, and a command refused for payment works again.";var qz={"claude-code":"Claude Code: a scheduled task or `/loop 2h` with install.prompt (code.claude.com/docs/en/scheduled-tasks)",codex:"Codex: an automation in the Codex app with install.prompt (developers.openai.com/codex/app/automations)",hermes:"Hermes: `hermes cron create` or the `cronjob_manage` tool, with install.prompt",grok:"Grok Build: `/loop 2h` with install.prompt",omp:'omp: it has no scheduler of its own, so add a crontab line (`crontab -e`) that runs `omp -p "<install.prompt>"` every 2 hours, like `17 */2 * * * omp -p "<install.prompt>"`, with the folders that hold omp and `axia` on that line\'s PATH'},$q=`Create a recurring job in your own harness that gives you install.prompt ${Wq}: it has you run the check-in and act on what is new. Then do one check-in now; your first check-in connects you.`,RJ={cli:`Run \`${G("install")}\`. It finds Claude Code and omp by itself; anywhere else name your harness: \`${G("install","--harness",`<${aq.join("|")}>`)}\`. It puts install.promptBlock into your harness's main prompt between Axia's markers and the Axia skill into its skill folder; \`${G("uninstall")}\` takes both out. ${$q}`,mcp:`Put install.promptBlock into your standing instructions yourself. ${$q}`},jq=(q)=>`Axia is in your main prompt and your skills. Now schedule your check-in with install.prompt (\`${G("status")}\` shows it), ${Wq}. ${qz[q]}. Then run \`${G("inbox","--check-in")}\` once now; your first check-in connects you.`,_J={cli:`You arrived: the line in HQ tells the team, and Axia is writing you a greeting there. Pull again in a minute with \`${G("inbox")}\` to read it, then answer in HQ.`,mcp:"You arrived: the line in HQ tells the team, and Axia is writing you a greeting there. Call axia_inbox again in a minute to read it, then answer in HQ."};var LJ={cli:`You said hello in HQ, so setup is done. From now on start every turn with \`${G("inbox")}\` and act on what is new.`,mcp:"You said hello in HQ, so setup is done. From now on start every turn with axia_inbox and act on what is new."},NJ=Object.entries(h).map(([q,z])=>[z,...Object.values(w).filter((J)=>J.section===q).flatMap((J)=>J.help.map(([Q,Z])=>`- \`${Q}\`${Z===""?"":`: ${Z}`}`))].join(`
|
|
3
|
+
`)).join(`
|
|
4
|
+
|
|
5
|
+
`);var zz=(q)=>q===void 0||/[\s.,!?;:)\]}'"]/.test(q),Jz=(q,z)=>z.some((J)=>q>=J.startIndex&&q<J.endIndex),Qz=(q,z,J)=>{let Q=q.slice(z+1);for(let Z of J){let $=Z.displayName;if($.length===0||!Q.toLowerCase().startsWith($.toLowerCase()))continue;if(!zz(Q[$.length]))continue;return Z}return null},Yq=(q)=>{if(q.candidates.length===0)return{text:q.text,mentions:q.mentions};let z=q.candidates.filter(($)=>$.kind!=="thread").sort(($,W)=>W.displayName.length-$.displayName.length),J=[...q.mentions],Q=q.mentions.some(($)=>$.kind==="agent"),Z=q.text;for(let $=0;$<Z.length;$+=1){if(Z[$]!=="@"||Jz($,J))continue;let W=Qz(Z,$,z);if(!W||W.kind==="agent"&&Q)continue;let X=`@${W.displayName}`;Z=`${Z.slice(0,$)}${X}${Z.slice($+X.length)}`,J.push({kind:W.kind,id:W.id,display:W.displayName,startIndex:$,endIndex:$+X.length}),Q=Q||W.kind==="agent",$+=X.length-1}return{text:Z,mentions:J.sort(($,W)=>$.startIndex-W.startIndex)}};import{dirname as Mq,join as T}from"node:path";import{chmod as Zz,mkdir as Bq,open as $z,readdir as Wz,readFile as Xz,rm as Vz,rmdir as jz,writeFile as Yz}from"node:fs/promises";import{dirname as Kq,isAbsolute as l,relative as Bz,resolve as Kz,sep as Gz}from"node:path";class E extends Error{name="OutsideRootError"}class u extends Error{name="LocalFileExistsError"}var S=(q,z)=>{if(!l(q))throw new E(`Local file root "${q}" is not absolute.`);let J=Kz(q,z),Q=Bz(q,J);if(l(z)||Q===""||Q===".."||Q.startsWith(`..${Gz}`)||l(Q))throw new E(`"${z}" is outside the folder it must stay in.`);return J},Gq=(q)=>{if(q.code==="ENOENT")return null;throw q},v=(q,z)=>Xz(S(q,z),"utf8").catch(Gq),k=async(q,z,J,Q={})=>{let Z=S(q,z);if(await Bq(Kq(Z),{recursive:!0,mode:Q.dirMode}),await Yz(Z,J,{mode:Q.mode}),Q.mode!==void 0)await Zz(Z,Q.mode)},Hq=async(q,z,J)=>{let Q=S(q,z);await Bq(Kq(Q),{recursive:!0});let Z=await $z(Q,"wx").catch(($)=>{if($.code==="EEXIST")throw new u(`"${z}" already exists.`);throw $});try{await Z.writeFile(J)}finally{await Z.close()}return{path:Q,bytes:J.byteLength}},x=async(q,z)=>{await Vz(S(q,z),{force:!0})},r=async(q,z)=>{let J=S(q,z),Q=await Wz(J).catch(Gq);if(Q!==null&&Q.length===0)await jz(J)};var b=(q)=>T(q.root,q.path),y="skills/axia/SKILL.md",Hz=["AGENTS.override.md","AGENTS.md"],Uz=async(q)=>{for(let z of Hz){let J=await v(q,z);if(J!==null&&J.trim()!=="")return z}return"AGENTS.md"},Mz=(q,z)=>{let J=T(q,z.PI_CONFIG_DIR??".omp"),Q=(z.OMP_PROFILE??z.PI_PROFILE??"").trim();if(Q!==""&&Q!=="default")return T(J,"profiles",Q,"agent");return z.PI_CODING_AGENT_DIR??T(J,"agent")},g={"claude-code":async(q)=>{let z=T(q,".claude");return{prompt:{root:z,path:"CLAUDE.md",owned:!1},skill:{root:z,path:y}}},codex:async(q,z)=>{let J=z.CODEX_HOME??T(q,".codex");return{prompt:{root:J,path:await Uz(J),owned:!1},skill:{root:T(q,".agents"),path:y}}},hermes:async(q,z)=>{let J=z.HERMES_HOME??T(q,".hermes");return{prompt:{root:J,path:"SOUL.md",owned:!1},skill:{root:J,path:y}}},grok:async(q)=>{let z=T(q,".grok");return{prompt:{root:z,path:"AGENTS.md",owned:!1},skill:{root:z,path:y}}},omp:async(q,z)=>{let J=Mz(q,z);return{prompt:{root:J,path:"rules/axia.md",owned:!0},skill:{root:J,path:y}}}},Pq=(q)=>Object.hasOwn(g,q),Dq=(q)=>q.OMPCODE==="1"?"omp":q.CLAUDE_CODE_CHILD_SESSION==="1"?"claude-code":null;class m extends Error{name="InstallRefusedError"}var wq="<!-- axia:begin -->",n="<!-- axia:end -->",p=(q)=>`${wq}
|
|
6
|
+
${q.trimEnd()}
|
|
7
|
+
${n}`,Pz=(q)=>`---
|
|
8
|
+
description: Axia, your person's company operating system
|
|
9
|
+
alwaysApply: true
|
|
10
|
+
---
|
|
11
|
+
${p(q)}
|
|
12
|
+
`,Uq=(q,z)=>q.root===z.root&&q.path===z.path,t=(q)=>{let z=q.indexOf(wq),J=z===-1?-1:q.indexOf(n,z);return z===-1||J===-1?null:{start:z,end:J+n.length}},Dz=(q,z)=>{let J=q===null?null:t(q);if(q!==null&&J!==null)return q.slice(0,J.start)+p(z)+q.slice(J.end);if(q===null||q==="")return`${p(z)}
|
|
13
|
+
`;return`${q}
|
|
14
|
+
${p(z)}
|
|
15
|
+
`},Fq=async(q)=>{if(q.owned){await x(q.root,q.path),await r(q.root,Mq(q.path));return}let z=await v(q.root,q.path),J=z===null?null:t(z);if(z===null||J===null)return;let Q=z.slice(0,J.start),Z=z.slice(J.end),$=Q===""?Z.replace(/^\n/,""):Q.replace(/\n$/,"")+Z.replace(/^\n/,"");if($===""&&q.created)await x(q.root,q.path);else await k(q.root,q.path,$)},Tq=async(q)=>{let{prompt:z,skill:J}=await g[q.harness](q.home,q.env),Q=await v(z.root,z.path);if(z.owned&&Q!==null&&t(Q)===null)throw new m(`${b(z)} is not Axia's, so Axia will not overwrite it. Move it and install again.`);let Z=q.previous,$=Z!==void 0&&Uq(Z.prompt,z);if(Z!==void 0&&!$)await Fq(Z.prompt);if(Z!==void 0&&!Uq(Z.skill,J))await x(Z.skill.root,Z.skill.path);await k(z.root,z.path,z.owned?Pz(q.promptBlock):Dz(Q,q.promptBlock)),await k(J.root,J.path,q.skill);let W=$?Z.prompt.created:Q===null;return{harness:q.harness,prompt:{...z,created:W},skill:J}},Oq=async(q)=>{await Fq(q.prompt),await x(q.skill.root,q.skill.path),await r(q.skill.root,Mq(q.skill.path))};var xq=Rz(Sq(),".axia"),yq="cli.json",Cq="https://api.axia.agency",hq=(q)=>q.apiUrl??Cq,Az={".pdf":"application/pdf",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".txt":"text/plain",".md":"text/markdown",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp"},Iq=(q)=>Fz(q).then(()=>!0,()=>!1),vz={axia_login_start:G("login"),axia_login_verify:G("login"),axia_logout:G("logout"),axia_onboarding_status:G("status"),axia_onboarding_join:G("join"),axia_onboarding_company:G("company"),axia_onboarding_answer:G("answer"),axia_onboarding_generate_strategy:G("strategy"),axia_onboarding_strategy_decision:G("decide"),axia_onboarding_profile:G("profile"),axia_onboarding_bot:G("bot"),axia_inbox:G("inbox"),billing_createSubscriptionCheckoutSession:G("subscribe"),email_getSetupLink:G("mail","setup")},kz=([q,z])=>{if(z==="")return` ${q}`;return q.length<35?` ${q.padEnd(35)}${z}`:` ${q} ${z}`},bz=["axia - Axia for agents, by text. You act for your person, with their permissions.",...Object.entries(h).map(([q,z])=>[z,...Object.values(w).filter((J)=>J.section===q).flatMap((J)=>J.help.map(kz))].join(`
|
|
16
|
+
`)),`Your person decides these in Axia itself, never you: approving an email or any other action that leaves
|
|
17
|
+
Axia (send them the link from axia mail send or axia report), changing anyone's access, and billing.`,`Axia's address is ${Cq}. --api <url> names another and is saved; AXIA_API_URL overrides it.`].join(`
|
|
18
|
+
|
|
19
|
+
`),Ez=new Set(["apiUrl","token","pendingEmail","cursors","installs"]),Sz=async()=>{let q=await v(xq,yq);if(q===null)return{};let{cursor:z,...J}=JSON.parse(q);if(z!==void 0)return await F(J),Y("~/.axia/cli.json held one inbox cursor from an older axia CLI. It names no company, so it was removed instead of guessed. Tell your person that changes made since your last pull may not be listed, then run the same command again; axia inbox then starts from now.");let Q=Object.keys(J).filter((Z)=>!Ez.has(Z));if(Q.length>0)return Y(`~/.axia/cli.json holds ${Q.join(", ")}, which this axia CLI does not know. Remove ${Q.length===1?"it":"them"} and run the same command again.`);return J},F=async(q)=>{await k(xq,yq,JSON.stringify(q,null,2),{mode:384,dirMode:448})},Y=(q,z)=>{console.log(JSON.stringify({problem:q,...z?{next_cli:z}:{}},null,2)),process.exit(1)},uq=(q)=>{let z=q.data?.next_cli;return Y(q.message??"The Axia server refused the call.",Array.isArray(z)?z.map(String):void 0)},xz=async(q,z)=>{let J=await q.text();if(!(q.headers.get("content-type")??"").includes("text/event-stream"))return JSON.parse(J);for(let Q of J.split(`
|
|
20
|
+
|
|
21
|
+
`)){let Z=Q.split(`
|
|
22
|
+
`).filter((W)=>W.startsWith("data:")).map((W)=>W.slice(5).trim()).join("");if(!Z)continue;let $=JSON.parse(Z);if($.id===z)return $}return Y("The Axia server closed the reply without an answer. Run the same command again.")},pq=async(q,z,J)=>{let Q=hq(q),Z={"content-type":"application/json",accept:"application/json, text/event-stream","user-agent":Zq};if(q.token)Z.authorization=`Bearer ${q.token}`;let $=Date.now(),W=await fetch(new URL("/mcp",Q),{method:"POST",headers:Z,body:JSON.stringify({jsonrpc:"2.0",id:$,method:z,params:J})});if(W.status===401)return await F({...q,token:void 0}),Y("The saved access token stopped working, so it was removed. Sign in again: axia login <email>");if(!W.ok)return Y(`The Axia server answered ${W.status}. Check the API address: ${Q}`);return await xz(W,$)},U=async(q,z,J)=>{let Q=await pq(q,"tools/call",{name:z,arguments:J});if(Q.error)return uq(Q.error);let Z=Q.result?.content?.[0]?.text??"{}",$;try{$=JSON.parse(Z)}catch{$={problem:Z}}return{payload:$,isError:Q.result?.isError===!0}},yz=(q)=>{let z=Object.entries(q.fields);if(z.length===0)return G("call",q.tool);let J=Object.fromEntries(z.map(([Q,Z])=>[Q,`<${Z}>`]));return G("call",q.tool,Qq(JSON.stringify(J)))},Cz=(q)=>{if(q.tool==="axia_login_verify")return"axia login --code <the 6-digit code>";if(q.tool==="axia_login_start")return"axia login <email>";if(q.tool==="axia_onboarding_join")return"axia join <invite link or code>";if(q.tool==="axia_inbox")return q.fields.checkIn?"axia inbox --check-in":"axia inbox";if(q.tool==="axia_onboarding_bot"&&"botId"in q.fields)return Xq;if(q.tool==="chat_send")return`axia send ${q.fields.threadId} <${q.fields.text}>`;if(q.tool==="workspace_read")return G("cat",`<${q.fields.path}>`);if(q.tool==="workspace_write")return G("write",`<${q.fields.path}>`,"--text .. | --file <local file> --version <the version axia cat shows>");if(q.tool==="axia_onboarding_strategy_decision")return q.fields.decision==="continue"?"axia decide continue":"axia decide revise --section <problem|currentGoal|objective|moves> --note <what to change>";let z=vz[q.tool];if(z===void 0)return yz(q);let J=Object.entries(q.fields).map(([Q,Z])=>{if(Q==="socials")return N.map(($)=>`[--${$} <handle or link>]`).join(" ");if(Q==="questionId")return`--questionId ${Z}`;return`--${Q==="selectedNudges"?"nudge":Q} <${Z}>`});return[z,...J].join(" ")},P=(q,z)=>{if(Array.isArray(q)){console.log(JSON.stringify(q,null,2));return}let J=Array.isArray(q.next)?q.next:[],{token:Q,...Z}=q;if(console.log(JSON.stringify({...Z,next_cli:J.map(Cz)},null,2)),z||"problem"in q)process.exitCode=1},hz=async()=>{if(!process.stdin.isTTY)return null;let q=_z({input:process.stdin,output:process.stdout}),z=(await q.question("6-digit code from the email: ")).trim();return q.close(),z||null},Iz=(q)=>Object.fromEntries(Object.entries(q).map(([z,J])=>[z,J==="switch"?{type:"boolean"}:{type:"string",multiple:!0}])),uz=Object.assign({},I,...Object.values(w).map((q)=>q.flags)),Rq=(q,z)=>{try{return Nz({args:process.argv.slice(2),allowPositionals:!0,strict:!0,options:Iz(q)})}catch(J){return Y(`${J instanceof Error?J.message:String(J)}.${z} Run: axia --help`)}},pz=()=>{let q=Rq(uz,""),[z,...J]=q.positionals;if(z===void 0||q.values.help===!0)return null;if(!Jq(z))return Y(`Unknown command "${z}". Run: axia --help`);let Q=Object.keys(w[z].flags).map(($)=>`--${$}`),{values:Z}=Rq({...I,...w[z].flags},` axia ${z} takes ${Q.length>0?Q.join(", "):"no flags"}.`);return{command:z,rest:J,values:Z}},_q=async(q,z,J,Q)=>{let Z=z("bot"),$=await U(q,"axia_login_verify",{email:J,code:Q,...Z?{botId:Z}:{}});if(typeof $.payload.token==="string")await F({...q,token:$.payload.token,pendingEmail:void 0});P($.payload,$.isError)},Lq=`--harness <${Object.keys(g).join("|")}>`,D=(q)=>{console.log(JSON.stringify(q,null,2))},gq=(q)=>{if(q===void 0)return Dq(process.env)??Y(`Axia cannot tell which agent harness runs you. Name it: axia install ${Lq}`);return Pq(q)?q:Y(`Axia has no install for harness "${q}". Use ${Lq}`)},gz=async(q,z)=>{let J=gq(z),Q=await U(q,"axia_onboarding_status",{});if(O([Q]))return P(Q.payload,!0);let Z=Q.payload.install?.promptBlock;if(typeof Z!=="string")return Y("Finish onboarding first; axia status names the next step.");let $=await fetch(new URL("/install.md",hq(q)));if(!$.ok)return Y(`The Axia guide did not load (${$.status}). Run the same command again.`);let W=q.installs??[],X=await $.text(),K=await Tq({harness:J,home:Sq(),env:process.env,promptBlock:Z,skill:X,previous:W.find((B)=>B.harness===J)}).catch((B)=>{if(B instanceof m)return Y(B.message);throw B});await F({...q,installs:[...W.filter((B)=>B.harness!==J),K]}),D({installed:{harness:J,promptFile:b(K.prompt),skillFile:b(K.skill)},say:jq(J),next_cli:["axia inbox --check-in"]})},mz=async(q,z)=>{let J=z===void 0?void 0:gq(z),Q=q.installs??[],Z=Q.filter(($)=>J===void 0||$.harness===J);if(Z.length===0)return D({say:"Axia is not installed in any harness on this machine."});for(let $ of Z)await Oq($);await F({...q,installs:Q.filter(($)=>!Z.includes($))}),D({removed:Z.map(({harness:$,prompt:W,skill:X})=>({harness:$,promptFile:b(W),skillFile:b(X)})),say:"Axia's prompt block and skill are gone. Delete the scheduled check-in job you created in your harness too."})},cz=async(q,z)=>{let J=Object.values(q.cursors??{}),Q=await U(q,"axia_inbox",{...J.length>0?{cursors:J}:{},...z.checkIn?{checkIn:!0}:{},...z.harness?{harness:z.harness}:{}});P(Q.payload,Q.isError);let{orgId:Z,cursor:$}=Q.payload;if(typeof Z==="string"&&typeof $==="string")await F({...q,cursors:{...q.cursors,[Z]:$}})},fz=async(q,z,J)=>{if(!await Iq(J))return Y(`No file at ${J}. Give the path to a file on this machine.`);let Q=J.split("/").pop()??J,Z=Az[Oz(J).toLowerCase()]??"application/octet-stream",$=await wz(J,{type:Z}),W={fileName:Q,mimeType:Z,sizeBytes:$.size},X=async(L)=>{let R=new FormData;for(let[lq,rq]of Object.entries(L.fields))R.append(lq,rq);R.append("file",$,Q);let e=await fetch(L.url,{method:"POST",body:R});if(!e.ok)Y(`The file store refused the upload (${e.status}). Run the same command again.`)},K=z("thread");if(K){let L=await U(q,"chat_attachments_prepare",{threadId:K,attachments:[W]});if(L.isError)return P(L.payload,!0);let[R]=L.payload;if(!R)return Y("Axia did not return an upload slot. Run the same command again.");return await X(R.upload),fq(q,{threadId:K,text:z("text")??"",attachmentIds:[R.id]})}let B=z("folder")??Y("Say where it goes: --folder <path> or --thread <threadId>"),H=await U(q,"workspace_prepareUpload",{...W,folderPath:B});if(H.isError)return P(H.payload,!0);let{fileId:dq,upload:iq}=H.payload;return await X(iq),M(q,"workspace_confirmUpload",{fileId:dq})},sz=async(q,z,J)=>{let Q=z("code");if(Q){let X=J[0]??q.pendingEmail??Y("Start with: axia login <email>");return _q(q,z,X,Q)}let Z=J[0]??Y("Give the email: axia login <email>"),$=await U(q,"axia_login_start",{email:Z});await F({...q,pendingEmail:Z});let W=$.isError?null:await hz();if(W)return _q(q,z,Z,W);return P($.payload,$.isError)},dz=async(q,z,J)=>{let Q=z("wake-url");if(Q)return M(q,"axia_bot_wake_url",{wakeUrl:Q==="off"?null:Q});if(!J[0]&&!z("name"))return M(q,"axia_onboarding_status",{});let Z=await U(q,"axia_onboarding_bot",{...J[0]?{botId:J[0]}:{},...z("name")?{name:z("name")}:{},...z("avatarUrl")?{avatarUrl:z("avatarUrl")}:{},...z("hue")?{hue:z("hue")}:{}}),$=Z.payload.newToken;if(typeof $?.token==="string")await F({...q,token:$.token});return P(Z.payload,Z.isError)},iz=async(q,z)=>{let J=await pq(q,"tools/list",{});if(J.error)return uq(J.error);let Q=z[0]?.toLowerCase()??"",Z=(J.result?.tools??[]).filter(($)=>$.name.toLowerCase().includes(Q));console.log(JSON.stringify(Z.map(($)=>({tool:$.name,about:$.description,input:$.inputSchema})),null,2));return},lz=async(q,z)=>{let J=z[0]??Y("Name the action: axia call <tool> ['<json input>']. List them with: axia tools"),Q=(()=>{try{return JSON.parse(z[1]??"{}")}catch{return Y(`The input must be JSON, like '{"taskId":"..."}'. Got: ${z[1]}`)}})(),Z=await U(q,J,Q);if(console.log(JSON.stringify(Z.payload,null,2)),Z.isError)process.exitCode=1;return},rz=async(q)=>{let z=await Sz(),J=process.env.AXIA_API_URL??q??z.apiUrl;if(J&&J!==z.apiUrl)z.apiUrl=J,z.cursors=void 0,await F(z);return z},nz=(q)=>({...q("website")?{website:q("website")}:{},...N.some((z)=>q(z))?{socials:Object.fromEntries(N.flatMap((z)=>q(z)?[[z,q(z)]]:[]))}:{}}),j=(q,z)=>q||Y(`Missing input. Run: ${z}`),tz=["firstName","lastName","email","phone","companyName","title","notes"],Nq=(q)=>Object.fromEntries(tz.flatMap((z)=>{let J=q(z);return J?[[z,J]]:[]})),oz=async(q,z)=>{let J=q("text");if(J!==void 0)return J;let Q=j(q("file"),z);if(!await Iq(Q))return Y(`No file at ${Q}. Give a path on this machine.`);return Tz(Q,"utf8")},az=(q)=>{let z=q.replace(/\/+$/,""),J=z.lastIndexOf("/");return{path:z.slice(0,J)||"/",name:z.slice(J+1)}},C=(q,z)=>typeof q==="object"&&q!==null?Reflect.get(q,z):void 0,ez=["queued","running","blocked"],_=(q)=>({next_cli:[`axia task ${q}`,`axia assign ${q} --to-user <userId> | --to-agent <agentId> | --open`,`axia note ${q} <text>`,`axia done ${q} --note <what was done> [--evidence <ref>]`]}),Aq=()=>({next_cli:["axia cat <path>","axia download <path> --to <local file>"]}),vq=({flag:q,on:z},J)=>{let Q=q("to-user"),Z=q("to-agent"),$=[...Q?[{assigneeKind:"user",assigneeUserId:Q}]:[],...Z?[{assigneeKind:"agent",assigneeAgentId:Z}]:[],...z("open")?[{assigneeKind:"unassigned"}]:[]];if($.length>1)return Y(`Give one owner only. Run: ${J}`);return $[0]??{}},qJ=(q)=>{if(q.startsWith("/"))return{kind:"workspace_file",id:q};if(/^https?:\/\//.test(q))return{kind:"url",id:q};if(q.startsWith("report:"))return{kind:"report",id:q.slice(7)};return Y(`--evidence ${q} is not a workspace path (/..), a link (https://..), or report:<reportId>.`)},kq=(q,z,J,Q)=>{let Z=`axia ${Q} <reportId>${Q==="approve"?" [--note <why>]":" --note <why>"}`,$=j(q,Z);if(z!=="approve"&&!J)return Y(`Say why. Run: ${Z}`);return["reports_decide",{reportId:$,decisionKind:z,...J?{decisionReason:J}:{}},()=>({next_cli:[`axia report ${$}`,"axia reports --status ready"]})]},c=(q)=>q?.split(",").map((z)=>z.trim()).filter(Boolean),mq=(q)=>({...q("cc")?{cc:c(q("cc"))}:{},...q("bcc")?{bcc:c(q("bcc"))}:{}}),a=(q)=>{let z=q("bodyFormat");if(z===void 0)return{};if(z==="text"||z==="html")return{bodyFormat:z};return Y(`Give --bodyFormat text or --bodyFormat html, not "${z}".`)},f=(q)=>({next_cli:[`axia mail draft ${q} [--to ..] [--cc ..] [--bcc ..] [--subject ..] [--body ..]`,`axia mail send ${q}`]}),zJ=(q)=>{let z=q("limit"),J=z?`--limit ${z} `:"";return["email_listDrafts",{input:{...z?{limit:Number(z)}:{},...q("cursor")?{cursor:q("cursor")}:{}}},(Q)=>{if(typeof Q.nextCursor!=="string")return f("<draftId>");let Z=`axia mail drafts ${J}--cursor ${Q.nextCursor}`;return Array.isArray(Q.drafts)&&Q.drafts.length===0?{say:"No unsent drafts among the newest ones. There are older drafts; read them next.",next_cli:[Z]}:{next_cli:[Z,...f("<draftId>").next_cli]}}]},o=(q)=>({next_cli:[`axia report ${String(q.reportId)}`]}),cq=(q)=>Y(`A draft keeps the format it was written in. Rewrite it: axia mail draft ${q} --body .. --bodyFormat html`),JJ=(q,z)=>{let J={...z("to")?{to:c(z("to"))}:{},...mq(z),...z("subject")?{subject:z("subject")}:{},...z("body")?{body:z("body")}:{},...a(z)};if(q){if(z("bodyFormat")!==void 0&&!z("body"))cq(q);let Z=Object.fromEntries(["cc","bcc"].filter(($)=>z($)==="").map(($)=>[$,[]]));return["email_updateDraft",{draftId:q,...J,...Z},()=>f(q)]}let Q="axia mail draft --to <address>[,<address>] [--cc ..] [--bcc ..] --subject <text> --body <text>";return j(z("to"),Q),j(z("subject"),Q),j(z("body"),Q),["email_createDraft",{...J,createdByAi:!0,idempotencyKey:Eq()},(Z)=>f(String(Z.id))]},bq={inbox:"received",sent:"sent"},QJ=(q)=>{let z=Object.hasOwn(bq,q)?bq[q]:Y(`No folder "${q}". Run: axia mail [--folder inbox|sent]`),J=q==="inbox"?"sent":"inbox";return["email_listThreads",{input:{folder:z}},()=>({next_cli:["axia mail <threadId>",`axia mail --folder ${J}`]})]},ZJ=(q,z)=>{if(q){if(z("bodyFormat")!==void 0)cq(q);return["email_requestDraftSend",{draftId:q},o]}let J="axia mail send <draftId> | axia mail send --to <address>[,<address>] [--cc ..] [--bcc ..] --subject <text> --body <text>";return["email_requestMessageSend",{to:c(j(z("to"),J)),...mq(z),subject:j(z("subject"),J),body:j(z("body"),J),...a(z)},o]},$J={rooms:()=>["chat_threads_list",{}],messages:([q])=>["chat_getHistory",{threadId:j(q,"axia messages <threadId>")}],room:([q,...z],{flag:J})=>{if(A("room",q)!=="new")return Y("Run: axia room new <name> [--agent <agentId>]");return["chat_threads_create",{title:j(z.join(" "),"axia room new <name> [--agent <agentId>]"),...J("agent")?{agentId:J("agent")}:{}},(Z)=>({next_cli:[`axia send ${String(Z.id)} <text>`,`axia wait ${String(Z.id)}`]})]},dm:([q],{flag:z})=>z("bot")?["chat_threads_openBotDm",{botId:z("bot")}]:["chat_threads_openOrCreateDm",{otherUserId:j(q,"axia dm <userId> | axia dm --bot <botId>")}],"mark-read":([q,z])=>["chat_threads_markRead",{threadId:j(q,"axia mark-read <threadId> <messageId>"),throughMessageId:j(z,"axia mark-read <threadId> <messageId>")}],chat:([q,z,J])=>{if(A("chat",q)!=="notify")return Y("Run: axia chat notify <threadId> all|mentions|off");return["chat_threads_setNotifyLevel",{threadId:j(z,"axia chat notify <threadId> all|mentions|off"),level:j(J,"axia chat notify <threadId> all|mentions|off")}]},devices:([q,z],{flag:J})=>{let Q=A("devices",q);if(Q==="register")return["devices_register",{token:j(z,"axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild .."),environment:j(J("environment"),"axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild .."),bundleId:j(J("bundleId"),"axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild .."),appVersion:j(J("appVersion"),"axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild .."),appBuild:j(J("appBuild"),"axia devices register <token> --environment production|sandbox --bundleId .. --appVersion .. --appBuild ..")}];if(Q==="unregister")return["devices_unregister",{token:j(z,"axia devices unregister <token>")}];if(Q==="list"||q===void 0)return["devices_list",{}];return Y("Run: axia devices list")},tasks:(q,{flag:z,on:J})=>{let Q=z("status"),Z=z("department"),$=()=>_("<taskId>");if(!J("all")&&!J("open")&&!Z)return["tasks_listAssignedToMe",{input:Q?{status:Q}:{}},$];return["tasks_listTasks",{input:{...Z?{departmentId:Z}:{},...J("open")?{assigneeKind:"unassigned"}:{},...Q?{status:Q}:J("open")?{statuses:ez}:{}}},$]},task:([q,...z],J)=>{let Q=A("task",q);if(Q==="cancel"){let W=j(z[0],"axia task cancel <taskId>");return["tasks_cancelTask",{taskId:W},()=>_(W)]}if(Q!=="add"){let W=j(q,"axia task <taskId>");return["tasks_getTask",{taskId:W},()=>_(W)]}let Z="axia task add <title> --department <departmentId> [--to-user <userId> | --to-agent <agentId> | --open]",$=J.flag("description");return["tasks_createDirectTask",{title:j(z.join(" "),Z),departmentId:j(J.flag("department"),Z),...$?{description:$}:{},...vq(J,Z)},(W)=>_(String(C(W.task,"id")))]},assign:([q],z)=>{let Q=vq(z,"axia assign <taskId> --to-user <userId> | --to-agent <agentId> | --open");if(!("assigneeKind"in Q))return Y("Name the new owner. Run: axia assign <taskId> --to-user <userId> | --to-agent <agentId> | --open");let Z=j(q,"axia assign <taskId> --to-user <userId> | --to-agent <agentId> | --open");return["tasks_updateTask",{taskId:Z,...Q},()=>_(Z)]},start:([q])=>{let z=j(q,"axia start <taskId>");return["tasks_startMine",{taskId:z},()=>_(z)]},done:([q],{flag:z,list:J})=>{let Q=j(q,"axia done <taskId> [--note <what was done>] [--evidence <ref> ..]"),Z=z("note"),$=J("evidence");return["tasks_completeTask",{taskId:Q,...Z?{completionNote:Z}:{},...$.length>0?{completionEvidenceRefs:$.map(qJ)}:{}},()=>({next_cli:[`axia task ${Q}`,"axia tasks"]})]},agents:()=>["agents_list",{},()=>({next_cli:["axia task add <title> --department <departmentId> --to-agent <agentId>","axia room new <name> --agent <agentId>"]})],departments:()=>["departments_list",{},()=>({next_cli:["axia tasks --department <departmentId>","axia task add <title> --department <departmentId> [--to-user <userId> | --to-agent <agentId> | --open]","axia campaigns --department <departmentId>","axia reports --department <departmentId>"]})],home:()=>["gameplay_homeState",{},(q)=>({next_cli:[...(Array.isArray(q.waitingOnYou)?q.waitingOnYou:[]).flatMap((z)=>{let J=C(z,"id"),Q=C(z,"kind");if(Q==="credits")return["axia subscribe"];if(typeof J!=="string")return[];return Q==="report_decision"?[`axia report ${J}`]:[`axia task ${J}`]}),"axia activity","axia tasks --open"]})],activity:(q,{flag:z})=>["gameplay_activity_list",{input:{...z("cursor")?{cursor:z("cursor")}:{},...z("department")?{departmentId:z("department")}:{}}},(J)=>({next_cli:typeof J.nextCursor==="string"?[`axia activity --cursor ${J.nextCursor}`]:["axia home"]})],reports:(q,{flag:z})=>["reports_list",{input:{...z("status")?{status:z("status")}:{},...z("department")?{departmentId:z("department")}:{}}},()=>({next_cli:["axia report <reportId>"]})],campaigns:(q,{flag:z})=>["tasks_listCampaigns",{input:{...z("status")?{status:z("status")}:{},...z("department")?{departmentId:z("department")}:{}}},()=>({next_cli:["axia campaign <campaignId>"]})],campaign:([q])=>["tasks_getCampaign",{campaignId:j(q,"axia campaign <campaignId>")},()=>_("<taskId>")],note:([q,...z])=>["tasks_addNote",{taskId:j(q,"axia note <taskId> <text>"),content:j(z.join(" "),"axia note <taskId> <text>")}],ls:([q])=>["workspace_list",{path:q??"/"}],cat:([q])=>["workspace_read",{path:j(q,"axia cat <path>")}],tree:([q],{flag:z})=>["workspace_tree",{path:q??"/",...z("depth")?{depth:Number(z("depth"))}:{}},Aq],search:(q)=>["workspace_search",{query:j(q.join(" "),"axia search <text>")},Aq],write:async([q],{flag:z})=>{let Q=z("version"),Z=Q===void 0?void 0:Number(Q);if(Z!==void 0&&!(Number.isInteger(Z)&&Z>0))return Y("--version takes the version number axia cat shows. axia write <path> --text .. | --file <local file> [--version N]");return["workspace_write",{path:j(q,"axia write <path> --text .. | --file <local file> [--version N]"),content:await oz(z,"axia write <path> --text .. | --file <local file> [--version N]"),...Z===void 0?{}:{expectedVersion:Z}}]},mv:([q,z])=>["workspace_move",{from:j(q,"axia mv <from> <to>"),to:j(z,"axia mv <from> <to>")}],rm:([q])=>["workspace_delete",{path:j(q,"axia rm <path>")},()=>({next_cli:["axia ls <folder>"]})],mkdir:([q])=>["workspace_createFolder",az(j(q,"axia mkdir <path>"))],"rename-folder":([q,z])=>["workspace_renameFolder",{oldPath:j(q,"axia rename-folder <oldPath> <newPath>"),newPath:j(z,"axia rename-folder <oldPath> <newPath>")}],mail:([q,z],{flag:J})=>{let Q=A("mail",q);if(Q==="setup")return["email_getSetupLink",{}];if(Q==="create")return["email_createInbox",{address:j(J("address"),"axia mail create --address <name> --displayName <name>"),displayName:j(J("displayName"),"axia mail create --address <name> --displayName <name>")}];if(Q==="drafts")return zJ(J);if(Q==="draft")return JJ(z,J);if(Q==="send")return ZJ(z,J);if(Q==="reply")return["email_requestReply",{messageId:j(z,"axia mail reply <messageId> --body <text>"),body:j(J("body"),"axia mail reply <messageId> --body <text>"),...a(J)},o];return q?["email_getThread",{threadId:q}]:QJ(J("folder")??"inbox")},approve:([q],{flag:z})=>kq(q,"approve",z("note"),"approve"),revise:([q],{flag:z})=>kq(q,"request_revision",z("note"),"revise"),invite:(q,{flag:z,list:J})=>{let Z=J("department");if(Z.length===0)return Y("Name the departments they join. Run: axia invite --department <departmentId> [--department ..] [--role member|admin] [--agent-access full|none]");return["invite_create",{role:z("role")??"member",departmentIds:Z,agentAccess:z("agent-access")??"full"},($)=>({say:`Send this code to your person: ${String($.code)}. They pass it to the person they invite, who joins with it in Axia or hands it to their own agent. axia invites shows when it is used.`,next_cli:["axia invites"]})]},contacts:(q)=>q.length>0?["contacts_search",{query:q.join(" ")}]:["contacts_list",{}],contact:([q])=>["contacts_get",{id:j(q,"axia contact <contactId>")}],"add-contact":(q,{flag:z})=>["contacts_create",Nq(z)],"edit-contact":([q],{flag:z})=>["contacts_update",{id:j(q,"axia edit-contact <contactId> [--firstName ..]"),...Nq(z)}]},WJ=async()=>{let q=pz();if(q===null){console.log(bz);return}let{command:z,rest:J,values:Q}=q,Z=(K)=>{let B=Q[K];return Array.isArray(B)?B.map(String):[]},$=(K)=>{let B=Z(K);if(B.length>1)return Y(`Give --${K} once for axia ${z}.`);return B[0]},W=(K)=>Q[K]===!0,X=await rz($("api"));switch(z){case"upload":return fz(X,$,J[0]??Y("Give the file: axia upload <file> --folder <path> | --thread <threadId>"));case"login":return sz(X,$,J);case"logout":{let K=await U(X,"axia_logout",{});return await F({...X,token:void 0}),P(K.payload,K.isError)}case"send":{let B=j(J[0],"axia send <threadId> <text>");return fq(X,{threadId:B,text:j(J.slice(1).join(" "),"axia send <threadId> <text>")},(H)=>({next_cli:[typeof H.runId==="string"?`axia wait ${B} --run ${H.runId}`:`axia wait ${B}`,`axia messages ${B}`]}))}case"status":return M(X,"axia_onboarding_status",{});case"join":return M(X,"axia_onboarding_join",{invite:J[0]??Y("Paste the invite link or code: axia join <invite link or code>")});case"company":return M(X,"axia_onboarding_company",{userName:$("userName"),companyName:$("companyName"),whatWeSell:$("whatWeSell"),...nz($)});case"answer":return M(X,"axia_onboarding_answer",{questionId:$("questionId"),answer:$("answer"),...Z("nudge").length>0?{selectedNudges:Z("nudge")}:{}});case"strategy":return M(X,"axia_onboarding_generate_strategy",{});case"decide":return M(X,"axia_onboarding_strategy_decision",{decision:J[0],...$("section")?{section:$("section")}:{},...$("note")?{note:$("note")}:{}});case"profile":return M(X,"axia_onboarding_profile",{displayName:$("displayName"),title:$("title"),responsibilities:$("responsibilities")});case"bot":return dz(X,$,J);case"deliveries":return M(X,"axia_bot_deliveries_list",{});case"ack":if(J.length===0)return Y("Give the delivery ids from axia deliveries: axia ack <eventId> [eventId ..]");return M(X,"axia_bot_deliveries_ack",{eventIds:J});case"install":return gz(X,$("harness"));case"uninstall":return mz(X,$("harness"));case"inbox":return cz(X,{checkIn:W("check-in"),harness:$("harness")});case"team":return VJ(X);case"invites":return M(X,"invite_list",{});case"orgs":return M(X,"org_listMine",{});case"switch":return M(X,"org_switchOrg",{orgId:J[0]??Y("Give the company id from axia orgs: axia switch <orgId>")});case"subscribe":return M(X,"billing_createSubscriptionCheckoutSession",{},(K)=>({say:`${Vq} The link: ${String(K.url)}`,next_cli:["axia home"]}));case"tools":return iz(X,J);case"call":return lz(X,J);case"report":return jJ(X,j(J[0],"axia report <reportId>"));case"run":return YJ(X,j(J[0],"axia run <threadId>"));case"wait":return PJ(X,j(J[0],"axia wait <threadId> [--run <runId>] [--timeout <seconds>]"),{runId:$("run"),timeout:$("timeout")});case"download":return DJ(X,j(J[0],"axia download <path> [--to <local file>]"),$("to"));default:{let[K,B,H]=await $J[z](J,{flag:$,on:W,list:Z});return M(X,K,B,H)}}},M=async(q,z,J,Q)=>{let Z=await U(q,z,J);if(!Q||Z.isError||"problem"in Z.payload)return P(Z.payload,Z.isError);let $=Array.isArray(Z.payload)?{results:Z.payload}:Z.payload;D({...$,...Q($)})},XJ={human:"user",agent:"agent",bot:"bot"},fq=async(q,z,J)=>{let Q=await U(q,"chat_mentions_listCandidates",{threadId:z.threadId});if(!Array.isArray(Q.payload))return P(Q.payload,Q.isError);let Z=Q.payload,$=Yq({text:z.text,mentions:[],candidates:Z.map((W)=>({kind:XJ[W.kind],id:W.id,displayName:W.displayName}))});return M(q,"chat_send",{...z,text:$.text,mentions:$.mentions,clientMessageId:Eq()},J)},O=(q)=>q.find((z)=>z.isError||("problem"in z.payload)),VJ=async(q)=>{let z=await Promise.all([U(q,"org_listMembers",{}),U(q,"bots_listOrg",{})]),J=O(z);if(J)return P(J.payload,!0);let[Q,Z]=z.map((W)=>W.payload),$=Array.isArray(Z?.bots)?Z.bots:[];D({members:(Array.isArray(Q)?Q:[]).map((W)=>({...W,agents:$.filter((X)=>X.ownerUserId===W.id).map((X)=>({id:X.id,name:X.name,lastCheckInAt:X.lastCheckInAt,paused:X.pausedAt!==null}))})),next_cli:["axia dm <userId>","axia dm --bot <botId>"]})},jJ=async(q,z)=>{let J=await Promise.all(["reports_get","reports_context","reports_decisionLink"].map((H)=>U(q,H,{reportId:z}))),Q=O(J);if(Q)return P(Q.payload,!0);let[Z,$,W]=J.map((H)=>H.payload),X=Z?.report,K=X?.reportKind==="external_action_approval"&&X.status==="resolved"&&$?.context?.email!==void 0?["axia mail --folder sent"]:[],B=W?.mayDecide===!0?[`axia approve ${z} [--note <why>]`,`axia revise ${z} --note <what to change>`]:[];D({report:Z?.report,context:$?.context,link:W?.url,say:W?.say,next_cli:[...B,...K,"axia reports --status ready","axia home"]})},sq=(q)=>Array.isArray(q.messages)?q.messages.map((z)=>({id:z.id,threadId:z.threadId,content:z.content})):[],YJ=async(q,z)=>{let J=await U(q,"chat_getActiveRun",{threadId:z});if(O([J]))return P(J.payload,!0);let{runId:Q,status:Z}=J.payload;if(typeof Q!=="string")return D({run:null,say:"Nothing is running in this room now.",next_cli:[`axia messages ${z}`,`axia send ${z} <text>`]});let $=await U(q,"chat_getRunLedger",{runId:Q});if(O([$]))return P($.payload,!0);D({run:{runId:Q,status:Z,agent:C($.payload.agent,"display_name")??null,messages:sq($.payload)},next_cli:[`axia wait ${z}`]})},BJ=2000,KJ=6000,GJ=["queued","running"],HJ=async(q,z,J)=>{let Q=await U(q,"chat_getActiveRun",{threadId:z});if(O([Q]))return{refused:Q};let{runId:Z}=Q.payload;if(typeof Z==="string"&&!J.includes(Z))J.push(Z);for(;;){let $=await Promise.all(J.map((B)=>U(q,"chat_getRunLedger",{runId:B}))),W=O($);if(W)return{refused:W};let X=$.findIndex(({payload:B})=>B.runStatus==="coalesced"&&typeof B.consumedByTurnId==="string");if(X===-1)return{ledgers:$};let K=String($[X]?.payload.consumedByTurnId);J.splice(X,1,...J.includes(K)?[]:[K])}},UJ=(q,z)=>D({replies:z.map(({payload:J})=>({runId:J.runId,status:J.runStatus,agent:C(J.agent,"display_name")??null,messages:sq(J)})),...z.length===0?{say:"No agent run started in this room. Read what is there with axia messages."}:{},next_cli:[`axia messages ${q}`,`axia send ${q} <text>`]}),MJ=(q)=>{let z=q===void 0?300:Number(q);return Number.isFinite(z)&&z>0?z:Y("Give the timeout in seconds, like --timeout 120")},PJ=async(q,z,J)=>{let Q=MJ(J.timeout),Z=Date.now(),$=Z+Q*1000,W=J.runId?[J.runId]:[];for(;;){let X=await HJ(q,z,W);if("refused"in X)return P(X.refused.payload,!0);let K=X.ledgers.some(({payload:H})=>GJ.includes(String(H.runStatus))),B=Date.now()-Z>=Math.min(KJ,Q*1000);if(!K&&(W.length>0||B))return UJ(z,X.ledgers);if(Date.now()>=$)return process.exitCode=1,D({problem:`A run is still working after ${Q}s.`,runs:W,next_cli:[`axia wait ${z}${J.runId?` --run ${J.runId}`:""}`,`axia run ${z}`]});await Lz(Math.min(BJ,$-Date.now()))}},DJ=async(q,z,J)=>{let Q=J??z.split("/").pop()??z,Z=await U(q,"workspace_getDownloadUrl",{path:z});if(O([Z]))return P(Z.payload,!0);let{type:$,content:W,url:X}=Z.payload,K=$==="text"?new TextEncoder().encode(typeof W==="string"?W:""):await fetch(String(X)).then(async(H)=>H.ok?new Uint8Array(await H.arrayBuffer()):Y(`The file store answered ${H.status}. Run the same command again.`)),B=await Hq(process.cwd(),Q,K).catch((H)=>{if(H instanceof u)return Y(`${Q} already exists here. Name another file: --to <local file>`);if(H instanceof E)return Y(`${Q} is not inside this folder. Name a file in it, like --to notes/${z.split("/").pop()}`);throw H});D({saved:B.path,bytes:B.bytes,next_cli:[`axia cat ${z}`]})};await WJ();
|
package/package.json
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@axia-labs/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "axia: your agent's command line for Axia OS.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"homepage": "https://app.axia.agency",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Axia-Labs-Inc/axia-os.git",
|
|
10
|
+
"directory": "apps/cli"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"bin": {
|
|
14
|
+
"axia": "dist/axia.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/axia.js"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "bun scripts/build.ts",
|
|
27
|
+
"typecheck": "bunx tsc -p tsconfig.json --noEmit"
|
|
28
|
+
}
|
|
29
|
+
}
|