@aventurevc/aventure-cli 0.8.57 → 0.8.60

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 CHANGED
@@ -53,22 +53,22 @@ paid plan (AI Plus or AI Pro). On the free plan, find a company by its website w
53
53
  `aventure entities search --text-search Stripe`.
54
54
 
55
55
  ```sh
56
- aventure lookup Stripe # by name
57
- aventure lookup --name Stripe --url https://stripe.com # by website
56
+ aventure lookup --name Stripe # by name
57
+ aventure lookup --url https://stripe.com # by website
58
58
  aventure search --query "payments infrastructure for online businesses" # by description
59
59
  ```
60
60
 
61
61
  Add `--location` or `--context` to tell companies with the same name apart:
62
62
 
63
63
  ```sh
64
- aventure lookup Mercury --context "banking for startups" --location "San Francisco"
64
+ aventure lookup --name Mercury --context "banking for startups" --location "San Francisco"
65
65
  ```
66
66
 
67
67
  ## Find a Person
68
68
 
69
69
  ```sh
70
- aventure people lookup "Patrick Collison" --context "Stripe co-founder"
71
- aventure people lookup "Patrick Collison" --url https://www.linkedin.com/in/patrickcollison
70
+ aventure lookup --kind PERSON --name "Patrick Collison" --context "Stripe co-founder"
71
+ aventure lookup --kind PERSON --name "Patrick Collison" --url https://www.linkedin.com/in/patrickcollison
72
72
  aventure search --query "fintech founders who previously worked at PayPal"
73
73
  ```
