@aventurevc/aventure-cli 0.8.62 → 0.8.64

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.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{_i as e,ca as t,ci as n,gi as r,ui as i}from"../chunks/client-CWGyF2b1.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-DEyrf0he.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-BZvig5Wx.js";import{r as u}from"../chunks/text-field-Ce8m6rqw.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-0ZqFzjbl.js`)}catch(e){if(!(e instanceof t))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-CavIYk38.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-DA-Y3Jut.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-DyZehDye.js";import{r as u}from"../chunks/text-field-DQT_m_C8.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-Dtp6MMKr.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-05T22:01:40.764Z",
4
+ "generatedAt": "2026-10-06T00:39:59.069Z",
5
5
  "totalOperations": 136,
6
6
  "note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
7
7
  "operations": [
@@ -1,4 +1,4 @@
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-CWGyF2b1.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-DEyrf0he.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-BZvig5Wx.js";import{a as ot}from"./text-field-Ce8m6rqw.js";import{i as st,n as ct,o as lt,s as ut,t as dt}from"./text-response-nkgHzRKC.js";import{n as ft,r as pt,t as mt}from"./oauth-login-DqgJxwQl.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(`
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-CavIYk38.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-DA-Y3Jut.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-DyZehDye.js";import{a as ot}from"./text-field-DQT_m_C8.js";import{i as st,n as ct,o as lt,s as ut,t as dt}from"./text-response-Bew_UQzj.js";import{n as ft,r as pt,t as mt}from"./oauth-login-Cr_yFhTu.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
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
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
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(`
@@ -25,7 +25,7 @@ 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
25
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
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
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-COGxhrgq.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(`
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-Co5l6_nl.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===`88901b58fb46bf4a`)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
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
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
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(`