@aventurevc/aventure-cli 0.8.94 → 0.8.95

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,di as t,li as n,ua as r,vi as i}from"../chunks/client-BfCiLIgS.js";import{_ as a,t as o}from"../chunks/oauth-bearer-credential-Dd1bEyz_.js";import{i as s}from"../chunks/text-field-C1R98s91.js";import{c,i as l,t as u}from"../chunks/openapi-commands-DS3MVeQF.js";var d=process.argv.slice(2);l(d)&&t(!1),d.includes(`--all-fields`)&&s(!0);try{if(i(),c(d,u)===`optional`)try{await o(),await a()}catch(t){n({component:e().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:t})}await import(`../chunks/aventure-cli-CVMjpuTM.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,di as t,li as n,ua as r,vi as i}from"../chunks/client-DxOlcB_9.js";import{_ as a,t as o}from"../chunks/oauth-bearer-credential-D4XL-ZEq.js";import{i as s}from"../chunks/text-field-BhLFT6Wh.js";import{c,i as l,t as u}from"../chunks/openapi-commands-CSDn5aDC.js";var d=process.argv.slice(2);l(d)&&t(!1),d.includes(`--all-fields`)&&s(!0);try{if(i(),c(d,u)===`optional`)try{await o(),await a()}catch(t){n({component:e().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:t})}await import(`../chunks/aventure-cli-B4N-9B43.js`)}catch(e){if(!(e instanceof r))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-07T08:41:41.085Z",
4
+ "generatedAt": "2026-10-07T17:28:28.177Z",
5
5
  "totalOperations": 140,
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{Ai as e,C as t,Ei as n,O as r,Oi as i,Si as a,Ti as o,_i as s,a as c,b as l,c as u,ca as d,d as f,da as p,f as m,hi as h,i as g,ji as _,ki as v,l as y,la as b,li as x,m as S,n as ee,o as te,p as ne,r as re,sa as ie,si as ae,u as oe,v as se,w as ce,wi as le,x as ue,xi as de,yi as C}from"./client-BfCiLIgS.js";import{M as fe,O as pe,i as w,o as me,v as he,w as T,y as E}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,E as ye,M as be,N as xe,O as D,S as Se,T as Ce,_ as we,a as Te,b as Ee,c as De,h as Oe,i as ke,k as Ae,l as je,o as Me,p as Ne,s as Pe,t as Fe,u as Ie,v as Le,x as Re,y as ze}from"./oauth-bearer-credential-Dd1bEyz_.js";import{c as Be,d as Ve,h as He,m as Ue,o as We,p as Ge,s as Ke,u as qe}from"./text-field-C1R98s91.js";import{a as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,l as et,m as tt,n as nt,o as O,p as rt,r as k,s as it,t as A,u as at}from"./openapi-commands-DS3MVeQF.js";import{a as ot,c as st,d as ct,i as j,l as lt,m as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./text-response-O5xmTK6h.js";import{n as gt,r as _t,t as vt}from"./oauth-login-C-QaUeGZ.js";import{spawnSync as yt}from"node:child_process";import{basename as bt,dirname as M,resolve as N,sep as P}from"node:path";import{copyFileSync as xt,existsSync as St,lstatSync as Ct,mkdirSync as wt,mkdtempSync as Tt,readFileSync as Et,readlinkSync as Dt,realpathSync as Ot,renameSync as kt,rmdirSync as At,unlinkSync as jt,writeFileSync as Mt}from"node:fs";import F,{stderr as I,stdin as Nt}from"node:process";import{TextDecoder as Pt,inspect as Ft}from"node:util";import{fileURLToPath as It}from"node:url";import{readFile as Lt}from"node:fs/promises";import{setTimeout as Rt}from"node:timers/promises";import{webcrypto as zt}from"node:crypto";import{homedir as Bt,hostname as Vt,platform as Ht}from"node:os";import{createInterface as Ut}from"node:readline/promises";function Wt(t,n,r){let i={...r};for(let e of n.parameter){let n=e.envName;if(n===void 0)continue;let r=process.env[n]?.trim();if(r===void 0||r.length===0)continue;let a=i[e.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==r))return{...v(`${t} ${e.flag.split(` `)[0]??e.name} conflicts with ${n}; omit the flag or use ${r}.`),data:i};a===void 0&&(i[e.optionKey]=r)}return e(`Environment-bound options applied`,i)}function Gt(e,t,n){if(!L(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||!on(n,r.name))continue;let a=an(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 Kt(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 qt(t,n,r,i=!1){if(i||!ln(n)||!Array.isArray(r))return dn(t,n,r);for(let[e,i]of r.entries()){let r=dn(t,n,i,e);if(!r.ok)return r}return e(`Body value assigned`,null)}function Jt(e,t,n,r){return dn(e,t,r,n)}function Yt(e){let t=[];for(let n of e.split(`.`)){let e=pn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Xt(e,t){let n=Yt(t);if(n===null)return null;let r=rn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:nn(r)}:null}function Zt(t,n){if(ln(t.name)||t.schemaType===`array`)return e(`Repeated body option selected`,typeof n==`string`?[n]:n);if(!Array.isArray(n))return e(`Scalar body option selected`,n);let r=t.flag.split(` `)[0]??t.name;return n.length===1?e(`Scalar body option selected`,n[0]):v(`${r} was already given; pass it once.`)}var Qt=/^(?<row>\d+):(?<item>.*)$/su;function $t(e,t){let n=Yt(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=Qt.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 en(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Yt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function tn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Xt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return v(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||$t(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return v(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function nn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function rn(e,t){let n=e;for(let e of t){if(!L(n))return;n=n[e]??null}return n}function an(e,t){if(!ln(t))return rn(e,t.split(`.`))}function on(e,t){return cn(e,t.split(`.`))}function sn(e,t,n){if(!L(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)&&on(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function cn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=pn(n);if(!L(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>cn(e,r)):cn(a,r)}function ln(e){return e.split(`.`).some(e=>pn(e).isArray)}function un(e,t){return e.parameter.length===0||!L(t)?null:hn(t,[],mn(e.parameter))}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dn(t,n,r,i=0){let a=n.split(`.`),o=t;for(let[t,s]of a.entries()){let c=pn(s),l=t===a.length-1,u=fn(o,c,n,l,r,i);if(!u.ok||u.data===null)return v(u.summary,u.warnings);if(l)return e(`Body value assigned`,null);o=u.data}return v(`${n} is not a valid body option path.`)}function fn(t,n,r,i,a,o){let s=()=>v(`${r} cannot be combined with another body option at ${n.key}.`),c=t[n.key];if(n.isArray){if(c!==void 0&&!Array.isArray(c))return s();let r=c??[];if(c===void 0&&(t[n.key]=r),i)return r[o]===void 0?(r[o]=a,e(`Body value assigned`,t)):s();let l=r[o];if(l===void 0){let t={};return r[o]=t,e(`Body path created`,t)}return L(l)?e(`Body path stepped`,l):s()}if(i)return c===void 0?(t[n.key]=a,e(`Body value assigned`,t)):s();if(c===void 0){let r={};return t[n.key]=r,e(`Body path created`,r)}return L(c)?e(`Body path stepped`,c):s()}function pn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function mn(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 hn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=hn(r,t,n);if(e!==null)return e}return null}if(!L(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!gn(a,n)){if(!_n(e))continue;return{path:a,suggestion:vn(e,n)}}let o=hn(i,e,n);if(o!==null)return o}return null}function gn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function _n(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function vn(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:yn(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 yn(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 bn(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(Ue(e)),t.description=u(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?On(r,i):r===void 0?i===void 0?0:1:-1})}function xn(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 Sn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Cn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:En(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 wn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Tn(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?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function En(e,t){let n=Ve(t.description,void 0),r=e.kind!==`multipart`&&ln(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}.`:``}${Dn(e,t)}`}function Dn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Yt(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 On(e,t){return Ge(e)-Ge(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function kn(t){let n;try{n=t===`-`?await An():await Lt(t,`utf8`)}catch(e){return v(`Could not read input: ${e.message}`,[`path=${t}`])}try{if(n.trim().length===0)return e(`No input provided`,null);let t=JSON.parse(n);return e(`Input parsed`,t)}catch(e){return v(`Input is not valid JSON: ${e.message}`)}}async function An(){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 jn=`--content-type`;function Mn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(jn)){let t=i.map(({contentType:e})=>e);e.addOption(new d(`${jn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Pn(i)))}if(Qn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new d(`--from-file <path>`,Tn(n,n.requiredPath)).argParser(In(`--from-file`)))}let a=xn(i).filter(e=>r(R(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>On(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new d(Sn(t),i.length>1?Cn(t):En(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?wn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Nn):ln(r.name)||r.schemaType===`array`?a.argParser(Fn):a.argParser(In(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`)})}Zn(e,t,a)}function Nn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Pn(e){return(t,n)=>{if(n!==void 0)throw new p(`${jn} was already given; pass it once.`);let i=r(e,t);if(!i.ok)throw new p(i.summary);return t}}function Fn(e,t){return[...t??[],e]}function In(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new p(`${t} was already given; pass it once.`);return e}}async function Ln(t,n){let i=Xe(t,n),a=r(t.requestBody??[],i);if(!a.ok||a.data===null)return v(a.summary,a.warnings);let o=a.data;if(o===void 0)return e(`No body`,void 0);let s=Rn(t,o,n);if(s!==null)return v(s);let c=Wt(t.operationId,o,n);if(!c.ok)return v(c.summary,c.warnings);n=c.data;let l=zn(o,n);if(l!==null)return v(l);let u=await Un(n);if(!u.ok)return v(u.summary,u.warnings);let d=sn(t.requestBody??[],o,u.data);if(d!==null)return v(d);let f=Hn(t.operationId,o,u.data);if(!f.ok)return f;let p=Gt(t.operationId,o,u.data);if(p!==null)return v(p);let m=Wn(t.operationId,o,n);if(!m.ok)return m;if(u.data===void 0&&m.data===void 0)return o.required?v(Xn(t.operationId,o)):e(`No body`,void 0);let h=Kn(t.operationId,o,u.data,m.data);if(!h.ok||h.data===void 0)return h;if(o.schemaType===`array`&&!Array.isArray(h.data))return v(`${t.operationId} requires a JSON array body.`);if(o.parameter.length>0&&!L(h.data)){let e=o.kind===`multipart`?` keyed by multipart part name`:` body`;return v(`${t.operationId} requires a JSON object${e}.`)}let g=Vn(o,h.data);if(g.length>0)return v(`${t.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,y=L(_)?Kt(o).filter(e=>!on(_,e)):[];return y.length>0?v(Bn(t.operationId,o,y)):h}function Rn(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`${R(t)} requires ${jn} ${i.join(` or `)}.`}return null}function zn(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 Bn(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 Vn(e,t){return L(t)?e.parameter.filter(e=>e.required&&!on(t,e.name)).map(R):[]}function Hn(t,n,r){let i=un(n,r);if(i===null)return e(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return v(`${t} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Un(t){let n=typeof t.fromFile==`string`?t.fromFile:void 0;if(n===void 0)return e(`No body file`,void 0);let r=await kn(n);if(!r.ok)return v(r.summary,r.warnings);let i=_.safeParse(r.data);return i.success?e(`Input parsed`,i.data):v(`Input is not valid JSON value: ${i.error.message}`)}function Wn(t,n,r){let i={},a=!1;for(let e of n.parameter){let t=Zt(e,r[e.optionKey]);if(!t.ok||t.data===null)return v(t.summary,t.warnings);let o=t.data;if(o===void 0)continue;let s=Gn(n,r,i,e,o);if(!s.ok)return v(s.summary,s.warnings);a=!0}if(!a)return e(`No direct body options`,void 0);let o=tn(t,n,r,i);return o===null?e(`Direct body options parsed`,i):o}function Gn(t,n,r,i,a){let o=$t(i,a);if(o===null){let e=Jn(i,a);return e.ok?qt(r,i.name,e.data,i.schemaType===`array`):v(e.summary,e.warnings)}if(o.plain.length>0)return v(`${R(i)} mixes row-form values with plain value(s): ${o.plain.join(`, `)} — prefix every value with its 0-based ${o.container}[] row index, as 0:value.`);let s=en(t,n,o.container);for(let e of o.rows.keys())if(!(e<s))return v(`${R(i)} names ${o.container}[] row ${e}, but these options build at most ${s} ${o.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 o.rows){let n=[];for(let e of t){let t=Yn(i.name,i.itemSchemaType,e);if(!t.ok)return v(t.summary,t.warnings);n.push(t.data)}let a=Jt(r,i.name,e,n);if(!a.ok)return a}return e(`Body value assigned`,null)}var R=e=>e.flag.split(` `)[0]??e.name;function Kn(t,n,r,i){if(r===void 0)return e(`Direct body parsed`,i);if(i===void 0)return e(`Input parsed`,r);if(L(r)&&L(i))try{return e(`Input parsed`,qn(n,r,i))}catch(e){return v(`${t} ${e.message}`)}return v(`${t} cannot combine --from-file with direct body options unless the file body is an object.`)}function qn(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(L(n)&&L(a))i[t]=qn(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:ot.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function Jn(t,n){if(typeof n==`boolean`)return e(`Body value parsed`,n);if(n===void 0||typeof n==`string`)return Yn(t.name,t.schemaType,n??``);let r=[],i=ln(t.name)&&t.schemaType!==`array`?t.schemaType:t.itemSchemaType;for(let e of n){let n=Yn(t.name,i,e);if(!n.ok)return n;r.push(n.data)}return e(`Body value parsed`,r)}function Yn(t,n,r){if(n===`boolean`)return r===`true`?e(`Body value parsed`,!0):r===`false`?e(`Body value parsed`,!1):v(`${t} must be true or false.`);if(n===`number`||n===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?v(`${t} must be a finite ${n}.`):n===`integer`&&!Number.isInteger(a)?v(`${t} must be an integer.`):e(`Body value parsed`,a)}return e(`Body value parsed`,r)}function Xn(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(R).join(`, `)}`;let r=Kt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(R).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Zn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:jn,location:`body`}),Qn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),bn(e.options,r)}function Qn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function $n(e){let t=i(e);return cr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function er(e){let t=i(e);cr(t);let n=ht(t.data,t.summary),r=[];if(t.ok&&n!==null){let e=tr(t);r.push(n.endsWith(`
1
+ import{Ai as e,C as t,Ei as n,O as r,Oi as i,Si as a,Ti as o,_i as s,a as c,b as l,c as u,ca as d,d as f,da as p,f as m,hi as h,i as g,ji as _,ki as v,l as y,la as b,li as x,m as S,n as ee,o as te,p as ne,r as re,sa as ie,si as ae,u as oe,v as se,w as ce,wi as le,x as ue,xi as de,yi as C}from"./client-DxOlcB_9.js";import{M as fe,O as pe,i as w,o as me,v as he,w as T,y as E}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,E as ye,M as be,N as xe,O as D,S as Se,T as Ce,_ as we,a as Te,b as Ee,c as De,h as Oe,i as ke,k as Ae,l as je,o as Me,p as Ne,s as Pe,t as Fe,u as Ie,v as Le,x as Re,y as ze}from"./oauth-bearer-credential-D4XL-ZEq.js";import{c as Be,d as Ve,h as He,m as Ue,o as We,p as Ge,s as Ke,u as qe}from"./text-field-BhLFT6Wh.js";import{a as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,l as et,m as tt,n as nt,o as O,p as rt,r as k,s as it,t as A,u as at}from"./openapi-commands-CSDn5aDC.js";import{a as ot,c as st,d as ct,i as j,l as lt,m as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./text-response-Dck-MXsh.js";import{n as gt,r as _t,t as vt}from"./oauth-login-DBcmkRQJ.js";import{spawnSync as yt}from"node:child_process";import{basename as bt,dirname as M,resolve as N,sep as P}from"node:path";import{copyFileSync as xt,existsSync as St,lstatSync as Ct,mkdirSync as wt,mkdtempSync as Tt,readFileSync as Et,readlinkSync as Dt,realpathSync as Ot,renameSync as kt,rmdirSync as At,unlinkSync as jt,writeFileSync as Mt}from"node:fs";import F,{stderr as I,stdin as Nt}from"node:process";import{TextDecoder as Pt,inspect as Ft}from"node:util";import{fileURLToPath as It}from"node:url";import{readFile as Lt}from"node:fs/promises";import{setTimeout as Rt}from"node:timers/promises";import{webcrypto as zt}from"node:crypto";import{homedir as Bt,hostname as Vt,platform as Ht}from"node:os";import{createInterface as Ut}from"node:readline/promises";function Wt(t,n,r){let i={...r};for(let e of n.parameter){let n=e.envName;if(n===void 0)continue;let r=process.env[n]?.trim();if(r===void 0||r.length===0)continue;let a=i[e.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==r))return{...v(`${t} ${e.flag.split(` `)[0]??e.name} conflicts with ${n}; omit the flag or use ${r}.`),data:i};a===void 0&&(i[e.optionKey]=r)}return e(`Environment-bound options applied`,i)}function Gt(e,t,n){if(!L(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||!on(n,r.name))continue;let a=an(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 Kt(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 qt(t,n,r,i=!1){if(i||!ln(n)||!Array.isArray(r))return dn(t,n,r);for(let[e,i]of r.entries()){let r=dn(t,n,i,e);if(!r.ok)return r}return e(`Body value assigned`,null)}function Jt(e,t,n,r){return dn(e,t,r,n)}function Yt(e){let t=[];for(let n of e.split(`.`)){let e=pn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Xt(e,t){let n=Yt(t);if(n===null)return null;let r=rn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:nn(r)}:null}function Zt(t,n){if(ln(t.name)||t.schemaType===`array`)return e(`Repeated body option selected`,typeof n==`string`?[n]:n);if(!Array.isArray(n))return e(`Scalar body option selected`,n);let r=t.flag.split(` `)[0]??t.name;return n.length===1?e(`Scalar body option selected`,n[0]):v(`${r} was already given; pass it once.`)}var Qt=/^(?<row>\d+):(?<item>.*)$/su;function $t(e,t){let n=Yt(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=Qt.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 en(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Yt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function tn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Xt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return v(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||$t(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return v(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function nn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function rn(e,t){let n=e;for(let e of t){if(!L(n))return;n=n[e]??null}return n}function an(e,t){if(!ln(t))return rn(e,t.split(`.`))}function on(e,t){return cn(e,t.split(`.`))}function sn(e,t,n){if(!L(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)&&on(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function cn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=pn(n);if(!L(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>cn(e,r)):cn(a,r)}function ln(e){return e.split(`.`).some(e=>pn(e).isArray)}function un(e,t){return e.parameter.length===0||!L(t)?null:hn(t,[],mn(e.parameter))}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function dn(t,n,r,i=0){let a=n.split(`.`),o=t;for(let[t,s]of a.entries()){let c=pn(s),l=t===a.length-1,u=fn(o,c,n,l,r,i);if(!u.ok||u.data===null)return v(u.summary,u.warnings);if(l)return e(`Body value assigned`,null);o=u.data}return v(`${n} is not a valid body option path.`)}function fn(t,n,r,i,a,o){let s=()=>v(`${r} cannot be combined with another body option at ${n.key}.`),c=t[n.key];if(n.isArray){if(c!==void 0&&!Array.isArray(c))return s();let r=c??[];if(c===void 0&&(t[n.key]=r),i)return r[o]===void 0?(r[o]=a,e(`Body value assigned`,t)):s();let l=r[o];if(l===void 0){let t={};return r[o]=t,e(`Body path created`,t)}return L(l)?e(`Body path stepped`,l):s()}if(i)return c===void 0?(t[n.key]=a,e(`Body value assigned`,t)):s();if(c===void 0){let r={};return t[n.key]=r,e(`Body path created`,r)}return L(c)?e(`Body path stepped`,c):s()}function pn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function mn(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 hn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=hn(r,t,n);if(e!==null)return e}return null}if(!L(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!gn(a,n)){if(!_n(e))continue;return{path:a,suggestion:vn(e,n)}}let o=hn(i,e,n);if(o!==null)return o}return null}function gn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function _n(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function vn(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:yn(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 yn(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 bn(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(Ue(e)),t.description=u(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?On(r,i):r===void 0?i===void 0?0:1:-1})}function xn(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 Sn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Cn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:En(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 wn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Tn(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?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function En(e,t){let n=Ve(t.description,void 0),r=e.kind!==`multipart`&&ln(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}.`:``}${Dn(e,t)}`}function Dn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Yt(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 On(e,t){return Ge(e)-Ge(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function kn(t){let n;try{n=t===`-`?await An():await Lt(t,`utf8`)}catch(e){return v(`Could not read input: ${e.message}`,[`path=${t}`])}try{if(n.trim().length===0)return e(`No input provided`,null);let t=JSON.parse(n);return e(`Input parsed`,t)}catch(e){return v(`Input is not valid JSON: ${e.message}`)}}async function An(){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 jn=`--content-type`;function Mn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(jn)){let t=i.map(({contentType:e})=>e);e.addOption(new d(`${jn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Pn(i)))}if(Qn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new d(`--from-file <path>`,Tn(n,n.requiredPath)).argParser(In(`--from-file`)))}let a=xn(i).filter(e=>r(R(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>On(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new d(Sn(t),i.length>1?Cn(t):En(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?wn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Nn):ln(r.name)||r.schemaType===`array`?a.argParser(Fn):a.argParser(In(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`)})}Zn(e,t,a)}function Nn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Pn(e){return(t,n)=>{if(n!==void 0)throw new p(`${jn} was already given; pass it once.`);let i=r(e,t);if(!i.ok)throw new p(i.summary);return t}}function Fn(e,t){return[...t??[],e]}function In(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new p(`${t} was already given; pass it once.`);return e}}async function Ln(t,n){let i=Xe(t,n),a=r(t.requestBody??[],i);if(!a.ok||a.data===null)return v(a.summary,a.warnings);let o=a.data;if(o===void 0)return e(`No body`,void 0);let s=Rn(t,o,n);if(s!==null)return v(s);let c=Wt(t.operationId,o,n);if(!c.ok)return v(c.summary,c.warnings);n=c.data;let l=zn(o,n);if(l!==null)return v(l);let u=await Un(n);if(!u.ok)return v(u.summary,u.warnings);let d=sn(t.requestBody??[],o,u.data);if(d!==null)return v(d);let f=Hn(t.operationId,o,u.data);if(!f.ok)return f;let p=Gt(t.operationId,o,u.data);if(p!==null)return v(p);let m=Wn(t.operationId,o,n);if(!m.ok)return m;if(u.data===void 0&&m.data===void 0)return o.required?v(Xn(t.operationId,o)):e(`No body`,void 0);let h=Kn(t.operationId,o,u.data,m.data);if(!h.ok||h.data===void 0)return h;if(o.schemaType===`array`&&!Array.isArray(h.data))return v(`${t.operationId} requires a JSON array body.`);if(o.parameter.length>0&&!L(h.data)){let e=o.kind===`multipart`?` keyed by multipart part name`:` body`;return v(`${t.operationId} requires a JSON object${e}.`)}let g=Vn(o,h.data);if(g.length>0)return v(`${t.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,y=L(_)?Kt(o).filter(e=>!on(_,e)):[];return y.length>0?v(Bn(t.operationId,o,y)):h}function Rn(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`${R(t)} requires ${jn} ${i.join(` or `)}.`}return null}function zn(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 Bn(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 Vn(e,t){return L(t)?e.parameter.filter(e=>e.required&&!on(t,e.name)).map(R):[]}function Hn(t,n,r){let i=un(n,r);if(i===null)return e(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return v(`${t} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Un(t){let n=typeof t.fromFile==`string`?t.fromFile:void 0;if(n===void 0)return e(`No body file`,void 0);let r=await kn(n);if(!r.ok)return v(r.summary,r.warnings);let i=_.safeParse(r.data);return i.success?e(`Input parsed`,i.data):v(`Input is not valid JSON value: ${i.error.message}`)}function Wn(t,n,r){let i={},a=!1;for(let e of n.parameter){let t=Zt(e,r[e.optionKey]);if(!t.ok||t.data===null)return v(t.summary,t.warnings);let o=t.data;if(o===void 0)continue;let s=Gn(n,r,i,e,o);if(!s.ok)return v(s.summary,s.warnings);a=!0}if(!a)return e(`No direct body options`,void 0);let o=tn(t,n,r,i);return o===null?e(`Direct body options parsed`,i):o}function Gn(t,n,r,i,a){let o=$t(i,a);if(o===null){let e=Jn(i,a);return e.ok?qt(r,i.name,e.data,i.schemaType===`array`):v(e.summary,e.warnings)}if(o.plain.length>0)return v(`${R(i)} mixes row-form values with plain value(s): ${o.plain.join(`, `)} — prefix every value with its 0-based ${o.container}[] row index, as 0:value.`);let s=en(t,n,o.container);for(let e of o.rows.keys())if(!(e<s))return v(`${R(i)} names ${o.container}[] row ${e}, but these options build at most ${s} ${o.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 o.rows){let n=[];for(let e of t){let t=Yn(i.name,i.itemSchemaType,e);if(!t.ok)return v(t.summary,t.warnings);n.push(t.data)}let a=Jt(r,i.name,e,n);if(!a.ok)return a}return e(`Body value assigned`,null)}var R=e=>e.flag.split(` `)[0]??e.name;function Kn(t,n,r,i){if(r===void 0)return e(`Direct body parsed`,i);if(i===void 0)return e(`Input parsed`,r);if(L(r)&&L(i))try{return e(`Input parsed`,qn(n,r,i))}catch(e){return v(`${t} ${e.message}`)}return v(`${t} cannot combine --from-file with direct body options unless the file body is an object.`)}function qn(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(L(n)&&L(a))i[t]=qn(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:ot.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function Jn(t,n){if(typeof n==`boolean`)return e(`Body value parsed`,n);if(n===void 0||typeof n==`string`)return Yn(t.name,t.schemaType,n??``);let r=[],i=ln(t.name)&&t.schemaType!==`array`?t.schemaType:t.itemSchemaType;for(let e of n){let n=Yn(t.name,i,e);if(!n.ok)return n;r.push(n.data)}return e(`Body value parsed`,r)}function Yn(t,n,r){if(n===`boolean`)return r===`true`?e(`Body value parsed`,!0):r===`false`?e(`Body value parsed`,!1):v(`${t} must be true or false.`);if(n===`number`||n===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?v(`${t} must be a finite ${n}.`):n===`integer`&&!Number.isInteger(a)?v(`${t} must be an integer.`):e(`Body value parsed`,a)}return e(`Body value parsed`,r)}function Xn(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(R).join(`, `)}`;let r=Kt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(R).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Zn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:jn,location:`body`}),Qn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),bn(e.options,r)}function Qn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function $n(e){let t=i(e);return cr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function er(e){let t=i(e);cr(t);let n=ht(t.data,t.summary),r=[];if(t.ok&&n!==null){let e=tr(t);r.push(n.endsWith(`
2
2
  `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(dt(r.join(`
3
3
  `),!0,!0,e.length));return}let a=t.ok?`OK`:`FAIL`;r.push(`[${a}] ${t.summary}`),!t.ok&&t.problem!==void 0&&r.push(...ir(t.problem)),r.push(...tr(t)),process.stdout.write(dt(r.join(`
4
4
  `),!0))}function tr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function z(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?i(t):t;cr(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?nr(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?$n(t):t;e.mode===`text`&&er(n),n.ok||(process.exitCode=1)}function nr(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 rr(e,t){let n=pt(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
@@ -27,7 +27,7 @@ import{Ai as e,C as t,Ei as n,O as r,Oi as i,Si as a,Ti as o,_i as s,a as c,b as
27
27
  `).slice(-3).join(` | `);return v(`npm ${t.join(` `)} exited ${o.status}`,[e||`no stderr`])}return e(`npm ok`,o.stdout??``)}function qa(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${h}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function Ja(t,n,r){let i;try{let e=s(N(t,`lib`,`node_modules`,...n.split(`/`),`package.json`));i=N(t,`bin`,e.bin[0])}catch(e){return v(`updated ${n} verification failed: ${$a(e)}`,[`invalid_package_metadata`])}let a=yt(process.execPath,[i,`--version`],{encoding:`utf8`});if(a.error)return v(`updated ${n} verification failed: ${a.error.message}`,[`spawn_error`]);let o=(a.stdout??``).trim();if(a.status!==0||o!==r){let e=(a.stderr??``).trim().split(`
28
28
  `).slice(-3).join(` | `);return v(`updated ${n} verification expected ${r} but active bin reported ${o||`empty output`}`,[e||`active bin: ${i}`])}return e(`active CLI version verified`,o)}function Ya(e){let t=`${P}lib${P}node_modules${P}${e.name.replace(`/`,P)}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:{installPrefix:e.packageRoot.slice(0,n)}}function Xa(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}${P}`))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=Ct(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=Ot(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:Dt(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=Tt(N(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:N(r,bt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(kt(e.binPath,e.backupPath),a.push(e),Dt(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=Za({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 Za(e,t){let n=[];for(let r of e.backup.toReversed())try{let e=Ct(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),Dt(r.binPath));if(t===null||n!==t&&!n.startsWith(`${t}${P}`))throw Error(`${r.binPath} is not owned by the standalone CLI package`);jt(r.binPath)}kt(r.backupPath,r.binPath)}catch(e){n.push($a(e))}if(e.backupDirectory!==null)try{At(e.backupDirectory)}catch(e){n.push($a(e))}return n.length===0?null:n.join(`; `)}function Qa(e){let t=[];for(let n of e.backup)try{jt(n.backupPath)}catch(e){t.push($a(e))}if(e.backupDirectory!==null)try{At(e.backupDirectory)}catch(e){t.push($a(e))}return t.length===0?null:t.join(`; `)}function $a(e){return e instanceof Error?e.message:String(e)}function eo(){try{return Ea()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var to=[{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`}],no=`operationFingerprint`;function ro(e,t=s().bin[0]){k(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: [...] }`:",...to.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(`
29
29
  `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),z({mode:O(e)},await io(t))})}async function io(t){let n=oo(),r=so(t),[i,a]=await Promise.all([co(t),lo(n,t)]),o=[r.check,i,a.check,await fo(t),vo(n,a.servedFingerprint,r.upgradeAvailable,t)],s={pass:ao(o,`pass`),fail:ao(o,`fail`),skip:ao(o,`skip`)},c=o.filter(e=>e.status===`fail`).map(e=>e.message),l={ok:c.length===0,check:o},u=[`doctor: ${s.pass} pass, ${s.fail} fail, ${s.skip} skip`,...o.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
30
- `);return l.ok?e(u,l,{counts:s}):{...v(u,c,{counts:s}),data:l}}function ao(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function oo(){return A.find(e=>e.intent===`status`&&e.resource===`status`)}function so(e){let t=s(),n=Ga(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 co(e){try{let{EntityDetailSchema:e}=await import(`./detail-C5CVQ5AL.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\` — ${D(t)}.`)}}async function lo(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 r;try{r=n().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${D(e)}.`),servedFingerprint:null}}let i=await te({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>v(D(e)));return i.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${r}.`),servedFingerprint:uo(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} 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 ${r} returned ${i.summary}.`),servedFingerprint:null}}function uo(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[no];return typeof n==`string`&&n.length>0?n:null}async function fo(e){let t=ve(),[n,r]=await Promise.all([po(),mo()]);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`&&Pe(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: ${ho(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 po(){let e;try{e=be(n().host)}catch(e){return{state:`unavailable`,summary:D(e)}}return await Me(e)}async function mo(){let e;try{e=be(n().host)}catch(e){return{state:`unavailable`,summary:D(e),cause:`environment`}}try{return await ze(e)}catch(e){return{state:`unavailable`,summary:D(e),cause:`storage`}}}function ho(e,t,n){return[va(e),`oauth=${_o(t)}`,`api-key=${go(n)}`].join(` `)}function go(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=be(n().host);return`${e.stored.activation}${ra(t,e)}`}function _o(e){switch(e.state){case`found`:return Pe(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 vo(e,t,n,r){let i=A.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 ${nt}.`);if(t===`761336862beb01ba`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${nt}).`);let a=`This catalog describes a different operation set than the API serves (${nt} 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 yo=j(V,`oauth`),bo=[j(V,`start`),j(V,`poll`),j(V,`acknowledge`)],xo=j(V,`revoke`);function So(e,t=s().bin[0]){let n=Eo(e);ro(n,t);let r=[`${yo.description} Default method: OAuth in your browser.`,`With --key: ${bo.map(({description:e})=>e).join(` `)}`].join(`
30
+ `);return l.ok?e(u,l,{counts:s}):{...v(u,c,{counts:s}),data:l}}function ao(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function oo(){return A.find(e=>e.intent===`status`&&e.resource===`status`)}function so(e){let t=s(),n=Ga(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 co(e){try{let{EntityDetailSchema:e}=await import(`./detail-C5CVQ5AL.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\` — ${D(t)}.`)}}async function lo(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 r;try{r=n().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${D(e)}.`),servedFingerprint:null}}let i=await te({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>v(D(e)));return i.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${r}.`),servedFingerprint:uo(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} 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 ${r} returned ${i.summary}.`),servedFingerprint:null}}function uo(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[no];return typeof n==`string`&&n.length>0?n:null}async function fo(e){let t=ve(),[n,r]=await Promise.all([po(),mo()]);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`&&Pe(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: ${ho(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 po(){let e;try{e=be(n().host)}catch(e){return{state:`unavailable`,summary:D(e)}}return await Me(e)}async function mo(){let e;try{e=be(n().host)}catch(e){return{state:`unavailable`,summary:D(e),cause:`environment`}}try{return await ze(e)}catch(e){return{state:`unavailable`,summary:D(e),cause:`storage`}}}function ho(e,t,n){return[va(e),`oauth=${_o(t)}`,`api-key=${go(n)}`].join(` `)}function go(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=be(n().host);return`${e.stored.activation}${ra(t,e)}`}function _o(e){switch(e.state){case`found`:return Pe(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 vo(e,t,n,r){let i=A.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 ${nt}.`);if(t===`87859afa2be6b461`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${nt}).`);let a=`This catalog describes a different operation set than the API serves (${nt} 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 yo=j(V,`oauth`),bo=[j(V,`start`),j(V,`poll`),j(V,`acknowledge`)],xo=j(V,`revoke`);function So(e,t=s().bin[0]){let n=Eo(e);ro(n,t);let r=[`${yo.description} Default method: OAuth in your browser.`,`With --key: ${bo.map(({description:e})=>e).join(` `)}`].join(`
31
31
  `);k(To(n,[yo,...bo],r)).action(Co),k(To(n,[xo],xo.description)).action(wo),k(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(`
32
32
  `)).addOption(new d(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Do(this),z({mode:O(e)},await Oo(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(`
33
33
  `)).action(async function(){Do(this);let e=await Yi(t),n=process.env[C.authToken]?.trim();if(e.failure===null&&n!==void 0&&n.length>0){process.stdout.write(`${n}\n`);return}z({mode:`text`},e.failure===null?Io(`auth token: no credentials resolved`,null,t,{oauth:!0,apiKey:!0}):v(`auth token: ${e.failure}`))})}async function Co(e){Do(this);let t=O(e);if(e.providers===!0){z({mode:t},await Ao());return}z({mode:t},e.key===!0?await Ri({noBrowser:!e.browser,clientLabel:e.clientLabel}):await _t({noBrowser:!e.browser}))}async function wo(e){Do(this),z({mode:O(e)},await Di({forgetLocal:e.forgetLocal===!0}))}function To(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 Eo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${yo.command}\`: ${yo.summary}; \`--key\` ${bo[0].summary.toLowerCase()}.`,`\`${xo.command}\`: ${xo.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(`