74
74
 
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{ci as e,hi as t,mi as n,oa as r,oi as i}from"../chunks/client-BpYMZcZs.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-o-bm4L7a.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-CFPO3tWH.js";import{r as u}from"../chunks/text-field-CptX-2Wn.js";var d=process.argv.slice(2);c(d)&&e(!1),d.includes(`--all-fields`)&&u(!0);try{if(t(),s(d,l)===`optional`)try{await a(),await o()}catch(e){i({component:n().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-YCyY07Pv.js`)}catch(e){if(!(e instanceof r))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
2
+ import{_i as e,ca as t,ci as n,gi as r,ui as i}from"../chunks/client-CPfxUSzY.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-DiWrWOhb.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-DuR3b95O.js";import{r as u}from"../chunks/text-field-DTg-kaR7.js";var d=process.argv.slice(2);c(d)&&i(!1),d.includes(`--all-fields`)&&u(!0);try{if(e(),s(d,l)===`optional`)try{await a(),await o()}catch(e){n({component:r().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-B4AdCqzQ.js`)}catch(e){if(!(e instanceof t))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "MCP_GENERATION_CONTRACT",
4
- "generatedAt": "2026-10-05T07:40:49.940Z",
4
+ "generatedAt": "2026-10-05T21:08:56.254Z",
5
5
  "totalOperations": 135,
6
6
  "note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
7
7
  "operations": [
@@ -0,0 +1,65 @@
1
+ import{C as e,Ci as t,D as n,Di as r,Ei as i,Oi as a,Si as o,T as s,a as c,aa as l,bi as u,c as d,ci as f,d as p,f as m,gi as h,i as g,ki as _,l as v,la as y,m as b,mi as ee,n as te,o as x,oa as S,oi as ne,p as re,r as ie,sa as ae,u as oe,v as se,vi as C,w as ce,wi as w,x as le,xi as ue,y as de}from"./client-CPfxUSzY.js";import{M as fe,O as pe,i as T,o as me,v as he,w as E,y as D}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,M as O,N as ye,O as be,S as xe,T as Se,a as Ce,b as we,c as Te,d as Ee,g as De,j as Oe,k as ke,l as Ae,m as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./oauth-bearer-credential-DiWrWOhb.js";import{C as Ve,S as He,_ as Ue,a as We,b as Ge,c as Ke,d as qe,f as Je,g as Ye,h as Xe,l as Ze,m as Qe,n as $e,o as k,p as et,r as A,s as tt,t as j,u as nt,v as rt,x as it,y as at}from"./openapi-commands-DuR3b95O.js";import{a as ot}from"./text-field-DTg-kaR7.js";import{i as st,n as ct,o as lt,s as ut,t as dt}from"./text-response-D0juNoOf.js";import{n as ft,r as pt,t as mt}from"./oauth-login-ByzrkTxe.js";import{spawnSync as ht}from"node:child_process";import{basename as gt,dirname as M,resolve as N,sep as _t}from"node:path";import{copyFileSync as vt,existsSync as yt,lstatSync as bt,mkdirSync as xt,mkdtempSync as St,readFileSync as Ct,readlinkSync as wt,realpathSync as Tt,renameSync as Et,rmdirSync as Dt,unlinkSync as Ot,writeFileSync as kt}from"node:fs";import P,{stderr as F,stdin as At}from"node:process";import{TextDecoder as jt,inspect as Mt}from"node:util";import{fileURLToPath as Nt}from"node:url";import{readFile as Pt}from"node:fs/promises";import{setTimeout as Ft}from"node:timers/promises";import{webcrypto as It}from"node:crypto";import{homedir as Lt,hostname as Rt,platform as zt}from"node:os";import{createInterface as Bt}from"node:readline/promises";function Vt(e,t,n){let i={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let a=process.env[t]?.trim();if(a===void 0||a.length===0)continue;let o=i[n.optionKey];if(o!==void 0&&(typeof o!=`string`||o!==a))return{...r(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${a}.`),data:i};o===void 0&&(i[n.optionKey]=a)}return a(`Environment-bound options applied`,i)}function Ht(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!nn(n,r.name))continue;let a=tn(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function Ut(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function Wt(e,t,n,r=!1){if(r||!on(t)||!Array.isArray(n))return cn(e,t,n);for(let[r,i]of n.entries()){let n=cn(e,t,i,r);if(!n.ok)return n}return a(`Body value assigned`,null)}function Gt(e,t,n,r){return cn(e,t,r,n)}function Kt(e){let t=[];for(let n of e.split(`.`)){let e=un(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function qt(e,t){let n=Kt(t);if(n===null)return null;let r=en(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:$t(r)}:null}function Jt(e,t){if(on(e.name)||e.schemaType===`array`)return a(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return a(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?a(`Scalar body option selected`,t[0]):r(`${n} was already given; pass it once.`)}var Yt=/^(?<row>\d+):(?<item>.*)$/su;function Xt(e,t){let n=Kt(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=Yt.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function Zt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Kt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Qt(e,t,n,i){for(let a of t.parameter){let t=n[a.optionKey];if(t===void 0)continue;let o=qt(i,a.name);if(o===null)continue;if(o.firstHole!==null)return r(`${e} has no ${o.path}[] row ${o.firstHole} — number ${o.path}[] rows from 0 with no gaps.`);if(a.schemaType!==`array`||o.rowCount<=1||Xt(a,t)!==null)continue;let s=a.flag.split(` `)[0]??a.name;return r(`${s} fills one ${o.path}[] row's list, so ${e} cannot also build ${o.rowCount} ${o.path}[] rows from direct options — prefix each value with its 0-based ${o.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function $t(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function en(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function tn(e,t){if(!on(t))return en(e,t.split(`.`))}function nn(e,t){return an(e,t.split(`.`))}function rn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&nn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function an(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=un(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>an(e,r)):an(a,r)}function on(e){return e.split(`.`).some(e=>un(e).isArray)}function sn(e,t){return e.parameter.length===0||!I(t)?null:fn(t,[],dn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cn(e,t,n,i=0){let o=t.split(`.`),s=e;for(let[e,c]of o.entries()){let l=un(c),u=e===o.length-1,d=ln(s,l,t,u,n,i);if(!d.ok||d.data===null)return r(d.summary,d.warnings);if(u)return a(`Body value assigned`,null);s=d.data}return r(`${t} is not a valid body option path.`)}function ln(e,t,n,i,o,s){let c=()=>r(`${n} cannot be combined with another body option at ${t.key}.`),l=e[t.key];if(t.isArray){if(l!==void 0&&!Array.isArray(l))return c();let n=l??[];if(l===void 0&&(e[t.key]=n),i)return n[s]===void 0?(n[s]=o,a(`Body value assigned`,e)):c();let r=n[s];if(r===void 0){let e={};return n[s]=e,a(`Body path created`,e)}return I(r)?a(`Body path stepped`,r):c()}if(i)return l===void 0?(e[t.key]=o,a(`Body value assigned`,e)):c();if(l===void 0){let n={};return e[t.key]=n,a(`Body path created`,n)}return I(l)?a(`Body path stepped`,l):c()}function un(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function dn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function fn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=fn(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!pn(a,n)){if(!mn(e))continue;return{path:a,suggestion:hn(e,n)}}let o=fn(i,e,n);if(o!==null)return o}return null}function pn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function mn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function hn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:gn(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function gn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}function _n(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(He(e)),t.description=d(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?Tn(r,i):r===void 0?i===void 0?0:1:-1})}function vn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function yn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function bn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Cn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function xn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Sn(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?Ve(n):`${Ve(n)} Required JSON paths: ${r.join(`, `)}.`}function Cn(e,t){let n=Ge(t.description,void 0),r=e.kind!==`multipart`&&on(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${wn(e,t)}`}function wn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Kt(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function Tn(e,t){return it(e)-it(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function En(e){let t;try{t=e===`-`?await Dn():await Pt(e,`utf8`)}catch(t){return r(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return a(`No input provided`,null);let e=JSON.parse(t);return a(`Input parsed`,e)}catch(e){return r(`Input is not valid JSON: ${e.message}`)}}async function Dn(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var On=`--content-type`;function kn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(On)){let t=i.map(({contentType:e})=>e);e.addOption(new S(`${On} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(jn(i)))}if(Xn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new S(`--from-file <path>`,Sn(n,n.requiredPath)).argParser(Nn(`--from-file`)))}let a=vn(i).filter(e=>r(L(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>Tn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new S(yn(t),i.length>1?bn(t):Cn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?xn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(An):on(r.name)||r.schemaType===`array`?a.argParser(Mn):a.argParser(Nn(r.flag)),e.addOption(a),a.envVar!==void 0&&e.on(`optionEnv:${a.name()}`,()=>{let t=e.opts()[r.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(r.optionKey,t.trim(),`env`)})}Yn(e,t,a)}function An(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function jn(e){return(t,r)=>{if(r!==void 0)throw new y(`${On} was already given; pass it once.`);let i=n(e,t);if(!i.ok)throw new y(i.summary);return t}}function Mn(e,t){return[...t??[],e]}function Nn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new y(`${t} was already given; pass it once.`);return e}}async function Pn(e,t){let i=qe(e,t),o=n(e.requestBody??[],i);if(!o.ok||o.data===null)return r(o.summary,o.warnings);let s=o.data;if(s===void 0)return a(`No body`,void 0);let c=Fn(e,s,t);if(c!==null)return r(c);let l=Vt(e.operationId,s,t);if(!l.ok)return r(l.summary,l.warnings);t=l.data;let u=In(s,t);if(u!==null)return r(u);let d=await Bn(t);if(!d.ok)return r(d.summary,d.warnings);let f=rn(e.requestBody??[],s,d.data);if(f!==null)return r(f);let p=zn(e.operationId,s,d.data);if(!p.ok)return p;let m=Ht(e.operationId,s,d.data);if(m!==null)return r(m);let h=Vn(e.operationId,s,t);if(!h.ok)return h;if(d.data===void 0&&h.data===void 0)return s.required?r(Jn(e.operationId,s)):a(`No body`,void 0);let g=Un(e.operationId,d.data,h.data);if(!g.ok||g.data===void 0)return g;if(s.schemaType===`array`&&!Array.isArray(g.data))return r(`${e.operationId} requires a JSON array body.`);if(s.parameter.length>0&&!I(g.data)){let t=s.kind===`multipart`?` keyed by multipart part name`:` body`;return r(`${e.operationId} requires a JSON object${t}.`)}let _=Rn(s,g.data);if(_.length>0)return r(`${e.operationId} requires body option(s): ${_.join(`, `)}`);let v=g.data,y=I(v)?Ut(s).filter(e=>!nn(v,e)):[];return y.length>0?r(Ln(e.operationId,s,y)):g}function Fn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${On} ${i.join(` or `)}.`}return null}function In(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Ln(e,t,n){let r=`${e} requires JSON body path(s): ${n.join(`, `)}`;return t.kind===`multipart`?`${r}. ${n.includes(`body`)?`For multipart --from-file, wrap the endpoint JSON under top-level "body".`:`For multipart --from-file, put the missing nested path(s) inside top-level "body".`}`:r}function Rn(e,t){return I(t)?e.parameter.filter(e=>e.required&&!nn(t,e.name)).map(L):[]}function zn(e,t,n){let i=sn(t,n);if(i===null)return a(`Body file paths validated`,null);let o=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return r(`${e} --from-file contains unknown JSON path ${i.path}.${o}`)}async function Bn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return a(`No body file`,void 0);let n=await En(t);if(!n.ok)return r(n.summary,n.warnings);let i=_.safeParse(n.data);return i.success?a(`Input parsed`,i.data):r(`Input is not valid JSON value: ${i.error.message}`)}function Vn(e,t,n){let i={},o=!1;for(let e of t.parameter){let a=Jt(e,n[e.optionKey]);if(!a.ok||a.data===null)return r(a.summary,a.warnings);let s=a.data;if(s===void 0)continue;let c=Hn(t,n,i,e,s);if(!c.ok)return r(c.summary,c.warnings);o=!0}if(!o)return a(`No direct body options`,void 0);let s=Qt(e,t,n,i);return s===null?a(`Direct body options parsed`,i):s}function Hn(e,t,n,i,o){let s=Xt(i,o);if(s===null){let e=Kn(i,o);return e.ok?Wt(n,i.name,e.data,i.schemaType===`array`):r(e.summary,e.warnings)}if(s.plain.length>0)return r(`${L(i)} mixes row-form values with plain value(s): ${s.plain.join(`, `)} — prefix every value with its 0-based ${s.container}[] row index, as 0:value.`);let c=Zt(e,t,s.container);for(let e of s.rows.keys())if(!(e<c))return r(`${L(i)} names ${s.container}[] row ${e}, but these options build at most ${c} ${s.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of s.rows){let a=[];for(let e of t){let t=qn(i.name,i.itemSchemaType,e);if(!t.ok)return r(t.summary,t.warnings);a.push(t.data)}let o=Gt(n,i.name,e,a);if(!o.ok)return o}return a(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function Un(e,t,n){if(t===void 0)return a(`Direct body parsed`,n);if(n===void 0)return a(`Input parsed`,t);if(I(t)&&I(n))try{return a(`Input parsed`,Wn(t,n))}catch(t){return r(`${e} ${t.message}`)}return r(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Wn(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(Array.isArray(t)&&Array.isArray(r))throw Error(`cannot combine --from-file array '${e}' with array body options at the same key — move the per-item fields inside the matching '${e}[]' object(s) in the file body.`);if(t!==void 0&&Gn(t)!==Gn(r))throw Error(`cannot combine --from-file ${Gn(t)} '${e}' with ${Gn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=I(t)&&I(r)?Wn(t,r):r}return n}function Gn(e){return Array.isArray(e)?`array`:I(e)?`object`:`scalar`}function Kn(e,t){if(typeof t==`boolean`)return a(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return qn(e.name,e.schemaType,t??``);let n=[],r=on(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=qn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return a(`Body value parsed`,n)}function qn(e,t,n){if(t===`boolean`)return n===`true`?a(`Body value parsed`,!0):n===`false`?a(`Body value parsed`,!1):r(`${e} must be true or false.`);if(t===`number`||t===`integer`){let i=n.trim(),o=Number(i);return i===``||!Number.isFinite(o)?r(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(o)?r(`${e} must be an integer.`):a(`Body value parsed`,o)}return a(`Body value parsed`,n)}function Jn(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=Ut(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Yn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:On,location:`body`}),Xn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),_n(e.options,r)}function Xn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Zn(e){let t=i(e);return or(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Qn(e){or(e);let t=dt(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
2
+ `)?t:`${t}\n`),$n(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&nr(e.problem),$n(e)}function $n(e){e.ids.length>0&&process.stdout.write(` ids: ${e.ids.join(`, `)}\n`);for(let[t,n]of Object.entries(e.counts))process.stdout.write(` ${t}: ${n}\n`);for(let t of e.references)process.stdout.write(` ref: ${t}\n`);if(e.truncation!==void 0){let t=e.truncation.omitted.join(`, `);process.stdout.write(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${t}\n`),process.stdout.write(` recovery: ${e.truncation.recovery}\n`)}for(let t of e.warnings)process.stdout.write(` warn: ${t}\n`)}function R(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?i(t):t;or(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?er(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Zn(t):t;e.mode===`text`&&Qn(n),n.ok||(process.exitCode=1)}function er(e){return typeof e!=`object`||!e||Array.isArray(e)||!Reflect.has(e,`method`)||!Reflect.has(e,`endpoint`)||!(`response`in e)||e.response===void 0?e:e.response}function tr(e,t){let n=ct(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
3
+ `),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function nr(e){typeof e.code==`string`&&process.stdout.write(` code: ${e.code}\n`),typeof e.detail==`string`&&process.stdout.write(` detail: ${e.detail}\n`),typeof e.hint==`string`&&process.stdout.write(` hint: ${e.hint}\n`),typeof e.suggestion==`string`&&process.stdout.write(` suggestion: ${e.suggestion}\n`);let t=Object.entries(e.suggestions??{});if(t.length>0){let e=t.map(([e,t])=>`${e}=${t}`).join(`; `);process.stdout.write(` suggestions: ${e}\n`)}typeof e.requiredRole==`string`&&process.stdout.write(` requiredRole: ${e.requiredRole}\n`),rr(e),ir(`unknownParameters`,e.unknownParameters),ir(`validParameters`,e.validParameters),ar(e.resolution)}function rr(e){let t=[];typeof e.limitType==`string`&&t.push(`limitType=${e.limitType}`),typeof e.used==`number`&&t.push(`used=${e.used}`),typeof e.limit==`number`&&t.push(`limit=${e.limit}`),typeof e.remaining==`number`&&t.push(`remaining=${e.remaining}`),typeof e.resetAt==`string`&&t.push(`resetAt=${e.resetAt}`),typeof e.windowSeconds==`number`&&t.push(`windowSeconds=${e.windowSeconds}`),typeof e.retryAfterSeconds==`number`&&t.push(`retryAfterSeconds=${e.retryAfterSeconds}`),t.length>0&&process.stdout.write(` meter: ${t.join(` `)}\n`)}function ir(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function ar(e){if(e==null)return;let t=[`action=${e.action}`];typeof e.parameter==`string`&&t.push(`parameter=${e.parameter}`),typeof e.fieldPath==`string`&&t.push(`fieldPath=${e.fieldPath}`),typeof e.endpoint==`string`&&t.push(`endpoint=${e.endpoint}`),e.acceptedValue!==null&&e.acceptedValue!==void 0&&e.acceptedValue.length>0&&t.push(`acceptedValue=${e.acceptedValue.join(`, `)}`),typeof e.retryable==`boolean`&&t.push(`retryable=${e.retryable}`),process.stdout.write(` resolution: ${t.join(` `)}\n`)}function or(e){e.ok&&e.warnings.length===0||f({component:h().bin[0],event:e.ok?`command_warning`:`command_failed`,message:e.warnings.length>0?e.warnings.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function sr(e,t,n=h().bin[0]){let i=e.limit===void 0?void 0:Number(e.limit);if(i!==void 0&&(e.limit?.trim()===``||!Number.isInteger(i)||i<0))return r(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let o=st(e.q??``,ur(t,n).filter(t=>mr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)]})).map(({item:e})=>e),s=o.slice(0,i);return a(`Operation catalog matches`,{operation:s,count:{totalOperations:t.length,matched:o.length,returned:s.length}})}function cr(e,t,n=h().bin[0]){let i=ur(t,n),o=e.operationId===void 0?lr(i,e.command):i.find(t=>t.operationId===e.operationId);if(o===void 0){let a=Or(e.command??``),o=i.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${a} `));if(o.length>0)return r(`${a} is a command group; show one of its subcommands.`,[`Run \`${n} command-catalog show --command "<subcommand>"\` with one of:`,...o]);let s=a.split(` `),c=new Set([...[...s.keys()].map(e=>s.slice(e+1).join(` `)),...s.slice(1).map((e,t)=>s.toSpliced(t,2,`${s[t]}-${e}`).join(` `))]),l=sr({q:e.command??e.operationId},t,n),u=[...i.filter(({cli:e})=>e.path.length>1&&c.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...l.data?.operation??[]];return r(`Generated operation not found`,[...[...new Set(u.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${n} command-catalog search "<text>"\`.`])}return a(`Generated operation detail`,{operation:o,usage:gr(o,i)})}function lr(e,t){if(t===void 0)return;let{bin:n}=h(),r=Or(t,n);return e.find(e=>Or(e.cli.command,n)===r)}function ur(t,n){return t.map(t=>{let r=t.requestBody??[],i=[...t.parameters.map(e=>dr(e)),...r.flatMap(e=>e.parameter.map(t=>dr(t,r.length>1?e.contentType:void 0))),...fr(r)],a=[n,...t.cliPath].join(` `),o=e(t.intent),c=t.method===`DELETE`||t.intent===`delete`,l=r[0];return{operationId:t.operationId,method:t.method,path:t.path,resource:t.resource,intent:t.intent,scope:t.scope,mutates:o,destructive:c,auth:t.auth,cli:{command:a,path:t.cliPath},mcpTool:t.binaryResponse||!s(t.path)?null:ce(t.intent),body:{hasBody:l!==void 0,kind:l?.kind??null,...l!==void 0&&r.length>1?{contentType:l.contentType}:{},required:l?.required??!1,description:l?.description??``,requiredPath:l?.requiredPath??[]},flags:i,errorResponse:t.errorResponse,summary:t.summary,description:t.description,deprecated:t.deprecated}})}function dr(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function fr(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request content type; omit for ${t[0]}.`,choices:t}]}function pr(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function mr(e,t){return!(t.root!==void 0&&!hr(e,t.root)||t.scope!==void 0&&t.scope!==`all`&&t.scope!==e.scope||t.mutates!==void 0&&t.mutates!==`any`&&t.mutates===`true`!==e.mutates||t.destructive!==void 0&&t.destructive!==`any`&&t.destructive===`true`!==e.destructive||t.intent!==void 0&&t.intent!==`all`&&t.intent!==e.intent||t.method!==void 0&&t.method!==`all`&&t.method!==e.method)}function hr(e,t){let n=ut(t);return n.length===0||ut(e.cli.path.at(0)??``)===n}function gr(e,t){let n=pr(e),r=n.filter(e=>e.required),i=n.filter(e=>!e.required);return[`cli: ${e.cli.command}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (CLI-only operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,z(`required path flags`,r,`path`),z(`required query flags`,r,`query`),z(`required header flags`,r,`header`),z(`required body flags`,r,`body`),z(`optional path flags`,i,`path`),z(`optional query flags`,i,`query`),z(`optional header flags`,i,`header`),z(`optional body flags`,i,`body`),...Cr(e,t),..._r(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
4
+ `)}function _r(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var vr=[`-id`,`-slug`,`-url`],yr=[`--id`,`--slug`,`--url`],br=`/v1/lookup`,xr=`--from-file "<path>"`;function Sr(e,t,n=h().bin[0]){let r=ur(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:Cr(i,r)}function Cr(e,t){return[`example: ${[e.cli.command,...Tr(e),`--data`].join(` `)}`,...wr(e,t)]}function wr(e,t){return pr(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${Dr(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===br),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${Dr(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}function Tr(e){let t=pr(e).filter(e=>e.required),n=(t.length>0?t:Er(e)).map(Dr);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,xr]:n}function Er(e){let t=new Set;lt(t,e.resource);for(let n of vr)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of yr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function Dr(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function z(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function Or(e,t=h().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var kr=`dist/aventure-cli/command-catalog.compact.txt`,Ar=` · `,jr=`-`;function Mr(e=h().bin[0]){return N(Nr(M(Nt(import.meta.url)),e),kr)}function Nr(e,t){let n=e;for(;;){if(yt(N(n,`package.json`)))return n;let r=M(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Pr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Fr(e,t,n,r=h().bin[0]){let i=sr(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Lr({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:zr(i.data,Rr(e.format,`lines`)),summary:`Generated operation matches`})}function Ir(e,t,n,r=h().bin[0]){let i=cr(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Lr({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Br(i.data,Rr(e.format,`usage`)),summary:`Generated operation detail`})}function Lr(e){let t=e.mode,n=Rr(e.opts.format,e.defaultFormat),i=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&i&&(n===`json`||n===`ndjson`)){R({mode:t},r(`--text or --all-fields cannot be combined with --format json or ndjson`,[`Omit the text flag for machine output, or use --format lines, compact, or text.`]));return}let o=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.matched===0&&(i||e.opts.format===void 0||n===`text`)?`No generated operations matched.`:e.rendered,s=o.endsWith(`
5
+ `)?o:`${o}\n`;if(e.opts.output!==void 0){kt(e.opts.output,s),R({mode:t},a(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(s,`utf8`),format:n},{counts:Gr(e.data)}));return}if(t===`text`){process.stdout.write(s);return}R({mode:t},a(e.summary,e.data,{counts:Gr(e.data)}))}function Rr(e,t){return e??t}function zr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
6
+ `):t===`text`?Ur(e.operation):t===`compact`?e.operation.map(Vr).join(`
7
+ `):e.operation.map(Wr).join(`
8
+ `)}function Br(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?Wr(e.operation):t===`compact`?Vr(e.operation):e.usage}function Vr(e){let t=Hr(e);return[e.cli.command,e.summary,t.length===0?jr:t.join(` `)].join(Ar)}function Hr(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function Ur(e){return e.map(e=>`${e.cli.command}\n ${Wr(e)}`).join(`
9
+ `)}function Wr(e){let t=Hr(e);return[B(`operationId`,e.operationId),B(`scope`,e.scope),B(`mutates`,String(e.mutates)),B(`destructive`,String(e.destructive)),B(`intent`,e.intent),B(`resource`,e.resource),B(`cli`,e.cli.command),e.mcpTool===null?``:B(`mcpTool`,e.mcpTool),B(`method`,e.method),B(`path`,e.path),B(`auth`,e.auth),B(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),B(`requiredFlags`,t.join(` `)),B(`bodyKind`,e.body.kind??``),B(`bodyRequired`,String(e.body.required)),B(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function B(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function Gr(e){return`count`in e?e.count:{returned:1}}function Kr(e,t,n=h().bin[0]){e.helpCommand(!1);let i=e.commands.find(e=>e.name()===`help`)??e.command(`help`);i.summary(`Show full documentation for a command, or ask a question`).description([`Show a command's full documentation offline. Select it by command path,`,"operationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.","`help ask <question>` or `help --ask <question>` answers a platform question."].join(`
10
+ `)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),i.addOption(new qr(i)),i.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let o=$r(t);o!==void 0&&i.option(`--ask <question>`,o.summary),A(i),i.action(async function(i){let s=this.optsWithGlobals();if(s.help&&i.length===0){this.outputHelp();return}if(!s.help&&o!==void 0&&s.ask!==void 0){let e=k(s);if(i.length>0){R({mode:e},r(`Use either a command path or --ask, not both.`));return}R({mode:e},await ri(o,s.ask,s.environment,e));return}let c=ni(e,i),l=t.find(t=>c!==void 0&&ni(e,t.cliPath)===c);if(s.help||c!==void 0&&l===void 0){c===void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${n} --help\` for the command tree)`),c.outputHelp();return}let u=l===void 0?ti(i,t):a(`Resolved by command path`,{operationId:l.operationId});if(u.ok&&u.data?.command!==void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${n} --help\` for the command tree)`),!u.ok||u.data===null){R({mode:k(s)},u);return}Ir({...s,...u.data},t,k(s,`text`),n)}),Qr(e,t,n)}var qr=class extends S{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},Jr=2,Yr=6,Xr={formatHelp(e,t){let n=n=>ae.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let r=t.padWidth(e,t),i={padWidth:()=>r,visibleOptions:()=>[],showGlobalOptions:!1},a=n({...i,visibleCommands:()=>[]}),o=n({padWidth:()=>r,visibleCommands:()=>[]}).slice(a.length);return n(i)+o},visibleCommands(e){let t=ae.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!rt.has(e.name())):t},subcommandTerm(e){let t=ae.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,r){let i=r.helpWidth??80,a=i-t-4;return n===``||a>=r.minWidthToWrap?ae.prototype.formatItem.call(r,e,t,n,r):`${` `.repeat(Jr)}${e}\n${Zr(n,i,r)}`}};function Zr(e,t,n){return n.boxWrap(e,t-Yr).replace(/^/gmu,` `.repeat(Yr))}function Qr(e,t,n){for(let r of t){let i=ni(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp();e.prepareContext({helpWidth:i.configureOutput().getOutHelpWidth?.()});let a=e.helpWidth??80,o=Sr(r.operationId,t,n),[s,...c]=_r(r.errorResponse),l=c.map(t=>Zr(t.trimStart(),a,e).replace(/^ +/u,` `.repeat(Jr))),u=s===void 0?[]:[``,s,...l];return`\n${[...o,...u].join(`
11
+ `)}\n`})}}function $r(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&ii(e)!==void 0});return n.length===0?t:void 0}var ei='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ti(e,t){let[n,...i]=e,o=re.find(e=>e===n?.toLowerCase());if(o===void 0||i.length===0){let n=e.join(` `).trim();return a(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=v(o),l=i.join(``),u=t.find(e=>e.method===s&&e.path===l);if(u!==void 0)return a(`Resolved by route template`,{operationId:u.operationId});let d=c({method:s,path:l});return!d.ok||d.data===null?r(d.summary,[...d.warnings,ei]):a(`Resolved by method and path`,{operationId:d.data.operation.operationId})}function ni(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}async function ri(e,t,n,i){let a=ii(e);if(a===void 0)return r(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let o=await Pn(e,{[a.optionKey]:t});return o.ok?await x({method:e.method,path:ie(e.operationId,{}),searchParams:{},body:o.data,auth:e.auth,responseFormat:We(i)?`json`:`auto`}):o}function ii(e){if(e.requestBody?.length!==1||e.parameters.some(e=>e.required))return;let t=(e.requestBody[0]?.parameter??[]).filter(e=>e.required);return t.length===1&&t[0]?.schemaType===`string`?t[0]:void 0}function ai(e,t,n){if(e.cliPath[0]!==`lookup`||!oi(n))return null;let i=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`),a=`no record for ${i.length===0?`the given input`:i.join(`, `)}`;return n.ok?r(a):r(a,[],{httpStatus:n.httpStatus,problem:n.problem})}function oi(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function si(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}var ci=D({artifact:E().nullish(),group:E().nullish(),name:E().nullish(),revision:E().nullish(),time:T({offset:!0}).nullish(),version:E().nullish()}),li=D({build:ci});function V(e,t){let[n,r]=e.filter(e=>e.role===t);if(n===void 0||r!==void 0)throw Error(`Generated composite CLI role '${t}' is incomplete`);return n}var ui=me([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),di=me([`RSA_OAEP_256_A256_GCM_V1`]),fi=D({clientLabel:E().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:ui.nullish(),encryptionAlgorithm:di.nullish(),encryptionPublicKey:E().min(344).max(12e3).nullish()}),pi=32;async function mi(){let e=await It.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await It.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function hi(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=gi(n,`wrapped key`,128,1024),s=gi(r,`nonce`,12,12),c=gi(i,`ciphertext`,1,65536),l=gi(a,`authentication tag`,16,16),u;try{u=await It.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==pi)throw Error(`broker credential used an invalid AES-256 key`);let e=await It.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await It.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new jt(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function gi(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var _i=me([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),vi=me([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),yi=D({approvedAt:T({offset:!0}).nullish(),clientLabel:E(),clientPlatform:ui,comparisonCode:E(),consumedAt:T({offset:!0}).nullish(),createdAt:T({offset:!0}),expiresAt:T({offset:!0}),id:pe(),intervalSeconds:he().int().min(1),keyReadyAt:T({offset:!0}).nullish(),status:_i,terminalAt:T({offset:!0}).nullish(),terminalReason:vi.nullish(),updatedAt:T({offset:!0})}),bi=D({algorithm:di,authenticationTag:E(),ciphertext:E(),nonce:E(),wrappedKey:E()}),xi=D({delivery:bi.nullish(),expiresAt:T({offset:!0}),status:_i,terminalReason:vi.nullish()}),Si=D({comparisonCode:E(),expiresAt:T({offset:!0}),id:pe(),intervalSeconds:he().int().min(1),pollSecret:E(),verificationUrl:E()}),H=[{command:`auth login`,role:`oauth`,summary:`Sign In Through Your Browser`,description:`Sign in through your browser and save verified CLI access in the credential store.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`},{optionKey:`providers`,flag:`--providers`,description:`Print the sign-in providers and CLI OAuth client, then exit without signing in.`}]},{command:`auth login`,role:`start`,summary:`Sign In With a Browser-Approved aVenture API Key`,description:`Creates a short-lived browser approval request and returns its poll credential once.`,operationId:`createCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations`,bodyOption:[{name:`clientLabel`,optionKey:`clientLabel`,flag:`--client-label <client-label>`,required:!1,description:`Label for this CLI installation.`}],localOption:[{optionKey:`key`,flag:`--key`,description:`Sign in with a browser-approved aVenture API key instead of OAuth; the approval URL opens on any device.`},{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`}]},{command:`auth login`,role:`poll`,summary:`Poll CLI Authorization`,description:`Returns pending state, a terminal state, or an encrypted one-time credential delivery.`,operationId:`pollCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/poll`,bodyOption:[],localOption:[]},{command:`auth login`,role:`acknowledge`,summary:`Acknowledge CLI Credential Delivery`,description:`Confirms the CLI stored the delivered API key in its credential store and clears transient delivery material.`,operationId:`acknowledgeCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/acknowledge`,bodyOption:[],localOption:[]},{command:`auth logout`,role:`revoke`,summary:`Sign Out: Revoke the API Key and Forget Stored OAuth`,description:`Revokes the aVenture API key authenticating this request and returns its metadata so the CLI can confirm revocation before deleting its saved copy.`,operationId:`revokeCurrentApiKey`,method:`DELETE`,path:`/v1/auth/api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Delete the saved key even when revocation cannot be confirmed.`}]}],Ci=V(H,`start`),wi=V(H,`poll`),Ti=V(H,`acknowledge`),U=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${ye(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=ji(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},Ei=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${O(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function Di(e){let t=await oe(ge(w()),{method:Ci.method,path:b(Ci.path,{},Ci.operationId),headers:{},contentType:`application/json`,body:e},Si);if(t.ok&&t.redirect)throw new U(`start`,Mi(t.status));if(!t.ok)throw new U(`start`,t.problem);return Ni(t.data)}async function Oi(e,t){let n=g(wi.operationId),r=await oe(ge(w()),{method:wi.method,path:b(wi.path,{cliAuthorizationId:e},wi.operationId),headers:{[n]:t}},xi);if(r.ok&&r.redirect)throw new U(`poll`,Mi(r.status),[t]);if(!r.ok)throw new U(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Ai(r.headers[`retry-after`])}}async function ki(e,t){let n=g(Ti.operationId),r;try{r=await oe(ge(w()),{method:Ti.method,path:b(Ti.path,{cliAuthorizationId:e},Ti.operationId),headers:{[n]:t}},yi)}catch(e){throw new Ei(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new U(`acknowledge`,Mi(r.status),[t]);if(!r.ok)throw new U(`acknowledge`,r.problem,[t]);return r.data}function Ai(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function ji(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Mi(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Ni(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[Mt.custom]:{enumerable:!1,value:a}})}async function Pi(e){let t=await Fi(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await _e(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`),verification:t}}catch(n){return{stored:e,verification:{state:`unavailable`,summary:`${t.summary}, but the cached metadata could not be updated — ${O(n,[e.credential.secret])}`}}}}async function Fi(e){let t=ge(w()),n;try{n=await oe(t,{method:`GET`,path:ie(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},Re)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${O(t,[e])}`}}return n.ok&&n.redirect?{state:`unavailable`,summary:`identity verification returned unexpected redirect ${n.status}`}:n.ok?n.data.status===`ACTIVE`?{state:`verified`,summary:`API key verified by aVenture sign-in`,apiKey:n.data}:{state:`invalid`,summary:`API key is not active`}:{state:n.problem.status===401||n.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${ye(n.problem,[e])}`}}var Ii=V(H,`revoke`);async function Li(e){let t;try{t=Be(w().host)}catch(e){return r(`auth logout: invalid API host — ${O(e)}`)}let n=await Ri(t),i=await Vi(t,e),o=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],s={host:t,revoked:!1,forgotten:!1,oauth:n};return i===null?n.state===`missing`?a(`No CLI credential is stored for this API host.`,s):n.state===`failed`?{...r(`auth logout: ${o[0]}`),data:s}:a(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,s,{warnings:o}):{...i,data:{...i.data??s,oauth:n},warnings:[...i.warnings,...o]}}async function Ri(e){let t=await Me(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Bi(t.stored):{revoked:!1};try{await Ce(e)}catch(e){return{state:`failed`,summary:O(e)}}return{state:`forgotten`,...n}}async function zi(e){let t=Reflect.get(await mt(e),`revocation_endpoint`);return typeof t==`string`?De(t,`revocation endpoint`,!0):void 0}async function Bi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await zi(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:Ie(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:O(e,je(n))}}}async function Vi(e,t){let n;try{n=await xe(e)}catch(e){return r(`auth logout: stored credential could not be read — ${O(e)}`)}if(n.state===`unavailable`)return{...r(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let i=n.stored,o=await Hi(i),s=o.outcome===`revoked`,c=i.activation===`pending`&&o.outcome===`rejected`;if(!s&&!c&&!t.forgetLocal)return{...r(`auth logout: remote revocation was not confirmed; local credential preserved — ${o.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:Ui(i,!1,!1)};try{await we(i.host)}catch(e){return{...r(`auth logout: local credential removal failed — ${O(e,[i.credential.secret])}`,[s?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:Ui(i,s,!1)}}return a(s?`API key revoked remotely and removed locally.`:c?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,Ui(i,s,!0),{ids:[i.credential.apiKey.id],warnings:s||c?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Hi(e){let t=ge(w());try{let n=await oe(t,{method:Ii.method,path:b(Ii.path,{},Ii.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},Re);return n.ok&&n.redirect?{outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${n.status}`}:n.ok?n.data.id!==e.credential.apiKey.id||n.data.subject!==e.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored API key identity`}:n.data.status===`REVOKED`?{outcome:`revoked`,summary:`remote key revocation confirmed`}:{outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}:{outcome:n.problem.status===401&&n.problem.type!==`about:blank`?`rejected`:`unconfirmed`,summary:ye(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:O(t,[e.credential.secret])}}}function Ui(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Wi=`RSA_OAEP_256_A256_GCM_V1`,Gi=1,Ki=30,qi=h().bin[0],Ji=`The local record remains pending and unavailable to ordinary commands. Re-run \`${qi} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Yi(e){if(!At.isTTY)return r(`${qi} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=w().host;t=Be(e),n=ke(e)}catch(e){return r(`auth login --key: invalid environment configuration — ${O(e)}`)}for(;;){let e;try{e=await ze(t)}catch(e){return r(`auth login --key: credential storage could not be inspected — ${O(e)}`)}if(e.state===`unavailable`)return r(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&F.write(Se(e.keyringFailure));break}let n=await Xi(e.stored);if(n!==null)return n}let i;try{i=await mi()}catch(e){return r(`auth login --key: ephemeral encryption key could not be created — ${O(e)}`)}let o=fi.safeParse({clientLabel:e.clientLabel?.trim()||(Rt().trim()||qi).slice(0,120),clientPlatform:ea(),encryptionAlgorithm:Wi,encryptionPublicKey:i.publicKey});if(!o.success)return r(`auth login --key: ${fe(o.error)}`);let s;try{s=await Di(o.data)}catch(e){return r(`auth login --key: could not start browser authorization — ${O(e)}`)}let c;try{c=be(s,n)}catch(e){return r(`auth login --key: unsafe browser authorization URL rejected — ${O(e)}`)}if(!$i(await ve(s,n,{noBrowser:e.noBrowser}),s,c))return r(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[c]});let l;try{l=await Qi(s)}catch(e){return r(`auth login --key: authorization did not complete — ${O(e)}`,[],{references:[c]})}if(l.algorithm!==Wi)return r(`auth login --key: broker selected an unsupported encryption algorithm`);let u;try{u=await hi(i.privateKey,l)}catch(e){return r(`auth login --key: encrypted credential could not be opened — ${O(e)}`)}let d=await Fi(u);if(d.state!==`verified`)return r(`auth login --key: decrypted credential was neither stored nor acknowledged — ${d.summary}`);let f;try{f=await _e(t,{apiKey:d.apiKey,secret:u},`pending`)}catch(e){return r(`auth login --key: credential could not be durably stored — ${O(e)}`)}let p;try{p=await Zi(s)}catch(e){return W(f,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${O(e,[s.pollSecret])}`,Ji)}if(p.status!==`CONSUMED`)return W(f,!0,`auth login --key: broker returned ${p.status} after acknowledgment`,Ji);let m=await Fi(u);if(m.state!==`verified`||!ia(m.apiKey,f.credential.apiKey))return W(f,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${m.summary}`,Ji);try{let e=await _e(t,{apiKey:m.apiKey,secret:u},`active`);return a(`API key stored; authenticated identity and broker acknowledgment verified.`,ra(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return W(f,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${O(e)}`,Ji)}}async function Xi(e){let t=await Fi(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?a(`API key is already stored and its authenticated identity was verified.`,ra(e,!0),{ids:[e.credential.apiKey.id]}):W(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${qi} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&ia(t.apiKey,e.credential.apiKey))try{let n=await _e(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return a(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,ra(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return W(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${O(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${qi} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return W(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${qi} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Hi(e);if(n.outcome===`unconfirmed`)return W(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await we(e.host)}catch(t){return W(e,!1,`auth login --key: stale pending credential could not be removed — ${O(t,[e.credential.secret])}`)}return F.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
12
+ `:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
13
+ `),null}async function Zi(e){let t=new Date(e.expiresAt).getTime(),n=ta(e.intervalSeconds);for(;;)try{return await ki(e.id,e.pollSecret)}catch(e){if(e instanceof U){if(!e.retryable)throw e;n=ta(e.retryAfterSeconds??n)}else if(!(e instanceof Ei))throw e;if(Date.now()>=t)throw e;F.write(`Broker acknowledgment was interrupted; retrying.
14
+ `),await na(n,t)}}async function Qi(e){let t=new Date(e.expiresAt).getTime(),n=ta(e.intervalSeconds),r;for(F.write(`Waiting for browser approval...
15
+ `);Date.now()<t;){let i;try{i=await Oi(e.id,e.pollSecret)}catch(e){if(e instanceof U){if(!e.retryable)throw e;n=ta(e.retryAfterSeconds??n)}r=e,F.write(`Authorization poll was interrupted; retrying.
16
+ `),await na(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=ta(i.retryAfterSeconds??n),await na(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:throw Error(p(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${O(r,[e.pollSecret])}`)}function $i(e,t,n){let r=e.state===`opened`;return!r&&!F.isTTY?!1:(F.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...F.isTTY?[`Open this one-time approval URL in your browser:`,t.verificationUrl]:[`Approval reference: ${n}`],`Comparison code: ${t.comparisonCode}`,`Confirm that the browser shows the same code before approving.`,``].join(`
17
+ `)),!0)}function ea(){switch(zt()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function ta(e){return Math.min(Ki,Math.max(Gi,e))}async function na(e,t){let n=t-Date.now();n>0&&await Ft(Math.min(e*1e3,n))}function ra(e,t){return{host:e.host,provider:e.provider,apiKeyId:e.credential.apiKey.id,name:p(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function W(e,t,n,i){return{...r(n,i===void 0?[]:[i]),data:ra(e,t)}}function ia(e,t){return e.expiresAt===null||e.expiresAt===void 0||t.expiresAt===null||t.expiresAt===void 0?!1:new Date(e.expiresAt)>new Date(t.expiresAt)}async function aa(){return null}async function oa(e){let t=null,n=e=>{t=e};try{await Fe(e,n),await Le(n)}catch(e){return{materialized:t,failure:O(e)}}return{materialized:t,failure:null}}async function sa(e,t,n,r){if(r.failure!==null)return{scope:e,selected:null,identity:null,authorization:null,error:r.failure};let i=null,a=null,o,s=e=>{o=e,a=ca(e.credential,r.materialized)};try{let t=await x({method:`POST`,path:`/v1/auth/me/permissions`,body:{operation:[]},auth:e,requesterScope:e,responseFormat:`json`,onAuthPrepared:s});if(!t.ok)throw Error(la(t));if(a===null)throw Error(`Live permission probe did not prepare a credential`);if(i=pa(t.data),e===`read`)return{scope:e,selected:a,identity:null,authorization:i,error:null};if(o===void 0)throw Error(`Live permission probe did not retain its prepared credential`);let n=await aa(e,o);return{scope:e,selected:a,identity:n,authorization:i,error:null}}catch(r){return{scope:e,selected:a,identity:null,authorization:i,error:O(r,ua(t,n,o))}}}function ca(e,t){if(e===null)return null;let n=t??Oe().source;if(n===null)throw Error(`Prepared credential has no local provenance`);return{credential:e,source:n}}function la(e){return[e.summary,...e.warnings].join(` — `)}function ua(e,t,n){return[w().userBearerToken,...m(n?.headers??{}),...e.state===`found`?je(e.stored.credential.tokens):[],t.state===`found`?t.stored.credential.secret:void 0]}function da(e,t,n=null){let r=t.state===`found`?t.stored:void 0,i=r?.credential.apiKey.expiresAt??null;return{host:e,present:r!==void 0,provider:r?.provider??null,activation:r?.activation??null,apiKeyId:r?.credential.apiKey.id??null,subject:r?.credential.apiKey.subject??null,scope:r?.credential.apiKey.scopes??[],name:r===void 0?null:p(r.credential.apiKey.name,[r.credential.secret]),status:r?.credential.apiKey.status??null,expiresAt:i,metadataSource:r===void 0?null:n?.state===`verified`?`clerk`:`store-cache`,live:n===null?null:{state:n.state,summary:n.summary},expiresInDay:ga(i),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function fa(e,t){let n=t.state===`found`?t.stored:void 0;return{host:e,present:n!==void 0,provider:n?.provider??null,expiresAt:n?.credential.expiresAt??null,expired:n===void 0?null:Te(n.credential),renewable:n===void 0?null:n.credential.tokens.refresh_token!==void 0,identity:n===void 0?null:Ee(n.credential),client:n?.credential.client??null,storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function pa(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)throw Error(`permission probe returned no JSON response`);let t=se.safeParse(e.response);if(!t.success)throw t.error;return t.data}function ma(e,t){let{expiresAt:n,expiresInDay:r}=da(e,t);return n!==null&&r!==null&&new Date(n).getTime()<=Date.now()?` (cached expiry passed ${Math.abs(r)}d ago; \`auth status\` re-checks it with aVenture sign-in)`:``}var ha=864e5;function ga(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/ha)}var _a=7;function va(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,_a)}\u2026${e.slice(-4)}`}var ya=13,ba=14;function xa(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.apiKey.host}`+(e.apiVersion===null?` (api build unavailable)`:` (api ${e.apiVersion})`),``,...Ca(e.oauth,e.cliName,e.refresh),...Ta(e.apiKey,e.oauth,e.cliName),``,G(`Providers`,Oa(e.providers)),G(`Environment`,ka(e.resolved)),G(`Selected`,Aa(e.resolved,e.refresh,e.cliName)),...Sa(e.live),...e.systemOk?[]:[G(`System`,`uptime read failed`)]].join(`
18
+ `)}function Sa(e){if(e===null)return[];let t=K(`local credential provenance was captured before verification`);if(e.error!==null)return[``,G(`Live probe`,`${e.scope} permission probe failed`),t,K(e.error)];if(e.authorization===null)return[];let n=e.authorization.permissionGrant,r=e.identity;return[``,G(`Live probe`,`${e.scope} permission probe succeeded`),t,K(`operation access ${e.authorization.operationAccess}; ${n.role.length} role; ${n.permission.length} permission`),...r===null?[K(e.scope===`read`?`identity not requested for a read-scope credential`:`identity unavailable in this build`)]:[G(`Live account`,r.nameFull??r.email??r.clerkUserId??r.id)],K(`no API operation was executed or individually authorized`)]}function G(e,t){return` ${e.padEnd(ya)}${t}`}function K(e){return` ${``.padEnd(ya)}${e}`}function Ca(e,t,n){switch(e.state){case`found`:{let{credential:r,provider:i}=e.stored,a=Ee(r);return[G(`OAuth`,`${a.email??a.subject??`unknown identity`} via ${i}`),K(wa(r,t,n))]}case`missing`:return[G(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[K(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[G(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[G(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function wa(e,t,n){return Te(e)?e.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:n.failure===null?n.materialized===`api-key`?`access token expired and renewal failed; the API key is in use — \`${t} auth login\` renews OAuth`:`access token expired — not renewed while AUTH_TOKEN is set in the environment`:`access token expired — ${n.failure}`:`access token valid until ${e.expiresAt}`}function Ta(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[G(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[K(`stored credential invalid: ${e.error}`)]]:[G(`Signed in`,`credential storage unavailable`),K(r)]}return[G(t.state===`found`?`API key`:`Signed in`,e.subject??`unknown subject`),K(`via ${e.provider??`unknown store`}`),G(`Key`,`${e.name??`unnamed`} ${va(e.apiKeyId)}`),...Ea(e,n),G(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function Ea(e,t){let n=e.live,r=e.expiresInDay,i=e.expiresAt;if(n?.state===`invalid`)return[G(`Key state`,`rejected by aVenture sign-in \u2014 ${n.summary}`),K(`run \`${t} auth logout\`, then \`${t} auth login --key\``)];let a=n?.state===`verified`;return[G(`Key state`,a?`${e.status??`unknown`}, verified by aVenture sign-in now`:`${e.status??`unknown`} when stored`),...i===null||r===null?[K(`no expiry recorded`)]:[K(Da(i,r,a?`expires`:`cached expiry`))],...a?[]:[K(n===null?"aVenture sign-in owns the live verdict — `auth status` re-checks it":`aVenture sign-in could not be reached \u2014 ${n.summary}`)]]}function Da(e,t,n){let r=e.slice(0,10);return new Date(e).getTime()<=Date.now()?`${n} ${r} passed ${Math.abs(t)}d ago`:t<=ba?`${n} ${r}, ${t}d away`:`${n} ${r}`}function Oa(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`browser sign-in`:`no browser sign-in`,t?`oauth ${Ae(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function ka(e){return`${C.authToken}=${e.present?e.source??`resolved`:`unset`}`}function Aa(e,t,n){return e.present||t.materialized===`env`?`${C.authToken} from the environment`:t.materialized===`oauth`?`saved OAuth access token`:t.materialized===`api-key`?`saved API key`:`none \u2014 sign in with \`${n} auth login\``}var ja=`# >>> aventure-cli completion setup (managed by aventure-cli) >>>`,Ma=`# <<< aventure-cli completion setup (managed by aventure-cli) <<<`,Na=`.aventure-cli-completion.bak`;function Pa(e,t){e.command(`install`).summary(`install shell completion loaders`).description(`Install managed shell completion loaders for supported shells.`).action(()=>Va([])),e.command(`uninstall`).summary(`remove shell completion loaders`).description(`Remove managed shell completion loaders installed by ${t}.`).action(()=>Va([`--uninstall`]))}function Fa(e,t){e.command(`setup`).summary(`configure zsh completion startup`).description(`Configure ~/.zshrc so zsh loads ${t} completion loaders.`).option(`--dry-run`,`print the managed zshrc block without writing`).option(`--yes`,`apply without prompting`).option(`--uninstall`,`remove the managed zshrc block`).action(async e=>{let t=za(),n=await Ra({rcFile:N(Lt(),`.zshrc`),installerPath:t,mode:e.uninstall?`uninstall`:`install`,dryRun:e.dryRun,prompter:e.yes||e.dryRun?void 0:Qa});P.stdout.write(`${n.message}\n`),!n.cancelled&&!e.dryRun&&Va(e.uninstall?[`--uninstall`]:[])})}function Ia(e,t=`fpath-only`){return[ja,`# installer: ${e}`,'fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath)',...t===`fpath-and-compinit`?[`autoload -Uz compinit`,`compinit`]:[],Ma].join(`
19
+ `)}function La(){let e=Va([`--status`],`pipe`);if(e.status!==0)return{refreshed:!1,message:`completion status exited ${e.status??1}`};if(!Ha(e.stdout??``))return{refreshed:!1,message:`no managed shell completions found`};let t=Va([],`pipe`);return t.status===0?{refreshed:!0,message:(t.stdout??``).trim()||`shell completions refreshed`}:{refreshed:!1,message:`completion refresh exited ${t.status??1}`}}async function Ra({rcFile:e,installerPath:t,mode:n,dryRun:r=!1,prompter:i}){let a=Ua(e),o=a.length===0?[]:a.split(`
20
+ `),s=Wa(o,e);if(n===`uninstall`&&s===null)return{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:a};let c=n===`install`?Ga(o,s,t,e):Ka(o,s);return c===a?{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:c}:r?{changed:!0,cancelled:!1,message:c,content:c}:i!==void 0&&!await i(`Update ${e}?`)?{changed:!0,cancelled:!0,message:`${e}: unchanged; pass --yes to apply without a prompt`,content:a}:(Ya(e,c),{changed:!0,cancelled:!1,message:`${e}: updated`,content:c})}function za(e=P.argv[1]){let t=e===void 0?``:Ba(e),n=N(M(t),`..`,`..`,`scripts`,`install-zsh-completion-loader.mjs`);return yt(n)?n:N(M(t),`..`,`scripts`,`install-zsh-completion-loader.mjs`)}function Ba(e){try{return Tt(e)}catch{return N(e)}}function Va(e,t=`inherit`){let n=ht(P.execPath,[za(),...e],{encoding:t===`pipe`?`utf8`:void 0,stdio:t});if(n.error!==void 0)throw n.error;if(t===`inherit`){n.status!==0&&(P.exitCode=n.status??1);return}return{stdout:n.stdout?.toString(),stderr:n.stderr?.toString(),status:n.status}}function Ha(e){return e.split(/\r?\n/u).some(e=>e.trim().endsWith(`: managed`))}function Ua(e){return yt(e)?(Xa(e),Ct(e,`utf8`)):``}function Wa(e,t){let n=qa(e,ja),r=qa(e,Ma);if(n.length===0&&r.length===0)return null;if(n.length!==1||r.length!==1||n[0]>=r[0])throw Error(`${t} has malformed managed completion setup markers; fix manually before retrying.`);return[n[0],r[0]]}function Ga(e,t,n,r){let i=t===null?[...e]:[...e.slice(0,t[0]),...e.slice(t[1]+1)],a=Ja(i),o=Ia(n,a===-1?`fpath-and-compinit`:`fpath-only`).split(`
21
+ `),s=t===null?a:t[0],c=s===-1?i.length:s;if(t!==null&&a!==-1&&a<c)throw Error(`${r} runs compinit before the managed block; move the block above compinit manually.`);return Za([...i.slice(0,c),...o,...i.slice(c)])}function Ka(e,t){return Za(t===null?e:[...e.slice(0,t[0]),...e.slice(t[1]+1)])}function qa(e,t){return e.flatMap((e,n)=>e===t?[n]:[])}function Ja(e){return e.findIndex(e=>/^\s*(autoload\s+.*\bcompinit\b|compinit(?:\s|$))/.test(e))}function Ya(e,t){xt(M(e),{recursive:!0}),yt(e)&&(Xa(e),Xa(`${e}${Na}`),vt(e,`${e}${Na}`));let n=N(M(e),`.${gt(e)}.${P.pid}.tmp`);Xa(n),kt(n,t,{mode:420}),Et(n,e)}function Xa(e){if(yt(e)&&bt(e).isSymbolicLink())throw Error(`refusing to write symlink: ${e}`)}function Za(e){let t=e.join(`
22
+ `);return t.length===0||t.endsWith(`
23
+ `)?t:`${t}\n`}async function Qa(e){if(!P.stdin.isTTY)return!1;let t=Bt({input:P.stdin,output:P.stdout});try{let n=await t.question(`${e} [y/N] `);return/^(y|yes)$/i.test(n.trim())}finally{t.close()}}var $a=new Intl.Collator(void 0,{numeric:!0}),eo=2e4;function to(e,t=h()){let n=t.registry===``?`Requires npm authentication for @aventurevc packages.`:`Installs from npm.`;A(e.command(`update`).summary(`Check for or install the latest release`).description([`Compare the running CLI version against the latest published`,`release and install it into the active published bin prefix.`,``,`Refuses to install when the running binary is the working-tree build`,`(rebuild that checkout instead). ${n}`,`--execute is deprecated, accepted, and ignored; update executes by its verb.`].join(`
24
+ `)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1)).action(e=>R({mode:k(e)},no()))}function no(e,t=`apply`){let n=e;try{n??=h(process.argv[1])}catch(e){return r(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=n.name,o=n.version,s=n.registry===``?``:ee,c=n.registry===``&&i===`@aventurevc/aventure-cli`,l=ro([`view`,s,`version`,`--silent`,`--global`],n,{timeout:eo});if(!l.ok)return{...l,data:null};let u=(l.data??``).trim();if(u===``)return r(`npm view ${s} returned empty version`,[`empty_stdout`]);let d=c||$a.compare(o,u)<0,f={targetPackage:s,runningPackage:i,currentVersion:o,latestVersion:u,upgradeAvailable:d,upgradeInstalled:!1};if(t===`check`)return a(`${i}@${o} → ${s}@${u} (${d?`available`:`up to date`})`,f);if(!d)return a(`${i}@${o} already matches ${s}@${u}`,f);if(n.workingTreeRoot!==null)return r(`Refusing to install over the working-tree build at ${n.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);let p=oo(n),m=p===null?[]:[`--prefix`,p.installPrefix],g=p===null?null:N(p.installPrefix,`lib`,`node_modules`,...s.split(`/`)),_=c?io(p,s,u):[];if(c){let e=ro([`uninstall`,`-g`,...m,ee],n,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return r(`Cannot remove the retired ${ee}: ${e.summary}`,[...e.warnings,..._])}let v;try{v=so(n,p)}catch(e){return r(`Cannot prepare MCP-owned CLI bins: ${uo(e)}`,[`npm install was not run`])}let y=ro([`install`,`-g`,...m,`${s}@${u}`],n,{stdio:[`ignore`,`inherit`,`inherit`]});if(!y.ok){let e=co(v,g);return e===null?{...y,warnings:[...y.warnings,..._],data:null}:r(`${y.summary}; MCP-owned CLI bin restoration failed`,[...y.warnings,e])}let b=p===null?void 0:ao(p.installPrefix,s,u);if(b?.ok===!1){let e=co(v,g);return e===null?{...b,warnings:[...b.warnings,..._],data:null}:r(`${b.summary}; MCP-owned CLI bin restoration failed`,[...b.warnings,e])}let te=lo(v);if(te!==null)return r(`${s} upgraded but MCP CLI bin backup cleanup failed`,[te]);let x=fo();return a(`${s} upgraded to ${u}`,{...f,upgradeInstalled:!0,installPrefix:p?.installPrefix,verifiedVersion:b?.data??void 0,completionRefreshed:x.refreshed,completionRefreshMessage:x.message})}function ro(e,t,n={}){let i={...process.env};t.registry===``?i.NODE_AUTH_TOKEN??=i.GH_PACKAGES_TOKEN:delete i.GH_PACKAGES_TOKEN;let o=[...e,`--@aventurevc:registry=${t.registry}`],s=ht(`npm`,o,{env:i,encoding:`utf8`,...n});if(s.error)return s.signal===`SIGTERM`&&n.timeout!==void 0?r(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):r(`npm ${e[0]??``} failed to start: ${s.error.message}`,[`spawn_error`]);if(s.status!==0){let t=(s.stderr??``).trim().split(`
25
+ `).slice(-3).join(` | `);return r(`npm ${e.join(` `)} exited ${s.status}`,[t||`no stderr`])}return a(`npm ok`,s.stdout??``)}function io(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${ee}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function ao(e,t,n){let i;try{let n=h(N(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));i=N(e,`bin`,n.bin[0])}catch(e){return r(`updated ${t} verification failed: ${uo(e)}`,[`invalid_package_metadata`])}let o=ht(process.execPath,[i,`--version`],{encoding:`utf8`});if(o.error)return r(`updated ${t} verification failed: ${o.error.message}`,[`spawn_error`]);let s=(o.stdout??``).trim();if(o.status!==0||s!==n){let e=(o.stderr??``).trim().split(`
26
+ `).slice(-3).join(` | `);return r(`updated ${t} verification expected ${n} but active bin reported ${s||`empty output`}`,[e||`active bin: ${i}`])}return a(`active CLI version verified`,s)}function oo(e){let t=`${_t}lib${_t}node_modules${_t}${e.name.replace(`/`,_t)}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:{installPrefix:e.packageRoot.slice(0,n)}}function so(e,t){if(e.name!==`@aventurevc/mcp-server`)return{backup:[],backupDirectory:null};if(t===null)throw Error(`the running MCP package is not in a verifiable global npm prefix`);if(!e.entryPath.startsWith(`${e.packageRoot}${_t}`))throw Error(`the running CLI entry is outside the MCP package root`);let n=e.bin.filter(e=>e===`aventure`||e===`aventure-cli`).flatMap(n=>{let r=N(t.installPrefix,`bin`,n),i=bt(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=Tt(r)}catch(e){throw Error(`${r} has a missing target`,{cause:e})}if(a!==e.entryPath)throw Error(`${r} is not owned by the running MCP CLI`);return{binPath:r,linkTarget:wt(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=St(N(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:N(r,gt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(Et(e.binPath,e.backupPath),a.push(e),wt(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=co({backup:a,backupDirectory:r},null);throw Error(`could not displace verified MCP CLI bins${t===null?``:`; restoration failed: ${t}`}`,{cause:e})}return{backup:a,backupDirectory:r}}function co(e,t){let n=[];for(let r of e.backup.toReversed())try{let e=bt(r.binPath,{throwIfNoEntry:!1});if(e!==void 0){if(!e.isSymbolicLink())throw Error(`${r.binPath} is not a symlink`);let n=N(M(r.binPath),wt(r.binPath));if(t===null||n!==t&&!n.startsWith(`${t}${_t}`))throw Error(`${r.binPath} is not owned by the standalone CLI package`);Ot(r.binPath)}Et(r.backupPath,r.binPath)}catch(e){n.push(uo(e))}if(e.backupDirectory!==null)try{Dt(e.backupDirectory)}catch(e){n.push(uo(e))}return n.length===0?null:n.join(`; `)}function lo(e){let t=[];for(let n of e.backup)try{Ot(n.backupPath)}catch(e){t.push(uo(e))}if(e.backupDirectory!==null)try{Dt(e.backupDirectory)}catch(e){t.push(uo(e))}return t.length===0?null:t.join(`; `)}function uo(e){return e instanceof Error?e.message:String(e)}function fo(){try{return La()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var po=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers its generated status operation`},{name:`auth`,purpose:`which credential scope materialized locally, never the secret`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}],mo=`operationFingerprint`;function ho(e,t=h().bin[0]){A(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",...po.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable)`,`does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
27
+ `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),R({mode:k(e)},await go(t))})}async function go(e){let t=vo(),n=yo(e),[i,o]=await Promise.all([bo(e),xo(t,e)]),s=[n.check,i,o.check,await Co(e),ko(t,o.servedFingerprint,n.upgradeAvailable,e)],c={pass:_o(s,`pass`),fail:_o(s,`fail`),skip:_o(s,`skip`)},l=s.filter(e=>e.status===`fail`).map(e=>e.message),u={ok:l.length===0,check:s},d=[`doctor: ${c.pass} pass, ${c.fail} fail, ${c.skip} skip`,...s.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
28
+ `);return u.ok?a(d,u,{counts:c}):{...r(d,l,{counts:c}),data:u}}function _o(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function vo(){return j.find(e=>e.intent===`status`&&e.resource===`status`)}function yo(e){let t=h(),n=no(t,`check`);if(!n.ok||n.data===null)return{check:q(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?q(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):q(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function bo(e){try{let{EntityDetailSchema:e}=await import(`./detail-DiVuj6vZ.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return q(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return q(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${O(t)}.`)}}async function xo(e,t){if(e===void 0)return{check:q(`api-host`,`skip`,`No status operation resolved from the generated catalog; fix the catalog check first.`),servedFingerprint:null};let n;try{n=w().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${O(e)}.`),servedFingerprint:null}}let i=await x({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>r(O(e)));return i.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${n}.`),servedFingerprint:So(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${n} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} at ${n} returned ${i.summary}.`),servedFingerprint:null}}function So(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t[mo];return typeof n==`string`&&n.length>0?n:null}async function Co(e){let t=Oe(),[n,r]=await Promise.all([wo(),To()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;return!i&&n.state===`invalid`?q(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`):!i&&n.state===`found`&&Te(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0?q(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`):!i&&!a&&n.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${C.authToken} through the environment — ${n.summary}.`):i||n.state===`found`||a?q(`auth`,`pass`,`Credential source available: ${Eo(t,n,r)}.`):r.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${C.authToken} through the environment — ${r.summary}.`):q(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${C.authToken} in the environment.`)}async function wo(){let e;try{e=Ne(w().host)}catch(e){return{state:`unavailable`,summary:O(e)}}return await Pe(e)}async function To(){let e;try{e=Be(w().host)}catch(e){return{state:`unavailable`,summary:O(e),cause:`environment`}}try{return await ze(e)}catch(e){return{state:`unavailable`,summary:O(e),cause:`storage`}}}function Eo(e,t,n){return[ka(e),`oauth=${Oo(t)}`,`api-key=${Do(n)}`].join(` `)}function Do(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=Be(w().host);return`${e.stored.activation}${ma(t,e)}`}function Oo(e){switch(e.state){case`found`:return Te(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function ko(e,t,n,r){let i=j.length;if(e===void 0)return q(`catalog`,`fail`,`Regenerate the command catalog with \`make mcp-generate-contracts\` and reinstall: none of its ${i} operations is the status operation.`);if(t===null)return q(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${$e}.`);if(t===`a0e928da9fa359c8`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${$e}).`);let a=`This catalog describes a different operation set than the API serves (${$e} vs ${t})`;return n===!0?q(`catalog`,`fail`,`${a}: run \`${r} update\`.`):q(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var Ao=V(H,`oauth`),jo=[V(H,`start`),V(H,`poll`),V(H,`acknowledge`)],Mo=V(H,`revoke`);function No(e,t=h().bin[0]){let n=Lo(e);ho(n,t);let i=[`${Ao.description} Default method: OAuth in your browser.`,`With --key: ${jo.map(({description:e})=>e).join(` `)}`].join(`
29
+ `);A(Io(n,[Ao,...jo],i)).action(Po),A(Io(n,[Mo],Mo.description)).action(Fo),A(n.command(`status`).summary(`Keep saved credentials current and report them with API build and uptime`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,` - system: GET /v1/status response (uptime SLA)`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
30
+ `)).addOption(new S(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Ro(this),R({mode:k(e)},await zo(t,e.verify))}),n.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${C.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
31
+ `)).action(async function(){Ro(this);let e=await oa(t),n=process.env[C.authToken]?.trim();if(e.failure===null&&n!==void 0&&n.length>0){process.stdout.write(`${n}\n`);return}R({mode:`text`},e.failure===null?qo(`auth token: no credentials resolved`,null,t,{oauth:!0,apiKey:!0}):r(`auth token: ${e.failure}`))})}async function Po(e){Ro(this);let t=k(e);if(e.providers===!0){R({mode:t},await Vo());return}R({mode:t},e.key===!0?await Yi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await pt({noBrowser:!e.browser}))}async function Fo(e){Ro(this),R({mode:k(e)},await Li({forgetLocal:e.forgetLocal===!0}))}function Io(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Lo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${Ao.command}\`: ${Ao.summary}; \`--key\` ${jo[0].summary.toLowerCase()}.`,`\`${Mo.command}\`: ${Mo.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build and uptime.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
32
+ `))}function Ro(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function zo(e,t){let n;try{n=Ne(w().host)}catch(e){return r(`auth status: invalid API host — ${O(e)}`)}let i=Oe(),o=oa(e),[s,c,l]=await Promise.all([Ko(`/v1/status`,`GET /v1/status`),Ko(`/info`,`GET /info`),Ho()]),u=await o,[d,f]=await Promise.all([Pe(n),Bo(n)]),p=t===void 0?null:await sa(t,d,f.inspection,u),m=h().version,g=da(n,f.inspection,f.verification),_=xa({cliName:e,cliVersion:m,apiVersion:c.ok?Wo(c.data):null,oauth:d,apiKey:g,providers:l,resolved:i,refresh:u,systemOk:s.ok,live:p}),v={cli:{version:m},api:c.ok?c.data??null:null,auth:{[C.authToken]:i},selected:u.materialized,oauth:fa(n,d),apiKey:g,providers:l,live:p,system:s.ok?s.data??null:null,...c.ok?{}:{apiError:c.summary},...s.ok?{}:{systemError:s.summary}};return u.failure===null?!c.ok&&c.httpStatus===401?{...r(`auth status: the API rejected the selected credential (401) | ${_}`,[`Replace or unset ${C.authToken}, or run \`${e} auth login\`.`]),data:v}:p!==null&&p.error!==null?{...r(`auth status: ${p.scope} permission probe failed — ${p.error}`,[p.error]),data:v}:p!==null||i.present||d.state===`found`||f.inspection.state===`found`?a(_,v):qo(`auth status: no credentials resolved | ${_}`,v,e,{oauth:d.state===`missing`,apiKey:f.inspection.state===`missing`}):{...r(`auth status: ${u.failure} | ${_}`,[u.failure]),data:v}}async function Bo(e){let t=await Uo(e);if(t.state!==`found`)return{inspection:t,verification:null};let{stored:n,verification:r}=await Pi(t.stored);return{inspection:{state:`found`,stored:n},verification:r}}async function Vo(){let e=await Ho();return e.state===`found`?a(`Sign-in providers for the selected API host`,e.catalog):r(`auth login --providers: ${e.summary}`)}async function Ho(){try{return{state:`found`,catalog:await ft()}}catch(e){return{state:`unavailable`,summary:O(e)}}}async function Uo(e){try{return await ze(e)}catch(e){return{state:`invalid`,summary:O(e)}}}function Wo(e){if(!Go(e))return null;let t=li.safeParse(Reflect.get(e,`response`));if(!t.success)return null;let n=t.data.build.version?.trim();return n&&n.length>0?n:null}function Go(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ko(e,t){return await x({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>r(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}function qo(e,t,n,i){return{...r(e,[...i.apiKey?[`For an API key (works over SSH), run \`${n} auth login --key\`.`]:[],...i.oauth?[`For OAuth, run \`${n} auth login\`; without a browser it prints a device code.`]:[],`For non-interactive use, set ${C.authToken} to an aVenture API key (create one at ${ue}/settings/api-keys).`]),data:t}}function Jo(e,t=j,n=h().bin[0]){let r=e.command(`completion`).summary(`Generate shell completion scripts`).description(`Generate shell completion scripts for the aVenture CLI.`);for(let i of[`bash`,`fish`,`zsh`])r.command(i).summary(`Print ${i} shell completions`).description(`Print ${i} completion definitions for ${n}.`).action(()=>{P.stdout.write(Xo(e,i,t))});Pa(r,n),Fa(r,n)}function Yo(){return h().bin}function Xo(e,t,n=j,r=Yo()){let i=as(n);return t===`fish`?[`# fish completions for ${r.join(`, `)}`,...Qo(e),...r.map(e=>`complete -c ${J(e)} -e`),`${vs(r)} -f`,...$o(e,r),...es(e,i,r),``].join(`
33
+ `):Zo(e,t,i,r)}function Zo(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=cs(e,n);return[...t===`zsh`?[`#compdef ${r.join(` `)}`]:[],`# ${t} completions for ${r.join(`, `)}`,`${i}_aventure_cli_commands=(`,...o.map(e=>` ${e}`),`)`,`${i}_aventure_cli_options=(`,...s.map(e=>` ${e}`),`)`,`${i}_aventure_cli_values=(`,...c.map(e=>` ${e}`),`)`,``,...ds(t),...t===`bash`?[a,``]:[``]].join(`
34
+ `)}function Qo(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${ts(e).filter(e=>e.required||e.optional).flatMap(e=>ms(e)??[]).map(J).join(` `)}\n set -l tokens (commandline -xpc)\n if test (count $tokens) -gt 0\n set -e tokens[1]\n end\n set -l path\n set -l skip_next 0\n for token in $tokens\n if test $skip_next -eq 1\n set skip_next 0\n continue\n end\n if string match -q -- '--*=*' $token\n set -l name (string replace -r '^--([^=]+)=.*$' '$1' -- $token)\n contains -- $name $global_value_options; and continue\n end\n if string match -q -- '--*' $token\n set -l name (string replace -r '^--' '' -- $token)\n if contains -- $name $global_value_options\n set skip_next 1\n continue\n end\n break\n end\n if string match -q -- '-*' $token\n break\n end\n set -a path $token\n end\n printf '%s\\n' $path\nend\n`,`function __aventure_cli_path_is
35
+ set -l expected $argv
36
+ set -l actual (__aventure_cli_command_path)
37
+ if test (count $actual) -ne (count $expected)
38
+ return 1
39
+ end
40
+ if test (count $expected) -eq 0
41
+ return 0
42
+ end
43
+ for index in (seq (count $expected))
44
+ if test $actual[$index] != $expected[$index]
45
+ return 1
46
+ end
47
+ end
48
+ return 0
49
+ end
50
+ `].flatMap(e=>e.split(`
51
+ `))}function $o(e,t){return ss(e).map(e=>`${vs(t)} -f -n ${J(ys(e.parentPath))} -a ${J(e.name)} -d ${J(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function es(e,t,n){return hs(e).flatMap(e=>{let r=_s(e),i=r.length===0?void 0:ys(r);return ts(e).flatMap(e=>{let a=t.get(os(r,e));return us(a)?ns(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function ts(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function ns(e,t,n,r){let i=ms(e);if(i===void 0)return[];let a=e.argChoices??ls(n),o=[`-l ${J(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${J(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${J(t)}`,c=e.required||e.optional?rs(a,is(i,n)):`-f`,l=`${vs(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${J(bs(e.description))}`]:a.map(t=>`${l} -a ${J(t)} -d ${J(bs(e.description))}`)}function rs(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function is(e,t){return e===`from-file`?!0:t===void 0||t.some(({location:e})=>e!==`body`)?!1:t.every(({schemaFormat:e})=>e===`binary`)?!0:t.length===1&&[`file`,`path`].includes(e.split(`-`).at(-1)??``)}function as(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...vn(e.requestBody??[]).map(({variant:e})=>e.map(({parameter:e})=>e))].flatMap(t=>{let n=t[0];if(n===void 0)throw Error(`Generated CLI option has no parameter`);return[[os(e.cliPath,n),t]]})))}function os(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):ms(t);if(`flag`in t&&(n===void 0||n.length===0||n===t.flag))throw Error(`Cannot render completion for option flag: ${t.flag}`);return`${e.join(`\0`)}\u0000${n??``}`}function ss(e){return hs(e).flatMap(e=>e.commands.map(t=>({parentPath:_s(e),name:t.name(),description:bs(t.summary()||t.description()||t.name())})))}function cs(e,t){let n=[],r=[];for(let i of hs(e)){let e=_s(i);for(let a of ts(i)){let i=ms(a);if(i===void 0)continue;let o=t.get(os(e,a));if(!us(o))continue;let s=a.argChoices??ls(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&is(i,o)&&(c=`file`)),n.push(fs([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(fs([e.join(` `),`--${i}`,t,a.description]))}}return[ss(e).map(e=>fs([e.parentPath.join(` `),e.name,e.description])).toSorted((e,t)=>e.localeCompare(t)),n.toSorted((e,t)=>e.localeCompare(t)),r.toSorted((e,t)=>e.localeCompare(t))]}function ls(e){let t=e?.[0]?.choices;if(e!==void 0&&t!==void 0)return e.every(e=>e.choices?.length===t.length&&e.choices.every((e,n)=>e===t[n]))?t:void 0}function us(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function ds(e){let t=e===`bash`,n=t?`COMP_WORDS`:`words`,r=t?`COMP_CWORD`:`CURRENT`,i=t?"${path[*]}":"${(j: :)path}",a=t?'"${_aventure_cli_options[@]}"':`$_aventure_cli_options`,o=t?'"${_aventure_cli_values[@]}"':`$_aventure_cli_values`,s=t?'"${_aventure_cli_commands[@]}"':`$_aventure_cli_commands`;return[`function _aventure_cli {`,` local current="\${${n}[${r}]}" previous="\${${n}[${r}-1]}" row row_path long short description mode name value option token key prefix candidate file_current`,...t?[` COMPREPLY=()`]:[],` local index=${t?1:2} skip_next=0; local -a path names descriptions`,` while (( index < ${r} )); do`,` token="\${${n}[index]}"; (( skip_next )) && { skip_next=0; (( index++ )); continue; }`,` if [[ "$token" == -* && "$token" != "-" && "$token" != "--" ]]; then`,` option="\${token%%=*}"; key="${i}"; mode=''`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && break; mode=''; done`,` [[ -n "$mode" && "$mode" != none && "$token" != *=* ]] && skip_next=1`,` elif [[ "$token" != -* ]]; then path+=("$token"); fi`,` (( index++ ))`,` done`,` key="${i}"`,` if [[ "$current" == --*=* || ( "$previous" == -* && "$current" != -* ) ]]; then`,` option="$previous"; prefix=''; file_current="$current"; [[ "$current" == --*=* ]] && { option="\${current%%=*}"; prefix="$option="; file_current="\${current#*=}"; }`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && { option="$long"; break; }; mode=''; done`,t?` [[ "$mode" == file ]] && { while IFS= read -r candidate; do COMPREPLY+=("$prefix$candidate"); done < <(compgen -f -- "$file_current"); return 0; }`:` [[ "$mode" == file ]] && { _files; return 0; }`,t?` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { candidate="$prefix$value"; [[ "$candidate" == "$current"* ]] && COMPREPLY+=("$candidate"); }; done`:` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { names+=("$prefix$value"); descriptions+=("$description"); }; done`,` elif [[ "$current" == -* ]]; then`,` for row in ${a}; do`,` IFS='|' read -r row_path long short description mode <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$long" == "$current"* ]] && COMPREPLY+=("$long"); [[ -n "$short" && "$short" == "$current"* ]] && COMPREPLY+=("$short"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$long"); descriptions+=("$description"); [[ -n "$short" ]] && { names+=("$short"); descriptions+=("$description"); }; }`,` done`,` elif [[ "$previous" != -* ]]; then`,` for row in ${s}; do`,` IFS='|' read -r row_path name description <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$name" == "$current"* ]] && COMPREPLY+=("$name"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$name"); descriptions+=("$description"); }`,` done`,` fi`,...t?[]:[" (( ${#names} )) && compadd -d descriptions -a names"],` return 0`,`}`,...t?[]:[`_aventure_cli "$@"`]]}function fs(e){return`$'${e.map(ps).join(`|`)}'`}function ps(e){return bs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function ms(e){return e.long?.replace(/^--/,``)}function hs(e){return[e,...e.commands.filter(gs).flatMap(e=>hs(e))]}var gs=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function _s(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function vs(e){return`complete ${e.map(e=>`-c ${J(e)}`).join(` `)}`}function ys(e){return[`__aventure_cli_path_is`,...e.map(J)].join(` `)}function bs(e){return e.replace(/\s+/g,` `).trim()}function J(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function xs(e,t){if(e!==t)return;let n=Ss(t);n!==void 0&&t.error(`error: ${ws(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function Ss(e){if(!process.argv.includes(`--`)&&e.args.some(Cs))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function Cs(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function ws(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Ts(e){return e.message.match(/required option '([^']+)' not specified/iu)?.[1]?.split(/\s+/u)[0]}function Es(e){return e.message.match(/unknown option '([^']+)'/iu)?.[1]}function Ds(e){return e.message.match(/unknown command '([^']+)'/iu)?.[1]}function Y(e){return e.flags.split(` `)[0]??e.flags}function Os(e,t){let n=Ts(t);if(n===void 0)return;let r=e.options.findIndex(e=>Y(e)===n);if(r<0)return;let i=e.options.slice(r+1).filter(e=>e.mandatory).map(t=>[Y(t),e.getOptionValue(t.attributeName())]).find(([,e])=>typeof e==`string`&&e.length>0)?.[0];if(i!==void 0)return`hint: ${n} is still required for this nested command; supplied child selector ${i} does not replace the parent selector.`}var ks=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`]];function As(e){let t=new Set(e.options.map(Y)),n=process.argv.slice(2).filter(e=>e.startsWith(`--`)).map(e=>e.split(`=`)[0]??e).filter(e=>!t.has(e)).flatMap(e=>{let n=ks.find(t=>t.includes(e))?.find(e=>t.has(e));return n===void 0?[]:[`use ${n}, not ${e}`]});return n.length===0?void 0:`hint: ${n.join(`; `)}`}function X(e){let t=[];for(let n=e;n!==null&&n.parent!==null;n=n.parent)t.unshift(n.name());return t}function js(e){return e.commands.length===0?[e]:e.commands.flatMap(js)}function Ms(e,t){return X(t).slice(X(e).length)}function Z(e){let t=e;for(;t.parent!==null;)t=t.parent;return t}function Ns(e,t){return t.toSorted((t,n)=>{let r=Ms(e,t),i=Ms(e,n),a=+![`get`,`list`].includes(r.at(-1)??``),o=+![`get`,`list`].includes(i.at(-1)??``);return r.length-i.length||a-o})[0]}function Ps(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function Fs(e,t){let n=X(e),r=process.argv.slice(2+n.length);return[Z(e).name(),...n,...Ms(e,t),...r].map(Ps).join(` `)}function Is(e,t){let n=Es(t);if(n===void 0||e.commands.length===0)return;let r=Ns(e,js(e).filter(e=>e.options.some(e=>Y(e)===n)));if(r!==void 0)return`hint: run: ${Fs(e,r)}`}function Ls(e){return e!==void 0&&Object.hasOwn(nt,e)}function Rs(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e);if(t===void 0)return;n=t}return n}function zs(e,t){let n=X(e),r=[...n.slice(1),t];if(!Ls(n.at(0))||!Ls(r.at(0)))return;let i=Rs(Z(e),r);if(i===void 0)return;let a=i;for(let e of process.argv.slice(2+n.length+1)){if(e.startsWith(`-`))break;let t=a.commands.find(t=>t.name()===e);if(t===void 0)break;r.push(e),a=t}return r}function Bs(e,t){let[n]=X(e);if(!Ls(n))return;let r=[n,t];return Rs(Z(e),r)?.commands.length===0?r:void 0}function Vs(e){let[t,...n]=e.args;if(t===void 0)return[];let r=js(Z(e)).map(X),i=n.findIndex((e,t)=>{let i=[...n.slice(0,t),e];return!r.some(e=>e.some((t,n)=>t===i[0]&&i.every((t,r)=>e[n+r]===t)))});return[t,...i<0?n:n.slice(0,i)]}function Hs(e,t){let n=process.argv.slice(2+X(e).length);if(!(t.length===0||t.some((e,t)=>n[t]!==e)))return Us(e,t)}function Us(e,t,n=[]){let r=X(e),i=Ze(j).map(e=>e.cliPath).filter(e=>e[0]!==r[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a!==void 0)return`hint: run: ${[Z(e).name(),...a,...n].map(Ps).join(` `)}`}function Ws(e,t,n){if(!Ks(t))return;let r=e.args.slice(n.length),i=r.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${[Z(e).name(),...t,...i<0?[]:r.slice(i)].map(Ps).join(` `)}`}function Gs(e){let t=X(e);if(t.at(1)!==void 0&&Ls(t.at(0)))return`hint: inspect generated command group: ${[Z(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Ks(t,n){let r=t.join(` `);return j.some(t=>t.cliPath.join(` `)===r?n===void 0||e(t.intent)===n:!1)}function qs(e){let t=X(e).join(` `),n=Ze(j),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:Sr(r.operationId,n,Z(e).name()).map(e=>`hint: ${e}`)}function Js(e){let t=X(e);if(Ls(t.at(0))&&Ks(t))return`hint: inspect generated command: ${[Z(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Ys(t){let n=new Set,r=[];for(let i of j){let a=Rs(t,i.cliPath);if(a===void 0)continue;let o=a.options.map(Y);if(e(i.intent))r.push(o);else for(let e of o)n.add(e)}let[i=[],...a]=r;return new Set(i.filter(e=>!n.has(e)&&a.every(t=>t.includes(e))))}function Xs(e,t){let n=X(e);if(Ks(n,!1)&&Ys(Z(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function Zs(e,t,n=!0){let r=Z(e),i=r.commands.find(e=>e.name()===`command-catalog`),a=i?.commands.find(e=>e.name()===`search`);if(i===void 0||a===void 0)return;let o=[r.name(),i.name(),a.name(),t],s=X(e).at(0),c=a.options.find(e=>Y(e)===`--root`),l=n&&c!==void 0&&Ls(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(Y(c),l);let u=Ze(j),d=sr({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?zr(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(Ps).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
52
+ `).filter(Boolean).map(e=>` ${e}`)].join(`
53
+ `)}function Qs(e){if(e.commands.length>0&&!Ks(X(e)))return;let t=e.options.flatMap(e=>e.hidden?[]:[Y(e)]);return`hint: ${X(e).join(` `)} accepts: ${t.join(` `)}`}function $s(e,t){let n=Ds(t);if(n===void 0||t.message.includes(`
54
+ (Did you mean `))return;let r=Vs(e),i=Hs(e,r);if(i!==void 0)return i;let a=X(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Ks(o)?o:void 0)??zs(e,n)??Bs(e,n);if(s!==void 0)return Ws(e,s,r)??Zs(e,s.join(` `),!1);let c=r.join(` `)||n,l=Gs(e)??Zs(e,c),u=[...X(e),...r.slice(1)];return[l,r.length===X(e).length+X(e).length&&X(e).at(-1)===X(e).at(0)?Ws(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Ws(e,u,r):void 0].filter(e=>e!==void 0).join(`
55
+ `)||void 0}function ec(e){return t=>{if(t.code===`commander.missingMandatoryOptionValue`){let n=e.options.filter(t=>t.mandatory&&e.getOptionValue(t.attributeName())===void 0);if(n.length>1){let e=n.map(e=>e.flags.split(`, `).at(-1)??e.flags);process.stderr.write(`error: missing required options: ${e.join(`, `)}\n`)}for(let n of[As(e),Ss(e),Os(e,t),...qs(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Ss(e)??Js(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=Es(t),r=As(e)??Is(e,t)??(n!==void 0&&!t.message.includes(`
56
+ (Did you mean `)?Xs(e,n)??Us(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??Qs(e)??Zs(e,X(e).slice(1).join(` `)||n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=$s(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}process.exit(t.exitCode)}}var tc=class extends S{group;constructor(e){super(`-h, --help`,`display help for command`),this.group=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.group.args.at(0);return t===void 0||t.startsWith(`-`)?!0:this.group.commands.some(e=>e.name()===t||e.aliases().includes(t))}};function nc(e){e.showHelpAfterError(!1).exitOverride(ec(e)),e.commands.length===0?e.hook(`preAction`,xs):e.addHelpOption(new tc(e));for(let t of e.commands)nc(t)}function rc(e,t=new Date){let n=oc(e);return{schemaVersion:1,generatedFrom:`MCP_GENERATION_CONTRACT`,generatedAt:t.toISOString(),totalOperations:n.length,note:`Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.`,operations:n}}function ic(e){return`${JSON.stringify(e,null,2)}\n`}function ac(e,t){let n=N(e),r=ic(t);return xt(M(n),{recursive:!0}),kt(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function oc(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,mcpTool:ce(e.intent),bodySchemaName:e.requestBody?.[0]?.schemaName??null,bodySchemaImport:e.requestBody?.[0]?.schemaImport??null,auth:e.projection.auth,scope:e.projection.scope,destructive:e.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var sc=`Match only the first canonical or CLI-alias command segment`,cc=[`text`,`lines`,`compact`,`json`,`ndjson`];function lc(e,t,n=h().bin[0]){let r=e.command(`command-catalog`).summary(`LLM agent only: search generated CLI metadata`).description([`LLM agent only: search and dump generated ${n} command metadata.`,`This is read-only command metadata derived from the generated OpenAPI command specs.`,`Use --format lines for rg/grep/ag/ack and --format ndjson|json for ast-grep/sg/parsers.`,"Use --format compact for one `cli · summary · requiredFlags` row per operation."].join(`
57
+ `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Mr(n)}\n`),uc(r,t,n),dc(r,t,n),fc(r,t,n),pc(r)}function uc(e,t,n){let r=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,sc).addOption(new S(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new S(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new S(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new S(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new S(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new S(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);A(r),r.action(function(e){let r=this.optsWithGlobals(),i=k(r,`text`);Fr(Pr(r,e),t,i,n)})}function dc(e,t,n){let r=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${n} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new S(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);A(r),r.action(function(){let e=this.optsWithGlobals();Ir(e,t,k(e,`text`),n)})}function fc(e,t,n){let r=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,sc).addOption(new S(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new S(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new S(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new S(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new S(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new S(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);A(r),r.action(function(){let e=this.optsWithGlobals();Fr(e,t,k(e,`text`),n)})}function pc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);A(t),t.action(function(){let e=this.optsWithGlobals(),t=k(e,`text`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},a(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:ot.length}}));return}let n=rc(ot);if(e.output!==void 0){let r=ac(e.output,n);R({mode:t},a(`Unified operations JSON written`,{outputPath:r.target,byteLength:r.byteLength,schemaVersion:n.schemaVersion},{counts:{totalOperations:r.totalOperations}}));return}if(t===`text`){process.stdout.write(ic(n));return}R({mode:t},a(`Unified operations JSON`,n,{counts:{totalOperations:n.totalOperations}}))})}var mc=h(Nt(import.meta.url)),Q=mc.bin[0];function hc(e,t){ne({component:Q,event:`fatal`,message:e.message,error:e}),process.stderr.write(`${Q} fatal (${t}): ${e.stack??e.message}\n`);let n=e instanceof te?{httpStatus:e.problem.status,problem:e.problem}:{};Zn({...r(`${Q} ${t}: ${e.message}`,[e.name||`Error`],n),counts:{exitCode:1}}),process.exit(1)}function gc(e){return Ue[at(e,nt)??`cli`]}function _c(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:gc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>tt(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)vc(e,t,r,a,i.has(t.cliPath.join(` `)))}function vc(t,n,i,a,o){let s=n.cliPath,c=t,l=``,u=!i.has(s[0]??``);for(let e of s.slice(0,-1)){l=l===``?e:`${l} ${e}`;let t=u&&l===e||!a.has(l);c=yc(c,e,l,t)}let d=s.at(-1)??n.operationId,f=c.commands.find(e=>e.name()===d)??c.command(d,n.deprecated===!0?{hidden:!0}:{}),p=n.requestBody?.flatMap(({parameter:e})=>e)??[];f.summary(n.summary||n.operationId).description([`${n.method} ${n.path}.`,n.summary||n.description,`Full documentation: ${Q} help ${n.cliPath.join(` `)}`,n.requestBody?.[0]?.kind===`json`||[...n.parameters,...p].some(e=>le(e.schemaType,e.itemSchemaType))?de:``].filter(Boolean).join(`
58
+ `));let m=Xe(n);for(let e of n.parameters)bc(f,e,o||e===m);if(kn(f,n),e(n.intent)&&f.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),A(f),f.hook(`preAction`,e=>Qe(e,n)),n.explain===!0&&f.option(`--explain`,`Print the search strategy and parsed constraints before the results`),m!==void 0){f.argument(`[text...]`,m.description||`Same as ${Je(m.flag)}.`),f.action(async function(e){let t=this.optsWithGlobals(),i=k(t),a=Ye(m,e,t);if(!a.ok||a.data===null)return R({mode:i},a);let o=et(n,a.data);if(o.length>0)return R({mode:i},r(`missing required options: ${o.join(`, `)}`));let s=await xc(n,a.data,i),c=ai(n,a.data,s);if(c!==null)return R({mode:i},c);t.explain===!0&&s.ok&&tr(i,s.data),s.ok&&s.data instanceof Uint8Array?process.stdout.write(s.data):R({mode:i},s)});return}f.action(async function(){let e=this.optsWithGlobals(),t=k(e),i=et(n,e);if(i.length>0)return R({mode:t},r(`missing required options: ${i.join(`, `)}`));let a=await xc(n,e,t),o=ai(n,e,a);if(o!==null)return R({mode:t},o);e.explain===!0&&a.ok&&tr(t,a.data),a.ok&&a.data instanceof Uint8Array?process.stdout.write(a.data):R({mode:t},a)})}function yc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=nt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function bc(e,t,n=!1){let r=t.description||`${t.name} ${t.location} parameter`,i=t.defaultValue===void 0?void 0:typeof t.defaultValue==`string`||typeof t.defaultValue==`boolean`?t.defaultValue:[...t.defaultValue];if(t.legacyFlag!==void 0){let a=new S(t.flag,r);i!==void 0&&a.default(i);let o=new S(t.legacyFlag,r).conflicts(t.optionKey);e.addOption(a).addOption(o),e.hook(`preAction`,e=>{let r=e.opts(),i=r[t.optionKey],s=r[o.attributeName()];if(s!==void 0){(i===void 0||e.getOptionValueSource(t.optionKey)==="default")&&e.setOptionValueWithSource(t.optionKey,s,`cli`);return}!n&&t.required&&i===void 0&&e.error(`error: required option '${a.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(i!==void 0){e.option(t.flag,r,i);return}if(t.required&&!n){e.requiredOption(t.flag,r);return}e.option(t.flag,r)}async function xc(e,n,i){if(n.environment!==void 0){let e=t(n.environment);if(e===null)return r(`Unknown aVenture environment '${n.environment}'`,[`Use one of: ${o().join(`, `)}`]);process.env.API_ENV=e}let a=await Pn(e,n);if(!a.ok)return a;let s=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let t=n[e.optionKey];if(Array.isArray(t))return[e.name,t.at(0)??``];if(t===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(t)]})),c=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let t=n[e.optionKey];if(t===void 0||Array.isArray(t)&&t.length===0)return[];let r=Array.isArray(t)||typeof t==`boolean`?t:String(t);return[[e.name,r]]})),l=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let t=n[e.optionKey];return t===void 0||Array.isArray(t)&&t.length===0?[]:[[e.name,Array.isArray(t)?t.join(`,`):String(t)]]}));return si(e,await x({method:e.method,path:ie(e.operationId,s),searchParams:c,headers:l,body:a.data,contentType:qe(e,n),auth:e.auth,responseFormat:We(i)?`json`:`auto`,responseBytes:e.binaryResponse===!0}))}process.on(`uncaughtException`,e=>hc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>hc(e instanceof Error?e:Error(String(e)),`unhandledRejection`));var Sc=Ke(process.argv.slice(2),j),Cc=Sc===`required`?j:Ze(j),$=new l;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(Xr).version(mc.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description([`The aVenture research API from your terminal. Three records — companies,`,`people, and news — carry everything else: funding, publications, and tags.
59
+ `,`Mutations execute directly; --execute is a deprecated no-op.
60
+ The aVenture MCP server tools execute through this same CLI.`].join(`
61
+ `)).addOption(new S(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${u})`).choices([...o()])).showHelpAfterError(`(run \`${Q} --help\` for usage)`),_c($,Cc),No($,Q),to($,mc),Jo($,Cc,Q),lc($,Cc,Q),Kr($,Cc,Q);for(let e of $.commands)e.helpGroup()||e.helpGroup(gc(e.name()).heading);if(nc($),Sc===`required`){let e=[$];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&(await Fe(),await Le())}))}}var wc=new Set($.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));$.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find one news article; companies and people use the root lookup`],[`get`,` get Read one record`],[`list`,` list Read many records`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>wc.has(e)?[t]:[]),``,`Account (free or paid; every command that calls aVenture needs one):`,` Create one at ${ue}/sign-up, then run: ${Q} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Profile views, searches, and web searches count toward your monthly allowance.`,` Usage and upgrades: ${ue}/settings/subscription`,` Plans and prices: ${Q} billing plans list`,` Check what this shell holds with: ${Q} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
62
+ `,`Exit codes:`,` 0 envelope.ok === true
63
+ 1 envelope.ok === false
64
+ `,`Examples:`,` $ ${Q} auth login`,` $ ${Q} lookup --name Stripe --url https://stripe.com`,` $ ${Q} search "fintech companies in Austin"\n`,`Run \`${Q} <command> --help\` for its subcommands and options,`,`or \`${Q} help <command>\` for its full documentation.`].join(`
65
+ `));try{await $.parseAsync()}catch(e){hc(e instanceof Error?e:Error(String(e)),`parseAsync`)}export{};