@aventurevc/aventure-cli 0.8.39 → 0.8.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/{aventure-cli-FEfgaevT.js → aventure-cli-BN7ZJVX1.js} +2 -2
- package/dist/chunks/{client-C81tj09w.js → client-B1JSksJR.js} +2 -2
- package/dist/chunks/{oauth-bearer-credential-C7MR0XqP.js → oauth-bearer-credential-CHAMnYqz.js} +2 -2
- package/dist/chunks/oauth-login-Cij68ZYT.js +1 -0
- package/dist/chunks/{oauth-login-C2S9y-yJ.js → oauth-login-CxxgtGt0.js} +1 -1
- package/dist/chunks/{openapi-commands-QmFLnBLM.js → openapi-commands-CO_7ezV2.js} +1 -1
- package/dist/chunks/provider-catalog-CDnbYtWd.js +1 -0
- package/dist/chunks/{text-response-CbuKPWXK.js → text-response-BG8Ycpdu.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/oauth-login-CT8gGUAw.js +0 -1
- package/dist/chunks/provider-catalog-BuHinSw3.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{fi as e,ia as t,ii as n,oi as r,pi as i}from"../chunks/client-
|
|
2
|
+
import{fi as e,ia as t,ii as n,oi as r,pi as i}from"../chunks/client-B1JSksJR.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-CHAMnYqz.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-CO_7ezV2.js";import{r as u}from"../chunks/text-field-7YbE3Zwj.js";var d=process.argv.slice(2);c(d)&&r(!1),d.includes(`--all-fields`)&&u(!0);try{if(i(),s(d,l)===`optional`)try{await a(),await o()}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-BN7ZJVX1.js`)}catch(e){if(!(e instanceof t))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"generatedFrom": "MCP_GENERATION_CONTRACT",
|
|
4
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"generatedAt": "2026-10-03T21:01:48.976Z",
|
|
5
5
|
"totalOperations": 131,
|
|
6
6
|
"note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
|
|
7
7
|
"operations": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,Ci as t,S as n,Si as r,Ti as i,_ as a,_i as o,a as s,aa as c,bi as l,c as u,d,f,fi as p,g as m,gi as h,i as g,ii as _,l as v,mi as y,n as ee,na as b,ni as te,o as ne,p as re,r as ie,ra as ae,ta as oe,u as se,ui as ce,vi as le,wi as x,x as ue,y as de,yi as fe}from"./client-C81tj09w.js";import{M as pe,O as me,i as S,o as he,v as ge,w as C,y as w}from"./person-owner-BJgNYLKX.js";import{A as _e,C as ve,D as ye,M as T,N as be,O as xe,S as Se,T as Ce,a as we,b as Te,c as Ee,d as De,g as Oe,j as ke,k as Ae,l as je,m as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve}from"./oauth-bearer-credential-C7MR0XqP.js";import{_ as He,a as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,l as Ye,m as Xe,n as Ze,o as E,p as Qe,r as D,s as $e,t as O,u as et}from"./openapi-commands-QmFLnBLM.js";import{a as tt}from"./text-field-7YbE3Zwj.js";import{a as nt,n as rt,o as it,r as at,t as ot}from"./text-response-CbuKPWXK.js";import{n as st,r as ct,t as lt}from"./oauth-login-C2S9y-yJ.js";import{spawnSync as ut}from"node:child_process";import{basename as dt,dirname as k,resolve as A,sep as ft}from"node:path";import{copyFileSync as pt,existsSync as mt,lstatSync as ht,mkdirSync as gt,mkdtempSync as _t,readFileSync as vt,readlinkSync as yt,realpathSync as bt,renameSync as xt,rmdirSync as St,unlinkSync as Ct,writeFileSync as wt}from"node:fs";import j,{stderr as M,stdin as Tt}from"node:process";import{TextDecoder as Et,inspect as Dt}from"node:util";import{fileURLToPath as Ot}from"node:url";import{readFile as kt}from"node:fs/promises";import{webcrypto as At}from"node:crypto";import{homedir as jt,hostname as Mt,platform as Nt}from"node:os";import{setTimeout as Pt}from"node:timers/promises";import{createInterface as Ft}from"node:readline/promises";function It(e,n,r){let i={...r};for(let r of n.parameter){let n=r.envName;if(n===void 0)continue;let a=process.env[n]?.trim();if(a===void 0||a.length===0)continue;let o=i[r.optionKey];if(o!==void 0&&(typeof o!=`string`||o!==a))return{...t(`${e} ${r.flag.split(` `)[0]??r.name} conflicts with ${n}; omit the flag or use ${a}.`),data:i};o===void 0&&(i[r.optionKey]=a)}return x(`Environment-bound options applied`,i)}function Lt(e,t,n){if(!P(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||!Zt(n,r.name))continue;let a=Xt(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 Rt(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 zt(e,t,n,r=!1){if(r||!N(t)||!Array.isArray(n))return tn(e,t,n);for(let[r,i]of n.entries()){let n=tn(e,t,i,r);if(!n.ok)return n}return x(`Body value assigned`,null)}function Bt(e,t,n,r){return tn(e,t,r,n)}function Vt(e){let t=[];for(let n of e.split(`.`)){let e=rn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Ht(e,t){let n=Vt(t);if(n===null)return null;let r=Yt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Jt(r)}:null}function Ut(e,n){if(N(e.name)||e.schemaType===`array`)return x(`Repeated body option selected`,typeof n==`string`?[n]:n);if(!Array.isArray(n))return x(`Scalar body option selected`,n);let r=e.flag.split(` `)[0]??e.name;return n.length===1?x(`Scalar body option selected`,n[0]):t(`${r} was already given; pass it once.`)}var Wt=/^(?<row>\d+):(?<item>.*)$/su;function Gt(e,t){let n=Vt(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=Wt.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 Kt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Vt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function qt(e,n,r,i){for(let a of n.parameter){let n=r[a.optionKey];if(n===void 0)continue;let o=Ht(i,a.name);if(o===null)continue;if(o.firstHole!==null)return t(`${e} has no ${o.path}[] row ${o.firstHole} — number ${o.path}[] rows from 0 with no gaps.`);if(a.schemaType!==`array`||o.rowCount<=1||Gt(a,n)!==null)continue;let s=a.flag.split(` `)[0]??a.name;return t(`${s} fills one ${o.path}[] row's list, so ${e} cannot also build ${o.rowCount} ${o.path}[] rows from direct options — prefix each value with its 0-based ${o.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function Jt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Yt(e,t){let n=e;for(let e of t){if(!P(n))return;n=n[e]??null}return n}function Xt(e,t){if(!N(t))return Yt(e,t.split(`.`))}function Zt(e,t){return $t(e,t.split(`.`))}function Qt(e,t,n){if(!P(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)&&Zt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function $t(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=rn(n);if(!P(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>$t(e,r)):$t(a,r)}function N(e){return e.split(`.`).some(e=>rn(e).isArray)}function en(e,t){return e.parameter.length===0||!P(t)?null:on(t,[],an(e.parameter))}function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tn(e,n,r,i=0){let a=n.split(`.`),o=e;for(let[e,s]of a.entries()){let c=rn(s),l=e===a.length-1,u=nn(o,c,n,l,r,i);if(!u.ok||u.data===null)return t(u.summary,u.warnings);if(l)return x(`Body value assigned`,null);o=u.data}return t(`${n} is not a valid body option path.`)}function nn(e,n,r,i,a,o){let s=()=>t(`${r} cannot be combined with another body option at ${n.key}.`),c=e[n.key];if(n.isArray){if(c!==void 0&&!Array.isArray(c))return s();let t=c??[];if(c===void 0&&(e[n.key]=t),i)return t[o]===void 0?(t[o]=a,x(`Body value assigned`,e)):s();let r=t[o];if(r===void 0){let e={};return t[o]=e,x(`Body path created`,e)}return P(r)?x(`Body path stepped`,r):s()}if(i)return c===void 0?(e[n.key]=a,x(`Body value assigned`,e)):s();if(c===void 0){let t={};return e[n.key]=t,x(`Body path created`,t)}return P(c)?x(`Body path stepped`,c):s()}function rn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function an(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 on(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=on(r,t,n);if(e!==null)return e}return null}if(!P(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!sn(a,n)){if(!cn(e))continue;return{path:a,suggestion:ln(e,n)}}let o=on(i,e,n);if(o!==null)return o}return null}function sn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function cn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function ln(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:un(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 un(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 dn(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(qe(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?yn(r,i):r===void 0?i===void 0?0:1:-1})}function fn(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 pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function mn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:_n(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 hn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function gn(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 _n(e,t){let n=Xe(t.description,void 0),r=e.kind!==`multipart`&&N(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}.`:``}${vn(e,t)}`}function vn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Vt(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 yn(e,t){return Je(e)-Je(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function bn(e){let n;try{n=e===`-`?await xn():await kt(e,`utf8`)}catch(n){return t(`Could not read input: ${n.message}`,[`path=${e}`])}try{if(n.trim().length===0)return x(`No input provided`,null);let e=JSON.parse(n);return x(`Input parsed`,e)}catch(e){return t(`Input is not valid JSON: ${e.message}`)}}async function xn(){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 Sn=`--content-type`;function Cn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(Sn)){let t=i.map(({contentType:e})=>e);e.addOption(new b(`${Sn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Tn(i)))}if(Wn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new b(`--from-file <path>`,gn(n,n.requiredPath)).argParser(Dn(`--from-file`)))}let a=fn(i).filter(e=>r(F(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>yn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new b(pn(t),i.length>1?mn(t):_n(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?hn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(wn):N(r.name)||r.schemaType===`array`?a.argParser(En):a.argParser(Dn(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`)})}Un(e,t,a)}function wn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Tn(t){return(n,r)=>{if(r!==void 0)throw new c(`${Sn} was already given; pass it once.`);let i=e(t,n);if(!i.ok)throw new c(i.summary);return n}}function En(e,t){return[...t??[],e]}function Dn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new c(`${t} was already given; pass it once.`);return e}}async function On(n,r){let i=typeof r.contentType==`string`?r.contentType:void 0,a=e(n.requestBody??[],i);if(!a.ok||a.data===null)return t(a.summary,a.warnings);let o=a.data;if(o===void 0)return x(`No body`,void 0);let s=kn(n,o,r);if(s!==null)return t(s);let c=It(n.operationId,o,r);if(!c.ok)return t(c.summary,c.warnings);r=c.data;let l=An(o,r);if(l!==null)return t(l);let u=await Pn(r);if(!u.ok)return t(u.summary,u.warnings);let d=Qt(n.requestBody??[],o,u.data);if(d!==null)return t(d);let f=Nn(n.operationId,o,u.data);if(!f.ok)return f;let p=Lt(n.operationId,o,u.data);if(p!==null)return t(p);let m=Fn(n.operationId,o,r);if(!m.ok)return m;if(u.data===void 0&&m.data===void 0)return o.required?t(Hn(n.operationId,o)):x(`No body`,void 0);let h=Ln(n.operationId,u.data,m.data);if(!h.ok||h.data===void 0)return h;if(o.schemaType===`array`&&!Array.isArray(h.data))return t(`${n.operationId} requires a JSON array body.`);if(o.parameter.length>0&&!P(h.data)){let e=o.kind===`multipart`?` keyed by multipart part name`:` body`;return t(`${n.operationId} requires a JSON object${e}.`)}let g=Mn(o,h.data);if(g.length>0)return t(`${n.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,v=P(_)?Rt(o).filter(e=>!Zt(_,e)):[];return v.length>0?t(jn(n.operationId,o,v)):h}function kn(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`${F(t)} requires ${Sn} ${i.join(` or `)}.`}return null}function An(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 jn(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 Mn(e,t){return P(t)?e.parameter.filter(e=>e.required&&!Zt(t,e.name)).map(F):[]}function Nn(e,n,r){let i=en(n,r);if(i===null)return x(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return t(`${e} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Pn(e){let n=typeof e.fromFile==`string`?e.fromFile:void 0;if(n===void 0)return x(`No body file`,void 0);let r=await bn(n);if(!r.ok)return t(r.summary,r.warnings);let a=i.safeParse(r.data);return a.success?x(`Input parsed`,a.data):t(`Input is not valid JSON value: ${a.error.message}`)}function Fn(e,n,r){let i={},a=!1;for(let e of n.parameter){let o=Ut(e,r[e.optionKey]);if(!o.ok||o.data===null)return t(o.summary,o.warnings);let s=o.data;if(s===void 0)continue;let c=In(n,r,i,e,s);if(!c.ok)return t(c.summary,c.warnings);a=!0}if(!a)return x(`No direct body options`,void 0);let o=qt(e,n,r,i);return o===null?x(`Direct body options parsed`,i):o}function In(e,n,r,i,a){let o=Gt(i,a);if(o===null){let e=Bn(i,a);return e.ok?zt(r,i.name,e.data,i.schemaType===`array`):t(e.summary,e.warnings)}if(o.plain.length>0)return t(`${F(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=Kt(e,n,o.container);for(let e of o.rows.keys())if(!(e<s))return t(`${F(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,n]of o.rows){let a=[];for(let e of n){let n=Vn(i.name,i.itemSchemaType,e);if(!n.ok)return t(n.summary,n.warnings);a.push(n.data)}let o=Bt(r,i.name,e,a);if(!o.ok)return o}return x(`Body value assigned`,null)}var F=e=>e.flag.split(` `)[0]??e.name;function Ln(e,n,r){if(n===void 0)return x(`Direct body parsed`,r);if(r===void 0)return x(`Input parsed`,n);if(P(n)&&P(r))try{return x(`Input parsed`,Rn(n,r))}catch(n){return t(`${e} ${n.message}`)}return t(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Rn(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&&zn(t)!==zn(r))throw Error(`cannot combine --from-file ${zn(t)} '${e}' with ${zn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=P(t)&&P(r)?Rn(t,r):r}return n}function zn(e){return Array.isArray(e)?`array`:P(e)?`object`:`scalar`}function Bn(e,t){if(typeof t==`boolean`)return x(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Vn(e.name,e.schemaType,t??``);let n=[],r=N(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Vn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return x(`Body value parsed`,n)}function Vn(e,n,r){if(n===`boolean`)return r===`true`?x(`Body value parsed`,!0):r===`false`?x(`Body value parsed`,!1):t(`${e} must be true or false.`);if(n===`number`||n===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?t(`${e} must be a finite ${n}.`):n===`integer`&&!Number.isInteger(a)?t(`${e} must be an integer.`):x(`Body value parsed`,a)}return x(`Body value parsed`,r)}function Hn(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(F).join(`, `)}`;let r=Rt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(F).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Un(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Sn,location:`body`}),Wn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),dn(e.options,r)}function Wn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Gn(e){let t=r(e);return er(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Kn(e){er(e);let t=ot(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
1
|
+
import{C as e,Ci as t,S as n,Si as r,Ti as i,_ as a,_i as o,a as s,aa as c,bi as l,c as u,d,f,fi as p,g as m,gi as h,i as g,ii as _,l as v,mi as y,n as ee,na as b,ni as te,o as ne,p as re,r as ie,ra as ae,ta as oe,u as se,ui as ce,vi as le,wi as x,x as ue,y as de,yi as fe}from"./client-B1JSksJR.js";import{M as pe,O as me,i as S,o as he,v as ge,w as C,y as w}from"./person-owner-BJgNYLKX.js";import{A as _e,C as ve,D as ye,M as T,N as be,O as xe,S as Se,T as Ce,a as we,b as Te,c as Ee,d as De,g as Oe,j as ke,k as Ae,l as je,m as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve}from"./oauth-bearer-credential-CHAMnYqz.js";import{_ as He,a as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,l as Ye,m as Xe,n as Ze,o as E,p as Qe,r as D,s as $e,t as O,u as et}from"./openapi-commands-CO_7ezV2.js";import{a as tt}from"./text-field-7YbE3Zwj.js";import{a as nt,n as rt,o as it,r as at,t as ot}from"./text-response-BG8Ycpdu.js";import{n as st,r as ct,t as lt}from"./oauth-login-CxxgtGt0.js";import{spawnSync as ut}from"node:child_process";import{basename as dt,dirname as k,resolve as A,sep as ft}from"node:path";import{copyFileSync as pt,existsSync as mt,lstatSync as ht,mkdirSync as gt,mkdtempSync as _t,readFileSync as vt,readlinkSync as yt,realpathSync as bt,renameSync as xt,rmdirSync as St,unlinkSync as Ct,writeFileSync as wt}from"node:fs";import j,{stderr as M,stdin as Tt}from"node:process";import{TextDecoder as Et,inspect as Dt}from"node:util";import{fileURLToPath as Ot}from"node:url";import{readFile as kt}from"node:fs/promises";import{webcrypto as At}from"node:crypto";import{homedir as jt,hostname as Mt,platform as Nt}from"node:os";import{setTimeout as Pt}from"node:timers/promises";import{createInterface as Ft}from"node:readline/promises";function It(e,n,r){let i={...r};for(let r of n.parameter){let n=r.envName;if(n===void 0)continue;let a=process.env[n]?.trim();if(a===void 0||a.length===0)continue;let o=i[r.optionKey];if(o!==void 0&&(typeof o!=`string`||o!==a))return{...t(`${e} ${r.flag.split(` `)[0]??r.name} conflicts with ${n}; omit the flag or use ${a}.`),data:i};o===void 0&&(i[r.optionKey]=a)}return x(`Environment-bound options applied`,i)}function Lt(e,t,n){if(!P(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||!Zt(n,r.name))continue;let a=Xt(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 Rt(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 zt(e,t,n,r=!1){if(r||!N(t)||!Array.isArray(n))return tn(e,t,n);for(let[r,i]of n.entries()){let n=tn(e,t,i,r);if(!n.ok)return n}return x(`Body value assigned`,null)}function Bt(e,t,n,r){return tn(e,t,r,n)}function Vt(e){let t=[];for(let n of e.split(`.`)){let e=rn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Ht(e,t){let n=Vt(t);if(n===null)return null;let r=Yt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Jt(r)}:null}function Ut(e,n){if(N(e.name)||e.schemaType===`array`)return x(`Repeated body option selected`,typeof n==`string`?[n]:n);if(!Array.isArray(n))return x(`Scalar body option selected`,n);let r=e.flag.split(` `)[0]??e.name;return n.length===1?x(`Scalar body option selected`,n[0]):t(`${r} was already given; pass it once.`)}var Wt=/^(?<row>\d+):(?<item>.*)$/su;function Gt(e,t){let n=Vt(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=Wt.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 Kt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Vt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function qt(e,n,r,i){for(let a of n.parameter){let n=r[a.optionKey];if(n===void 0)continue;let o=Ht(i,a.name);if(o===null)continue;if(o.firstHole!==null)return t(`${e} has no ${o.path}[] row ${o.firstHole} — number ${o.path}[] rows from 0 with no gaps.`);if(a.schemaType!==`array`||o.rowCount<=1||Gt(a,n)!==null)continue;let s=a.flag.split(` `)[0]??a.name;return t(`${s} fills one ${o.path}[] row's list, so ${e} cannot also build ${o.rowCount} ${o.path}[] rows from direct options — prefix each value with its 0-based ${o.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function Jt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Yt(e,t){let n=e;for(let e of t){if(!P(n))return;n=n[e]??null}return n}function Xt(e,t){if(!N(t))return Yt(e,t.split(`.`))}function Zt(e,t){return $t(e,t.split(`.`))}function Qt(e,t,n){if(!P(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)&&Zt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function $t(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=rn(n);if(!P(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>$t(e,r)):$t(a,r)}function N(e){return e.split(`.`).some(e=>rn(e).isArray)}function en(e,t){return e.parameter.length===0||!P(t)?null:on(t,[],an(e.parameter))}function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tn(e,n,r,i=0){let a=n.split(`.`),o=e;for(let[e,s]of a.entries()){let c=rn(s),l=e===a.length-1,u=nn(o,c,n,l,r,i);if(!u.ok||u.data===null)return t(u.summary,u.warnings);if(l)return x(`Body value assigned`,null);o=u.data}return t(`${n} is not a valid body option path.`)}function nn(e,n,r,i,a,o){let s=()=>t(`${r} cannot be combined with another body option at ${n.key}.`),c=e[n.key];if(n.isArray){if(c!==void 0&&!Array.isArray(c))return s();let t=c??[];if(c===void 0&&(e[n.key]=t),i)return t[o]===void 0?(t[o]=a,x(`Body value assigned`,e)):s();let r=t[o];if(r===void 0){let e={};return t[o]=e,x(`Body path created`,e)}return P(r)?x(`Body path stepped`,r):s()}if(i)return c===void 0?(e[n.key]=a,x(`Body value assigned`,e)):s();if(c===void 0){let t={};return e[n.key]=t,x(`Body path created`,t)}return P(c)?x(`Body path stepped`,c):s()}function rn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function an(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 on(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=on(r,t,n);if(e!==null)return e}return null}if(!P(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!sn(a,n)){if(!cn(e))continue;return{path:a,suggestion:ln(e,n)}}let o=on(i,e,n);if(o!==null)return o}return null}function sn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function cn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function ln(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:un(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 un(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 dn(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(qe(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?yn(r,i):r===void 0?i===void 0?0:1:-1})}function fn(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 pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function mn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:_n(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 hn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function gn(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 _n(e,t){let n=Xe(t.description,void 0),r=e.kind!==`multipart`&&N(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}.`:``}${vn(e,t)}`}function vn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Vt(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 yn(e,t){return Je(e)-Je(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function bn(e){let n;try{n=e===`-`?await xn():await kt(e,`utf8`)}catch(n){return t(`Could not read input: ${n.message}`,[`path=${e}`])}try{if(n.trim().length===0)return x(`No input provided`,null);let e=JSON.parse(n);return x(`Input parsed`,e)}catch(e){return t(`Input is not valid JSON: ${e.message}`)}}async function xn(){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 Sn=`--content-type`;function Cn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(Sn)){let t=i.map(({contentType:e})=>e);e.addOption(new b(`${Sn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(Tn(i)))}if(Wn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new b(`--from-file <path>`,gn(n,n.requiredPath)).argParser(Dn(`--from-file`)))}let a=fn(i).filter(e=>r(F(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>yn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new b(pn(t),i.length>1?mn(t):_n(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?hn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(wn):N(r.name)||r.schemaType===`array`?a.argParser(En):a.argParser(Dn(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`)})}Un(e,t,a)}function wn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Tn(t){return(n,r)=>{if(r!==void 0)throw new c(`${Sn} was already given; pass it once.`);let i=e(t,n);if(!i.ok)throw new c(i.summary);return n}}function En(e,t){return[...t??[],e]}function Dn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new c(`${t} was already given; pass it once.`);return e}}async function On(n,r){let i=typeof r.contentType==`string`?r.contentType:void 0,a=e(n.requestBody??[],i);if(!a.ok||a.data===null)return t(a.summary,a.warnings);let o=a.data;if(o===void 0)return x(`No body`,void 0);let s=kn(n,o,r);if(s!==null)return t(s);let c=It(n.operationId,o,r);if(!c.ok)return t(c.summary,c.warnings);r=c.data;let l=An(o,r);if(l!==null)return t(l);let u=await Pn(r);if(!u.ok)return t(u.summary,u.warnings);let d=Qt(n.requestBody??[],o,u.data);if(d!==null)return t(d);let f=Nn(n.operationId,o,u.data);if(!f.ok)return f;let p=Lt(n.operationId,o,u.data);if(p!==null)return t(p);let m=Fn(n.operationId,o,r);if(!m.ok)return m;if(u.data===void 0&&m.data===void 0)return o.required?t(Hn(n.operationId,o)):x(`No body`,void 0);let h=Ln(n.operationId,u.data,m.data);if(!h.ok||h.data===void 0)return h;if(o.schemaType===`array`&&!Array.isArray(h.data))return t(`${n.operationId} requires a JSON array body.`);if(o.parameter.length>0&&!P(h.data)){let e=o.kind===`multipart`?` keyed by multipart part name`:` body`;return t(`${n.operationId} requires a JSON object${e}.`)}let g=Mn(o,h.data);if(g.length>0)return t(`${n.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,v=P(_)?Rt(o).filter(e=>!Zt(_,e)):[];return v.length>0?t(jn(n.operationId,o,v)):h}function kn(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`${F(t)} requires ${Sn} ${i.join(` or `)}.`}return null}function An(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 jn(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 Mn(e,t){return P(t)?e.parameter.filter(e=>e.required&&!Zt(t,e.name)).map(F):[]}function Nn(e,n,r){let i=en(n,r);if(i===null)return x(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return t(`${e} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Pn(e){let n=typeof e.fromFile==`string`?e.fromFile:void 0;if(n===void 0)return x(`No body file`,void 0);let r=await bn(n);if(!r.ok)return t(r.summary,r.warnings);let a=i.safeParse(r.data);return a.success?x(`Input parsed`,a.data):t(`Input is not valid JSON value: ${a.error.message}`)}function Fn(e,n,r){let i={},a=!1;for(let e of n.parameter){let o=Ut(e,r[e.optionKey]);if(!o.ok||o.data===null)return t(o.summary,o.warnings);let s=o.data;if(s===void 0)continue;let c=In(n,r,i,e,s);if(!c.ok)return t(c.summary,c.warnings);a=!0}if(!a)return x(`No direct body options`,void 0);let o=qt(e,n,r,i);return o===null?x(`Direct body options parsed`,i):o}function In(e,n,r,i,a){let o=Gt(i,a);if(o===null){let e=Bn(i,a);return e.ok?zt(r,i.name,e.data,i.schemaType===`array`):t(e.summary,e.warnings)}if(o.plain.length>0)return t(`${F(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=Kt(e,n,o.container);for(let e of o.rows.keys())if(!(e<s))return t(`${F(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,n]of o.rows){let a=[];for(let e of n){let n=Vn(i.name,i.itemSchemaType,e);if(!n.ok)return t(n.summary,n.warnings);a.push(n.data)}let o=Bt(r,i.name,e,a);if(!o.ok)return o}return x(`Body value assigned`,null)}var F=e=>e.flag.split(` `)[0]??e.name;function Ln(e,n,r){if(n===void 0)return x(`Direct body parsed`,r);if(r===void 0)return x(`Input parsed`,n);if(P(n)&&P(r))try{return x(`Input parsed`,Rn(n,r))}catch(n){return t(`${e} ${n.message}`)}return t(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Rn(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&&zn(t)!==zn(r))throw Error(`cannot combine --from-file ${zn(t)} '${e}' with ${zn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=P(t)&&P(r)?Rn(t,r):r}return n}function zn(e){return Array.isArray(e)?`array`:P(e)?`object`:`scalar`}function Bn(e,t){if(typeof t==`boolean`)return x(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Vn(e.name,e.schemaType,t??``);let n=[],r=N(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Vn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return x(`Body value parsed`,n)}function Vn(e,n,r){if(n===`boolean`)return r===`true`?x(`Body value parsed`,!0):r===`false`?x(`Body value parsed`,!1):t(`${e} must be true or false.`);if(n===`number`||n===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?t(`${e} must be a finite ${n}.`):n===`integer`&&!Number.isInteger(a)?t(`${e} must be an integer.`):x(`Body value parsed`,a)}return x(`Body value parsed`,r)}function Hn(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(F).join(`, `)}`;let r=Rt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(F).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Un(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Sn,location:`body`}),Wn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),dn(e.options,r)}function Wn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Gn(e){let t=r(e);return er(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Kn(e){er(e);let t=ot(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
2
2
|
`)?t:`${t}\n`),qn(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&Xn(e.problem),qn(e)}function qn(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 I(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?r(t):t;er(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?Jn(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Gn(t):t;e.mode===`text`&&Kn(n),n.ok||(process.exitCode=1)}function Jn(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 Yn(e,t){let n=rt(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 Xn(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`),Zn(e),Qn(`unknownParameters`,e.unknownParameters),Qn(`validParameters`,e.validParameters),$n(e.resolution)}function Zn(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 Qn(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function $n(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 er(e){e.ok&&e.warnings.length===0||_({component:p().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 tr(e,n,r=p().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 t(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let a=at(e.q??``,ir(n,r).filter(t=>cr(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),o=a.slice(0,i);return x(`Operation catalog matches`,{operation:o,count:{totalOperations:n.length,matched:a.length,returned:o.length}})}function nr(e,n,r=p().bin[0]){let i=ir(n,r),a=e.operationId===void 0?rr(i,e.command):i.find(t=>t.operationId===e.operationId);if(a===void 0){let a=xr(e.command??``),o=i.map(e=>e.cli.command).filter(e=>e.startsWith(`${r} ${a} `));if(o.length>0)return t(`${a} is a command group; show one of its subcommands.`,[`Run \`${r} command-catalog show --command "<subcommand>"\` with one of:`,...o]);let s=a.split(` `),c=new Set([...[...s.keys()].map(e=>s.slice(e+1).join(` `)),...s.slice(1).map((e,t)=>s.toSpliced(t,2,`${s[t]}-${e}`).join(` `))]),l=tr({q:e.command??e.operationId},n,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 t(`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 x(`Generated operation detail`,{operation:a,usage:ur(a,i)})}function rr(e,t){if(t===void 0)return;let{bin:n}=p(),r=xr(t,n);return e.find(e=>xr(e.cli.command,n)===r)}function ir(e,t){return e.map(e=>{let r=e.requestBody??[],i=[...e.parameters.map(e=>ar(e)),...r.flatMap(e=>e.parameter.map(t=>ar(t,r.length>1?e.contentType:void 0))),...or(r)],a=[t,...e.cliPath].join(` `),o=ue(e.intent),s=e.method===`DELETE`||e.intent===`delete`,c=r[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:o,destructive:s,auth:e.auth,cli:{command:a,path:e.cliPath},mcpTool:e.binaryResponse?null:n(e.intent),body:{hasBody:c!==void 0,kind:c?.kind??null,...c!==void 0&&r.length>1?{contentType:c.contentType}:{},required:c?.required??!1,description:c?.description??``,requiredPath:c?.requiredPath??[]},flags:i,errorResponse:e.errorResponse,summary:e.summary,description:e.description,deprecated:e.deprecated}})}function ar(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 or(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 sr(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function cr(e,t){return!(t.root!==void 0&&!lr(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 lr(e,t){let n=it(t);return n.length===0||it(e.cli.path.at(0)??``)===n}function ur(e,t){let n=sr(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`,L(`required path flags`,r,`path`),L(`required query flags`,r,`query`),L(`required header flags`,r,`header`),L(`required body flags`,r,`body`),L(`optional path flags`,i,`path`),L(`optional query flags`,i,`query`),L(`optional header flags`,i,`header`),L(`optional body flags`,i,`body`),...gr(e,t),...dr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
4
4
|
`)}function dr(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var fr=[`-id`,`-slug`,`-url`],pr=[`--id`,`--slug`,`--url`],mr=`--from-file "<path>"`;function hr(e,t,n=p().bin[0]){let r=ir(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:gr(i,r)}function gr(e,t){return[`example: ${[e.cli.command,...vr(e),`--data`].join(` `)}`,..._r(e,t)]}function _r(e,t){return sr(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} ${br(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} ${br(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}function vr(e){let t=sr(e).filter(e=>e.required),n=(t.length>0?t:yr(e)).map(br);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,mr]:n}function yr(e){let t=new Set;nt(t,e.resource);for(let n of fr)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 pr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function br(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function L(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function xr(e,t=p().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var Sr=`dist/aventure-cli/command-catalog.compact.txt`,Cr=` · `,wr=`-`;function Tr(e=p().bin[0]){return A(Er(k(Ot(import.meta.url)),e),Sr)}function Er(e,t){let n=e;for(;;){if(mt(A(n,`package.json`)))return n;let r=k(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Dr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Or(e,t,n,r=p().bin[0]){let i=tr(e,t,r);if(!i.ok||i.data===null){I({mode:n},i);return}Ar({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Mr(i.data,jr(e.format,`lines`)),summary:`Generated operation matches`})}function kr(e,t,n,r=p().bin[0]){let i=nr(e,t,r);if(!i.ok||i.data===null){I({mode:n},i);return}Ar({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Nr(i.data,jr(e.format,`usage`)),summary:`Generated operation detail`})}function Ar(e){let n=e.mode,r=jr(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`)){I({mode:n},t(`--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&&n===`text`&&`count`in e.data&&e.data.count.returned===0&&(i||e.opts.format===void 0||r===`text`)?`No generated operations matched.`:e.rendered,o=a.endsWith(`
|
|
@@ -25,7 +25,7 @@ import{C as e,Ci as t,S as n,Si as r,Ti as i,_ as a,_i as o,a as s,aa as c,bi as
|
|
|
25
25
|
`).slice(-3).join(` | `);return t(`npm ${e.join(` `)} exited ${o.status}`,[n||`no stderr`])}return x(`npm ok`,o.stdout??``)}function to(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${ce}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function no(e,n,r){let i;try{let t=p(A(e,`lib`,`node_modules`,...n.split(`/`),`package.json`));i=A(e,`bin`,t.bin[0])}catch(e){return t(`updated ${n} verification failed: ${K(e)}`,[`invalid_package_metadata`])}let a=ut(process.execPath,[i,`--version`],{encoding:`utf8`});if(a.error)return t(`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(`
|
|
26
26
|
`).slice(-3).join(` | `);return t(`updated ${n} verification expected ${r} but active bin reported ${o||`empty output`}`,[e||`active bin: ${i}`])}return x(`active CLI version verified`,o)}function ro(e){let t=`${ft}lib${ft}node_modules${ft}${e.name.replace(`/`,ft)}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:{installPrefix:e.packageRoot.slice(0,n)}}function io(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}${ft}`))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=A(t.installPrefix,`bin`,n),i=ht(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=bt(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:yt(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=_t(A(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:A(r,dt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(xt(e.binPath,e.backupPath),a.push(e),yt(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=ao({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 ao(e,t){let n=[];for(let r of e.backup.toReversed())try{let e=ht(r.binPath,{throwIfNoEntry:!1});if(e!==void 0){if(!e.isSymbolicLink())throw Error(`${r.binPath} is not a symlink`);let n=A(k(r.binPath),yt(r.binPath));if(t===null||n!==t&&!n.startsWith(`${t}${ft}`))throw Error(`${r.binPath} is not owned by the standalone CLI package`);Ct(r.binPath)}xt(r.backupPath,r.binPath)}catch(e){n.push(K(e))}if(e.backupDirectory!==null)try{St(e.backupDirectory)}catch(e){n.push(K(e))}return n.length===0?null:n.join(`; `)}function oo(e){let t=[];for(let n of e.backup)try{Ct(n.backupPath)}catch(e){t.push(K(e))}if(e.backupDirectory!==null)try{St(e.backupDirectory)}catch(e){t.push(K(e))}return t.length===0?null:t.join(`; `)}function K(e){return e instanceof Error?e.message:String(e)}function so(){try{return Pa()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var co=[{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`}],lo=`operationFingerprint`;function uo(e,t=p().bin[0]){D(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: [...] }`:",...co.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable)`,`does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
|
|
27
27
|
`))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),I({mode:E(e)},await fo(t))})}async function fo(e){let n=mo(),r=ho(e),[i,a]=await Promise.all([go(e),_o(n,e)]),o=[r.check,i,a.check,await yo(e),To(n,a.servedFingerprint,r.upgradeAvailable,e)],s={pass:po(o,`pass`),fail:po(o,`fail`),skip:po(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(`
|
|
28
|
-
`);return l.ok?x(u,l,{counts:s}):{...t(u,c,{counts:s}),data:l}}function po(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function mo(){return O.find(e=>e.intent===`status`&&e.resource===`status`)}function ho(e){let t=p(),n=$a(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 go(e){try{let{EntityDetailSchema:e}=await import(`./detail-DYfulvpx.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\` — ${T(t)}.`)}}async function _o(e,n){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=l().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${T(e)}.`),servedFingerprint:null}}let i=await ne({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>t(T(e)));return i.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${r}.`),servedFingerprint:vo(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${n} auth login\`, then rerun \`${n} 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 \`${n} auth doctor\` — ${e.method} ${e.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function vo(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[lo];return typeof n==`string`&&n.length>0?n:null}async function yo(e){let t=ke(),[n,r]=await Promise.all([bo(),xo()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present;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`&&Ee(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&&r.state!==`found`&&n.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${y.authToken} through the environment — ${n.summary}.`):i||n.state===`found`||r.state===`found`?q(`auth`,`pass`,`Credential source available: ${So(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 ${y.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 ${y.authToken} in the environment.`)}async function bo(){let e;try{e=Pe(l().host)}catch(e){return{state:`unavailable`,summary:T(e)}}return await Fe(e)}async function xo(){let e;try{e=Ve(l().host)}catch(e){return{state:`unavailable`,summary:T(e),cause:`environment`}}try{return await Be(e)}catch(e){return{state:`unavailable`,summary:T(e),cause:`storage`}}}function So(e,t,n){return[Ea(e),`oauth=${wo(t)}`,`api-key=${Co(n)}`].join(` `)}function Co(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=Ve(l().host);return`${e.stored.activation}${da(t,e)}`}function wo(e){switch(e.state){case`found`:return Ee(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 To(e,t,n,r){let i=O.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 ${Ze}.`);if(t===`
|
|
28
|
+
`);return l.ok?x(u,l,{counts:s}):{...t(u,c,{counts:s}),data:l}}function po(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function mo(){return O.find(e=>e.intent===`status`&&e.resource===`status`)}function ho(e){let t=p(),n=$a(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 go(e){try{let{EntityDetailSchema:e}=await import(`./detail-DYfulvpx.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\` — ${T(t)}.`)}}async function _o(e,n){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=l().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${T(e)}.`),servedFingerprint:null}}let i=await ne({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>t(T(e)));return i.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${r}.`),servedFingerprint:vo(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${n} auth login\`, then rerun \`${n} 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 \`${n} auth doctor\` — ${e.method} ${e.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function vo(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[lo];return typeof n==`string`&&n.length>0?n:null}async function yo(e){let t=ke(),[n,r]=await Promise.all([bo(),xo()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present;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`&&Ee(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&&r.state!==`found`&&n.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${y.authToken} through the environment — ${n.summary}.`):i||n.state===`found`||r.state===`found`?q(`auth`,`pass`,`Credential source available: ${So(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 ${y.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 ${y.authToken} in the environment.`)}async function bo(){let e;try{e=Pe(l().host)}catch(e){return{state:`unavailable`,summary:T(e)}}return await Fe(e)}async function xo(){let e;try{e=Ve(l().host)}catch(e){return{state:`unavailable`,summary:T(e),cause:`environment`}}try{return await Be(e)}catch(e){return{state:`unavailable`,summary:T(e),cause:`storage`}}}function So(e,t,n){return[Ea(e),`oauth=${wo(t)}`,`api-key=${Co(n)}`].join(` `)}function Co(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=Ve(l().host);return`${e.stored.activation}${da(t,e)}`}function wo(e){switch(e.state){case`found`:return Ee(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 To(e,t,n,r){let i=O.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 ${Ze}.`);if(t===`dd72503540113afd`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ze}).`);let a=`This catalog describes a different operation set than the API serves (${Ze} 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 Eo=z(B,`oauth`),Do=[z(B,`start`),z(B,`poll`),z(B,`acknowledge`)],Oo=z(B,`revoke`);function ko(e,n=p().bin[0]){let r=No(e);uo(r,n);let i=[`${Eo.description} Default method: OAuth in your browser.`,`With --key: ${Do.map(({description:e})=>e).join(` `)}`].join(`
|
|
29
29
|
`);D(Mo(r,[Eo,...Do],i)).action(Ao),D(Mo(r,[Oo],Oo.description)).action(jo),D(r.command(`status`).summary(`Keep saved credentials current and report them with API build and uptime`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,` - system: GET /v1/status response (uptime SLA)`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
|
|
30
30
|
`)).addOption(new b(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Po(this),I({mode:E(e)},await Fo(n,e.verify))}),r.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: ${y.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
|
|
31
31
|
`)).action(async function(){Po(this);let e=await ra(n),r=process.env[y.authToken]?.trim();if(e.failure===null&&r!==void 0&&r.length>0){process.stdout.write(`${r}\n`);return}I({mode:`text`},e.failure===null?Uo(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):t(`auth token: ${e.failure}`))})}async function Ao(e){Po(this);let t=E(e);if(e.providers===!0){I({mode:t},await Lo());return}I({mode:t},e.key===!0?await Ki({noBrowser:!e.browser,clientLabel:e.clientLabel}):await ct({noBrowser:!e.browser}))}async function jo(e){Po(this),I({mode:E(e)},await Fi({forgetLocal:e.forgetLocal===!0}))}function Mo(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 No(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${Eo.command}\`: ${Eo.summary}; \`--key\` ${Do[0].summary.toLowerCase()}.`,`\`${Oo.command}\`: ${Oo.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(`
|