@aventurevc/aventure-cli 0.8.46 → 0.8.47

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{ci as e,hi as t,mi as n,oa as r,oi as i}from"../chunks/client-LQPEw77G.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-CQFC2YIz.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-CWWMbFAY.js";import{r as u}from"../chunks/text-field-CcOyrAOu.js";var d=process.argv.slice(2);c(d)&&e(!1),d.includes(`--all-fields`)&&u(!0);try{if(t(),s(d,l)===`optional`)try{await a(),await o()}catch(e){i({component:n().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-BdkckIvm.js`)}catch(e){if(!(e instanceof r))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
2
+ import{ci as e,hi as t,mi as n,oa as r,oi as i}from"../chunks/client-Bm0yIt0Y.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-Bng7aPLe.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-DvGIzIbd.js";import{r as u}from"../chunks/text-field-CoZsgTRF.js";var d=process.argv.slice(2);c(d)&&e(!1),d.includes(`--all-fields`)&&u(!0);try{if(t(),s(d,l)===`optional`)try{await a(),await o()}catch(e){i({component:n().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-BY4ekH3D.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-04T16:39:39.593Z",
4
+ "generatedAt": "2026-10-04T18:17:53.158Z",
5
5
  "totalOperations": 134,
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,Di as t,Ei as n,S as r,Si as i,T as a,Ti as o,_ as s,a as c,aa as l,b as u,bi as d,c as f,d as p,f as m,fi as h,gi as g,i as _,ia as v,ii as y,l as b,m as x,mi as S,n as ee,o as te,oi as ne,r as re,ra as ie,sa as ae,u as oe,v as se,vi as ce,wi as le,xi as ue,yi as de}from"./client-LQPEw77G.js";import{M as fe,O as pe,i as C,o as me,v as he,w,y as T}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,M as E,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-CQFC2YIz.js";import{_ as Ve,a as He,c as Ue,d as We,f as Ge,g as Ke,h as qe,l as Je,m as Ye,n as Xe,o as D,p as Ze,r as O,s as Qe,t as k,u as $e}from"./openapi-commands-CWWMbFAY.js";import{a as et}from"./text-field-CcOyrAOu.js";import{a as tt,n as nt,o as rt,r as it,t as at}from"./text-response-uyztC0NO.js";import{n as ot,r as st,t as ct}from"./oauth-login-CuJAnI3R.js";import{spawnSync as lt}from"node:child_process";import{basename as ut,dirname as A,resolve as j,sep as M}from"node:path";import{copyFileSync as dt,existsSync as ft,lstatSync as pt,mkdirSync as mt,mkdtempSync as ht,readFileSync as gt,readlinkSync as _t,realpathSync as vt,renameSync as yt,rmdirSync as bt,unlinkSync as xt,writeFileSync as St}from"node:fs";import N,{stderr as P,stdin as Ct}from"node:process";import{TextDecoder as wt,inspect as Tt}from"node:util";import{fileURLToPath as Et}from"node:url";import{readFile as Dt}from"node:fs/promises";import{webcrypto as Ot}from"node:crypto";import{homedir as kt,hostname as At,platform as jt}from"node:os";import{setTimeout as Mt}from"node:timers/promises";import{createInterface as Nt}from"node:readline/promises";function Pt(e,t,r){let i={...r};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let r=process.env[t]?.trim();if(r===void 0||r.length===0)continue;let a=i[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==r))return{...o(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${r}.`),data:i};a===void 0&&(i[n.optionKey]=r)}return n(`Environment-bound options applied`,i)}function Ft(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||!Yt(n,r.name))continue;let a=Jt(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 It(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 Lt(e,t,r,i=!1){if(i||!F(t)||!Array.isArray(r))return $t(e,t,r);for(let[n,i]of r.entries()){let r=$t(e,t,i,n);if(!r.ok)return r}return n(`Body value assigned`,null)}function Rt(e,t,n,r){return $t(e,t,r,n)}function zt(e){let t=[];for(let n of e.split(`.`)){let e=tn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Bt(e,t){let n=zt(t);if(n===null)return null;let r=qt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Kt(r)}:null}function Vt(e,t){if(F(e.name)||e.schemaType===`array`)return n(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return n(`Scalar body option selected`,t);let r=e.flag.split(` `)[0]??e.name;return t.length===1?n(`Scalar body option selected`,t[0]):o(`${r} was already given; pass it once.`)}var Ht=/^(?<row>\d+):(?<item>.*)$/su;function Ut(e,t){let n=zt(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=Ht.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 Wt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&zt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Gt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Bt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return o(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Ut(i,t)!==null)continue;let s=i.flag.split(` `)[0]??i.name;return o(`${s} 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 Kt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function qt(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function Jt(e,t){if(!F(t))return qt(e,t.split(`.`))}function Yt(e,t){return Zt(e,t.split(`.`))}function Xt(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)&&Yt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function Zt(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=tn(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=>Zt(e,r)):Zt(a,r)}function F(e){return e.split(`.`).some(e=>tn(e).isArray)}function Qt(e,t){return e.parameter.length===0||!I(t)?null:rn(t,[],nn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $t(e,t,r,i=0){let a=t.split(`.`),s=e;for(let[e,c]of a.entries()){let l=tn(c),u=e===a.length-1,d=en(s,l,t,u,r,i);if(!d.ok||d.data===null)return o(d.summary,d.warnings);if(u)return n(`Body value assigned`,null);s=d.data}return o(`${t} is not a valid body option path.`)}function en(e,t,r,i,a,s){let c=()=>o(`${r} 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 r=l??[];if(l===void 0&&(e[t.key]=r),i)return r[s]===void 0?(r[s]=a,n(`Body value assigned`,e)):c();let o=r[s];if(o===void 0){let e={};return r[s]=e,n(`Body path created`,e)}return I(o)?n(`Body path stepped`,o):c()}if(i)return l===void 0?(e[t.key]=a,n(`Body value assigned`,e)):c();if(l===void 0){let r={};return e[t.key]=r,n(`Body path created`,r)}return I(l)?n(`Body path stepped`,l):c()}function tn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function nn(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 rn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=rn(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(!an(a,n)){if(!on(e))continue;return{path:a,suggestion:sn(e,n)}}let o=rn(i,e,n);if(o!==null)return o}return null}function an(e,t){return t.prefix.has(e)||t.leaf.has(e)}function on(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function sn(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:cn(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 cn(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 ln(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(Ke(e))}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?_n(r,i):r===void 0?i===void 0?0:1:-1})}function un(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 dn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:hn(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 pn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function mn(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 hn(e,t){let n=Ye(t.description,void 0),r=e.kind!==`multipart`&&F(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}.`:``}${gn(e,t)}`}function gn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=zt(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 _n(e,t){return qe(e)-qe(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function vn(e){let t;try{t=e===`-`?await yn():await Dt(e,`utf8`)}catch(t){return o(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return n(`No input provided`,null);let e=JSON.parse(t);return n(`Input parsed`,e)}catch(e){return o(`Input is not valid JSON: ${e.message}`)}}async function yn(){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 bn=`--content-type`;function xn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(bn)){let t=i.map(({contentType:e})=>e);e.addOption(new v(`${bn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Cn(i)))}if(Hn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new v(`--from-file <path>`,mn(n,n.requiredPath)).argParser(Tn(`--from-file`)))}let a=un(i).filter(e=>r(L(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>_n(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new v(dn(t),i.length>1?fn(t):hn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?pn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Sn):F(r.name)||r.schemaType===`array`?a.argParser(wn):a.argParser(Tn(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`)})}Vn(e,t,a)}function Sn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Cn(e){return(t,n)=>{if(n!==void 0)throw new ae(`${bn} was already given; pass it once.`);let r=a(e,t);if(!r.ok)throw new ae(r.summary);return t}}function wn(e,t){return[...t??[],e]}function Tn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new ae(`${t} was already given; pass it once.`);return e}}async function En(e,t){let r=typeof t.contentType==`string`?t.contentType:void 0,i=a(e.requestBody??[],r);if(!i.ok||i.data===null)return o(i.summary,i.warnings);let s=i.data;if(s===void 0)return n(`No body`,void 0);let c=Dn(e,s,t);if(c!==null)return o(c);let l=Pt(e.operationId,s,t);if(!l.ok)return o(l.summary,l.warnings);t=l.data;let u=On(s,t);if(u!==null)return o(u);let d=await Mn(t);if(!d.ok)return o(d.summary,d.warnings);let f=Xt(e.requestBody??[],s,d.data);if(f!==null)return o(f);let p=jn(e.operationId,s,d.data);if(!p.ok)return p;let m=Ft(e.operationId,s,d.data);if(m!==null)return o(m);let h=Nn(e.operationId,s,t);if(!h.ok)return h;if(d.data===void 0&&h.data===void 0)return s.required?o(Bn(e.operationId,s)):n(`No body`,void 0);let g=Fn(e.operationId,d.data,h.data);if(!g.ok||g.data===void 0)return g;if(s.schemaType===`array`&&!Array.isArray(g.data))return o(`${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 o(`${e.operationId} requires a JSON object${t}.`)}let _=An(s,g.data);if(_.length>0)return o(`${e.operationId} requires body option(s): ${_.join(`, `)}`);let v=g.data,y=I(v)?It(s).filter(e=>!Yt(v,e)):[];return y.length>0?o(kn(e.operationId,s,y)):g}function Dn(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 ${bn} ${i.join(` or `)}.`}return null}function On(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 kn(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 An(e,t){return I(t)?e.parameter.filter(e=>e.required&&!Yt(t,e.name)).map(L):[]}function jn(e,t,r){let i=Qt(t,r);if(i===null)return n(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return o(`${e} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Mn(e){let r=typeof e.fromFile==`string`?e.fromFile:void 0;if(r===void 0)return n(`No body file`,void 0);let i=await vn(r);if(!i.ok)return o(i.summary,i.warnings);let a=t.safeParse(i.data);return a.success?n(`Input parsed`,a.data):o(`Input is not valid JSON value: ${a.error.message}`)}function Nn(e,t,r){let i={},a=!1;for(let e of t.parameter){let n=Vt(e,r[e.optionKey]);if(!n.ok||n.data===null)return o(n.summary,n.warnings);let s=n.data;if(s===void 0)continue;let c=Pn(t,r,i,e,s);if(!c.ok)return o(c.summary,c.warnings);a=!0}if(!a)return n(`No direct body options`,void 0);let s=Gt(e,t,r,i);return s===null?n(`Direct body options parsed`,i):s}function Pn(e,t,r,i,a){let s=Ut(i,a);if(s===null){let e=Rn(i,a);return e.ok?Lt(r,i.name,e.data,i.schemaType===`array`):o(e.summary,e.warnings)}if(s.plain.length>0)return o(`${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=Wt(e,t,s.container);for(let e of s.rows.keys())if(!(e<c))return o(`${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 n=[];for(let e of t){let t=zn(i.name,i.itemSchemaType,e);if(!t.ok)return o(t.summary,t.warnings);n.push(t.data)}let a=Rt(r,i.name,e,n);if(!a.ok)return a}return n(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function Fn(e,t,r){if(t===void 0)return n(`Direct body parsed`,r);if(r===void 0)return n(`Input parsed`,t);if(I(t)&&I(r))try{return n(`Input parsed`,In(t,r))}catch(t){return o(`${e} ${t.message}`)}return o(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function In(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&&Ln(t)!==Ln(r))throw Error(`cannot combine --from-file ${Ln(t)} '${e}' with ${Ln(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=I(t)&&I(r)?In(t,r):r}return n}function Ln(e){return Array.isArray(e)?`array`:I(e)?`object`:`scalar`}function Rn(e,t){if(typeof t==`boolean`)return n(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return zn(e.name,e.schemaType,t??``);let r=[],i=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let n of t){let t=zn(e.name,i,n);if(!t.ok)return t;r.push(t.data)}return n(`Body value parsed`,r)}function zn(e,t,r){if(t===`boolean`)return r===`true`?n(`Body value parsed`,!0):r===`false`?n(`Body value parsed`,!1):o(`${e} must be true or false.`);if(t===`number`||t===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?o(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(a)?o(`${e} must be an integer.`):n(`Body value parsed`,a)}return n(`Body value parsed`,r)}function Bn(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=It(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 Vn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:bn,location:`body`}),Hn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),ln(e.options,r)}function Hn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Un(e){let t=le(e);return Qn(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Wn(e){Qn(e);let t=at(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
1
+ import{C as e,Di as t,Ei as n,S as r,Si as i,T as a,Ti as o,_ as s,a as c,aa as l,b as u,bi as d,c as f,d as p,f as m,fi as h,gi as g,i as _,ia as v,ii as y,l as b,m as x,mi as S,n as ee,o as te,oi as ne,r as re,ra as ie,sa as ae,u as oe,v as se,vi as ce,wi as le,xi as ue,yi as de}from"./client-Bm0yIt0Y.js";import{M as fe,O as pe,i as C,o as me,v as he,w,y as T}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,M as E,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-Bng7aPLe.js";import{_ as Ve,a as He,c as Ue,d as We,f as Ge,g as Ke,h as qe,l as Je,m as Ye,n as Xe,o as D,p as Ze,r as O,s as Qe,t as k,u as $e}from"./openapi-commands-DvGIzIbd.js";import{a as et}from"./text-field-CoZsgTRF.js";import{a as tt,n as nt,o as rt,r as it,t as at}from"./text-response-jSQIxoFJ.js";import{n as ot,r as st,t as ct}from"./oauth-login-W0wIP9n1.js";import{spawnSync as lt}from"node:child_process";import{basename as ut,dirname as A,resolve as j,sep as M}from"node:path";import{copyFileSync as dt,existsSync as ft,lstatSync as pt,mkdirSync as mt,mkdtempSync as ht,readFileSync as gt,readlinkSync as _t,realpathSync as vt,renameSync as yt,rmdirSync as bt,unlinkSync as xt,writeFileSync as St}from"node:fs";import N,{stderr as P,stdin as Ct}from"node:process";import{TextDecoder as wt,inspect as Tt}from"node:util";import{fileURLToPath as Et}from"node:url";import{readFile as Dt}from"node:fs/promises";import{webcrypto as Ot}from"node:crypto";import{homedir as kt,hostname as At,platform as jt}from"node:os";import{setTimeout as Mt}from"node:timers/promises";import{createInterface as Nt}from"node:readline/promises";function Pt(e,t,r){let i={...r};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let r=process.env[t]?.trim();if(r===void 0||r.length===0)continue;let a=i[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==r))return{...o(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${r}.`),data:i};a===void 0&&(i[n.optionKey]=r)}return n(`Environment-bound options applied`,i)}function Ft(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||!Yt(n,r.name))continue;let a=Jt(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 It(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 Lt(e,t,r,i=!1){if(i||!F(t)||!Array.isArray(r))return $t(e,t,r);for(let[n,i]of r.entries()){let r=$t(e,t,i,n);if(!r.ok)return r}return n(`Body value assigned`,null)}function Rt(e,t,n,r){return $t(e,t,r,n)}function zt(e){let t=[];for(let n of e.split(`.`)){let e=tn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Bt(e,t){let n=zt(t);if(n===null)return null;let r=qt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Kt(r)}:null}function Vt(e,t){if(F(e.name)||e.schemaType===`array`)return n(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return n(`Scalar body option selected`,t);let r=e.flag.split(` `)[0]??e.name;return t.length===1?n(`Scalar body option selected`,t[0]):o(`${r} was already given; pass it once.`)}var Ht=/^(?<row>\d+):(?<item>.*)$/su;function Ut(e,t){let n=zt(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=Ht.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 Wt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&zt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Gt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Bt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return o(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Ut(i,t)!==null)continue;let s=i.flag.split(` `)[0]??i.name;return o(`${s} 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 Kt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function qt(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function Jt(e,t){if(!F(t))return qt(e,t.split(`.`))}function Yt(e,t){return Zt(e,t.split(`.`))}function Xt(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)&&Yt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function Zt(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=tn(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=>Zt(e,r)):Zt(a,r)}function F(e){return e.split(`.`).some(e=>tn(e).isArray)}function Qt(e,t){return e.parameter.length===0||!I(t)?null:rn(t,[],nn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $t(e,t,r,i=0){let a=t.split(`.`),s=e;for(let[e,c]of a.entries()){let l=tn(c),u=e===a.length-1,d=en(s,l,t,u,r,i);if(!d.ok||d.data===null)return o(d.summary,d.warnings);if(u)return n(`Body value assigned`,null);s=d.data}return o(`${t} is not a valid body option path.`)}function en(e,t,r,i,a,s){let c=()=>o(`${r} 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 r=l??[];if(l===void 0&&(e[t.key]=r),i)return r[s]===void 0?(r[s]=a,n(`Body value assigned`,e)):c();let o=r[s];if(o===void 0){let e={};return r[s]=e,n(`Body path created`,e)}return I(o)?n(`Body path stepped`,o):c()}if(i)return l===void 0?(e[t.key]=a,n(`Body value assigned`,e)):c();if(l===void 0){let r={};return e[t.key]=r,n(`Body path created`,r)}return I(l)?n(`Body path stepped`,l):c()}function tn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function nn(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 rn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=rn(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(!an(a,n)){if(!on(e))continue;return{path:a,suggestion:sn(e,n)}}let o=rn(i,e,n);if(o!==null)return o}return null}function an(e,t){return t.prefix.has(e)||t.leaf.has(e)}function on(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function sn(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:cn(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 cn(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 ln(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(Ke(e))}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?_n(r,i):r===void 0?i===void 0?0:1:-1})}function un(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 dn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:hn(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 pn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function mn(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 hn(e,t){let n=Ye(t.description,void 0),r=e.kind!==`multipart`&&F(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}.`:``}${gn(e,t)}`}function gn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=zt(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 _n(e,t){return qe(e)-qe(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function vn(e){let t;try{t=e===`-`?await yn():await Dt(e,`utf8`)}catch(t){return o(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return n(`No input provided`,null);let e=JSON.parse(t);return n(`Input parsed`,e)}catch(e){return o(`Input is not valid JSON: ${e.message}`)}}async function yn(){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 bn=`--content-type`;function xn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(bn)){let t=i.map(({contentType:e})=>e);e.addOption(new v(`${bn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Cn(i)))}if(Hn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new v(`--from-file <path>`,mn(n,n.requiredPath)).argParser(Tn(`--from-file`)))}let a=un(i).filter(e=>r(L(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>_n(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new v(dn(t),i.length>1?fn(t):hn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?pn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Sn):F(r.name)||r.schemaType===`array`?a.argParser(wn):a.argParser(Tn(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`)})}Vn(e,t,a)}function Sn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Cn(e){return(t,n)=>{if(n!==void 0)throw new ae(`${bn} was already given; pass it once.`);let r=a(e,t);if(!r.ok)throw new ae(r.summary);return t}}function wn(e,t){return[...t??[],e]}function Tn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new ae(`${t} was already given; pass it once.`);return e}}async function En(e,t){let r=typeof t.contentType==`string`?t.contentType:void 0,i=a(e.requestBody??[],r);if(!i.ok||i.data===null)return o(i.summary,i.warnings);let s=i.data;if(s===void 0)return n(`No body`,void 0);let c=Dn(e,s,t);if(c!==null)return o(c);let l=Pt(e.operationId,s,t);if(!l.ok)return o(l.summary,l.warnings);t=l.data;let u=On(s,t);if(u!==null)return o(u);let d=await Mn(t);if(!d.ok)return o(d.summary,d.warnings);let f=Xt(e.requestBody??[],s,d.data);if(f!==null)return o(f);let p=jn(e.operationId,s,d.data);if(!p.ok)return p;let m=Ft(e.operationId,s,d.data);if(m!==null)return o(m);let h=Nn(e.operationId,s,t);if(!h.ok)return h;if(d.data===void 0&&h.data===void 0)return s.required?o(Bn(e.operationId,s)):n(`No body`,void 0);let g=Fn(e.operationId,d.data,h.data);if(!g.ok||g.data===void 0)return g;if(s.schemaType===`array`&&!Array.isArray(g.data))return o(`${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 o(`${e.operationId} requires a JSON object${t}.`)}let _=An(s,g.data);if(_.length>0)return o(`${e.operationId} requires body option(s): ${_.join(`, `)}`);let v=g.data,y=I(v)?It(s).filter(e=>!Yt(v,e)):[];return y.length>0?o(kn(e.operationId,s,y)):g}function Dn(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 ${bn} ${i.join(` or `)}.`}return null}function On(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 kn(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 An(e,t){return I(t)?e.parameter.filter(e=>e.required&&!Yt(t,e.name)).map(L):[]}function jn(e,t,r){let i=Qt(t,r);if(i===null)return n(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return o(`${e} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Mn(e){let r=typeof e.fromFile==`string`?e.fromFile:void 0;if(r===void 0)return n(`No body file`,void 0);let i=await vn(r);if(!i.ok)return o(i.summary,i.warnings);let a=t.safeParse(i.data);return a.success?n(`Input parsed`,a.data):o(`Input is not valid JSON value: ${a.error.message}`)}function Nn(e,t,r){let i={},a=!1;for(let e of t.parameter){let n=Vt(e,r[e.optionKey]);if(!n.ok||n.data===null)return o(n.summary,n.warnings);let s=n.data;if(s===void 0)continue;let c=Pn(t,r,i,e,s);if(!c.ok)return o(c.summary,c.warnings);a=!0}if(!a)return n(`No direct body options`,void 0);let s=Gt(e,t,r,i);return s===null?n(`Direct body options parsed`,i):s}function Pn(e,t,r,i,a){let s=Ut(i,a);if(s===null){let e=Rn(i,a);return e.ok?Lt(r,i.name,e.data,i.schemaType===`array`):o(e.summary,e.warnings)}if(s.plain.length>0)return o(`${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=Wt(e,t,s.container);for(let e of s.rows.keys())if(!(e<c))return o(`${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 n=[];for(let e of t){let t=zn(i.name,i.itemSchemaType,e);if(!t.ok)return o(t.summary,t.warnings);n.push(t.data)}let a=Rt(r,i.name,e,n);if(!a.ok)return a}return n(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function Fn(e,t,r){if(t===void 0)return n(`Direct body parsed`,r);if(r===void 0)return n(`Input parsed`,t);if(I(t)&&I(r))try{return n(`Input parsed`,In(t,r))}catch(t){return o(`${e} ${t.message}`)}return o(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function In(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&&Ln(t)!==Ln(r))throw Error(`cannot combine --from-file ${Ln(t)} '${e}' with ${Ln(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=I(t)&&I(r)?In(t,r):r}return n}function Ln(e){return Array.isArray(e)?`array`:I(e)?`object`:`scalar`}function Rn(e,t){if(typeof t==`boolean`)return n(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return zn(e.name,e.schemaType,t??``);let r=[],i=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let n of t){let t=zn(e.name,i,n);if(!t.ok)return t;r.push(t.data)}return n(`Body value parsed`,r)}function zn(e,t,r){if(t===`boolean`)return r===`true`?n(`Body value parsed`,!0):r===`false`?n(`Body value parsed`,!1):o(`${e} must be true or false.`);if(t===`number`||t===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?o(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(a)?o(`${e} must be an integer.`):n(`Body value parsed`,a)}return n(`Body value parsed`,r)}function Bn(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=It(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 Vn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:bn,location:`body`}),Hn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),ln(e.options,r)}function Hn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Un(e){let t=le(e);return Qn(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Wn(e){Qn(e);let t=at(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
2
2
  `)?t:`${t}\n`),Gn(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&Jn(e.problem),Gn(e)}function Gn(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`?le(t):t;Qn(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?Kn(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Un(t):t;e.mode===`text`&&Wn(n),n.ok||(process.exitCode=1)}function Kn(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 qn(e,t){let n=nt(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 Jn(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`),Yn(e),Xn(`unknownParameters`,e.unknownParameters),Xn(`validParameters`,e.validParameters),Zn(e.resolution)}function Yn(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 Xn(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function Zn(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 Qn(e){e.ok&&e.warnings.length===0||ne({component:S().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 $n(e,t,r=S().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 o(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let a=it(e.q??``,nr(t,r).filter(t=>or(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]),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)]})).map(({item:e})=>e),s=a.slice(0,i);return n(`Operation catalog matches`,{operation:s,count:{totalOperations:t.length,matched:a.length,returned:s.length}})}function er(e,t,r=S().bin[0]){let i=nr(t,r),a=e.operationId===void 0?tr(i,e.command):i.find(t=>t.operationId===e.operationId);if(a===void 0){let n=yr(e.command??``),a=i.map(e=>e.cli.command).filter(e=>e.startsWith(`${r} ${n} `));if(a.length>0)return o(`${n} is a command group; show one of its subcommands.`,[`Run \`${r} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let s=n.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=$n({q:e.command??e.operationId},t,r),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 o(`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 \`${r} command-catalog search "<text>"\`.`])}return n(`Generated operation detail`,{operation:a,usage:cr(a,i)})}function tr(e,t){if(t===void 0)return;let{bin:n}=S(),r=yr(t,n);return e.find(e=>yr(e.cli.command,n)===r)}function nr(t,n){return t.map(t=>{let i=t.requestBody??[],a=[...t.parameters.map(e=>rr(e)),...i.flatMap(e=>e.parameter.map(t=>rr(t,i.length>1?e.contentType:void 0))),...ir(i)],o=[n,...t.cliPath].join(` `),s=r(t.intent),c=t.method===`DELETE`||t.intent===`delete`,l=i[0];return{operationId:t.operationId,method:t.method,path:t.path,resource:t.resource,intent:t.intent,scope:t.scope,mutates:s,destructive:c,auth:t.auth,cli:{command:o,path:t.cliPath},mcpTool:t.binaryResponse?null:e(t.intent),body:{hasBody:l!==void 0,kind:l?.kind??null,...l!==void 0&&i.length>1?{contentType:l.contentType}:{},required:l?.required??!1,description:l?.description??``,requiredPath:l?.requiredPath??[]},flags:a,errorResponse:t.errorResponse,summary:t.summary,description:t.description,deprecated:t.deprecated}})}function rr(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 ir(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 ar(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function or(e,t){return!(t.root!==void 0&&!sr(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 sr(e,t){let n=rt(t);return n.length===0||rt(e.cli.path.at(0)??``)===n}function cr(e,t){let n=ar(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 (binary CLI 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`),...mr(e,t),...lr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
4
4
  `)}function lr(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var ur=[`-id`,`-slug`,`-url`],dr=[`--id`,`--slug`,`--url`],fr=`--from-file "<path>"`;function pr(e,t,n=S().bin[0]){let r=nr(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:mr(i,r)}function mr(e,t){return[`example: ${[e.cli.command,...gr(e),`--data`].join(` `)}`,...hr(e,t)]}function hr(e,t){return ar(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} ${vr(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===r.path.replace(/-exact$/u,``)),s=o?.flags.find(e=>e.optionKey===`name`),c=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0?[c]:[c,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${vr(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}function gr(e){let t=ar(e).filter(e=>e.required),n=(t.length>0?t:_r(e)).map(vr);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,fr]:n}function _r(e){let t=new Set;tt(t,e.resource);for(let n of ur)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 dr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function vr(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 yr(e,t=S().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var br=`dist/aventure-cli/command-catalog.compact.txt`,xr=` · `,Sr=`-`;function Cr(e=S().bin[0]){return j(wr(A(Et(import.meta.url)),e),br)}function wr(e,t){let n=e;for(;;){if(ft(j(n,`package.json`)))return n;let r=A(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Tr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Er(e,t,n,r=S().bin[0]){let i=$n(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Or({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Ar(i.data,kr(e.format,`lines`)),summary:`Generated operation matches`})}function Dr(e,t,n,r=S().bin[0]){let i=er(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Or({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:jr(i.data,kr(e.format,`usage`)),summary:`Generated operation detail`})}function Or(e){let t=e.mode,r=kr(e.opts.format,e.defaultFormat),i=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&i&&(r===`json`||r===`ndjson`)){R({mode:t},o(`--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 a=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.returned===0&&(i||e.opts.format===void 0||r===`text`)?`No generated operations matched.`:e.rendered,s=a.endsWith(`