@aventurevc/aventure-cli 0.7.301 → 0.7.302
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/command-catalog.compact.txt +1 -1
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/{auth-DIikL8AE.js → auth-BSlYTFnP.js} +1 -1
- package/dist/chunks/aventure-cli-CTuT5oFj.js +73 -0
- package/dist/chunks/{index.node-LwG3axmM.js → index.node-BLqj0Ipp.js} +1 -1
- package/dist/chunks/{mcp-generation-contract-BdBNx3qx.js → mcp-generation-contract-BAgQo1bp.js} +2 -2
- package/dist/chunks/{oauth-credential-BwiTQED3.js → oauth-credential-BnJutDiR.js} +1 -1
- package/dist/chunks/oauth-login-BVlbsAdy.js +1 -0
- package/dist/chunks/{oauth-login-DlCQkNvx.js → oauth-login-ZPvGlkQO.js} +1 -1
- package/dist/chunks/openapi-commands-BekuCdC5.js +3 -0
- package/package.json +3 -3
- package/dist/chunks/aventure-cli-dQwsB1r3.js +0 -73
- package/dist/chunks/oauth-login-CDzQlEcb.js +0 -1
- package/dist/chunks/openapi-commands-BtFm7m9T.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventurevc/aventure-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.302",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Public aVenture CLI.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"aventurePublicApi": {
|
|
34
34
|
"repository": "aventurevc/aventure-docs",
|
|
35
|
-
"commit": "
|
|
35
|
+
"commit": "52e6ea94d4db7946dc06a2bca5815ddbb934f508",
|
|
36
36
|
"openapiPath": "openapi/openapi.json",
|
|
37
|
-
"openapiSha256": "
|
|
37
|
+
"openapiSha256": "985f5872dec6e3d679185d0cb35207370bee2614a55d25a7db914eeaa0781e79"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {}
|
|
40
40
|
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import{C as e,D as t,_ as n,a as r,k as i,v as a,x as o}from"./person-owner-ChqQWHII.js";import{$ as s,A as c,B as l,C as u,Ct as d,D as f,E as p,F as m,J as h,M as g,N as ee,P as te,Q as ne,R as _,S as re,T as ie,W as v,X as y,Y as ae,Z as oe,b as se,c as ce,et as le,f as ue,g as de,h as fe,it as b,k as pe,l as me,m as he,nt as ge,o as _e,p as ve,rt as x,s as ye,tt as S,v as be,x as xe}from"./auth-DIikL8AE.js";import{E as Se,T as C,_ as Ce,a as we,c as Te,f as Ee,i as De,l as Oe,m as ke,o as Ae,r as je,t as Me,w as Ne,x as Pe}from"./oauth-credential-BwiTQED3.js";import{C as Fe,S as Ie,_ as Le,a as Re,b as ze,c as Be,d as Ve,f as He,g as Ue,h as We,l as Ge,m as Ke,n as qe,o as w,p as Je,r as T,s as Ye,t as E,u as Xe,v as Ze,x as Qe,y as $e}from"./openapi-commands-BtFm7m9T.js";import{a as et,f as tt,i as nt,l as rt,n as it,r as at,s as ot,t as st}from"./mcp-generation-contract-BdBNx3qx.js";import{a as ct,n as lt,o as ut,r as dt,t as ft}from"./oauth-login-DlCQkNvx.js";import{spawnSync as pt}from"node:child_process";import{createHash as mt,webcrypto as ht}from"node:crypto";import{readFile as gt}from"node:fs/promises";import{homedir as _t,hostname as vt,platform as yt}from"node:os";import{basename as bt,dirname as D,join as O,resolve as k,sep as xt}from"node:path";import A,{stderr as j,stdin as St}from"node:process";import{appendFileSync as Ct,copyFileSync as wt,existsSync as M,lstatSync as Tt,mkdirSync as Et,mkdtempSync as Dt,readFileSync as N,readlinkSync as Ot,realpathSync as kt,renameSync as At,rmSync as jt,rmdirSync as Mt,unlinkSync as Nt,writeFileSync as P}from"node:fs";import{fileURLToPath as Pt}from"node:url";import{TextDecoder as Ft,inspect as It}from"node:util";import{setTimeout as Lt}from"node:timers/promises";import{createInterface as Rt}from"node:readline/promises";function zt(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function Bt(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||!en(n,r.name))continue;let a=$t(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 Vt(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 Ht(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return an(e,t,n);for(let[r,i]of n.entries()){let n=an(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function Ut(e,t,n,r){return an(e,t,r,n)}function Wt(e){let t=[];for(let n of e.split(`.`)){let e=sn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Gt(e,t){let n=Wt(t);if(n===null)return null;let r=Qt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Zt(r)}:null}function Kt(e,t){if(F(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var qt=/^(?<row>\d+):(?<item>.*)$/su;function Jt(e,t){let n=Wt(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=qt.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function Yt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Wt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Xt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Gt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Jt(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function Zt(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 $t(e,t){if(!F(t))return Qt(e,t.split(`.`))}function en(e,t){return nn(e,t.split(`.`))}function tn(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)&&en(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function nn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=sn(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=>nn(e,r)):nn(a,r)}function F(e){return e.split(`.`).some(e=>sn(e).isArray)}function rn(e,t){return e.parameter.length===0||!I(t)?null:ln(t,[],cn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function an(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=sn(o),c=e===i.length-1,l=on(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function on(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return I(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return I(s)?b(`Body path stepped`,s):o()}function sn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function cn(e){let t=new Set,n=new Set,r=new Map;for(let i of e){let e=`${i.name}${i.schemaType===`array`?`[]`:``}`;t.add(e),r.set(e,i.flag.split(` `)[0]??i.name);let a=e.split(`.`);for(let e=1;e<a.length;e+=1)n.add(a.slice(0,e).join(`.`))}return{leaf:t,prefix:n,flagByLeaf:r}}function ln(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=ln(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(!un(a,n)){if(!dn(e))continue;return{path:a,suggestion:fn(e,n)}}let o=ln(i,e,n);if(o!==null)return o}return null}function un(e,t){return t.prefix.has(e)||t.leaf.has(e)}function dn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function fn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``,[i]=[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:pn(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path));if(i!==void 0)return{path:i.path,flag:t.flagByLeaf.get(i.path)??i.path}}function pn(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 mn(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(Je(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?Sn(r,i):r===void 0?i===void 0?0:1:-1})}function hn(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 gn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function _n(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:bn(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 vn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function yn(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?Ke(n):`${Ke(n)} Required JSON paths: ${r.join(`, `)}.`}function bn(e,t){return`${Ve(t.description,void 0)}${e.kind!==`multipart`&&F(t.name)?` Repeat to add another value.`:``}${xn(e,t)}`}function xn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Wt(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 Sn(e,t){return He(e)-He(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Cn(e){let t;try{t=e===`-`?await wn():await gt(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function wn(){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 Tn=`--content-type`;function En(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(Tn)){let t=i.map(({contentType:e})=>e);e.addOption(new f(`${Tn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(On(i)))}if(Jn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new f(`--from-file <path>`,yn(n,n.requiredPath)).argParser(An(`--from-file`)))}let a=hn(i).filter(e=>r(Bn(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>Sn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new f(gn(t),i.length>1?_n(t):bn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?vn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Dn):F(r.name)||r.schemaType===`array`?a.argParser(kn):a.argParser(An(r.flag)),e.addOption(a)}qn(e,t,a)}function Dn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function On(e){return(t,n)=>{if(n!==void 0)throw new pe(`${Tn} was already given; pass it once.`);let r=ie(e,t);if(!r.ok)throw new pe(r.summary);return t}}function kn(e,t){return[...t??[],e]}function An(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new pe(`${t} was already given; pass it once.`);return e}}async function jn(e,t){let n=typeof t.contentType==`string`?t.contentType:void 0,r=ie(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=Mn(e,i,t);if(a!==null)return x(a);let o=zt(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Nn(i,t);if(s!==null)return x(s);let c=await Ln(t);if(!c.ok)return x(c.summary,c.warnings);let l=tn(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=In(e.operationId,i,c.data);if(!u.ok)return u;let d=Bt(e.operationId,i,c.data);if(d!==null)return x(d);let f=Rn(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(Kn(e.operationId,i)):b(`No body`,void 0);let p=Vn(e.operationId,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let m=Fn(i,p.data);if(m.length>0)return x(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?Vt(i).filter(e=>!en(h,e)):[];return g.length>0?x(Pn(e.operationId,i,g)):p}function Mn(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`${Bn(t)} requires ${Tn} ${i.join(` or `)}.`}return null}function Nn(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 Pn(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 Fn(e,t){return I(t)?e.parameter.filter(e=>e.required&&!en(t,e.name)).map(Bn):[]}function In(e,t,n){let r=rn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion.path} (${r.suggestion.flag}).`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function Ln(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await Cn(t);if(!n.ok)return x(n.summary,n.warnings);let r=d.safeParse(n.data);return r.success?b(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function Rn(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Kt(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=zn(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=Xt(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function zn(e,t,n,r,i){let a=Jt(r,i);if(a===null){let e=Wn(r,i);return e.ok?Ht(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${Bn(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=Yt(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${Bn(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.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 a.rows){let i=[];for(let e of t){let t=Gn(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=Ut(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}var Bn=e=>e.flag.split(` `)[0]??e.name;function Vn(e,t,n){if(t===void 0)return b(`Direct body parsed`,n);if(n===void 0)return b(`Input parsed`,t);if(I(t)&&I(n))try{return b(`Input parsed`,Hn(t,n))}catch(t){return x(`${e} ${t.message}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Hn(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&&Un(t)!==Un(r))throw Error(`cannot combine --from-file ${Un(t)} '${e}' with ${Un(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=I(t)&&I(r)?Hn(t,r):r}return n}function Un(e){return Array.isArray(e)?`array`:I(e)?`object`:`scalar`}function Wn(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Gn(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Gn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function Gn(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function Kn(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(Bn).join(`, `)}`;let r=Vt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(Bn).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function qn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Tn,location:`body`}),Jn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),mn(e.options,r)}function Jn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Yn(e){let t=ge(e);return nr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Xn(e){nr(e);let t=it(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
2
|
-
`)?t:`${t}\n`),Zn(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&$n(e.problem),Zn(e)}function Zn(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 L(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?ge(t):t;nr(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?Qn(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Yn(t):t;e.mode===`text`&&Xn(n),n.ok||(process.exitCode=1)}function Qn(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 $n(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`)}er(`unknownParameters`,e.unknownParameters),er(`validParameters`,e.validParameters),tr(e.resolution)}function er(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function tr(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 nr(e){e.ok&&e.warnings.length===0||l({component:`aventure-cli`,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 rr(e,t,n=h().bin[0]){let r=t.length,i=ot(e.q?.trim()??``),a=et(i),o=rt(i),s=or(t,n).filter(t=>ur(t,e)).map(e=>({operation:e,score:fr(i,a,o,e)})).filter(({score:e})=>i===``||e>0).toSorted((e,t)=>t.score-e.score||e.operation.cli.command.localeCompare(t.operation.cli.command)||e.operation.operationId.localeCompare(t.operation.operationId)).map(({operation:e})=>e),c=_r(e.limit,s.length),l=s.slice(0,c);return b(`Operation catalog matches`,{operation:l,count:{totalOperations:r,matched:s.length,returned:l.length}})}function ir(e,t,n=h().bin[0]){let r=or(t,n),i=e.operationId===void 0?ar(r,e.command):r.find(t=>t.operationId===e.operationId);return i===void 0?x(`Generated operation not found`,[`List candidates with \`${n} command-catalog search "<text>"\`.`]):b(`Generated operation detail`,{operation:i,usage:vr(i)})}function ar(e,t){if(t===void 0)return;let n=Dr(t);return e.find(e=>Dr(e.cli.command)===n||e.cli.alias!==null&&Dr(e.cli.alias)===n)}function or(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>sr(e)),...n.flatMap(e=>e.parameter.map(t=>sr(t,n.length>1?e.contentType:void 0))),...cr(n)],i=[t,...e.cliPath,...e.mode?[xe(e.mode)]:[]].join(` `),a=e.cliAliasPath===void 0?null:`${t} ${e.cliAliasPath.join(` `)}`,o=re(e.intent),s=e.method===`DELETE`||e.intent===`delete`,c=n[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:i,path:e.cliPath,alias:a,aliasPath:e.cliAliasPath??null},mcpTool:e.binaryResponse?null:u(e.intent),body:{hasBody:c!==void 0,kind:c?.kind??null,...c!==void 0&&n.length>1?{contentType:c.contentType}:{},required:c?.required??!1,description:c?.description??``,requiredPath:c?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,summary:e.summary,description:e.description}})}function sr(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 cr(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 lr(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function ur(e,t){return!(t.root!==void 0&&!dr(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 dr(e,t){let n=ot(t);return n.length===0||ot(e.cli.path.at(0)??``)===n||ot(e.cli.aliasPath?.at(0)??``)===n}function fr(e,t,n,r){if(e.length===0)return 1;let i=mr(r),a=pr(e,t,i,{exactQuery:120,partialQuery:60,exactToken:18,partialToken:6})+pr(e,t,hr(r),{exactQuery:12,partialQuery:6,exactToken:2,partialToken:1});nt(n,i)&&(a+=200);for(let e of r.cli.path){let n=new Set;at(n,e),[...n].some(e=>t.has(e))&&(a+=15)}return ot(r.cli.command).endsWith(e)&&(a+=40),a}function pr(e,t,n,r){let i=0;n.includes(e)&&(i+=r.exactQuery),n.some(t=>t.includes(e))&&(i+=r.partialQuery);for(let e of t)n.includes(e)?i+=r.exactToken:n.some(t=>t.includes(e))&&(i+=r.partialToken);return i}function mr(e){return gr([e.operationId,e.cli.command,e.cli.alias??``,e.summary])}function hr(e){return gr([e.method,e.path,e.resource,e.intent,e.scope,e.mutates?`mutates mutation write`:`read only no mutation`,e.destructive?`destructive delete`:`non destructive`,e.mcpTool??``,e.body.kind??``,e.body.description,e.body.requiredPath.join(` `),e.description,...e.flags.flatMap(e=>[e.name,e.optionKey,e.wireName,e.description,e.choices.join(` `)])])}function gr(e){return e.map(ot).filter(e=>e.length>0)}function _r(e,t){if(e===void 0)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.trunc(n)):t}function vr(e){let t=lr(e),n=t.filter(e=>e.required),r=t.filter(e=>!e.required);return[`cli: ${e.cli.command}`,e.cli.alias===null?``:`alias: ${e.cli.alias}`,`${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`,R(`required path flags`,n,`path`),R(`required query flags`,n,`query`),R(`required header flags`,n,`header`),R(`required body flags`,n,`body`),R(`optional path flags`,r,`path`),R(`optional query flags`,r,`query`),R(`optional header flags`,r,`header`),R(`optional body flags`,r,`body`),...Cr(e),...yr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
3
|
-
`)}function yr(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var br=[`-id`,`-slug`,`-url`],xr=[`--id`,`--slug`,`--url`],Sr=`--from-file "<path>"`;function Cr(e){return[`example: ${[e.cli.command,...wr(e),`--data`].join(` `)}`]}function wr(e){let t=lr(e).filter(e=>e.required),n=(t.length>0?t:Tr(e)).map(Er);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,Sr]:n}function Tr(e){let t=new Set;at(t,e.resource);for(let n of br)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 xr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function Er(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function R(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function Dr(e){return e.trim().replace(/^aventure(?:-cli)?\s+/u,``).replaceAll(/\s+/gu,` `)}function Or(e,t,n=h().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show command help, or ask a grounded question`).description([`Show local --help output for a command path (deterministic, offline),`,`or answer a natural-language platform question with --ask via the grounded`,"help operation (the same generated operation as `help ask`)."].join(`
|
|
4
|
-
`)).argument(`[command...]`,"command path to show help for, e.g. `help search entities`"),r.addOption(new kr(r));let i=jr(t);i!==void 0&&r.option(`--ask <question>`,i.summary),T(r),r.action(async function(t){let r=this.optsWithGlobals();if(r.help&&t.length===0){this.outputHelp();return}if(!r.help&&i!==void 0&&r.ask!==void 0){let e=w(r);if(t.length>0){L({mode:e},x(`Use either a command path or --ask, not both.`));return}L({mode:e},await Nr(i,r.ask,r.environment,e));return}let a=Mr(e,t);a===void 0&&this.error(`unknown command '${t.join(` `)}' (run \`${n} --help\` for the command tree)`),a.outputHelp()}),Ar(e,t)}var kr=class extends f{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}};function Ar(e,t){let n=new Set;for(let r of t){let t=yr(r.errorResponse);if(t.length!==0)for(let i of[r.cliPath,r.cliAliasPath]){let r=i===void 0?void 0:Mr(e,i);r===void 0||n.has(r)||(n.add(r),r.addHelpText(`after`,`\n${t.join(`
|
|
5
|
-
`)}\n`))}}}function jr(e){let[t,...n]=e.filter(e=>{let[t,n,r]=e.cliPath;return t===`help`&&n!==void 0&&r===void 0&&Pr(e)!==void 0});return n.length===0?t:void 0}function Mr(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}async function Nr(e,t,n,r){let i=Pr(e);if(i===void 0)return x(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let a=await jn(e,{[i.optionKey]:t});return a.ok?await me({method:e.method,path:_e(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:Re(r)?`json`:`auto`}):a}function Pr(e){if(e.requestBody?.length!==1||e.parameters.some(e=>e.required))return;let t=(e.requestBody[0]?.parameter??[]).filter(e=>e.required);return t.length===1&&t[0]?.schemaType===`string`?t[0]:void 0}function Fr(e){let t=new Map;for(let n of e){if(n.mode===void 0)continue;let e=n.cliPath.join(` `);t.set(e,[...t.get(e)??[],n])}return t}function Ir(e,t){for(let n of t){if(n.mode===void 0)continue;let t=Rr(n,n.mode);e.addOption(new f(t?.flag??xe(n.mode),n.summary||n.operationId))}}function Lr(e,t,n){let r=n.flatMap(t=>t.mode!==void 0&&e.getOptionValueSource(t.mode)===`cli`?[{spec:t,flag:xe(t.mode)}]:[]),[i,a]=r;return a===void 0?b(i===void 0?`Base operation`:`Folded operation`,i?.spec??t):x(`Use one of ${r.map(({flag:e})=>e).join(`, `)}, not more than one.`)}function Rr(e,t){return[...e.parameters,...e.requestBody?.flatMap(({parameter:e})=>e)??[]].find(e=>e.optionKey===t)}function zr(e){return new Set(e.map(e=>e.mode??``))}function Br(e){return e.map(e=>z(Rr(e,e.mode??``)?.flag??xe(e.mode??``)))}function Vr(e){return new Set(e.flatMap(e=>(e.requestBody??[]).flatMap(({parameter:e})=>e.filter(e=>e.schemaType===`array`||F(e.name)).map(e=>z(e.flag)))))}function Hr(e,t){let n=zr(t),r=new Set;return[e,...t].flatMap(e=>e.parameters.filter(e=>{if(n.has(e.optionKey))return!1;let t=z(e.flag);return!r.has(t)&&(r.add(t),!0)}))}function Ur(e,t){return e.parameters.filter(e=>e.required&&t[e.optionKey]===void 0).map(e=>e.flag)}function Wr(e,t,n){let r=n[e];if(r===void 0||Kr(t).has(e))return n;let[i,a]=qr(t).filter(e=>n[e.optionKey]===void 0);return i===void 0||a!==void 0?n:{...n,[e]:void 0,[i.optionKey]:r}}function Gr(e,t){let n=t.mode===void 0?``:` ${xe(t.mode)}`;return`hint: '${e.join(` `)}' is the retired spelling; use '${t.cliPath.join(` `)}${n}' (retired paths run for one release train).`}function Kr(e){return new Set([...e.parameters,...e.requestBody?.flatMap(({parameter:e})=>e)??[]].map(e=>e.optionKey))}function qr(e){return[...e.parameters,...e.requestBody?.flatMap(({parameter:e})=>e)??[]].filter(e=>e.required&&(e.schemaType===void 0||e.schemaType===`string`))}function z(e){return e.split(` `)[0]??e}function Jr(e){if(e.requestBody===void 0||e.requestBody.length===0){let[t,n]=e.parameters.filter(e=>e.required);return n===void 0&&t?.schemaType===`string`?t:void 0}if(e.requestBody.length!==1||e.parameters.some(e=>e.required))return;let t=e.requestBody[0]?.parameter??[],n=t.filter(e=>e.required);if(n.length===1&&n[0]?.schemaType===`string`)return n[0];if(n.length!==0||e.intent!==`search`)return;let r=t.filter(e=>{let t=e.name.split(`.`).at(-1);return e.schemaType===`string`&&(t===`query`||t===`search`)});return r.length===1?r[0]:void 0}function Yr(e,t,n){let r=t.join(` `).trim();return r.length===0?b(`No positional text`,n):n[e.optionKey]===void 0?b(`Positional text parsed`,{...n,[e.optionKey]:r}):x(`Use either the positional argument or ${z(e.flag)}, not both.`)}function Xr(e,t,n){if(e.cliPath[0]!==`lookup`||!Zr(n))return null;let r=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`);return x(`no record for ${r.length===0?`the given input`:r.join(`, `)}`)}function Zr(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}var Qr=a({artifact:e().nullish(),group:e().nullish(),name:e().nullish(),revision:e().nullish(),time:i({offset:!0}).nullish(),version:e().nullish()}),$r=a({build:Qr});function B(e,t){let[n,r]=e.filter(e=>e.role===t);if(n===void 0||r!==void 0)throw Error(`Generated composite CLI role '${t}' is incomplete`);return n}var ei=r([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),ti=r([`RSA_OAEP_256_A256_GCM_V1`]),ni=a({clientLabel:e().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:ei.nullish(),encryptionAlgorithm:ti.nullish(),encryptionPublicKey:e().min(344).max(12e3).nullish()}),ri=32;async function ii(){let e=await ht.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await ht.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function ai(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=oi(n,`wrapped key`,128,1024),s=oi(r,`nonce`,12,12),c=oi(i,`ciphertext`,1,65536),l=oi(a,`authentication tag`,16,16),u;try{u=await ht.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==ri)throw Error(`broker credential used an invalid AES-256 key`);let e=await ht.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await ht.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Ft(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function oi(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var si=r([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),ci=r([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`Personal API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),li=a({approvedAt:i({offset:!0}).nullish(),clientLabel:e(),clientPlatform:ei,comparisonCode:e(),consumedAt:i({offset:!0}).nullish(),createdAt:i({offset:!0}),expiresAt:i({offset:!0}),id:t(),intervalSeconds:n().int().min(1),keyReadyAt:i({offset:!0}).nullish(),status:si,terminalAt:i({offset:!0}).nullish(),terminalReason:ci.nullish(),updatedAt:i({offset:!0})}),ui=a({algorithm:ti,authenticationTag:e(),ciphertext:e(),nonce:e(),wrappedKey:e()}),di=a({delivery:ui.nullish(),expiresAt:i({offset:!0}),status:si,terminalReason:ci.nullish()}),fi=a({comparisonCode:e(),expiresAt:i({offset:!0}),id:t(),intervalSeconds:n().int().min(1),pollSecret:e(),verificationUrl:e()}),V=[{command:`auth login`,role:`oauth`,summary:`Sign in through your browser`,description:`Sign in through your browser and save verified CLI access in the credential store.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`},{optionKey:`providers`,flag:`--providers`,description:`Print the sign-in providers and CLI OAuth client, then exit without signing in.`}]},{command:`auth login`,role:`start`,summary:`Sign in with a browser-approved personal API key`,description:`Creates a short-lived browser approval request and returns its poll credential once.`,operationId:`createCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations`,bodyOption:[{name:`clientLabel`,optionKey:`clientLabel`,flag:`--client-label <client-label>`,required:!1,description:`Label for this CLI installation.`}],localOption:[{optionKey:`key`,flag:`--key`,description:`Sign in with a browser-approved personal API key instead of OAuth; the approval URL opens on any device.`},{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`}]},{command:`auth login`,role:`poll`,summary:`Poll CLI authorization`,description:`Returns pending state, a terminal state, or an encrypted one-time credential delivery.`,operationId:`pollCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/poll`,bodyOption:[],localOption:[]},{command:`auth login`,role:`acknowledge`,summary:`Acknowledge CLI credential delivery`,description:`Confirms the CLI stored the delivered personal key in its credential store and clears transient delivery material.`,operationId:`acknowledgeCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/acknowledge`,bodyOption:[],localOption:[]},{command:`auth logout`,role:`revoke`,summary:`Sign out: revoke the personal key and forget stored OAuth`,description:`Revokes the stored personal key and returns provider metadata so the CLI can confirm remote revocation before removing local bytes.`,operationId:`revokeCurrentPersonalApiKey`,method:`DELETE`,path:`/v1/auth/personal-api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Remove local bytes even when remote revocation cannot be confirmed.`}]}],pi=B(V,`start`),mi=B(V,`poll`),hi=B(V,`acknowledge`),gi=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${Se(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Si(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},_i=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${C(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function vi(e){let t=await fe(Ne(S()),{method:pi.method,path:ve(pi.path,{},pi.operationId),headers:{},contentType:`application/json`,body:e},fi);if(!t.ok)throw new gi(`start`,t.problem);return Ci(t.data)}async function yi(e,t){let n=ye(mi.operationId),r=await fe(Ne(S()),{method:mi.method,path:ve(mi.path,{cliAuthorizationId:e},mi.operationId),headers:{[n]:t}},di);if(!r.ok)throw new gi(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:xi(r.headers[`retry-after`])}}async function bi(e,t){let n=ye(hi.operationId),r;try{r=await fe(Ne(S()),{method:hi.method,path:ve(hi.path,{cliAuthorizationId:e},hi.operationId),headers:{[n]:t}},li)}catch(e){throw new _i(`acknowledge`,e,[t])}if(!r.ok)throw new gi(`acknowledge`,r.problem,[t]);return r.data}function xi(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Si(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Ci(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[It.custom]:{enumerable:!1,value:a}})}async function wi(e){let t=Ne(S()),n;try{n=await fe(t,{method:`GET`,path:_e(`getCurrentPersonalApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},Ie)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${C(t,[e])}`}}return n.ok?n.data.status===`ACTIVE`?{state:`verified`,summary:`personal API-key metadata verified`,apiKey:n.data}:{state:`invalid`,summary:`personal API-key self metadata is not active`}:{state:n.problem.status===401||n.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${Se(n.problem,[e])}`}}var Ti=B(V,`revoke`);async function Ei(e){let t;try{t=Le(S().host)}catch(e){return x(`auth logout: invalid API host — ${C(e)}`)}let[n,r]=await Promise.all([Di(t),Ai(t,e)]),i=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],a={host:t,revoked:!1,forgotten:!1,oauth:n};return r===null?n.state===`missing`?b(`No CLI credential is stored for this API host.`,a):n.state===`failed`?{...x(`auth logout: ${i[0]}`),data:a}:b(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,a,{warnings:i}):{...r,data:{...r.data??a,oauth:n},warnings:[...r.warnings,...i]}}async function Di(e){let t=await De(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await ki(t.stored):{revoked:!1};try{await je(e)}catch(e){return{state:`failed`,summary:C(e)}}return{state:`forgotten`,...n}}async function Oi(e){let t=Reflect.get(await ft(e),`revocation_endpoint`);return typeof t==`string`?ke(t,`revocation endpoint`,!0):void 0}async function ki(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Oi(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:Oe(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:C(e,Ee(n))}}}async function Ai(e,t){let n;try{n=await ze(e)}catch(e){return x(`auth logout: stored credential could not be read — ${C(e)}`)}if(n.state===`unavailable`)return{...x(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await ji(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...x(`auth logout: remote revocation was not confirmed; local credential preserved — ${i.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:Mi(r,!1,!1)};try{await Ze(r.host)}catch(e){return{...x(`auth logout: local credential removal failed — ${C(e,[r.credential.secret])}`,[a?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:Mi(r,a,!1)}}return b(a?`Personal CLI credential revoked remotely and removed locally.`:o?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`Personal CLI credential removed locally without confirmed remote revocation.`,Mi(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the personal key may remain active.`]})}async function ji(e){let t=Ne(S());try{let n=await fe(t,{method:Ti.method,path:ve(Ti.path,{},Ti.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},Ie);return n.ok?n.data.id!==e.credential.apiKey.id||n.data.subject!==e.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored personal key identity`}:n.data.status===`REVOKED`?{outcome:`revoked`,summary:`remote key revocation confirmed`}:{outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}:{outcome:n.problem.status===401&&n.problem.type!==`about:blank`?`rejected`:`unconfirmed`,summary:Se(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:C(t,[e.credential.secret])}}}function Mi(e,t,n){return{host:e.host,personalApiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Ni=`RSA_OAEP_256_A256_GCM_V1`,Pi=1,Fi=30,Ii=h().bin[0],Li=`The local record remains pending and unavailable to ordinary commands. Re-run \`${Ii} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Ri(e){if(!St.isTTY)return x(`${Ii} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject CLIENT_SECRET, ADMIN_API_KEY, or AUTH_TOKEN through the environment or configured Doppler source.`]);let t,n;try{let e=S().host;t=Le(e),n=Pe(e)}catch(e){return x(`auth login --key: invalid environment configuration — ${C(e)}`)}for(;;){let e;try{e=await $e(t)}catch(e){return x(`auth login --key: credential storage could not be inspected — ${C(e)}`)}if(e.state===`unavailable`)return x(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use CLIENT_SECRET, ADMIN_API_KEY, or AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&j.write(Ce(e.keyringFailure));break}let n=await zi(e.stored);if(n!==null)return n}let r;try{r=await ii()}catch(e){return x(`auth login --key: ephemeral encryption key could not be created — ${C(e)}`)}let i=ni.safeParse({clientLabel:e.clientLabel?.trim()||(vt().trim()||`aventure-cli`).slice(0,120),clientPlatform:Ui(),encryptionAlgorithm:Ni,encryptionPublicKey:r.publicKey});if(!i.success)return x(`auth login --key: local authorization input is invalid`);let a;try{a=await vi(i.data)}catch(e){return x(`auth login --key: could not start browser authorization — ${C(e)}`)}let o;try{o=ut(a,n)}catch(e){return x(`auth login --key: unsafe browser authorization URL rejected — ${C(e)}`)}if(!Hi(await ct(a,n,{noBrowser:e.noBrowser}),a,o))return x(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[o]});let s;try{s=await Vi(a)}catch(e){return x(`auth login --key: authorization did not complete — ${C(e)}`,[],{references:[o]})}if(s.algorithm!==Ni)return x(`auth login --key: broker selected an unsupported encryption algorithm`);let c;try{c=await ai(r.privateKey,s)}catch(e){return x(`auth login --key: encrypted credential could not be opened — ${C(e)}`)}let l=await wi(c);if(l.state!==`verified`)return x(`auth login --key: decrypted credential was neither stored nor acknowledged — ${l.summary}`);let u;try{u=await Qe(t,{apiKey:l.apiKey,secret:c},`pending`)}catch(e){return x(`auth login --key: credential could not be durably stored — ${C(e)}`)}let d;try{d=await Bi(a)}catch(e){return H(u,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${C(e,[a.pollSecret])}`,Li)}if(d.status!==`CONSUMED`)return H(u,!0,`auth login --key: broker returned ${d.status} after acknowledgment`,Li);let f=await wi(c);if(f.state!==`verified`||!qi(f.apiKey,u.credential.apiKey))return H(u,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${f.summary}`,Li);try{let e=await Qe(t,{apiKey:f.apiKey,secret:c},`active`);return b(`Personal CLI credential stored; authenticated identity and broker acknowledgment verified.`,Ki(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return H(u,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${C(e)}`,Li)}}async function zi(e){let t=await wi(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?b(`Personal CLI credential is already stored and its authenticated identity was verified.`,Ki(e,!0),{ids:[e.credential.apiKey.id]}):H(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${Ii} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&qi(t.apiKey,e.credential.apiKey))try{let n=await Qe(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return b(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,Ki(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return H(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${C(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${Ii} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return H(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${Ii} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await ji(e);if(n.outcome===`unconfirmed`)return H(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await Ze(e.host)}catch(t){return H(e,!1,`auth login --key: stale pending credential could not be removed — ${C(t,[e.credential.secret])}`)}return j.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
6
|
-
`:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
|
|
7
|
-
`),null}async function Bi(e){let t=new Date(e.expiresAt).getTime(),n=Wi(e.intervalSeconds);for(;;)try{return await bi(e.id,e.pollSecret)}catch(e){if(e instanceof gi){if(!e.retryable)throw e;n=Wi(e.retryAfterSeconds??n)}else if(!(e instanceof _i))throw e;if(Date.now()>=t)throw e;j.write(`Broker acknowledgment was interrupted; retrying.
|
|
8
|
-
`),await Gi(n,t)}}async function Vi(e){let t=new Date(e.expiresAt).getTime(),n=Wi(e.intervalSeconds),r;for(j.write(`Waiting for browser approval...
|
|
9
|
-
`);Date.now()<t;){let i;try{i=await yi(e.id,e.pollSecret)}catch(e){if(e instanceof gi){if(!e.retryable)throw e;n=Wi(e.retryAfterSeconds??n)}r=e,j.write(`Authorization poll was interrupted; retrying.
|
|
10
|
-
`),await Gi(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=Wi(i.retryAfterSeconds??n),await Gi(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:throw Error(de(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${C(r,[e.pollSecret])}`)}function Hi(e,t,n){let r=e.state===`opened`;return!r&&!j.isTTY?!1:(j.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...j.isTTY?[`Open this one-time approval URL in your browser:`,t.verificationUrl]:[`Approval reference: ${n}`],`Comparison code: ${t.comparisonCode}`,`Confirm that the browser shows the same code before approving.`,``].join(`
|
|
11
|
-
`)),!0)}function Ui(){switch(yt()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function Wi(e){return Math.min(Fi,Math.max(Pi,e))}async function Gi(e,t){let n=t-Date.now();n>0&&await Lt(Math.min(e*1e3,n))}function Ki(e,t){return{host:e.host,provider:e.provider,personalApiKeyId:e.credential.apiKey.id,name:de(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function H(e,t,n,r){return{...x(n,r===void 0?[]:[r]),data:Ki(e,t)}}function qi(e,t){return e.expiresAt===null||e.expiresAt===void 0||t.expiresAt===null||t.expiresAt===void 0?!1:new Date(e.expiresAt)>new Date(t.expiresAt)}function Ji(e,t){let n=t.state===`found`?t.stored:void 0,r=n?.credential.apiKey.expiresAt??null;return{host:e,present:n!==void 0,provider:n?.provider??null,activation:n?.activation??null,apiKeyId:n?.credential.apiKey.id??null,subject:n?.credential.apiKey.subject??null,scope:n?.credential.apiKey.scopes??[],name:n===void 0?null:de(n.credential.apiKey.name,[n.credential.secret]),status:n?.credential.apiKey.status??null,expiresAt:r,metadataSource:n===void 0?null:`store-cache`,expiresInDay:Xi(r),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}var Yi=864e5;function Xi(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/Yi)}var Zi=7;function Qi(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,Zi)}\u2026${e.slice(-4)}`}var $i=13,ea=14;function ta(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.personal.host}`+(e.apiVersion===null?` (api unreachable)`:` (api ${e.apiVersion})`),``,...na(e.oauth,e.cliName),...ra(e.personal,e.oauth,e.cliName),``,U(`Providers`,oa(e.providers)),...sa(e.resolved,e.config),...e.systemOk?[]:[U(`System`,`uptime read failed`)]].join(`
|
|
12
|
-
`)}function U(e,t){return` ${e.padEnd($i)}${t}`}function W(e){return` ${``.padEnd($i)}${e}`}function na(e,t){switch(e.state){case`found`:return[U(`OAuth`,`stored via ${e.stored.provider}; identity is not cached`),W(Ae(e.stored.credential)?e.stored.credential.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:`access token expired — the next command renews it with the refresh token`:`cached expiry ${e.stored.credential.expiresAt}`)];case`missing`:return[U(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[W(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[U(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[U(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function ra(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[U(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[W(`stored credential invalid: ${e.error}`)]]:[U(`Signed in`,`credential storage unavailable`),W(r)]}return[U(t.state===`found`?`Personal key`:`Signed in`,e.subject??`unknown subject`),W(`via ${e.provider??`unknown store`}`),U(`Key`,`${e.name??`unnamed`} ${Qi(e.apiKeyId)}`),...ia(e,n),U(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function ia(e,t){let n=`${e.status??`unknown`} when stored`,r=e.expiresInDay,i=e.expiresAt===null?null:e.expiresAt.slice(0,10);return[U(`Key state`,n),...i===null||r===null?[W(`no expiry recorded`)]:[W(aa(i,r))],W(`Clerk owns the live verdict \u2014 \`${t} auth login --key\` refreshes this cache`)]}function aa(e,t){return t<0?`cached expiry ${e} passed ${Math.abs(t)}d ago`:t<=ea?`cached expiry ${e}, ${t}d away`:`cached expiry ${e}`}function oa(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`clerk browser sign-in`:`no browser sign-in`,t?`oauth ${Te(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function sa(e,t){return[U(`Secrets`,y.map(t=>la(t,e)).join(` `)),U(`Config`,t===null?`none`:`doppler ${t.project}/${t.config}`)]}function ca(e){return y.map(t=>la(t,e)).join(` `)}function la(e,t){let n=t[e];return n.present?`${e}=${n.source??`resolved`}`:`${e}=${n.source===`config`?`config (unresolved)`:`unset`}`}var ua=r([`PROMPT`,`SKILL`,`AGENT`]),da=a({kind:ua,name:e(),version:e()}),fa=a({content:e(),core:da}),pa=a({key:e(),version:e()}),ma=a({agent:o(e(),pa),prompt:o(e(),pa),skill:o(e(),pa)}),G=`aventure`,ha=`SKILL.md`,ga=`.aventure-skills.json`,_a=`claude`,va=2e4,ya=2,ba=[{name:`claude-code`,base:`home`,detect:[`.claude`],skill:[`.claude`,`skills`],mcp:{shape:`claude-cli`,file:[`.claude.json`],key:`mcpServers`}},{name:`codex`,base:`home`,detect:[`.codex`],skill:[`.agents`,`skills`],mcp:{shape:`toml`,file:[`.codex`,`config.toml`]}},{name:`cursor`,base:`home`,detect:[`.cursor`],skill:null,mcp:{shape:`json`,file:[`.cursor`,`mcp.json`],key:`mcpServers`,entry:e=>({type:`http`,url:e})}},{name:`opencode`,base:`config`,detect:[`opencode`],skill:[`opencode`,`skills`],mcp:{shape:`json`,file:[`opencode`,`opencode.json`],key:`mcp`,entry:e=>({type:`remote`,url:e,enabled:!0})}}];function xa(e){return M(Sa(e))}function Sa(e){return O(Ta(e),...e.detect)}function Ca(e){return e.skill===null?null:O(Ta(e),...e.skill)}function wa(e){return O(Ta(e),...e.mcp.file)}function Ta(e){return e.base===`home`?Da(`HOME`)??_t():Ea()}function Ea(){return Da(`XDG_CONFIG_HOME`)??O(Da(`HOME`)??_t(),`.config`)}function Da(e){let t=process.env[e]?.trim();return t===void 0||t.length===0?void 0:t}function Oa(e){return O(D(e),ga)}function ka(e){if(!M(e))return{};try{let t=ma.safeParse(JSON.parse(N(e,`utf8`)));return t.success?t.data.skill:{}}catch{return{}}}function Aa(e,t,n){let r=Oa(e),i={...ka(r)};for(let e of n){let n=t.skill[e];n!==void 0&&(i[e]=n)}return Ma(r,`${JSON.stringify({prompt:{},skill:i,agent:{}},null,ya)}\n`)}function ja(e,t,n){let r=O(e,t,ha);return D(D(r))===e?Ma(r,n):`refusing to install ${t}: it does not name one directory inside ${e}`}function Ma(e,t){try{Na(e,t)}catch(t){return`cannot write ${e}: ${C(t)}`}return null}function Na(e,t){Et(D(e),{recursive:!0});let n=`${e}.aventure-tmp`;try{P(n,t,`utf8`),At(n,e)}finally{jt(n,{force:!0})}}var Pa=RegExp(`^[ \\t]*\\[[ \\t]*mcp_servers[ \\t]*\\.[ \\t]*"?${G}"?[ \\t]*\\]`),Fa=/^[ \t]*mcp_servers[ \t]*=/m;function Ia(e){let t=wa(e);if(!M(t))return null;try{let n=N(t,`utf8`);if(e.mcp.shape===`toml`)return Ra(n);let r=Ua(n)?.[e.mcp.key],i=(r!==void 0&&Wa(r)?r:void 0)?.[G];return i===void 0||!Wa(i)?null:typeof i.url==`string`?i.url:La}catch{return null}}var La=`unknown`;function Ra(e){let t=e.split(`
|
|
13
|
-
`),n=t.findIndex(e=>Pa.test(e));if(n<0)return null;for(let e of t.slice(n+1)){if(e.trimStart().startsWith(`[`))break;let t=/^[ \t]*url[ \t]*=[ \t]*"([^"]*)"/.exec(e);if(t?.[1]!==void 0)return t[1]}return La}function za(e,t){let n=e.mcp,r=wa(e);if(n.shape===`claude-cli`)return Ha(t);try{if(n.shape===`toml`)return Ba(r,t);Va(r,n.key,n.entry(t))}catch(e){return`cannot write ${r}: ${C(e)}`}return null}function Ba(e,t){let n=M(e)?N(e,`utf8`):``,r=`[mcp_servers.${G}]\nurl = "${t}"\n`;return Fa.test(n)?`${e} declares mcp_servers as an inline table, which this command cannot extend; add by hand:\n${r}`:Ma(e,`${n}${n.length===0||n.endsWith(`
|
|
14
|
-
`)?``:`
|
|
15
|
-
`}\n${r}`)}function Va(e,t,n){let r=Ua(M(e)?N(e,`utf8`):`{}`);if(r===null)throw Error(`${e} is not a JSON object`);let i={...r},a=i[t];i[t]={...a!==void 0&&Wa(a)?a:{},[G]:n},Na(e,`${JSON.stringify(i,null,ya)}\n`)}function Ha(e){let t=[`mcp`,`add`,`--transport`,`http`,`-s`,`user`,G,e],n=pt(_a,t,{encoding:`utf8`,timeout:va}),r=`${_a} ${t.join(` `)}`;if(n.error!==void 0)return`run \`${r}\`: ${n.error.message}`;if(n.status!==0){let e=(n.stderr??``).trim().split(`
|
|
16
|
-
`).slice(-2).join(` | `);return`\`${r}\` exited ${n.status}: ${e||`no stderr`}`}return null}function Ua(e){let t=d.safeParse(JSON.parse(e));return t.success&&Wa(t.data)?t.data:null}function Wa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ga=`aventure`;function Ka(e,t=h().bin[0]){T(qa(e).command(`setup`).summary(`Install the aventure skill bundle and MCP server into your agent runtimes`).description([`Detect the agent runtimes installed for this user (${ba.map(e=>e.name).join(`, `)}),`,`install or refresh the published ${Ga}* skill bundle into each runtime's own`,`skill directory, and register the ${G} MCP server in each runtime's own config.`,``,` ${t} agents setup # write the skills and the MCP registration`,` ${t} agents setup --status # compare what is installed; exit 1 on drift`,`--execute is deprecated, accepted, and ignored; setup executes by its verb.`].join(`
|
|
17
|
-
`)).addOption(new f(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`).default(!1)).addOption(new f(`--status`,`report installed skill versions against the manifest and exit 1 on drift; compares recorded versions, not file content, and writes nothing`).default(!1))).action(async function(e){let t=this.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment),L({mode:w(e)},await Ja(e))})}function qa(e){let t=`agents`,n=e.commands.find(e=>e.name()===t);if(n!==void 0)return n;let r=We[t]?.summary??t;return e.command(t).summary(r).description(r)}async function Ja(e){let t=oo();if(!t.ok||t.data===null)return{...t,data:null};let n=await io(`getAgentInstructionManifest`,ma);if(!n.ok||n.data===null)return{...n,data:null};let r=n.data,i=t.data,a=Object.keys(r.skill).filter(e=>e.startsWith(Ga)).toSorted();if(a.length===0)return x(`The agent instruction manifest carries no ${Ga}* skill; nothing to install.`);let o=ba.map(e=>Qa(e,r,a,i));return Ya({runtime:e.status===!0?o:await eo(o,r,i)},e,i)}function Ya(e,t,n){let r=e.runtime.filter(e=>e.detected),i=r.flatMap(e=>e.action.filter(e=>e.state!==`current`)),a=i.filter(e=>e.state===`failed`),o={runtimeDetected:r.length,actionPending:i.length,actionFailed:a.length},s=[`agents setup: ${r.length} runtime detected, ${i.length} action pending, mcp ${n}`,...e.runtime.map(Xa)].join(`
|
|
18
|
-
`);if(r.length===0){let t=ba.map(e=>`${e.name}: no ${Sa(e)}`);return{...x(s,t,{counts:o}),data:e}}let c=a.length>0?a:t.status===!0?i:[];return c.length===0?b(s,e,{counts:o}):{...x(s,c.map(Za),{counts:o}),data:e}}function Xa(e){if(!e.detected)return` ${e.name} not installed`;let t=e.action.filter(e=>e.state!==`current`);return t.length===0?` ${e.name} current (${e.action.length} item)`:` ${e.name} ${t.length} pending — ${t.map(Za).join(`; `)}`}function Za(e){return`${e.kind} ${e.name} ${e.state}: ${e.detail}`}function K(e,t,n,r){return{kind:e,name:t,state:n,detail:r}}function Qa(e,t,n,r){let i=Ca(e),a=wa(e),o={name:e.name,skillDir:i,mcpConfig:a};if(!xa(e))return{...o,detected:!1,action:[]};let s=Ia(e),c=s===null?K(`mcp`,G,`install`,`register ${r} in ${a}`):K(`mcp`,G,`current`,`${s} in ${a}`);return{...o,detected:!0,action:[...i===null?[]:$a(i,t,n),c]}}function $a(e,t,n){let r=ka(Oa(e));return n.map(n=>{let i=t.skill[n]?.version??``,a=r[n]?.version,o=O(e,n,ha);return a===void 0||!M(o)?K(`skill`,n,`install`,`write ${o} at version ${i}`):a===i?K(`skill`,n,`current`,`${o} at version ${i}`):K(`skill`,n,`update`,`${o} ${a} -> ${i}`)})}async function eo(e,t,n){let r=e.flatMap(e=>e.action.filter(e=>e.kind===`skill`&&e.state!==`current`).map(e=>e.name)),i=new Map;for(let e of[...new Set(r)].toSorted())i.set(e,await ro(e));return e.map(e=>{let r=ba.find(t=>t.name===e.name);if(!e.detected||r===void 0)return e;let a=[],o=e.action.map(t=>{if(t.state===`current`)return t;if(t.kind===`mcp`)return to(r,e.mcpConfig,n);let o=no(e.skillDir,t.name,i.get(t.name));return o.state===`current`&&a.push(t.name),o}),s=e.skillDir===null||a.length===0?null:Aa(e.skillDir,t,a),c=s===null?[]:[K(`skill`,ga,`failed`,s)];return{...e,action:[...o,...c]}})}function to(e,t,n){let r=za(e,n);return r===null?K(`mcp`,G,`current`,`registered ${n} in ${t}`):K(`mcp`,G,`failed`,r)}function no(e,t,n){if(e===null||n===void 0||!n.ok||n.data===null)return K(`skill`,t,`failed`,n?.summary??`no document fetched for ${t}`);let r=ja(e,t,n.data.content);return r===null?K(`skill`,t,`current`,`${O(e,t,ha)} at version ${n.data.core.version}`):K(`skill`,t,`failed`,r)}async function ro(e){return await io(`getAgentInstruction`,fa,{kind:ua.enum.SKILL,name:e})}async function io(e,t,n={}){let r=ao(e);if(r===void 0)return x(`The generated command catalog carries no ${e} operation; regenerate it with \`make mcp-generate-contracts\` and reinstall.`);let i;try{i=_e(r.operationId,n)}catch(t){return x(`Cannot address ${e}: ${C(t)}`)}let a=await me({method:r.method,path:i,auth:r.auth,responseFormat:`json`}).catch(e=>x(C(e)));if(!a.ok)return{...a,summary:`${r.method} ${i} failed: ${a.summary}`,data:null};let o=a.data,s=t.safeParse(typeof o==`object`&&o&&`response`in o?o.response:void 0);return s.success?b(`${r.method} ${i} answered`,s.data):x(`${i} returned an unexpected body: ${s.error.message}`)}function ao(e){return E.find(t=>t.operationId===e)}function oo(){try{return b(`MCP host derived`,tt(S().host,`/mcp`).href)}catch(e){return x(`Correct API_ENV or pass \`--environment <name>\` — ${C(e)}.`)}}var so=`# >>> aventure-cli completion setup (managed by aventure-cli) >>>`,co=`# <<< aventure-cli completion setup (managed by aventure-cli) <<<`,lo=`.aventure-cli-completion.bak`;function uo(e,t){e.command(`install`).summary(`install shell completion loaders`).description(`Install managed shell completion loaders for supported shells.`).action(()=>vo([])),e.command(`uninstall`).summary(`remove shell completion loaders`).description(`Remove managed shell completion loaders installed by ${t}.`).action(()=>vo([`--uninstall`]))}function fo(e,t){e.command(`setup`).summary(`configure zsh completion startup`).description(`Configure ~/.zshrc so zsh loads ${t} completion loaders.`).option(`--dry-run`,`print the managed zshrc block without writing`).option(`--yes`,`apply without prompting`).option(`--uninstall`,`remove the managed zshrc block`).action(async e=>{let t=go(),n=await ho({rcFile:k(_t(),`.zshrc`),installerPath:t,mode:e.uninstall?`uninstall`:`install`,dryRun:e.dryRun,prompter:e.yes||e.dryRun?void 0:ko});A.stdout.write(`${n.message}\n`),!n.cancelled&&!e.dryRun&&vo(e.uninstall?[`--uninstall`]:[])})}function po(e,t=`fpath-only`){return[so,`# installer: ${e}`,'fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath)',...t===`fpath-and-compinit`?[`autoload -Uz compinit`,`compinit`]:[],co].join(`
|
|
19
|
-
`)}function mo(){let e=vo([`--status`],`pipe`);if(e.status!==0)return{refreshed:!1,message:`completion status exited ${e.status??1}`};if(!yo(e.stdout??``))return{refreshed:!1,message:`no managed shell completions found`};let t=vo([],`pipe`);return t.status===0?{refreshed:!0,message:(t.stdout??``).trim()||`shell completions refreshed`}:{refreshed:!1,message:`completion refresh exited ${t.status??1}`}}async function ho({rcFile:e,installerPath:t,mode:n,dryRun:r=!1,prompter:i}){let a=bo(e),o=a.length===0?[]:a.split(`
|
|
20
|
-
`),s=xo(o,e);if(n===`uninstall`&&s===null)return{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:a};let c=n===`install`?So(o,s,t,e):Co(o,s);return c===a?{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:c}:r?{changed:!0,cancelled:!1,message:c,content:c}:i!==void 0&&!await i(`Update ${e}?`)?{changed:!0,cancelled:!0,message:`${e}: cancelled`,content:a}:(Eo(e,c),{changed:!0,cancelled:!1,message:`${e}: updated`,content:c})}function go(e=A.argv[1]){let t=e===void 0?``:_o(e),n=k(D(t),`..`,`..`,`scripts`,`install-zsh-completion-loader.mjs`);return M(n)?n:k(D(t),`..`,`scripts`,`install-zsh-completion-loader.mjs`)}function _o(e){try{return kt(e)}catch{return k(e)}}function vo(e,t=`inherit`){let n=pt(A.execPath,[go(),...e],{encoding:t===`pipe`?`utf8`:void 0,stdio:t});if(n.error!==void 0)throw n.error;if(t===`inherit`){n.status!==0&&(A.exitCode=n.status??1);return}return{stdout:n.stdout?.toString(),stderr:n.stderr?.toString(),status:n.status}}function yo(e){return e.split(/\r?\n/u).some(e=>e.trim().endsWith(`: managed`))}function bo(e){return M(e)?(Do(e),N(e,`utf8`)):``}function xo(e,t){let n=wo(e,so),r=wo(e,co);if(n.length===0&&r.length===0)return null;if(n.length!==1||r.length!==1||n[0]>=r[0])throw Error(`${t} has malformed managed completion setup markers; fix manually before retrying.`);return[n[0],r[0]]}function So(e,t,n,r){let i=t===null?[...e]:[...e.slice(0,t[0]),...e.slice(t[1]+1)],a=To(i),o=po(n,a===-1?`fpath-and-compinit`:`fpath-only`).split(`
|
|
21
|
-
`),s=t===null?a:t[0],c=s===-1?i.length:s;if(t!==null&&a!==-1&&a<c)throw Error(`${r} runs compinit before the managed block; move the block above compinit manually.`);return Oo([...i.slice(0,c),...o,...i.slice(c)])}function Co(e,t){return Oo(t===null?e:[...e.slice(0,t[0]),...e.slice(t[1]+1)])}function wo(e,t){return e.flatMap((e,n)=>e===t?[n]:[])}function To(e){return e.findIndex(e=>/^\s*(autoload\s+.*\bcompinit\b|compinit(?:\s|$))/.test(e))}function Eo(e,t){Et(D(e),{recursive:!0}),M(e)&&(Do(e),Do(`${e}${lo}`),wt(e,`${e}${lo}`));let n=k(D(e),`.${bt(e)}.${A.pid}.tmp`);Do(n),P(n,t,{mode:420}),At(n,e)}function Do(e){if(M(e)&&Tt(e).isSymbolicLink())throw Error(`refusing to write symlink: ${e}`)}function Oo(e){let t=e.join(`
|
|
22
|
-
`);return t.length===0||t.endsWith(`
|
|
23
|
-
`)?t:`${t}\n`}async function ko(e){let t=Rt({input:A.stdin,output:A.stdout});try{let n=await t.question(`${e} [y/N] `);return/^(y|yes)$/i.test(n.trim())}finally{t.close()}}var Ao=new Intl.Collator(void 0,{numeric:!0}),jo=2e4;function Mo(e,t=h()){let n=t.registry===`https://npm.pkg.github.com/`?`Requires npm authentication for @aventurevc packages.`:`Installs from the public npm registry; no credential required.`;T(e.command(`update`).summary(`Check for or install the latest release`).description([`Compare the running CLI version against the latest published`,`release and install it into the active published bin prefix.`,``,`Refuses to install when the running binary is the working-tree build`,`(use \`make\` to rebuild that). ${n}`,`--execute is deprecated, accepted, and ignored; update executes by its verb.`].join(`
|
|
24
|
-
`)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1)).action(e=>L({mode:w(e)},No()))}function No(e,t=`apply`){let n=e;try{n??=h(process.argv[1])}catch(e){return x(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let r=n.name,i=n.version,a=Po([`view`,v,`version`,`--silent`,`--global`],n,{timeout:jo});if(!a.ok)return{...a,data:null};let o=(a.data??``).trim();if(o===``)return x(`npm view ${v} returned empty version`,[`empty_stdout`]);let s=Ao.compare(i,o)<0,c={targetPackage:v,runningPackage:r,currentVersion:i,latestVersion:o,upgradeAvailable:s,upgradeInstalled:!1};if(t===`check`)return b(`${r}@${i} → ${v}@${o} (${s?`available`:`up to date`})`,c);if(!s)return b(`${r}@${i} already matches ${v}@${o}`,c);if(n.workingTreeRoot!==null)return x(`Refusing to install over the working-tree build at ${n.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);let l=Io(n),u;try{u=Lo(n,l)}catch(e){return x(`Cannot prepare MCP-owned CLI bins: ${Bo(e)}`,[`npm install was not run`])}let d=[`install`,`-g`];l!==null&&d.push(`--prefix`,l.installPrefix),d.push(`${v}@${o}`);let f=Po(d,n,{stdio:[`ignore`,`inherit`,`inherit`]});if(!f.ok){let e=Ro(u,l?.installPrefix??null);return e===null?{...f,data:null}:x(`${f.summary}; MCP-owned CLI bin restoration failed`,[...f.warnings,e])}let p=l===null?void 0:Fo(l.entryPath,o);if(p?.ok===!1){let e=Ro(u,l?.installPrefix??null);return e===null?{...p,data:null}:x(`${p.summary}; MCP-owned CLI bin restoration failed`,[...p.warnings,e])}let m=zo(u);if(m!==null)return x(`${v} upgraded but MCP CLI bin backup cleanup failed`,[m]);let g=Vo();return b(`${v} upgraded to ${o}`,{...c,upgradeInstalled:!0,installPrefix:l?.installPrefix,verifiedVersion:p?.data??void 0,completionRefreshed:g.refreshed,completionRefreshMessage:g.message})}function Po(e,t,n={}){let r={...process.env};t.registry===`https://npm.pkg.github.com/`?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let i=[...e,`--@aventurevc:registry=${t.registry}`],a=pt(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?x(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):x(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
|
|
25
|
-
`).slice(-3).join(` | `);return x(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return b(`npm ok`,a.stdout??``)}function Fo(e,t){let n=pt(process.execPath,[e,`--version`],{encoding:`utf8`});if(n.error)return x(`updated ${v} verification failed: ${n.error.message}`,[`spawn_error`]);let r=(n.stdout??``).trim();if(n.status!==0||r!==t){let i=(n.stderr??``).trim().split(`
|
|
26
|
-
`).slice(-3).join(` | `);return x(`updated ${v} verification expected ${t} but active bin reported ${r||`empty output`}`,[i||`active bin: ${e}`])}return b(`active CLI version verified`,r)}function Io(e){let t=`${xt}lib${xt}node_modules${xt}${e.name.replace(`/`,xt)}`,n=e.packageRoot.lastIndexOf(t),r=e.bin.includes(`aventure-cli`)?`aventure-cli`:e.bin[0];return n<0?null:{entryPath:k(e.packageRoot.slice(0,n),`bin`,r),installPrefix:e.packageRoot.slice(0,n)}}function Lo(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}${xt}`))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=k(t.installPrefix,`bin`,n),i=Tt(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=kt(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:Ot(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=Dt(k(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:k(r,bt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(At(e.binPath,e.backupPath),a.push(e),Ot(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=Ro({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 Ro(e,t){let n=t===null?null:k(t,`lib`,`node_modules`,...v.split(`/`)),r=[];for(let t of e.backup.toReversed())try{let e=Tt(t.binPath,{throwIfNoEntry:!1});if(e!==void 0){if(!e.isSymbolicLink())throw Error(`${t.binPath} is not a symlink`);let r=k(D(t.binPath),Ot(t.binPath));if(n===null||r!==n&&!r.startsWith(`${n}${xt}`))throw Error(`${t.binPath} is not owned by the standalone CLI package`);Nt(t.binPath)}At(t.backupPath,t.binPath)}catch(e){r.push(Bo(e))}if(e.backupDirectory!==null)try{Mt(e.backupDirectory)}catch(e){r.push(Bo(e))}return r.length===0?null:r.join(`; `)}function zo(e){let t=[];for(let n of e.backup)try{Nt(n.backupPath)}catch(e){t.push(Bo(e))}if(e.backupDirectory!==null)try{Mt(e.backupDirectory)}catch(e){t.push(Bo(e))}return t.length===0?null:t.join(`; `)}function Bo(e){return e instanceof Error?e.message:String(e)}function Vo(){try{return mo()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var Ho=[{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 catalog was generated from the operation set the API serves`}],Uo=`operationFingerprint`;function Wo(e,t=h().bin[0]){T(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: [...] }`:",...Ho.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable)`,`does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
|
|
27
|
-
`))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),L({mode:w(e)},await Go(t))})}async function Go(e){let t=qo(),n=Jo(e),[r,i]=await Promise.all([Yo(e),Xo(t,e)]),a=[n.check,r,i.check,await Qo(e),as(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:Ko(a,`pass`),fail:Ko(a,`fail`),skip:Ko(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
28
|
-
`);return c.ok?b(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function Ko(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function qo(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function Jo(e){let t=h(),n=No(t,`check`);if(!n.ok||n.data===null)return{check:q(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?q(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):q(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function Yo(e){try{let{EntityDetailSchema:e}=await import(`./detail-DeMsv_6C.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\` — ${C(t)}.`)}}async function Xo(e,t){if(e===void 0)return{check:q(`api-host`,`skip`,`No status operation resolved from the generated catalog; fix the catalog check first.`),servedFingerprint:null};let n;try{n=S().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${C(e)}.`),servedFingerprint:null}}let r=await me({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>x(C(e)));return r.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${n}.`),servedFingerprint:Zo(r.data)}:{check:q(`api-host`,`fail`,`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} at ${n} returned ${r.summary}.`),servedFingerprint:null}}function Zo(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[Uo];return typeof n==`string`&&n.length>0?n:null}async function Qo(e){await g();let t;try{t=te(await ee())}catch(t){return q(`auth`,`fail`,`Repair or remove ${c()} and run \`${e} auth init\` — ${C(t)}.`)}let[n,r]=await Promise.all([$o(),es()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t[ae.authToken].present,a=y.some(e=>t[e].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`&&Ae(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.`):!a&&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 ${ae.authToken} through the environment — ${n.summary}.`):a||n.state===`found`||r.state===`found`?q(`auth`,`pass`,`Credential source available: ${ts(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.join(`/`)} through the environment — ${r.summary}.`):y.some(e=>t[e].source===`config`)?q(`auth`,`fail`,`The Doppler source in ${c()} resolved no credential: confirm your access to that project and config, or inject ${y.join(`/`)} through the environment.`):q(`auth`,`fail`,`Run \`${e} auth login\` for OAuth, \`${e} auth login --key\` for a personal credential, or \`${e} auth init\` to select a Doppler source.`)}async function $o(){let e;try{e=Me(S().host)}catch(e){return{state:`unavailable`,summary:C(e)}}return await we(e)}async function es(){let e;try{e=Le(S().host)}catch(e){return{state:`unavailable`,summary:C(e),cause:`environment`}}try{return await $e(e)}catch(e){return{state:`unavailable`,summary:C(e),cause:`storage`}}}function ts(e,t,n){return[...y.map(t=>`${t}=${ns(e,t)}`),`oauth=${is(t)}`,`personal=${rs(n)}`].join(` `)}function ns(e,t){let n=e[t];return n.present?n.source??`resolved`:n.source===`config`?`config (unresolved)`:`unset`}function rs(e){return e.state===`found`?e.stored.activation:e.state===`missing`?`unset`:`unavailable`}function is(e){switch(e.state){case`found`:return Ae(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 as(e,t,n,r){let i=E.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 ${qe}.`);if(t===`e2c601b4e859c89d`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${qe}).`);let a=`This catalog describes a different operation set than the API serves (${qe} 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 os=B(V,`oauth`),ss=[B(V,`start`),B(V,`poll`),B(V,`acknowledge`)],cs=B(V,`revoke`),ls=`personal-login`,us=`personal-logout`;function ds(e,t=h().bin[0]){let n=ps(e);Wo(n,t),Ka(e,t);let r=[`${os.description} Default method: OAuth in your browser.`,`With --key: ${ss.map(({description:e})=>e).join(` `)}`].join(`
|
|
29
|
-
`),i=async function(e){ms(this);let n=w(e);if(e.providers===!0){L({mode:n},await _s());return}L({mode:n},e.key===!0?await Ri({noBrowser:!e.browser,clientLabel:e.clientLabel}):await dt({noBrowser:!e.browser},t))};T(fs(n,[os,...ss],r)).action(i),T(fs(n,[...ss],r,ls)).action(async function(e){await i.call(this,{...e,key:!0})});let a=async function(e){ms(this),L({mode:w(e)},await Ei({forgetLocal:e.forgetLocal===!0}))};T(fs(n,[cs],cs.description)).action(a),T(fs(n,[cs],cs.description,us)).action(a),T(n.command(`init`).summary(`Interactive credential setup`).description([`Interactively record the Doppler project/config used by ${t} + the MCP server.`,`Credentials resolve from the injected environment first, then Doppler; auth init never writes credentials to disk.`,``,`Prompts go to stderr so stdout stays reserved for the result envelope.`].join(`
|
|
30
|
-
`))).action(async function(e){ms(this),L({mode:w(e)},await Cs(t))}),T(n.command(`status`).summary(`Local credential provenance, API build, and server uptime`).description([`Reports local credentials plus two independent remote health signals:`,` - auth: per-credential local provenance (env vs ~/.config/aventure/config.json vs unset)`,` - oauth: stored OAuth access-token metadata for the selected API host, without the token`,` - personal: stored personal-key metadata for the selected API host, without the secret`,` - providers: GET /v1/auth/providers (Clerk instance and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,` - system: GET /v1/status response (Better Stack uptime SLA)`,``,`No headers are sent to the server. Credential provenance is computed locally; this`,`answers whether service credentials, OAuth, or a personal CLI credential are wired without exposing them.`,`To prove a credential survives transit, call any real endpoint that requires it.`].join(`
|
|
31
|
-
`))).action(async function(e){ms(this),L({mode:w(e)},await hs(t))})}function fs(e,t,n,r){let[i]=t,a=e.command(r??i.command.slice(i.command.indexOf(` `)+1),{hidden:r!==void 0}).summary(i.summary).description(n),o=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])o.has(t.flag)||(o.add(t.flag),`required`in t&&t.required?a.requiredOption(t.flag,t.description):a.option(t.flag,t.description));return a}function ps(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${os.command}\`: ${os.summary}; \`--key\` ${ss[0].summary.toLowerCase()}.`,`\`${cs.command}\`: ${cs.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 init` configures the local Doppler source used by generated API commands."].join(`
|
|
32
|
-
`))}function ms(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function hs(e){let t;try{t=await ee()}catch(t){return x(`auth status: cannot read ${c()} — ${t instanceof Error?t.message:String(t)}`,[`configPath=${c()}`,`errorName=${t instanceof Error?t.name:`Error`}`,...Ms(e)])}let n;try{n=Me(S().host)}catch(e){return x(`auth status: invalid API host — ${C(e)}`)}let[r,i,a,o,s]=await Promise.all([Ss(`/v1/status`,`GET /v1/status`),Ss(`/info`,`GET /info`),we(n),ys(n),vs()]),l=te(t),u=h().version,d=Ji(n,o),f=ta({cliName:e,cliVersion:u,apiVersion:i.ok?bs(i.data):null,oauth:a,personal:d,providers:s,resolved:l,config:t,systemOk:r.ok}),p={cli:{version:u},api:i.ok?i.data??null:null,auth:Ds(t,l),oauth:gs(n,a),personal:d,providers:s,system:r.ok?r.data??null:null,...i.ok?{}:{apiError:i.summary},...r.ok?{}:{systemError:r.summary}};return Os(l)||a.state===`found`||o.state===`found`?b(f,p):ks(`auth status: no credentials resolved | ${f}`,p,e,{oauth:a.state===`missing`,personal:o.state===`missing`})}function gs(e,t){let n=t.state===`found`?t.stored:void 0;return{host:e,present:n!==void 0,provider:n?.provider??null,expiresAt:n?.credential.expiresAt??null,expired:n===void 0?null:Ae(n.credential),client:n?.credential.client??null,storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}async function _s(){let e=await vs();return e.state===`found`?b(`Sign-in providers for the selected API host`,e.catalog):x(`auth login --providers: ${e.summary}`)}async function vs(){try{return{state:`found`,catalog:await lt()}}catch(e){return{state:`unavailable`,summary:C(e)}}}async function ys(e){try{return await $e(e)}catch(e){return{state:`invalid`,summary:C(e)}}}function bs(e){if(!xs(e))return null;let t=$r.safeParse(Reflect.get(e,`response`));if(!t.success)return null;let n=t.data.build.version?.trim();return n&&n.length>0?n:null}function xs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ss(e,t){return await me({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>x(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}async function Cs(e){if(!St.isTTY)return x(`${e} auth init requires an interactive TTY on stdin`,["non-interactive caller: hand-write `~/.config/aventure/config.json` directly",...Ms(e)]);let t=Rt({input:St,output:j});try{j.write(`${e} auth init\n\n`);let n=await ws(t);try{await m(n)}catch(t){return x(`auth init: cannot write ${c()} — ${t instanceof Error?t.message:String(t)}`,[`configPath=${c()}`,`errorName=${t instanceof Error?t.name:`Error`}`,...Ms(e)])}return await g(),Es(`saved`,n,e)}finally{t.close()}}async function ws(e){return{source:`doppler`,project:await Ts(e,`Doppler project: `),config:await Ts(e,`Doppler config (e.g. staging): `)}}async function Ts(e,t){for(;;){let n=(await e.question(t)).trim();if(n.length>0)return n;j.write(` required
|
|
33
|
-
`)}}function Es(e,t,n){let r=te(t),i=`${js(e,t,r)} | ${As()}`,a=Ds(t,r);return Os(r)?b(i,a):ks(`no credentials resolved | ${i}`,a,n)}function Ds(e,t){return{configPath:c(),configSource:e?.source??null,...e?.source===`doppler`?{configProject:e.project,configConfig:e.config}:{},resolved:t}}function Os(e){return y.some(t=>e[t].present)}function ks(e,t,n,r={oauth:!0,personal:!0}){return{...x(e,[...r.personal?[`For a personal key (works over SSH), run \`${n} auth login --key\`.`]:[],...r.oauth?[`For OAuth, run \`${n} auth login\` in an interactive terminal.`]:[],h().registry===`https://registry.npmjs.org/`?`For non-interactive use, set AUTH_TOKEN to a personal API key in the environment.`:`Run \`${n} auth init\` to select Doppler, or inject credentials through the environment.`]),data:t}}function As(){return`read=${le(`read`).ok?`available`:`unavailable`} write=${le(`write`).ok?`available`:`unavailable`}`}function js(e,t,n){return`${e}: ${ca(n)} | ${t===null?`no config`:`doppler ${t.project}/${t.config}`}`}function Ms(e){return[`no config at the path above — run \`${e} auth init\` in an interactive terminal, or write a non-secret Doppler source config:`,` {"auth":{"source":"doppler","project":"<project>","config":"<config>"}}`,`legacy inline configs are rejected; move credentials to Doppler or the environment before replacing the config.`]}function Ns(e,t,n=h().bin[0]){let r=Dr(t),i=e.find(e=>e.cliPath.join(` `)===r||e.cliAliasPath?.join(` `)===r||e.operationId===r);return i===void 0?x(`No generated operation matches "${t}"`,[`Resolve the exact command with \`${n} command-catalog search "<query>"\`.`]):b(`Resolved ${i.operationId}`,i)}function Ps(e){return e.parameters.some(e=>e.location===`path`)?x(`${e.operationId} has path parameters and cannot be batch-driven`,[e.path]):b(`no path parameters`,null)}function Fs(e){let t={};for(let n of e){let e=n.indexOf(`=`);if(e<=0)return x(`--query expects key=value, got "${n}"`);t[n.slice(0,e)]=n.slice(e+1)}return b(`query parsed`,t)}function Is(e,t,n,r){let i=Number(t);return!Number.isInteger(i)||i<n||i>r?x(`${e} must be an integer between ${n} and ${r}, got "${t}"`):b(`${e} parsed`,i)}function Ls(e){let t=d.safeParse(e);return t.success?t.data:void 0}function Rs(e,t){let n=Ls(e);for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function zs(e){let t=Ls(e);return typeof t!=`object`||!t||Array.isArray(t)?null:t}function Bs(e){return typeof e==`object`&&e&&`response`in e?Ls(e.response):Ls(e)}function Vs(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function Hs(e){if(!M(e))return x(`--input file not found: ${e}`);let t=N(e,`utf8`),n=[],r=t.split(`
|
|
34
|
-
`);for(let[e,t]of r.entries()){if(t.trim()===``)continue;let r=d.safeParse(Ks(t));if(!r.success)return x(`--input line ${e+1} is not valid JSON`,[t.slice(0,120)]);n.push(r.data)}return n.length===0?x(`--input has no NDJSON rows: ${e}`):b(`input parsed`,{row:n,digest:qs(t)})}function Us(e,t,n){let r={inputDigest:t,chunkSize:n,completedChunk:[]};if(e===void 0||!M(e))return b(`no checkpoint`,r);let i=Ks(N(e,`utf8`));if(i===void 0)return x(`--checkpoint file is not valid JSON: ${e}`);let a=Rs(i,`inputDigest`),o=Rs(i,`chunkSize`),s=Rs(i,`completedChunk`);if(a!==t||o!==n)return x(`--checkpoint ${e} was written for different input or chunk size`,[`Delete the checkpoint to start over, or restore the original input file.`]);if(!Array.isArray(s))return x(`--checkpoint ${e} has an invalid completedChunk list`);let c=s.filter(e=>Number.isInteger(e));return c.length===s.length?b(`checkpoint loaded`,{inputDigest:t,chunkSize:n,completedChunk:c}):x(`--checkpoint ${e} has an invalid completedChunk list`)}function Ws(e,t,n,r){if(e===void 0)return;let i={inputDigest:t,chunkSize:n,completedChunk:[...r].toSorted((e,t)=>e-t)};P(e,`${JSON.stringify(i)}\n`)}function Gs(e,t){return[...t,e]}function Ks(e){try{return JSON.parse(e)}catch{return}}function qs(e){return mt(`sha256`).update(e).digest(`hex`)}function Js(e,t,n=h().bin[0]){let r=e.command(`batch`).summary(`Export reads and run bulk writes as NDJSON`).description(`batch export pages a cursor read into an NDJSON file; batch preview reports a chunk plan; batch run sends chunked NDJSON writes with bounded concurrency and checkpoint/resume. Resolve targets with command-catalog search|show first.`);Ys(r,t,n),Xs(r,t,`preview`,n),Xs(r,t,`run`,n)}function Ys(e,t,n){let r=e.command(`export`).summary(`Page a cursor read operation into an NDJSON row file`).description([`Repeatedly call one generated cursor-paginated read operation and append`,`every returned row to --out as NDJSON while stdout stays a compact summary.`,` ${n} batch export --command "<resource> <area> <operation>" \\`,` --from-file filter.json --query size=200 --out rows.ndjson`].join(`
|
|
35
|
-
`)).requiredOption(`--command <command>`,`Generated CLI command path or operationId`).option(`--from-file <path>`,`JSON request body sent on every page`).option(`--query <key=value>`,`Query parameter, repeatable`,Gs,[]).requiredOption(`--out <path>`,`NDJSON output file; overwritten at start`).option(`--cursor <cursor>`,`Starting cursor value`).option(`--cursor-param <name>`,`Cursor query parameter name`,`cursor`).option(`--rows-path <path>`,`Dot path to the row array in the response`,`row`).option(`--next-cursor-path <path>`,`Dot path to the next cursor in the response`,`nextCursor`).option(`--max-pages <count>`,`Safety cap on pages fetched`,`1000`);T(r),r.action(async function(){let e=this.optsWithGlobals();L({mode:w(e)},await Zs(t,e,n))})}function Xs(e,t,n,r){let i=e.command(n).summary(n===`run`?`Send NDJSON rows through a batched write operation`:`Preview one batched write operation without sending rows`).description(n===`run`?[`Chunk NDJSON rows into batched request bodies for one generated write`,`operation and send them with bounded concurrency. Every chunk response is`,`appended to --out as NDJSON; --checkpoint records completed chunks so an`,`interrupted run resumes without resending them.`,`Use batch preview to inspect the chunk plan before sending rows.`,`--execute is deprecated, accepted, and ignored; run executes by its verb.`].join(`
|
|
36
|
-
`):`Build the same chunk plan as batch run without sending rows or writing --out.`).requiredOption(`--command <command>`,`Generated CLI command path or operationId`).requiredOption(`--input <path>`,`NDJSON file; each line is one batch row`).requiredOption(`--array-field <name>`,`Body field receiving each chunk of rows`).option(`--base <path>`,`JSON file with fixed body fields merged into every chunk`).option(`--query <key=value>`,`Query parameter, repeatable`,Gs,[]).requiredOption(`--out <path>`,`NDJSON file receiving one response line per chunk`).option(`--chunk-size <count>`,`Rows per request body`,`25`).option(`--concurrency <count>`,`Concurrent requests, 1-8`,`2`).option(`--checkpoint <path>`,`JSON checkpoint file for resume`).addOption(new f(`--no-halt-on-failure`,`keep sending remaining chunks after a failed chunk`));n===`run`&&i.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),T(i),i.action(async function(){let e=this.optsWithGlobals();L({mode:w(e)},await Qs(t,e,n,r))})}async function Zs(e,t,n){let r=Ns(e,t.command,n);if(!r.ok||r.data===null)return r;if(re(r.data.intent))return x(`${t.command} is a write operation; use \`batch run\``,[r.data.path]);let i=Ps(r.data);if(!i.ok)return i;let a=Fs(t.query??[]);if(!a.ok||a.data===null)return a;let o=Is(`--max-pages`,t.maxPages,1,1e6);if(!o.ok||o.data===null)return o;let s=t.fromFile===void 0?void 0:await Cn(t.fromFile);if(s!==void 0&&!s.ok)return s;let c=s===void 0?void 0:zs(s.data);if(s!==void 0&&c===null)return x(`--from-file must contain a JSON object`,[t.fromFile??``]);P(t.out,``);let l=t.cursor,u=0,d=0,f=!1;for(;u<o.data;){let e={...a.data,...l===void 0?{}:{[t.cursorParam]:l}},n=await me({method:r.data.method,path:r.data.path,searchParams:e,body:c??void 0,auth:r.data.auth,responseFormat:`json`});if(!n.ok)return x(`page ${u+1} failed: ${n.summary}`,[`rows already written to ${t.out}: ${d}`,...l===void 0?[]:[`resume with --cursor "${l}"`]]);let i=Bs(n.data),o=Rs(i,t.rowsPath);if(!Array.isArray(o))return x(`response has no array at --rows-path "${t.rowsPath}"`,[`page ${u+1}`]);Ct(t.out,o.map(e=>`${JSON.stringify(e)}\n`).join(``)),u+=1,d+=o.length;let s=Rs(i,t.nextCursorPath);if(typeof s!=`string`||s===``||s===l){f=!0;break}l=s}return b(`${d} rows across ${u} pages written to ${t.out}${f?``:`; PARTIAL export — hit --max-pages ${o.data}, resume with --cursor "${l}"`}`,{outPath:t.out,exhausted:f,lastCursor:l},{counts:{pageCount:u,rowCount:d}})}async function Qs(e,t,n,r){let i=Ns(e,t.command,r);if(!i.ok||i.data===null)return i;if(!re(i.data.intent))return x(`${t.command} is not a write operation; use \`batch export\``,[i.data.path]);let a=Ps(i.data);if(!a.ok)return a;let o=Fs(t.query??[]);if(!o.ok||o.data===null)return o;let s=Is(`--chunk-size`,t.chunkSize,1,1e4);if(!s.ok||s.data===null)return s;let c=Is(`--concurrency`,t.concurrency,1,8);if(!c.ok||c.data===null)return c;let l=t.base===void 0?void 0:await Cn(t.base);if(l!==void 0&&!l.ok)return l;let u=zs(l?.data??{});if(u===null)return x(`--base must contain a JSON object`,[t.base??``]);let d=Hs(t.input);if(!d.ok||d.data===null)return d;let f=Vs(d.data.row,s.data),p=Us(t.checkpoint,d.data.digest,s.data);if(!p.ok||p.data===null)return p;let m=new Set(p.data.completedChunk),h=[...f.keys()].filter(e=>!m.has(e));if(n===`preview`)return b(`PREVIEW — nothing sent. ${h.length} of ${f.length} chunks (${d.data.row.length} rows) would ${i.data.method} ${i.data.path}. Run ${r} batch run to send.`,{mode:`preview`,method:i.data.method,endpoint:i.data.path,arrayField:t.arrayField,outPath:t.out},{counts:{rowCount:d.data.row.length,chunkCount:f.length,pendingChunkCount:h.length,skippedChunkCount:m.size}});P(t.out,``,{flag:m.size>0?`a`:`w`});let g=i.data,ee=o.data,te=d.data.digest,ne=s.data,_=[],ie=!1,v=0,y=async e=>{let n=f[e]??[],r={...u,[t.arrayField]:n},i=await me({method:g.method,path:g.path,searchParams:ee,body:r,auth:g.auth,responseFormat:`json`}),a=i.ok?Bs(i.data):null;return Ct(t.out,`${JSON.stringify({chunk:e,rowCount:n.length,ok:i.ok,summary:i.summary,response:a??i.data??null})}\n`),i.ok?(m.add(e),Ws(t.checkpoint,te,ne,m),!0):(_.push(e),!1)};await Promise.all(Array.from({length:c.data},async()=>{for(;!ie;){let e=h[v];if(v+=1,e===void 0)return;!await y(e)&&t.haltOnFailure&&(ie=!0)}}));let ae={rowCount:d.data.row.length,chunkCount:f.length,completedChunkCount:m.size,failedChunkCount:_.length,remainingChunkCount:f.length-m.size-_.length},oe={outPath:t.out,checkpointPath:t.checkpoint,failedChunk:_,halted:ie};return _.length>0?x(`${_.length} chunk(s) failed; responses in ${t.out}${t.checkpoint===void 0?``:`, resume via --checkpoint ${t.checkpoint}`}`,[JSON.stringify({...oe,...ae})]):b(`${m.size}/${f.length} chunks sent; responses in ${t.out}`,oe,{counts:ae})}function $s(e,t=E,n=h().bin[0]){let r=e.command(`completion`).summary(`Generate shell completion scripts`).description(`Generate shell completion scripts for the aVenture CLI.`);for(let i of[`bash`,`fish`,`zsh`])r.command(i).summary(`Print ${i} shell completions`).description(`Print ${i} completion definitions for ${n}.`).action(()=>{A.stdout.write(tc(e,i,t))});uo(r,n),fo(r,n)}function ec(){return h().bin}function tc(e,t,n=E,r=ec()){let i=uc(n);return t===`fish`?[`# fish completions for ${r.join(`, `)}`,...rc(e),...r.map(e=>`complete -c ${J(e)} -e`),`${Cc(r)} -f`,...ic(e,r),...ac(e,i,r),``].join(`
|
|
37
|
-
`):nc(e,t,i,r)}function nc(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=pc(e,n);return[...t===`zsh`?[`#compdef ${r.join(` `)}`]:[],`# ${t} completions for ${r.join(`, `)}`,`${i}_aventure_cli_commands=(`,...o.map(e=>` ${e}`),`)`,`${i}_aventure_cli_options=(`,...s.map(e=>` ${e}`),`)`,`${i}_aventure_cli_values=(`,...c.map(e=>` ${e}`),`)`,``,...gc(t),...t===`bash`?[a,``]:[``]].join(`
|
|
38
|
-
`)}function rc(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${oc(e).filter(e=>e.required||e.optional).flatMap(e=>yc(e)??[]).map(J).join(` `)}\n set -l tokens (commandline -xpc)\n if test (count $tokens) -gt 0\n set -e tokens[1]\n end\n set -l path\n set -l skip_next 0\n for token in $tokens\n if test $skip_next -eq 1\n set skip_next 0\n continue\n end\n if string match -q -- '--*=*' $token\n set -l name (string replace -r '^--([^=]+)=.*$' '$1' -- $token)\n contains -- $name $global_value_options; and continue\n end\n if string match -q -- '--*' $token\n set -l name (string replace -r '^--' '' -- $token)\n if contains -- $name $global_value_options\n set skip_next 1\n continue\n end\n break\n end\n if string match -q -- '-*' $token\n break\n end\n set -a path $token\n end\n printf '%s\\n' $path\nend\n`,`function __aventure_cli_path_is
|
|
39
|
-
set -l expected $argv
|
|
40
|
-
set -l actual (__aventure_cli_command_path)
|
|
41
|
-
if test (count $actual) -ne (count $expected)
|
|
42
|
-
return 1
|
|
43
|
-
end
|
|
44
|
-
if test (count $expected) -eq 0
|
|
45
|
-
return 0
|
|
46
|
-
end
|
|
47
|
-
for index in (seq (count $expected))
|
|
48
|
-
if test $actual[$index] != $expected[$index]
|
|
49
|
-
return 1
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
return 0
|
|
53
|
-
end
|
|
54
|
-
`].flatMap(e=>e.split(`
|
|
55
|
-
`))}function ic(e,t){return fc(e).map(e=>`${Cc(t)} -f -n ${J(wc(e.parentPath))} -a ${J(e.name)} -d ${J(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function ac(e,t,n){return bc(e).flatMap(e=>{let r=Sc(e),i=r.length===0?void 0:wc(r);return oc(e).flatMap(e=>{let a=t.get(dc(r,e));return hc(a)?sc(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function oc(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function sc(e,t,n,r){let i=yc(e);if(i===void 0)return[];let a=e.argChoices??mc(n),o=[`-l ${J(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${J(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${J(t)}`,c=e.required||e.optional?cc(a,lc(i,n)):`-f`,l=`${Cc(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${J(Tc(e.description))}`]:a.map(t=>`${l} -a ${J(t)} -d ${J(Tc(e.description))}`)}function cc(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function lc(e,t){return e===`from-file`?!0:t===void 0||t.some(({location:e})=>e!==`body`)?!1:t.every(({schemaFormat:e})=>e===`binary`)?!0:t.length===1&&[`file`,`path`].includes(e.split(`-`).at(-1)??``)}function uc(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...hn(e.requestBody??[]).map(({variant:e})=>e.map(({parameter:e})=>e))].flatMap(t=>{let n=t[0];if(n===void 0)throw Error(`Generated CLI option has no parameter`);let r=e.cliAliasPath===void 0?[]:[e.cliAliasPath];return[e.cliPath,...r].map(e=>[dc(e,n),t])})))}function dc(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):yc(t);if(`flag`in t&&(n===void 0||n.length===0||n===t.flag))throw Error(`Cannot render completion for option flag: ${t.flag}`);return`${e.join(`\0`)}\u0000${n??``}`}function fc(e){return bc(e).flatMap(e=>e.commands.map(t=>({parentPath:Sc(e),name:t.name(),description:Tc(t.summary()||t.description()||t.name())})))}function pc(e,t){let n=[],r=[];for(let i of bc(e)){let e=Sc(i);for(let a of oc(i)){let i=yc(a);if(i===void 0)continue;let o=t.get(dc(e,a));if(!hc(o))continue;let s=a.argChoices??mc(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&lc(i,o)&&(c=`file`)),n.push(_c([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(_c([e.join(` `),`--${i}`,t,a.description]))}}return[fc(e).map(e=>_c([e.parentPath.join(` `),e.name,e.description])).toSorted((e,t)=>e.localeCompare(t)),n.toSorted((e,t)=>e.localeCompare(t)),r.toSorted((e,t)=>e.localeCompare(t))]}function mc(e){let t=e?.[0]?.choices;if(e!==void 0&&t!==void 0)return e.every(e=>e.choices?.length===t.length&&e.choices.every((e,n)=>e===t[n]))?t:void 0}function hc(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function gc(e){let t=e===`bash`,n=t?`COMP_WORDS`:`words`,r=t?`COMP_CWORD`:`CURRENT`,i=t?"${path[*]}":"${(j: :)path}",a=t?'"${_aventure_cli_options[@]}"':`$_aventure_cli_options`,o=t?'"${_aventure_cli_values[@]}"':`$_aventure_cli_values`,s=t?'"${_aventure_cli_commands[@]}"':`$_aventure_cli_commands`;return[`function _aventure_cli {`,` local current="\${${n}[${r}]}" previous="\${${n}[${r}-1]}" row row_path long short description mode name value option token key prefix candidate file_current`,...t?[` COMPREPLY=()`]:[],` local index=${t?1:2} skip_next=0; local -a path names descriptions`,` while (( index < ${r} )); do`,` token="\${${n}[index]}"; (( skip_next )) && { skip_next=0; (( index++ )); continue; }`,` if [[ "$token" == -* && "$token" != "-" && "$token" != "--" ]]; then`,` option="\${token%%=*}"; key="${i}"; mode=''`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && break; mode=''; done`,` [[ -n "$mode" && "$mode" != none && "$token" != *=* ]] && skip_next=1`,` elif [[ "$token" != -* ]]; then path+=("$token"); fi`,` (( index++ ))`,` done`,` key="${i}"`,` if [[ "$current" == --*=* || ( "$previous" == -* && "$current" != -* ) ]]; then`,` option="$previous"; prefix=''; file_current="$current"; [[ "$current" == --*=* ]] && { option="\${current%%=*}"; prefix="$option="; file_current="\${current#*=}"; }`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && { option="$long"; break; }; mode=''; done`,t?` [[ "$mode" == file ]] && { while IFS= read -r candidate; do COMPREPLY+=("$prefix$candidate"); done < <(compgen -f -- "$file_current"); return 0; }`:` [[ "$mode" == file ]] && { _files; return 0; }`,t?` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { candidate="$prefix$value"; [[ "$candidate" == "$current"* ]] && COMPREPLY+=("$candidate"); }; done`:` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { names+=("$prefix$value"); descriptions+=("$description"); }; done`,` elif [[ "$current" == -* ]]; then`,` for row in ${a}; do`,` IFS='|' read -r row_path long short description mode <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$long" == "$current"* ]] && COMPREPLY+=("$long"); [[ -n "$short" && "$short" == "$current"* ]] && COMPREPLY+=("$short"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$long"); descriptions+=("$description"); [[ -n "$short" ]] && { names+=("$short"); descriptions+=("$description"); }; }`,` done`,` elif [[ "$previous" != -* ]]; then`,` for row in ${s}; do`,` IFS='|' read -r row_path name description <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$name" == "$current"* ]] && COMPREPLY+=("$name"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$name"); descriptions+=("$description"); }`,` done`,` fi`,...t?[]:[" (( ${#names} )) && compadd -d descriptions -a names"],` return 0`,`}`,...t?[]:[`_aventure_cli "$@"`]]}function _c(e){return`$'${e.map(vc).join(`|`)}'`}function vc(e){return Tc(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function yc(e){return e.long?.replace(/^--/,``)}function bc(e){return[e,...e.commands.filter(xc).flatMap(e=>bc(e))]}var xc=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function Sc(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function Cc(e){return`complete ${e.map(e=>`-c ${J(e)}`).join(` `)}`}function wc(e){return[`__aventure_cli_path_is`,...e.map(J)].join(` `)}function Tc(e){return e.replace(/\s+/g,` `).trim()}function J(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function Ec(e,t){if(e!==t)return;let n=Dc(t);n!==void 0&&t.error(`error: ${kc(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function Dc(e){if(!process.argv.includes(`--`)&&e.args.some(Oc))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function Oc(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function kc(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Ac(e){return e.message.match(/required option '([^']+)' not specified/iu)?.[1]?.split(/\s+/u)[0]}function jc(e){return e.message.match(/unknown option '([^']+)'/iu)?.[1]}function Mc(e){return e.message.match(/unknown command '([^']+)'/iu)?.[1]}function Nc(e){return e.flags.split(` `)[0]??e.flags}function Pc(e,t){let n=Ac(t);if(n===void 0)return;let r=e.options.findIndex(e=>Nc(e)===n);if(r<0)return;let i=e.options.slice(r+1).filter(e=>e.mandatory).map(t=>[Nc(t),e.getOptionValue(t.attributeName())]).find(([,e])=>typeof e==`string`&&e.length>0)?.[0];if(i!==void 0)return`hint: ${n} is still required for this nested command; supplied child selector ${i} does not replace the parent selector.`}function Y(e){let t=[];for(let n=e;n!==null&&n.parent!==null;n=n.parent)t.unshift(n.name());return t}function Fc(e){return e.commands.length===0?[e]:e.commands.flatMap(Fc)}function Ic(e,t){return Y(t).slice(Y(e).length)}function X(e){let t=e;for(;t.parent!==null;)t=t.parent;return t}function Lc(e,t){return t.toSorted((t,n)=>{let r=Ic(e,t),i=Ic(e,n),a=r.at(-1)===`get`?0:1,o=i.at(-1)===`get`?0:1;return r.length-i.length||a-o})[0]}function Rc(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function zc(e,t){let n=Y(e),r=process.argv.slice(2+n.length);return[X(e).name(),...n,...Ic(e,t),...r].map(Rc).join(` `)}function Bc(e,t){let n=jc(t);if(n===void 0||e.commands.length===0)return;let r=Lc(e,Fc(e).filter(e=>e.options.some(e=>Nc(e)===n)));if(r!==void 0)return`hint: run: ${zc(e,r)}`}function Vc(e){return e!==void 0&&Object.hasOwn(We,e)}function Hc(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e);if(t===void 0)return;n=t}return n}function Uc(e,t){let n=Y(e),r=[...n.slice(1),t];if(!Vc(n.at(0))||!Vc(r.at(0)))return;let i=Hc(X(e),r);if(i===void 0)return;let a=i;for(let e of process.argv.slice(2+n.length+1)){if(e.startsWith(`-`))break;let t=a.commands.find(t=>t.name()===e);if(t===void 0)break;r.push(e),a=t}return r}function Wc(e,t){let[n]=Y(e);if(!Vc(n))return;let r=[n,t];return Hc(X(e),r)?.commands.length===0?r:void 0}function Gc(e){let[t,...n]=e.args;if(t===void 0)return[];let r=Fc(X(e)).map(Y),i=n.findIndex((e,t)=>{let i=[...n.slice(0,t),e];return!r.some(e=>e.some((t,n)=>t===i[0]&&i.every((t,r)=>e[n+r]===t)))});return[t,...i<0?n:n.slice(0,i)]}function Kc(e,t){let n=Y(e),r=process.argv.slice(2+n.length);if(t.length===0||t.some((e,t)=>r[t]!==e))return;let i=Be(E).map(e=>e.cliPath).filter(e=>e[0]!==n[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a!==void 0)return`hint: run: ${[X(e).name(),...a].map(Rc).join(` `)}`}function qc(e,t,n){if(!Yc(t))return;let r=e.args.slice(n.length),i=r.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${[X(e).name(),...t,...i<0?[]:r.slice(i)].map(Rc).join(` `)}`}function Jc(e){let t=Y(e);if(t.at(1)!==void 0&&Vc(t.at(0)))return`hint: inspect generated command group: ${[X(e).name(),...t,`--help`].map(Rc).join(` `)}`}function Yc(e,t){let n=e.join(` `);return E.some(e=>{let r=`cliAliasPath`in e?e.cliAliasPath:void 0;return e.cliPath.join(` `)!==n&&r?.join(` `)!==n?!1:t===void 0||re(e.intent)===t})}function Xc(e){let t=Y(e);if(Vc(t.at(0))&&Yc(t))return`hint: inspect generated command: ${[X(e).name(),...t,`--help`].map(Rc).join(` `)}`}function Zc(e){let t=new Set,n=[];for(let r of E){let i=Hc(e,r.cliPath);if(i===void 0)continue;let a=i.options.map(Nc);if(re(r.intent))n.push(a);else for(let e of a)t.add(e)}let[r=[],...i]=n;return new Set(r.filter(e=>!t.has(e)&&i.every(t=>t.includes(e))))}function Qc(e,t){let n=Y(e);if(Yc(n,!1)&&Zc(X(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function $c(e,t,n=!0){let r=X(e),i=r.commands.find(e=>e.name()===`command-catalog`),a=i?.commands.find(e=>e.name()===`search`);if(i===void 0||a===void 0)return;let o=[r.name(),i.name(),a.name(),t],s=Y(e).at(0),c=a.options.find(e=>Nc(e)===`--root`);return n&&s!==void 0&&c!==void 0&&Vc(s)&&o.push(Nc(c),s),`hint: search generated commands: ${o.map(Rc).join(` `)}`}function el(e,t){let n=Mc(t);if(n===void 0||t.message.includes(`
|
|
56
|
-
(Did you mean `))return;let r=Gc(e),i=Kc(e,r);if(i!==void 0)return i;let a=Uc(e,n);if(a!==void 0)return $c(e,a.join(` `),!1);let o=Wc(e,n);if(o!==void 0)return qc(e,o,r)??$c(e,o.join(` `),!1);let s=r.join(` `)||n;return Jc(e)??$c(e,s)}function tl(e){return t=>{if(t.code===`commander.missingMandatoryOptionValue`){let n=e.options.filter(t=>t.mandatory&&e.getOptionValue(t.attributeName())===void 0);if(n.length>1){let e=n.map(e=>e.flags.split(`, `).at(-1)??e.flags);process.stderr.write(`error: missing required options: ${e.join(`, `)}\n`)}for(let n of[Dc(e),Pc(e,t)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Dc(e)??Xc(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=jc(t),r=Bc(e,t)??(n!==void 0&&!t.message.includes(`
|
|
57
|
-
(Did you mean `)?Qc(e,n)??$c(e,n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=el(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}process.exit(t.exitCode)}}var nl=class extends f{group;constructor(e){super(`-h, --help`,`display help for command`),this.group=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.group.args.at(0);return t===void 0||t.startsWith(`-`)?!0:this.group.commands.some(e=>e.name()===t||e.aliases().includes(t))}};function rl(e){e.showHelpAfterError(!1).exitOverride(tl(e)),e.commands.length===0?e.hook(`preAction`,Ec):e.addHelpOption(new nl(e));for(let t of e.commands)rl(t)}var il=`dist/aventure-cli/command-catalog.compact.txt`,al=` · `,ol=`-`;function sl(e=h().bin[0]){return k(cl(D(Pt(import.meta.url)),e),il)}function cl(e,t){let n=e;for(;;){if(M(k(n,`package.json`)))return n;let r=D(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function ll(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function ul(e,t,n,r=h().bin[0]){let i=rr(e,t,r);if(!i.ok){L({mode:n},i);return}fl({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:ml(i.data,pl(e.format,`lines`)),summary:`Generated operation matches`})}function dl(e,t,n,r=h().bin[0]){let i=ir(e,t,r);if(!i.ok||i.data===null){L({mode:n},i);return}fl({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:hl(i.data,pl(e.format,`usage`)),summary:`Generated operation detail`})}function fl(e){let t=e.mode,n=e.rendered.endsWith(`
|
|
58
|
-
`)?e.rendered:`${e.rendered}\n`;if(e.opts.output!==void 0){P(e.opts.output,n),L({mode:t},b(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(n,`utf8`),format:pl(e.opts.format,e.defaultFormat)},{counts:bl(e.data)}));return}if(t===`text`){process.stdout.write(n);return}L({mode:t},b(e.summary,e.data,{counts:bl(e.data)}))}function pl(e,t){return e??t}function ml(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
|
|
59
|
-
`):t===`text`?vl(e.operation):t===`compact`?e.operation.map(gl).join(`
|
|
60
|
-
`):e.operation.map(yl).join(`
|
|
61
|
-
`)}function hl(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?yl(e.operation):t===`compact`?gl(e.operation):e.usage}function gl(e){let t=_l(e);return[e.cli.command,e.summary,t.length===0?ol:t.join(` `)].join(al)}function _l(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function vl(e){return e.map(e=>`${e.cli.command}\n ${yl(e)}`).join(`
|
|
62
|
-
`)}function yl(e){let t=_l(e);return[Z(`operationId`,e.operationId),Z(`scope`,e.scope),Z(`mutates`,String(e.mutates)),Z(`destructive`,String(e.destructive)),Z(`intent`,e.intent),Z(`resource`,e.resource),Z(`cli`,e.cli.command),e.cli.alias===null?``:Z(`alias`,e.cli.alias),e.mcpTool===null?``:Z(`mcpTool`,e.mcpTool),Z(`method`,e.method),Z(`path`,e.path),Z(`auth`,e.auth),Z(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),Z(`requiredFlags`,t.join(` `)),Z(`bodyKind`,e.body.kind??``),Z(`bodyRequired`,String(e.body.required)),Z(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function Z(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function bl(e){return`count`in e?e.count:{returned:1}}function xl(e,t=new Date){let n=wl(e);return{schemaVersion:1,generatedFrom:`MCP_GENERATION_CONTRACT`,generatedAt:t.toISOString(),totalOperations:n.length,note:`Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.`,operations:n}}function Sl(e){return`${JSON.stringify(e,null,2)}\n`}function Cl(e,t){let n=k(e),r=Sl(t);return Et(D(n),{recursive:!0}),P(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function wl(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,cliAliasCommand:e.projection.cliAliasPath?.join(` `)??null,cliAliasPath:e.projection.cliAliasPath??null,mcpTool:u(e.intent),bodySchemaName:e.requestBody?.[0]?.schemaName??null,bodySchemaImport:e.requestBody?.[0]?.schemaImport??null,auth:e.projection.auth,scope:e.projection.scope,destructive:e.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var Tl=`Match only the first canonical or CLI-alias command segment`;function El(e,t,n=h().bin[0]){Ol(e,t,n);let r=e.command(`command-catalog`).summary(`LLM agent only: search generated CLI metadata`).description([`LLM agent only: search and dump generated ${n} command metadata.`,`This is read-only command metadata derived from the generated OpenAPI command specs.`,`Use --format lines for rg/grep/ag/ack and --format ndjson|json for ast-grep/sg/parsers.`,"Use --format compact for one `cli · summary · requiredFlags` row per operation."].join(`
|
|
63
|
-
`));r.addHelpText(`after`,()=>`\nShipped compact catalog, greppable without running this CLI:\n ${sl(n)}\n`),Dl(r,t,n),jl(r,t,n),Ml(r,t,n),Nl(r)}function Dl(e,t,n){let r=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,Tl).addOption(new f(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new f(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new f(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new f(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new f(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new f(`--format <format>`,`Text/file render format`).choices([`text`,`lines`,`compact`,`json`,`ndjson`]).default(`lines`)).option(`--output <path>`,`Write rendered output to a file`);T(r),r.action(function(e){let r=this.optsWithGlobals(),i=w(r,`text`),a=r.limit?.trim()??``,o=a===``?NaN:Number(a);if(!Number.isInteger(o)||o<0){L({mode:i},x(`Invalid --limit value: ${JSON.stringify(r.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`; omit the flag for the default of 20."]));return}ul(ll(r,e),t,i,n)})}function Ol(e,t,n){let r=e.command(`docs`).summary(`Look up generated API documentation offline`).description(`Print generated operation documentation without calling the API.`).command(`api`).summary(`Show documentation for one operation`).description([`Print one operation's summary, description, flags, example, and error contract.`,"Select it by `<METHOD> <path>` (route template or concrete path), by operationId,",`or by CLI command path, e.g. "entities get".`].join(`
|
|
64
|
-
`)).argument(`<selector...>`,`METHOD and path, an operationId, or a CLI command path`);T(r),r.action(function(e){let r=this.optsWithGlobals(),i=w(r),a=Al(e,t);if(!a.ok||a.data===null){L({mode:i},a);return}dl({...r,...a.data},t,i,n)})}var kl='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function Al(e,t){let[n,...r]=e,i=ue.find(e=>e===n?.toLowerCase());if(i===void 0||r.length===0){let n=e.join(` `).trim();return b(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let a=he(i),o=r.join(``),s=t.find(e=>e.method===a&&e.path===o);if(s!==void 0)return b(`Resolved by route template`,{operationId:s.operationId});let c=ce({method:a,path:o});return!c.ok||c.data===null?x(c.summary,[...c.warnings,kl]):b(`Resolved by method and path`,{operationId:c.data.operation.operationId})}function jl(e,t,n){let r=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${n} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new f(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);T(r),r.action(function(){let e=this.optsWithGlobals();dl(e,t,w(e,`text`),n)})}function Ml(e,t,n){let r=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,Tl).addOption(new f(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new f(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new f(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new f(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new f(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new f(`--format <format>`,`Text/file render format`).choices([`text`,`lines`,`compact`,`json`,`ndjson`]).default(`lines`)).option(`--output <path>`,`Write rendered output to a file`);T(r),r.action(function(){let e=this.optsWithGlobals();ul(e,t,w(e,`text`),n)})}function Nl(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);T(t),t.action(function(){let e=this.optsWithGlobals(),t=w(e,`text`),n=xl(st);if(e.output!==void 0){let r=Cl(e.output,n);L({mode:t},b(`Unified operations JSON written`,{outputPath:r.target,byteLength:r.byteLength,schemaVersion:n.schemaVersion},{counts:{totalOperations:r.totalOperations}}));return}if(t===`text`){process.stdout.write(Sl(n));return}L({mode:t},b(`Unified operations JSON`,n,{counts:{totalOperations:n.totalOperations}}))})}var Pl=h(Pt(import.meta.url)),Q=Pl.bin[0];function Fl(e,t){_({component:`aventure-cli`,event:`fatal`,message:e.message,error:e}),process.stderr.write(`${Q} fatal (${t}): ${e.stack??e.message}\n`),Yn({...x(`${Q} ${t}: ${e.message}`,[e.name||`Error`]),counts:{exitCode:1}}),process.exit(1)}function Il(e){return Ge[Xe(e)??`cli`]}function Ll(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:Il(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=Fr(n),i=new Set(n.filter(e=>e.mode===void 0).map(e=>e.cliPath[0]??``));for(let t of n){if(t.mode!==void 0){t.cliAliasPath!==void 0&&t.cliAliasPath.join(` `)!==t.cliPath.join(` `)&&Rl(e,t,t.cliAliasPath,[],!0,i);continue}let n=r.get(t.cliPath.join(` `))??[];Rl(e,t,t.cliPath,n),t.cliAliasPath!==void 0&&t.cliAliasPath.join(` `)!==t.cliPath.join(` `)&&Rl(e,t,t.cliAliasPath,n,!0,i)}}function Rl(e,t,n,r,i=!1,a){let o=e,s=``,c=a?.has(n[0]??``)===!1;for(let e of n.slice(0,-1))s=s===``?e:`${s} ${e}`,o=zl(o,e,s,c);let l=n.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l),d=i?Gr(n,t):void 0,f=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full API documentation: ${Q} docs api ${t.operationId}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...f].some(e=>se(e.schemaType,e.itemSchemaType))?be:``].filter(Boolean).join(`
|
|
65
|
-
`));let p=Jr(t);if(r.length===0){for(let e of t.parameters)Bl(u,e,e===p);En(u,t)}else{let e=[t,...r],n=Vr(e),i=Hr(t,r).filter(e=>!n.has(z(e.flag)));for(let e of i)Bl(u,e,!0);let a=new Set([...Br(r),...i.map(e=>z(e.flag))]);for(let t of e.toSorted((e,t)=>Number(Vr([t]).size)-Number(Vr([e]).size)))En(u,t,a)}if(re(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),Ir(u,r),T(u),p!==void 0){u.argument(`[text...]`,p.description||`Same as ${z(p.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),i=w(n);d!==void 0&&process.stderr.write(`${d}\n`);let a=Yr(p,e,n);if(!a.ok||a.data===null)return L({mode:i},a);let o=Lr(this,t,r);if(!o.ok||o.data===null)return L({mode:i},o);let s=Wr(p.optionKey,o.data,a.data),c=Ur(o.data,s);if(c.length>0)return L({mode:i},x(`missing required options: ${c.join(`, `)}`));let l=await Vl(o.data,s,i),u=Xr(o.data,s,l);if(u!==null)return L({mode:i},u);l.ok&&l.data instanceof Uint8Array?process.stdout.write(l.data):L({mode:i},l)});return}u.action(async function(){let e=this.optsWithGlobals(),n=w(e);d!==void 0&&process.stderr.write(`${d}\n`);let i=Lr(this,t,r);if(!i.ok||i.data===null)return L({mode:n},i);let a=Ur(i.data,e);if(a.length>0)return L({mode:n},x(`missing required options: ${a.join(`, `)}`));let o=await Vl(i.data,e,n),s=Xr(i.data,e,o);if(s!==null)return L({mode:n},s);o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):L({mode:n},o)})}function zl(e,t,n,r=!1){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=We[n],o=e.command(t,r&&n===t?{hidden:!0}:{});return a!==void 0&&o.summary(a.summary).description(a.summary),o}function Bl(e,t,n=!1){let r=t.description||`${t.name} ${t.location} parameter`,i=t.defaultValue===void 0?void 0:typeof t.defaultValue==`string`||typeof t.defaultValue==`boolean`?t.defaultValue:[...t.defaultValue];if(t.legacyFlag!==void 0){let a=new f(t.flag,r);i!==void 0&&a.default(i);let o=new f(t.legacyFlag,r).conflicts(t.optionKey);e.addOption(a).addOption(o),e.hook(`preAction`,e=>{let r=e.opts(),i=r[t.optionKey],s=r[o.attributeName()];if(s!==void 0){(i===void 0||e.getOptionValueSource(t.optionKey)==="default")&&e.setOptionValueWithSource(t.optionKey,s,`cli`);return}!n&&t.required&&i===void 0&&e.error(`error: required option '${a.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(i!==void 0){e.option(t.flag,r,i);return}if(t.required&&!n){e.requiredOption(t.flag,r);return}e.option(t.flag,r)}async function Vl(e,t,n){if(t.environment!==void 0){let e=s(t.environment);if(e===null)return x(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${ne().join(`, `)}`]);process.env.API_ENV=e}let r=await jn(e,t);if(!r.ok)return r;let i=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let n=t[e.optionKey];if(Array.isArray(n))return[e.name,n.at(0)??``];if(n===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(n)]})),a=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let n=t[e.optionKey];if(n===void 0||Array.isArray(n)&&n.length===0)return[];let r=Array.isArray(n)||typeof n==`boolean`?n:String(n);return[[e.name,r]]})),o=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let n=t[e.optionKey];return n===void 0||Array.isArray(n)&&n.length===0?[]:[[e.name,Array.isArray(n)?n.join(`,`):String(n)]]}));return await me({method:e.method,path:_e(e.operationId,i),searchParams:a,headers:o,body:r.data,contentType:typeof t.contentType==`string`?t.contentType:void 0,auth:e.auth,responseFormat:Re(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0})}process.on(`uncaughtException`,e=>Fl(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>Fl(e instanceof Error?e:Error(String(e)),`unhandledRejection`));var Hl=Ye(process.argv.slice(2),E),Ul=Hl===`required`?E:Be(E),$=new p;$.name(Q).configureHelp({helpWidth:1/0}).version(Pl.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description([`The aVenture research API from your terminal. Three records — companies,`,`people, and news — carry everything else: funding, publications, and tags.
|
|
66
|
-
`,` Sign in: ${Q} auth login`,` Search: ${Q} entities search --query "fintech companies in Austin"\n`,`Mutations execute directly; --execute is a deprecated no-op.
|
|
67
|
-
The aventure-mcp-server tools execute through this same CLI.`].join(`
|
|
68
|
-
`)).addOption(new f(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${oe})`).choices([...ne()])).showHelpAfterError(`(run \`${Q} --help\` for usage)`),Ll($,Ul),ds($,Q),Mo($,Pl),Js($,Ul,Q),$s($,Ul,Q),El($,Ul,Q),Or($,Ul,Q);for(let e of $.commands)e.helpGroup()||e.helpGroup(Il(e.name()).heading);if(rl($),Hl===`required`){let e=[$];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&(await g(),await Fe(),await Ue())}))}}$.addHelpText(`after`,[``,`Verbs, the same on every record:`,` search Find many from a plain-English query or a filter`,` lookup Resolve a name, URL, slug, ticker, or id to its record`,` get Read one record`,` list Read many records`,` suggest Read proposed values for a field`,` create, update, delete Write; each needs a credential that permits it
|
|
69
|
-
`,`Environment (credentials by command group):`,` CLIENT_SECRET client access to authenticated reads, search, and lookups`,` ADMIN_API_KEY admin and write commands (mutations, media, jobs, harness)`,` AUTH_TOKEN signed-in session or personal API key; reads and writes`,` Public reads work with no credential; a saved sign-in is used when present.`,` Check what this shell holds with: ${Q} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents
|
|
70
|
-
`,`Exit codes:`,` 0 envelope.ok === true
|
|
71
|
-
1 envelope.ok === false
|
|
72
|
-
`,`Examples:`,` $ ${Q} auth login`,` $ ${Q} entities search --query "fintech companies in Austin"`,` $ ${Q} entities get --entity-slug stripe`,` $ ${Q} entities investors list --entity-slug stripe`].join(`
|
|
73
|
-
`));try{await $.parseAsync()}catch(e){Fl(e instanceof Error?e:Error(String(e)),`parseAsync`)}export{};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./oauth-login-DlCQkNvx.js";export{e as renewOAuthTokens};
|