@aventurevc/aventure-cli 0.8.50 → 0.8.53
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 +7 -5
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +46 -7
- package/dist/chunks/aventure-cli-BNIgZA3T.js +65 -0
- package/dist/chunks/client-SclaVr61.js +114 -0
- package/dist/chunks/{detail-DYfulvpx.js → detail-C462_tj4.js} +1 -1
- package/dist/chunks/{oauth-bearer-credential-B8KEp-Qz.js → oauth-bearer-credential-Bg04hOTJ.js} +2 -2
- package/dist/chunks/{oauth-login-C_y49CxG.js → oauth-login-DCuPY5A9.js} +1 -1
- package/dist/chunks/oauth-login-DQggudce.js +1 -0
- package/dist/chunks/openapi-commands-BAeIoVUn.js +1 -0
- package/dist/chunks/provider-catalog-jh0a9-Wz.js +1 -0
- package/dist/chunks/text-field-BhCFbqJ5.js +1 -0
- package/dist/chunks/{text-response-CGcFPo_4.js → text-response-D7u2LftD.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/aventure-cli-DdmMEJgR.js +0 -65
- package/dist/chunks/client-CcjLYAaT.js +0 -114
- package/dist/chunks/oauth-login-CQcUe9SJ.js +0 -1
- package/dist/chunks/openapi-commands-CAft_Ngg.js +0 -1
- package/dist/chunks/provider-catalog-Dgyf764K.js +0 -1
- package/dist/chunks/text-field-CNn6lG8Y.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
aventure lookup · Read a Company, Product, Service, or Person Identity Without Enrichment ·
|
|
2
|
-
aventure lookup-from-file · Identify a Company, Product, Service, or Person by Name, URL, or ID ·
|
|
1
|
+
aventure lookup · Read a Company, Product, Service, or Person Identity Without Enrichment · -
|
|
2
|
+
aventure lookup-from-file · Identify a Company, Product, Service, or Person by Name, URL, or ID · -
|
|
3
3
|
aventure lookup-mentions · Identify Every Company and Person a Page or Screenshot Names · -
|
|
4
4
|
aventure metrics · Get Platform Totals for Companies, Funding, and People · -
|
|
5
5
|
aventure search · Search Companies, People, and News Together · --query
|
|
@@ -7,7 +7,7 @@ aventure status · Get System Uptime · -
|
|
|
7
7
|
aventure enrichments enrich · Enrich Many Companies and People · -
|
|
8
8
|
aventure entities get · Get One Company, Product, or Service by ID · --entity-id
|
|
9
9
|
aventure entities list · List Companies, Products, and Services · -
|
|
10
|
-
aventure entities lookup · Deprecated: Identify a Company, Product, or Service by Name and Scope ·
|
|
10
|
+
aventure entities lookup · Deprecated: Identify a Company, Product, or Service by Name and Scope · -
|
|
11
11
|
aventure entities lookup-batch · Look Up Companies in Bulk by ID, Slug, or URL · -
|
|
12
12
|
aventure entities lookup-matches · Look Up Which Company Each Identifier Matches · -
|
|
13
13
|
aventure entities search · Search Companies, Products, and Services · -
|
|
@@ -19,7 +19,7 @@ aventure news list · List News Articles, Including a Company's or Person's News
|
|
|
19
19
|
aventure news lookup · Look Up One News Article · -
|
|
20
20
|
aventure people get · Get One Person by ID · --person-id
|
|
21
21
|
aventure people list · List People · -
|
|
22
|
-
aventure people lookup · Deprecated: Find Which Person a Name Refers to, or Confirm They Are New ·
|
|
22
|
+
aventure people lookup · Deprecated: Find Which Person a Name Refers to, or Confirm They Are New · -
|
|
23
23
|
aventure people lookup-batch · Look Up People in Bulk by ID or Slug · -
|
|
24
24
|
aventure people search · Search People · -
|
|
25
25
|
aventure resolve get · Deprecated: Find the Record Behind an ID, Slug, or URL · --token
|
|
@@ -61,7 +61,7 @@ aventure entities investments list · List the Investments a Company Made · --e
|
|
|
61
61
|
aventure entities investor-activity get · Get Investor Activity · --entity-id
|
|
62
62
|
aventure entities investors list · List a Company's Investors · --entity-id
|
|
63
63
|
aventure entities logo get · Get a Company Logo · --entity-id
|
|
64
|
-
aventure entities lookup-exact get · Read Full Entity Detail by Exact Slug, URL, or Domain · -
|
|
64
|
+
aventure entities lookup-exact get · Read Full Entity Detail by Exact Slug, Website, URL, or Domain · -
|
|
65
65
|
aventure entities people get · Get One Person's Role at a Company · --entity-id --association-id
|
|
66
66
|
aventure entities people list · List the People at a Company · --entity-id
|
|
67
67
|
aventure entities person-investors list · List Person Investors · --entity-id
|
|
@@ -88,6 +88,7 @@ aventure entities valuations list · List a Company's Valuation Over Time · --e
|
|
|
88
88
|
aventure harness runs get · Get One Run · --run-id
|
|
89
89
|
aventure news feedback create · Submit News Feedback · -
|
|
90
90
|
aventure news related-entities list · List the Entities a News Article Is About · --news-id
|
|
91
|
+
aventure news subscriptions list · List Entity News Subscriptions · -
|
|
91
92
|
aventure news subscriptions subscribe · Subscribe to Entity News · --arguments-entity-id --delivery-mode --delivery-url --name
|
|
92
93
|
aventure news subscriptions unsubscribe · Unsubscribe From Entity News · --arguments-entity-id --delivery-url --name
|
|
93
94
|
aventure news thumbnail get · Get News Thumbnail · --news-id
|
|
@@ -129,6 +130,7 @@ aventure entities research-details types list · List the Accepted Research Deta
|
|
|
129
130
|
aventure entities research-snippets types list · List the Accepted Research Snippet Types · -
|
|
130
131
|
aventure entities similar summary list · Get Similar Company Summaries by ID · --entity-id
|
|
131
132
|
aventure entities texts types list · List the Accepted Company Text Types · -
|
|
133
|
+
aventure news subscriptions test-events send · Send a Test News Event · --subscription-id
|
|
132
134
|
aventure people content facets list · Count a Person's Publications · --person-id
|
|
133
135
|
aventure people texts types list · List the Accepted Person Text Types · -
|
|
134
136
|
aventure search link jobs get · Get a Link Search Job · --job-id
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{ci as e,hi as t,mi as n,oa as r,oi as i}from"../chunks/client-
|
|
2
|
+
import{ci as e,hi as t,mi as n,oa as r,oi as i}from"../chunks/client-SclaVr61.js";import{t as a,v as o}from"../chunks/oauth-bearer-credential-Bg04hOTJ.js";import{c as s,i as c,t as l}from"../chunks/openapi-commands-BAeIoVUn.js";import{r as u}from"../chunks/text-field-BhCFbqJ5.js";var d=process.argv.slice(2);c(d)&&e(!1),d.includes(`--all-fields`)&&u(!0);try{if(t(),s(d,l)===`optional`)try{await a(),await o()}catch(e){i({component:n().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-BNIgZA3T.js`)}catch(e){if(!(e instanceof r))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"generatedFrom": "MCP_GENERATION_CONTRACT",
|
|
4
|
-
"generatedAt": "2026-10-
|
|
5
|
-
"totalOperations":
|
|
4
|
+
"generatedAt": "2026-10-05T01:55:01.270Z",
|
|
5
|
+
"totalOperations": 135,
|
|
6
6
|
"note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
|
|
7
7
|
"operations": [
|
|
8
8
|
{
|
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
"mcpTool": "aventure_read",
|
|
267
267
|
"bodySchemaName": null,
|
|
268
268
|
"bodySchemaImport": null,
|
|
269
|
-
"auth": "
|
|
269
|
+
"auth": "bearer",
|
|
270
270
|
"scope": "read",
|
|
271
271
|
"destructive": false
|
|
272
272
|
},
|
|
@@ -1086,7 +1086,7 @@
|
|
|
1086
1086
|
"mcpTool": "aventure_read",
|
|
1087
1087
|
"bodySchemaName": null,
|
|
1088
1088
|
"bodySchemaImport": null,
|
|
1089
|
-
"auth": "
|
|
1089
|
+
"auth": "bearer",
|
|
1090
1090
|
"scope": "read",
|
|
1091
1091
|
"destructive": false
|
|
1092
1092
|
},
|
|
@@ -1238,7 +1238,7 @@
|
|
|
1238
1238
|
"mcpTool": "aventure_read",
|
|
1239
1239
|
"bodySchemaName": null,
|
|
1240
1240
|
"bodySchemaImport": null,
|
|
1241
|
-
"auth": "
|
|
1241
|
+
"auth": "bearer",
|
|
1242
1242
|
"scope": "read",
|
|
1243
1243
|
"destructive": false
|
|
1244
1244
|
},
|
|
@@ -1686,6 +1686,25 @@
|
|
|
1686
1686
|
"scope": "write",
|
|
1687
1687
|
"destructive": true
|
|
1688
1688
|
},
|
|
1689
|
+
{
|
|
1690
|
+
"operationId": "listNewsSubscriptions",
|
|
1691
|
+
"method": "GET",
|
|
1692
|
+
"path": "/v1/news/subscriptions",
|
|
1693
|
+
"resource": "news",
|
|
1694
|
+
"intent": "read",
|
|
1695
|
+
"cliCommand": "news subscriptions list",
|
|
1696
|
+
"cliPath": [
|
|
1697
|
+
"news",
|
|
1698
|
+
"subscriptions",
|
|
1699
|
+
"list"
|
|
1700
|
+
],
|
|
1701
|
+
"mcpTool": "aventure_read",
|
|
1702
|
+
"bodySchemaName": null,
|
|
1703
|
+
"bodySchemaImport": null,
|
|
1704
|
+
"auth": "bearer",
|
|
1705
|
+
"scope": "read",
|
|
1706
|
+
"destructive": false
|
|
1707
|
+
},
|
|
1689
1708
|
{
|
|
1690
1709
|
"operationId": "subscribeNewsSubscription",
|
|
1691
1710
|
"method": "PUT",
|
|
@@ -1705,6 +1724,26 @@
|
|
|
1705
1724
|
"scope": "write",
|
|
1706
1725
|
"destructive": false
|
|
1707
1726
|
},
|
|
1727
|
+
{
|
|
1728
|
+
"operationId": "sendNewsSubscriptionTestEvent",
|
|
1729
|
+
"method": "POST",
|
|
1730
|
+
"path": "/v1/news/subscriptions/{subscriptionId}/test-events",
|
|
1731
|
+
"resource": "news",
|
|
1732
|
+
"intent": "write",
|
|
1733
|
+
"cliCommand": "news subscriptions test-events send",
|
|
1734
|
+
"cliPath": [
|
|
1735
|
+
"news",
|
|
1736
|
+
"subscriptions",
|
|
1737
|
+
"test-events",
|
|
1738
|
+
"send"
|
|
1739
|
+
],
|
|
1740
|
+
"mcpTool": "aventure_write",
|
|
1741
|
+
"bodySchemaName": null,
|
|
1742
|
+
"bodySchemaImport": null,
|
|
1743
|
+
"auth": "bearer",
|
|
1744
|
+
"scope": "write",
|
|
1745
|
+
"destructive": false
|
|
1746
|
+
},
|
|
1708
1747
|
{
|
|
1709
1748
|
"operationId": "listPeople",
|
|
1710
1749
|
"method": "GET",
|
|
@@ -1737,7 +1776,7 @@
|
|
|
1737
1776
|
"mcpTool": "aventure_read",
|
|
1738
1777
|
"bodySchemaName": null,
|
|
1739
1778
|
"bodySchemaImport": null,
|
|
1740
|
-
"auth": "
|
|
1779
|
+
"auth": "bearer",
|
|
1741
1780
|
"scope": "read",
|
|
1742
1781
|
"destructive": false
|
|
1743
1782
|
},
|
|
@@ -2249,7 +2288,7 @@
|
|
|
2249
2288
|
"mcpTool": "aventure_read",
|
|
2250
2289
|
"bodySchemaName": null,
|
|
2251
2290
|
"bodySchemaImport": null,
|
|
2252
|
-
"auth": "
|
|
2291
|
+
"auth": "bearer",
|
|
2253
2292
|
"scope": "read",
|
|
2254
2293
|
"destructive": false
|
|
2255
2294
|
},
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{C as e,Di as t,Ei as n,S as r,Si as i,T as a,Ti as o,_ as s,a as c,aa as l,b as u,bi as d,c as f,d as p,f as m,fi as h,gi as g,i as _,ia as v,ii as y,l as b,mi as x,n as ee,o as S,oi as te,p as ne,r as re,ra as ie,sa as ae,u as oe,v as se,vi as ce,wi as le,xi as ue,yi as de}from"./client-SclaVr61.js";import{M as fe,O as pe,i as C,o as me,v as he,w,y as T}from"./person-owner-BJgNYLKX.js";import{A as ge,C as _e,D as ve,M as E,N as ye,O as be,S as xe,T as Se,a as Ce,b as we,c as Te,d as Ee,g as De,j as Oe,k as ke,l as Ae,m as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./oauth-bearer-credential-Bg04hOTJ.js";import{C as Ve,S as He,_ as Ue,a as We,b as Ge,c as Ke,d as qe,f as Je,g as Ye,h as Xe,l as Ze,m as Qe,n as $e,o as D,p as et,r as O,s as tt,t as k,u as nt,v as rt,x as it,y as at}from"./openapi-commands-BAeIoVUn.js";import{a as ot}from"./text-field-BhCFbqJ5.js";import{a as st,n as ct,o as lt,r as ut,t as dt}from"./text-response-D7u2LftD.js";import{n as ft,r as pt,t as mt}from"./oauth-login-DCuPY5A9.js";import{spawnSync as ht}from"node:child_process";import{basename as gt,dirname as A,resolve as j,sep as _t}from"node:path";import{copyFileSync as vt,existsSync as yt,lstatSync as bt,mkdirSync as xt,mkdtempSync as St,readFileSync as Ct,readlinkSync as wt,realpathSync as Tt,renameSync as Et,rmdirSync as Dt,unlinkSync as Ot,writeFileSync as kt}from"node:fs";import M,{stderr as N,stdin as At}from"node:process";import{TextDecoder as jt,inspect as Mt}from"node:util";import{fileURLToPath as Nt}from"node:url";import{readFile as Pt}from"node:fs/promises";import{webcrypto as Ft}from"node:crypto";import{homedir as It,hostname as Lt,platform as Rt}from"node:os";import{setTimeout as zt}from"node:timers/promises";import{createInterface as Bt}from"node:readline/promises";function Vt(e,t,r){let i={...r};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let r=process.env[t]?.trim();if(r===void 0||r.length===0)continue;let a=i[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==r))return{...o(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${r}.`),data:i};a===void 0&&(i[n.optionKey]=r)}return n(`Environment-bound options applied`,i)}function Ht(e,t,n){if(!P(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!nn(n,r.name))continue;let a=tn(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function Ut(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function Wt(e,t,r,i=!1){if(i||!on(t)||!Array.isArray(r))return cn(e,t,r);for(let[n,i]of r.entries()){let r=cn(e,t,i,n);if(!r.ok)return r}return n(`Body value assigned`,null)}function Gt(e,t,n,r){return cn(e,t,r,n)}function Kt(e){let t=[];for(let n of e.split(`.`)){let e=un(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function qt(e,t){let n=Kt(t);if(n===null)return null;let r=en(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:$t(r)}:null}function Jt(e,t){if(on(e.name)||e.schemaType===`array`)return n(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return n(`Scalar body option selected`,t);let r=e.flag.split(` `)[0]??e.name;return t.length===1?n(`Scalar body option selected`,t[0]):o(`${r} was already given; pass it once.`)}var Yt=/^(?<row>\d+):(?<item>.*)$/su;function Xt(e,t){let n=Kt(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=Yt.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function Zt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Kt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Qt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=qt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return o(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Xt(i,t)!==null)continue;let s=i.flag.split(` `)[0]??i.name;return o(`${s} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function $t(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function en(e,t){let n=e;for(let e of t){if(!P(n))return;n=n[e]??null}return n}function tn(e,t){if(!on(t))return en(e,t.split(`.`))}function nn(e,t){return an(e,t.split(`.`))}function rn(e,t,n){if(!P(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&nn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function an(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=un(n);if(!P(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>an(e,r)):an(a,r)}function on(e){return e.split(`.`).some(e=>un(e).isArray)}function sn(e,t){return e.parameter.length===0||!P(t)?null:fn(t,[],dn(e.parameter))}function P(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cn(e,t,r,i=0){let a=t.split(`.`),s=e;for(let[e,c]of a.entries()){let l=un(c),u=e===a.length-1,d=ln(s,l,t,u,r,i);if(!d.ok||d.data===null)return o(d.summary,d.warnings);if(u)return n(`Body value assigned`,null);s=d.data}return o(`${t} is not a valid body option path.`)}function ln(e,t,r,i,a,s){let c=()=>o(`${r} cannot be combined with another body option at ${t.key}.`),l=e[t.key];if(t.isArray){if(l!==void 0&&!Array.isArray(l))return c();let r=l??[];if(l===void 0&&(e[t.key]=r),i)return r[s]===void 0?(r[s]=a,n(`Body value assigned`,e)):c();let o=r[s];if(o===void 0){let e={};return r[s]=e,n(`Body path created`,e)}return P(o)?n(`Body path stepped`,o):c()}if(i)return l===void 0?(e[t.key]=a,n(`Body value assigned`,e)):c();if(l===void 0){let r={};return e[t.key]=r,n(`Body path created`,r)}return P(l)?n(`Body path stepped`,l):c()}function un(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function dn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function fn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=fn(r,t,n);if(e!==null)return e}return null}if(!P(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!pn(a,n)){if(!mn(e))continue;return{path:a,suggestion:hn(e,n)}}let o=fn(i,e,n);if(o!==null)return o}return null}function pn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function mn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function hn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:gn(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function gn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}function _n(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&t.helpGroup(He(e))}e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?Tn(r,i):r===void 0?i===void 0?0:1:-1})}function vn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function yn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function bn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Cn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function xn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Sn(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?Ve(n):`${Ve(n)} Required JSON paths: ${r.join(`, `)}.`}function Cn(e,t){let n=Ge(t.description,void 0),r=e.kind!==`multipart`&&on(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${wn(e,t)}`}function wn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Kt(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function Tn(e,t){return it(e)-it(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function En(e){let t;try{t=e===`-`?await Dn():await Pt(e,`utf8`)}catch(t){return o(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return n(`No input provided`,null);let e=JSON.parse(t);return n(`Input parsed`,e)}catch(e){return o(`Input is not valid JSON: ${e.message}`)}}async function Dn(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var On=`--content-type`;function kn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(On)){let t=i.map(({contentType:e})=>e);e.addOption(new v(`${On} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(jn(i)))}if(Xn(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new v(`--from-file <path>`,Sn(n,n.requiredPath)).argParser(Nn(`--from-file`)))}let a=vn(i).filter(e=>r(F(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>Tn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new v(yn(t),i.length>1?bn(t):Cn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?xn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(An):on(r.name)||r.schemaType===`array`?a.argParser(Mn):a.argParser(Nn(r.flag)),e.addOption(a),a.envVar!==void 0&&e.on(`optionEnv:${a.name()}`,()=>{let t=e.opts()[r.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(r.optionKey,t.trim(),`env`)})}Yn(e,t,a)}function An(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function jn(e){return(t,n)=>{if(n!==void 0)throw new ae(`${On} was already given; pass it once.`);let r=a(e,t);if(!r.ok)throw new ae(r.summary);return t}}function Mn(e,t){return[...t??[],e]}function Nn(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new ae(`${t} was already given; pass it once.`);return e}}async function Pn(e,t){let r=qe(e,t),i=a(e.requestBody??[],r);if(!i.ok||i.data===null)return o(i.summary,i.warnings);let s=i.data;if(s===void 0)return n(`No body`,void 0);let c=Fn(e,s,t);if(c!==null)return o(c);let l=Vt(e.operationId,s,t);if(!l.ok)return o(l.summary,l.warnings);t=l.data;let u=In(s,t);if(u!==null)return o(u);let d=await Bn(t);if(!d.ok)return o(d.summary,d.warnings);let f=rn(e.requestBody??[],s,d.data);if(f!==null)return o(f);let p=zn(e.operationId,s,d.data);if(!p.ok)return p;let m=Ht(e.operationId,s,d.data);if(m!==null)return o(m);let h=Vn(e.operationId,s,t);if(!h.ok)return h;if(d.data===void 0&&h.data===void 0)return s.required?o(Jn(e.operationId,s)):n(`No body`,void 0);let g=Un(e.operationId,d.data,h.data);if(!g.ok||g.data===void 0)return g;if(s.schemaType===`array`&&!Array.isArray(g.data))return o(`${e.operationId} requires a JSON array body.`);if(s.parameter.length>0&&!P(g.data)){let t=s.kind===`multipart`?` keyed by multipart part name`:` body`;return o(`${e.operationId} requires a JSON object${t}.`)}let _=Rn(s,g.data);if(_.length>0)return o(`${e.operationId} requires body option(s): ${_.join(`, `)}`);let v=g.data,y=P(v)?Ut(s).filter(e=>!nn(v,e)):[];return y.length>0?o(Ln(e.operationId,s,y)):g}function Fn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${F(t)} requires ${On} ${i.join(` or `)}.`}return null}function In(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Ln(e,t,n){let r=`${e} requires JSON body path(s): ${n.join(`, `)}`;return t.kind===`multipart`?`${r}. ${n.includes(`body`)?`For multipart --from-file, wrap the endpoint JSON under top-level "body".`:`For multipart --from-file, put the missing nested path(s) inside top-level "body".`}`:r}function Rn(e,t){return P(t)?e.parameter.filter(e=>e.required&&!nn(t,e.name)).map(F):[]}function zn(e,t,r){let i=sn(t,r);if(i===null)return n(`Body file paths validated`,null);let a=i.suggestion===void 0?``:` Use ${i.suggestion}.`;return o(`${e} --from-file contains unknown JSON path ${i.path}.${a}`)}async function Bn(e){let r=typeof e.fromFile==`string`?e.fromFile:void 0;if(r===void 0)return n(`No body file`,void 0);let i=await En(r);if(!i.ok)return o(i.summary,i.warnings);let a=t.safeParse(i.data);return a.success?n(`Input parsed`,a.data):o(`Input is not valid JSON value: ${a.error.message}`)}function Vn(e,t,r){let i={},a=!1;for(let e of t.parameter){let n=Jt(e,r[e.optionKey]);if(!n.ok||n.data===null)return o(n.summary,n.warnings);let s=n.data;if(s===void 0)continue;let c=Hn(t,r,i,e,s);if(!c.ok)return o(c.summary,c.warnings);a=!0}if(!a)return n(`No direct body options`,void 0);let s=Qt(e,t,r,i);return s===null?n(`Direct body options parsed`,i):s}function Hn(e,t,r,i,a){let s=Xt(i,a);if(s===null){let e=Kn(i,a);return e.ok?Wt(r,i.name,e.data,i.schemaType===`array`):o(e.summary,e.warnings)}if(s.plain.length>0)return o(`${F(i)} mixes row-form values with plain value(s): ${s.plain.join(`, `)} — prefix every value with its 0-based ${s.container}[] row index, as 0:value.`);let c=Zt(e,t,s.container);for(let e of s.rows.keys())if(!(e<c))return o(`${F(i)} names ${s.container}[] row ${e}, but these options build at most ${c} ${s.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of s.rows){let n=[];for(let e of t){let t=qn(i.name,i.itemSchemaType,e);if(!t.ok)return o(t.summary,t.warnings);n.push(t.data)}let a=Gt(r,i.name,e,n);if(!a.ok)return a}return n(`Body value assigned`,null)}var F=e=>e.flag.split(` `)[0]??e.name;function Un(e,t,r){if(t===void 0)return n(`Direct body parsed`,r);if(r===void 0)return n(`Input parsed`,t);if(P(t)&&P(r))try{return n(`Input parsed`,Wn(t,r))}catch(t){return o(`${e} ${t.message}`)}return o(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Wn(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(Array.isArray(t)&&Array.isArray(r))throw Error(`cannot combine --from-file array '${e}' with array body options at the same key — move the per-item fields inside the matching '${e}[]' object(s) in the file body.`);if(t!==void 0&&Gn(t)!==Gn(r))throw Error(`cannot combine --from-file ${Gn(t)} '${e}' with ${Gn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=P(t)&&P(r)?Wn(t,r):r}return n}function Gn(e){return Array.isArray(e)?`array`:P(e)?`object`:`scalar`}function Kn(e,t){if(typeof t==`boolean`)return n(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return qn(e.name,e.schemaType,t??``);let r=[],i=on(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let n of t){let t=qn(e.name,i,n);if(!t.ok)return t;r.push(t.data)}return n(`Body value parsed`,r)}function qn(e,t,r){if(t===`boolean`)return r===`true`?n(`Body value parsed`,!0):r===`false`?n(`Body value parsed`,!1):o(`${e} must be true or false.`);if(t===`number`||t===`integer`){let i=r.trim(),a=Number(i);return i===``||!Number.isFinite(a)?o(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(a)?o(`${e} must be an integer.`):n(`Body value parsed`,a)}return n(`Body value parsed`,r)}function Jn(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(F).join(`, `)}`;let r=Ut(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(F).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Yn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:On,location:`body`}),Xn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),_n(e.options,r)}function Xn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Zn(e){let t=le(e);return or(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Qn(e){or(e);let t=dt(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
2
|
+
`)?t:`${t}\n`),$n(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&nr(e.problem),$n(e)}function $n(e){e.ids.length>0&&process.stdout.write(` ids: ${e.ids.join(`, `)}\n`);for(let[t,n]of Object.entries(e.counts))process.stdout.write(` ${t}: ${n}\n`);for(let t of e.references)process.stdout.write(` ref: ${t}\n`);if(e.truncation!==void 0){let t=e.truncation.omitted.join(`, `);process.stdout.write(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${t}\n`),process.stdout.write(` recovery: ${e.truncation.recovery}\n`)}for(let t of e.warnings)process.stdout.write(` warn: ${t}\n`)}function I(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?le(t):t;or(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?er(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Zn(t):t;e.mode===`text`&&Qn(n),n.ok||(process.exitCode=1)}function er(e){return typeof e!=`object`||!e||Array.isArray(e)||!Reflect.has(e,`method`)||!Reflect.has(e,`endpoint`)||!(`response`in e)||e.response===void 0?e:e.response}function tr(e,t){let n=ct(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
|
|
3
|
+
`),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function nr(e){typeof e.code==`string`&&process.stdout.write(` code: ${e.code}\n`),typeof e.detail==`string`&&process.stdout.write(` detail: ${e.detail}\n`),typeof e.hint==`string`&&process.stdout.write(` hint: ${e.hint}\n`),typeof e.suggestion==`string`&&process.stdout.write(` suggestion: ${e.suggestion}\n`);let t=Object.entries(e.suggestions??{});if(t.length>0){let e=t.map(([e,t])=>`${e}=${t}`).join(`; `);process.stdout.write(` suggestions: ${e}\n`)}typeof e.requiredRole==`string`&&process.stdout.write(` requiredRole: ${e.requiredRole}\n`),rr(e),ir(`unknownParameters`,e.unknownParameters),ir(`validParameters`,e.validParameters),ar(e.resolution)}function rr(e){let t=[];typeof e.limitType==`string`&&t.push(`limitType=${e.limitType}`),typeof e.used==`number`&&t.push(`used=${e.used}`),typeof e.limit==`number`&&t.push(`limit=${e.limit}`),typeof e.remaining==`number`&&t.push(`remaining=${e.remaining}`),typeof e.resetAt==`string`&&t.push(`resetAt=${e.resetAt}`),typeof e.windowSeconds==`number`&&t.push(`windowSeconds=${e.windowSeconds}`),typeof e.retryAfterSeconds==`number`&&t.push(`retryAfterSeconds=${e.retryAfterSeconds}`),t.length>0&&process.stdout.write(` meter: ${t.join(` `)}\n`)}function ir(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function ar(e){if(e==null)return;let t=[`action=${e.action}`];typeof e.parameter==`string`&&t.push(`parameter=${e.parameter}`),typeof e.fieldPath==`string`&&t.push(`fieldPath=${e.fieldPath}`),typeof e.endpoint==`string`&&t.push(`endpoint=${e.endpoint}`),e.acceptedValue!==null&&e.acceptedValue!==void 0&&e.acceptedValue.length>0&&t.push(`acceptedValue=${e.acceptedValue.join(`, `)}`),typeof e.retryable==`boolean`&&t.push(`retryable=${e.retryable}`),process.stdout.write(` resolution: ${t.join(` `)}\n`)}function or(e){e.ok&&e.warnings.length===0||te({component:x().bin[0],event:e.ok?`command_warning`:`command_failed`,message:e.warnings.length>0?e.warnings.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function sr(e,t,r=x().bin[0]){let i=e.limit===void 0?void 0:Number(e.limit);if(i!==void 0&&(e.limit?.trim()===``||!Number.isInteger(i)||i<0))return o(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let a=ut(e.q??``,ur(t,r).filter(t=>mr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)]})).map(({item:e})=>e),s=a.slice(0,i);return n(`Operation catalog matches`,{operation:s,count:{totalOperations:t.length,matched:a.length,returned:s.length}})}function cr(e,t,r=x().bin[0]){let i=ur(t,r),a=e.operationId===void 0?lr(i,e.command):i.find(t=>t.operationId===e.operationId);if(a===void 0){let n=Dr(e.command??``),a=i.map(e=>e.cli.command).filter(e=>e.startsWith(`${r} ${n} `));if(a.length>0)return o(`${n} is a command group; show one of its subcommands.`,[`Run \`${r} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let s=n.split(` `),c=new Set([...[...s.keys()].map(e=>s.slice(e+1).join(` `)),...s.slice(1).map((e,t)=>s.toSpliced(t,2,`${s[t]}-${e}`).join(` `))]),l=sr({q:e.command??e.operationId},t,r),u=[...i.filter(({cli:e})=>e.path.length>1&&c.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...l.data?.operation??[]];return o(`Generated operation not found`,[...[...new Set(u.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${r} command-catalog search "<text>"\`.`])}return n(`Generated operation detail`,{operation:a,usage:gr(a,i)})}function lr(e,t){if(t===void 0)return;let{bin:n}=x(),r=Dr(t,n);return e.find(e=>Dr(e.cli.command,n)===r)}function ur(t,n){return t.map(t=>{let i=t.requestBody??[],a=[...t.parameters.map(e=>dr(e)),...i.flatMap(e=>e.parameter.map(t=>dr(t,i.length>1?e.contentType:void 0))),...fr(i)],o=[n,...t.cliPath].join(` `),s=r(t.intent),c=t.method===`DELETE`||t.intent===`delete`,l=i[0];return{operationId:t.operationId,method:t.method,path:t.path,resource:t.resource,intent:t.intent,scope:t.scope,mutates:s,destructive:c,auth:t.auth,cli:{command:o,path:t.cliPath},mcpTool:t.binaryResponse?null:e(t.intent),body:{hasBody:l!==void 0,kind:l?.kind??null,...l!==void 0&&i.length>1?{contentType:l.contentType}:{},required:l?.required??!1,description:l?.description??``,requiredPath:l?.requiredPath??[]},flags:a,errorResponse:t.errorResponse,summary:t.summary,description:t.description,deprecated:t.deprecated}})}function dr(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function fr(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request content type; omit for ${t[0]}.`,choices:t}]}function pr(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function mr(e,t){return!(t.root!==void 0&&!hr(e,t.root)||t.scope!==void 0&&t.scope!==`all`&&t.scope!==e.scope||t.mutates!==void 0&&t.mutates!==`any`&&t.mutates===`true`!==e.mutates||t.destructive!==void 0&&t.destructive!==`any`&&t.destructive===`true`!==e.destructive||t.intent!==void 0&&t.intent!==`all`&&t.intent!==e.intent||t.method!==void 0&&t.method!==`all`&&t.method!==e.method)}function hr(e,t){let n=lt(t);return n.length===0||lt(e.cli.path.at(0)??``)===n}function gr(e,t){let n=pr(e),r=n.filter(e=>e.required),i=n.filter(e=>!e.required);return[`cli: ${e.cli.command}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (binary CLI operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,L(`required path flags`,r,`path`),L(`required query flags`,r,`query`),L(`required header flags`,r,`header`),L(`required body flags`,r,`body`),L(`optional path flags`,i,`path`),L(`optional query flags`,i,`query`),L(`optional header flags`,i,`header`),L(`optional body flags`,i,`body`),...Sr(e,t),..._r(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
4
|
+
`)}function _r(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var vr=[`-id`,`-slug`,`-url`],yr=[`--id`,`--slug`,`--url`],br=`--from-file "<path>"`;function xr(e,t,n=x().bin[0]){let r=ur(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:Sr(i,r)}function Sr(e,t){return[`example: ${[e.cli.command,...wr(e),`--data`].join(` `)}`,...Cr(e,t)]}function Cr(e,t){return pr(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${Er(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===r.path.replace(/-exact$/u,``)),s=o?.flags.find(e=>e.optionKey===`name`),c=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0?[c]:[c,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${Er(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}function wr(e){let t=pr(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,br]:n}function Tr(e){let t=new Set;st(t,e.resource);for(let n of vr)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of yr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function Er(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function L(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function Dr(e,t=x().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var Or=`dist/aventure-cli/command-catalog.compact.txt`,kr=` · `,Ar=`-`;function jr(e=x().bin[0]){return j(Mr(A(Nt(import.meta.url)),e),Or)}function Mr(e,t){let n=e;for(;;){if(yt(j(n,`package.json`)))return n;let r=A(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Nr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Pr(e,t,n,r=x().bin[0]){let i=sr(e,t,r);if(!i.ok||i.data===null){I({mode:n},i);return}Ir({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Rr(i.data,Lr(e.format,`lines`)),summary:`Generated operation matches`})}function Fr(e,t,n,r=x().bin[0]){let i=cr(e,t,r);if(!i.ok||i.data===null){I({mode:n},i);return}Ir({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:zr(i.data,Lr(e.format,`usage`)),summary:`Generated operation detail`})}function Ir(e){let t=e.mode,r=Lr(e.opts.format,e.defaultFormat),i=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&i&&(r===`json`||r===`ndjson`)){I({mode:t},o(`--text or --all-fields cannot be combined with --format json or ndjson`,[`Omit the text flag for machine output, or use --format lines, compact, or text.`]));return}let a=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.matched===0&&(i||e.opts.format===void 0||r===`text`)?`No generated operations matched.`:e.rendered,s=a.endsWith(`
|
|
5
|
+
`)?a:`${a}\n`;if(e.opts.output!==void 0){kt(e.opts.output,s),I({mode:t},n(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(s,`utf8`),format:r},{counts:Wr(e.data)}));return}if(t===`text`){process.stdout.write(s);return}I({mode:t},n(e.summary,e.data,{counts:Wr(e.data)}))}function Lr(e,t){return e??t}function Rr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
|
|
6
|
+
`):t===`text`?Hr(e.operation):t===`compact`?e.operation.map(Br).join(`
|
|
7
|
+
`):e.operation.map(Ur).join(`
|
|
8
|
+
`)}function zr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?Ur(e.operation):t===`compact`?Br(e.operation):e.usage}function Br(e){let t=Vr(e);return[e.cli.command,e.summary,t.length===0?Ar:t.join(` `)].join(kr)}function Vr(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function Hr(e){return e.map(e=>`${e.cli.command}\n ${Ur(e)}`).join(`
|
|
9
|
+
`)}function Ur(e){let t=Vr(e);return[R(`operationId`,e.operationId),R(`scope`,e.scope),R(`mutates`,String(e.mutates)),R(`destructive`,String(e.destructive)),R(`intent`,e.intent),R(`resource`,e.resource),R(`cli`,e.cli.command),e.mcpTool===null?``:R(`mcpTool`,e.mcpTool),R(`method`,e.method),R(`path`,e.path),R(`auth`,e.auth),R(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),R(`requiredFlags`,t.join(` `)),R(`bodyKind`,e.body.kind??``),R(`bodyRequired`,String(e.body.required)),R(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function R(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function Wr(e){return`count`in e?e.count:{returned:1}}function Gr(e,t,r=x().bin[0]){e.helpCommand(!1);let i=e.commands.find(e=>e.name()===`help`)??e.command(`help`);i.summary(`Show full documentation for a command, or ask a question`).description([`Show a command's full documentation offline. Select it by command path,`,"operationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.","`help ask <question>` or `help --ask <question>` answers a platform question."].join(`
|
|
10
|
+
`)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),i.addOption(new Kr(i)),i.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let a=Qr(t);a!==void 0&&i.option(`--ask <question>`,a.summary),O(i),i.action(async function(i){let s=this.optsWithGlobals();if(s.help&&i.length===0){this.outputHelp();return}if(!s.help&&a!==void 0&&s.ask!==void 0){let e=D(s);if(i.length>0){I({mode:e},o(`Use either a command path or --ask, not both.`));return}I({mode:e},await ni(a,s.ask,s.environment,e));return}let c=ti(e,i),l=t.find(t=>c!==void 0&&ti(e,t.cliPath)===c);if(s.help||c!==void 0&&l===void 0){c===void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${r} --help\` for the command tree)`),c.outputHelp();return}let u=l===void 0?ei(i,t):n(`Resolved by command path`,{operationId:l.operationId});if(u.ok&&u.data?.command!==void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${r} --help\` for the command tree)`),!u.ok||u.data===null){I({mode:D(s)},u);return}Fr({...s,...u.data},t,D(s,`text`),r)}),Zr(e,t,r)}var Kr=class extends v{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))}},qr=2,Jr=6,Yr={formatHelp(e,t){let n=n=>l.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let r=t.padWidth(e,t),i={padWidth:()=>r,visibleOptions:()=>[],showGlobalOptions:!1},a=n({...i,visibleCommands:()=>[]}),o=n({padWidth:()=>r,visibleCommands:()=>[]}).slice(a.length);return n(i)+o},visibleCommands(e){let t=l.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!rt.has(e.name())):t},subcommandTerm(e){let t=l.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,r){let i=r.helpWidth??80,a=i-t-4;return n===``||a>=r.minWidthToWrap?l.prototype.formatItem.call(r,e,t,n,r):`${` `.repeat(qr)}${e}\n${Xr(n,i,r)}`}};function Xr(e,t,n){return n.boxWrap(e,t-Jr).replace(/^/gmu,` `.repeat(Jr))}function Zr(e,t,n){for(let r of t){let i=ti(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp();e.prepareContext({helpWidth:i.configureOutput().getOutHelpWidth?.()});let a=e.helpWidth??80,o=xr(r.operationId,t,n),[s,...c]=_r(r.errorResponse),l=c.map(t=>Xr(t.trimStart(),a,e).replace(/^ +/u,` `.repeat(qr))),u=s===void 0?[]:[``,s,...l];return`\n${[...o,...u].join(`
|
|
11
|
+
`)}\n`})}}function Qr(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&ri(e)!==void 0});return n.length===0?t:void 0}var $r='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ei(e,t){let[r,...i]=e,a=m.find(e=>e===r?.toLowerCase());if(a===void 0||i.length===0){let r=e.join(` `).trim();return n(`Resolved by name`,t.some(e=>e.operationId===r)?{operationId:r}:{command:r})}let s=f(a),l=i.join(``),u=t.find(e=>e.method===s&&e.path===l);if(u!==void 0)return n(`Resolved by route template`,{operationId:u.operationId});let d=c({method:s,path:l});return!d.ok||d.data===null?o(d.summary,[...d.warnings,$r]):n(`Resolved by method and path`,{operationId:d.data.operation.operationId})}function ti(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 ni(e,t,n,r){let i=ri(e);if(i===void 0)return o(`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 Pn(e,{[i.optionKey]:t});return a.ok?await S({method:e.method,path:re(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:We(r)?`json`:`auto`}):a}function ri(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 ii(e,t,n){if(e.cliPath[0]!==`lookup`||!ai(n))return null;let r=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`),i=`no record for ${r.length===0?`the given input`:r.join(`, `)}`;return n.ok?o(i):o(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ai(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}var oi=T({artifact:w().nullish(),group:w().nullish(),name:w().nullish(),revision:w().nullish(),time:C({offset:!0}).nullish(),version:w().nullish()}),si=T({build:oi});function z(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 ci=me([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),li=me([`RSA_OAEP_256_A256_GCM_V1`]),ui=T({clientLabel:w().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:ci.nullish(),encryptionAlgorithm:li.nullish(),encryptionPublicKey:w().min(344).max(12e3).nullish()}),di=32;async function fi(){let e=await Ft.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await Ft.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function pi(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=mi(n,`wrapped key`,128,1024),s=mi(r,`nonce`,12,12),c=mi(i,`ciphertext`,1,65536),l=mi(a,`authentication tag`,16,16),u;try{u=await Ft.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!==di)throw Error(`broker credential used an invalid AES-256 key`);let e=await Ft.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 Ft.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new jt(`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 mi(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 hi=me([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),gi=me([`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`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),_i=T({approvedAt:C({offset:!0}).nullish(),clientLabel:w(),clientPlatform:ci,comparisonCode:w(),consumedAt:C({offset:!0}).nullish(),createdAt:C({offset:!0}),expiresAt:C({offset:!0}),id:pe(),intervalSeconds:he().int().min(1),keyReadyAt:C({offset:!0}).nullish(),status:hi,terminalAt:C({offset:!0}).nullish(),terminalReason:gi.nullish(),updatedAt:C({offset:!0})}),vi=T({algorithm:li,authenticationTag:w(),ciphertext:w(),nonce:w(),wrappedKey:w()}),yi=T({delivery:vi.nullish(),expiresAt:C({offset:!0}),status:hi,terminalReason:gi.nullish()}),bi=T({comparisonCode:w(),expiresAt:C({offset:!0}),id:pe(),intervalSeconds:he().int().min(1),pollSecret:w(),verificationUrl:w()}),B=[{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 aVenture 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 aVenture 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 API 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 API Key and Forget Stored OAuth`,description:`Revokes the aVenture API key authenticating this request and returns its metadata so the CLI can confirm revocation before deleting its saved copy.`,operationId:`revokeCurrentApiKey`,method:`DELETE`,path:`/v1/auth/api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Delete the saved key even when revocation cannot be confirmed.`}]}],xi=z(B,`start`),Si=z(B,`poll`),Ci=z(B,`acknowledge`),V=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${ye(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=ki(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},wi=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${E(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function Ti(e){let t=await b(ge(i()),{method:xi.method,path:ne(xi.path,{},xi.operationId),headers:{},contentType:`application/json`,body:e},bi);if(t.ok&&t.redirect)throw new V(`start`,Ai(t.status));if(!t.ok)throw new V(`start`,t.problem);return ji(t.data)}async function Ei(e,t){let n=_(Si.operationId),r=await b(ge(i()),{method:Si.method,path:ne(Si.path,{cliAuthorizationId:e},Si.operationId),headers:{[n]:t}},yi);if(r.ok&&r.redirect)throw new V(`poll`,Ai(r.status),[t]);if(!r.ok)throw new V(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Oi(r.headers[`retry-after`])}}async function Di(e,t){let n=_(Ci.operationId),r;try{r=await b(ge(i()),{method:Ci.method,path:ne(Ci.path,{cliAuthorizationId:e},Ci.operationId),headers:{[n]:t}},_i)}catch(e){throw new wi(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new V(`acknowledge`,Ai(r.status),[t]);if(!r.ok)throw new V(`acknowledge`,r.problem,[t]);return r.data}function Oi(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function ki(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Ai(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function ji(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())})`},[Mt.custom]:{enumerable:!1,value:a}})}async function Mi(e){let t=await Ni(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await _e(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`),verification:t}}catch(n){return{stored:e,verification:{state:`unavailable`,summary:`${t.summary}, but the cached metadata could not be updated — ${E(n,[e.credential.secret])}`}}}}async function Ni(e){let t=ge(i()),n;try{n=await b(t,{method:`GET`,path:re(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},Re)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${E(t,[e])}`}}return n.ok&&n.redirect?{state:`unavailable`,summary:`identity verification returned unexpected redirect ${n.status}`}:n.ok?n.data.status===`ACTIVE`?{state:`verified`,summary:`API key verified by aVenture sign-in`,apiKey:n.data}:{state:`invalid`,summary:`API key is not active`}:{state:n.problem.status===401||n.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${ye(n.problem,[e])}`}}var Pi=z(B,`revoke`);async function Fi(e){let t;try{t=Be(i().host)}catch(e){return o(`auth logout: invalid API host — ${E(e)}`)}let r=await Ii(t),a=await zi(t,e),s=r.state===`failed`?[`OAuth credential could not be removed — ${r.summary}`]:r.state===`forgotten`&&!r.revoked?[`OAuth refresh token was not revoked remotely — ${r.summary??`no revocation endpoint`}`]:[],c={host:t,revoked:!1,forgotten:!1,oauth:r};return a===null?r.state===`missing`?n(`No CLI credential is stored for this API host.`,c):r.state===`failed`?{...o(`auth logout: ${s[0]}`),data:c}:n(r.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,c,{warnings:s}):{...a,data:{...a.data??c,oauth:r},warnings:[...a.warnings,...s]}}async function Ii(e){let t=await Me(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Ri(t.stored):{revoked:!1};try{await Ce(e)}catch(e){return{state:`failed`,summary:E(e)}}return{state:`forgotten`,...n}}async function Li(e){let t=Reflect.get(await mt(e),`revocation_endpoint`);return typeof t==`string`?De(t,`revocation endpoint`,!0):void 0}async function Ri(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Li(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:Ie(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:E(e,je(n))}}}async function zi(e,t){let r;try{r=await xe(e)}catch(e){return o(`auth logout: stored credential could not be read — ${E(e)}`)}if(r.state===`unavailable`)return{...o(`auth logout: ${r.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(r.state===`missing`)return null;let i=r.stored,a=await Bi(i),s=a.outcome===`revoked`,c=i.activation===`pending`&&a.outcome===`rejected`;if(!s&&!c&&!t.forgetLocal)return{...o(`auth logout: remote revocation was not confirmed; local credential preserved — ${a.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:Vi(i,!1,!1)};try{await we(i.host)}catch(e){return{...o(`auth logout: local credential removal failed — ${E(e,[i.credential.secret])}`,[s?"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:Vi(i,s,!1)}}return n(s?`API key revoked remotely and removed locally.`:c?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,Vi(i,s,!0),{ids:[i.credential.apiKey.id],warnings:s||c?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Bi(e){let t=ge(i());try{let n=await b(t,{method:Pi.method,path:ne(Pi.path,{},Pi.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},Re);return n.ok&&n.redirect?{outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${n.status}`}: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 API 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:ye(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:E(t,[e.credential.secret])}}}function Vi(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Hi=`RSA_OAEP_256_A256_GCM_V1`,Ui=1,Wi=30,Gi=x().bin[0],Ki=`The local record remains pending and unavailable to ordinary commands. Re-run \`${Gi} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function qi(e){if(!At.isTTY)return o(`${Gi} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,r;try{let e=i().host;t=Be(e),r=ke(e)}catch(e){return o(`auth login --key: invalid environment configuration — ${E(e)}`)}for(;;){let e;try{e=await ze(t)}catch(e){return o(`auth login --key: credential storage could not be inspected — ${E(e)}`)}if(e.state===`unavailable`)return o(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&N.write(Se(e.keyringFailure));break}let n=await Ji(e.stored);if(n!==null)return n}let a;try{a=await fi()}catch(e){return o(`auth login --key: ephemeral encryption key could not be created — ${E(e)}`)}let s=ui.safeParse({clientLabel:e.clientLabel?.trim()||(Lt().trim()||Gi).slice(0,120),clientPlatform:Qi(),encryptionAlgorithm:Hi,encryptionPublicKey:a.publicKey});if(!s.success)return o(`auth login --key: ${fe(s.error)}`);let c;try{c=await Ti(s.data)}catch(e){return o(`auth login --key: could not start browser authorization — ${E(e)}`)}let l;try{l=be(c,r)}catch(e){return o(`auth login --key: unsafe browser authorization URL rejected — ${E(e)}`)}if(!Zi(await ve(c,r,{noBrowser:e.noBrowser}),c,l))return o(`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:[l]});let u;try{u=await Xi(c)}catch(e){return o(`auth login --key: authorization did not complete — ${E(e)}`,[],{references:[l]})}if(u.algorithm!==Hi)return o(`auth login --key: broker selected an unsupported encryption algorithm`);let d;try{d=await pi(a.privateKey,u)}catch(e){return o(`auth login --key: encrypted credential could not be opened — ${E(e)}`)}let f=await Ni(d);if(f.state!==`verified`)return o(`auth login --key: decrypted credential was neither stored nor acknowledged — ${f.summary}`);let p;try{p=await _e(t,{apiKey:f.apiKey,secret:d},`pending`)}catch(e){return o(`auth login --key: credential could not be durably stored — ${E(e)}`)}let m;try{m=await Yi(c)}catch(e){return H(p,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${E(e,[c.pollSecret])}`,Ki)}if(m.status!==`CONSUMED`)return H(p,!0,`auth login --key: broker returned ${m.status} after acknowledgment`,Ki);let h=await Ni(d);if(h.state!==`verified`||!na(h.apiKey,p.credential.apiKey))return H(p,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${h.summary}`,Ki);try{let e=await _e(t,{apiKey:h.apiKey,secret:d},`active`);return n(`API key stored; authenticated identity and broker acknowledgment verified.`,ta(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return H(p,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${E(e)}`,Ki)}}async function Ji(e){let t=await Ni(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?n(`API key is already stored and its authenticated identity was verified.`,ta(e,!0),{ids:[e.credential.apiKey.id]}):H(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${Gi} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&na(t.apiKey,e.credential.apiKey))try{let r=await _e(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return n(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,ta(r,!0),{ids:[r.credential.apiKey.id]})}catch(t){return H(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${E(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${Gi} 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 \`${Gi} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let r=await Bi(e);if(r.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 — ${r.summary}. Retry when the API is reachable.`);try{await we(e.host)}catch(t){return H(e,!1,`auth login --key: stale pending credential could not be removed — ${E(t,[e.credential.secret])}`)}return N.write(r.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
12
|
+
`:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
|
|
13
|
+
`),null}async function Yi(e){let t=new Date(e.expiresAt).getTime(),n=$i(e.intervalSeconds);for(;;)try{return await Di(e.id,e.pollSecret)}catch(e){if(e instanceof V){if(!e.retryable)throw e;n=$i(e.retryAfterSeconds??n)}else if(!(e instanceof wi))throw e;if(Date.now()>=t)throw e;N.write(`Broker acknowledgment was interrupted; retrying.
|
|
14
|
+
`),await ea(n,t)}}async function Xi(e){let t=new Date(e.expiresAt).getTime(),n=$i(e.intervalSeconds),r;for(N.write(`Waiting for browser approval...
|
|
15
|
+
`);Date.now()<t;){let i;try{i=await Ei(e.id,e.pollSecret)}catch(e){if(e instanceof V){if(!e.retryable)throw e;n=$i(e.retryAfterSeconds??n)}r=e,N.write(`Authorization poll was interrupted; retrying.
|
|
16
|
+
`),await ea(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=$i(i.retryAfterSeconds??n),await ea(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(oe(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: ${E(r,[e.pollSecret])}`)}function Zi(e,t,n){let r=e.state===`opened`;return!r&&!N.isTTY?!1:(N.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...N.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(`
|
|
17
|
+
`)),!0)}function Qi(){switch(Rt()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function $i(e){return Math.min(Wi,Math.max(Ui,e))}async function ea(e,t){let n=t-Date.now();n>0&&await zt(Math.min(e*1e3,n))}function ta(e,t){return{host:e.host,provider:e.provider,apiKeyId:e.credential.apiKey.id,name:oe(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function H(e,t,n,r){return{...o(n,r===void 0?[]:[r]),data:ta(e,t)}}function na(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)}async function ra(){return null}async function ia(e){let t=null,n=e=>{t=e};try{await Fe(e,n),await Le(n)}catch(e){return{materialized:t,failure:E(e)}}return{materialized:t,failure:null}}async function aa(e,t,n,r){if(r.failure!==null)return{scope:e,selected:null,identity:null,authorization:null,error:r.failure};let i=null,a=null,o,s=e=>{o=e,a=oa(e.credential,r.materialized)};try{let t=await S({method:`POST`,path:`/v1/auth/me/permissions`,body:{operation:[]},auth:e,requesterScope:e,responseFormat:`json`,onAuthPrepared:s});if(!t.ok)throw Error(sa(t));if(a===null)throw Error(`Live permission probe did not prepare a credential`);if(i=da(t.data),e===`read`)return{scope:e,selected:a,identity:null,authorization:i,error:null};if(o===void 0)throw Error(`Live permission probe did not retain its prepared credential`);let n=await ra(e,o);return{scope:e,selected:a,identity:n,authorization:i,error:null}}catch(r){return{scope:e,selected:a,identity:null,authorization:i,error:E(r,ca(t,n,o))}}}function oa(e,t){if(e===null)return null;let n=t??Oe().source;if(n===null)throw Error(`Prepared credential has no local provenance`);return{credential:e,source:n}}function sa(e){return[e.summary,...e.warnings].join(` — `)}function ca(e,t,n){return[i().userBearerToken,...p(n?.headers??{}),...e.state===`found`?je(e.stored.credential.tokens):[],t.state===`found`?t.stored.credential.secret:void 0]}function la(e,t,n=null){let r=t.state===`found`?t.stored:void 0,i=r?.credential.apiKey.expiresAt??null;return{host:e,present:r!==void 0,provider:r?.provider??null,activation:r?.activation??null,apiKeyId:r?.credential.apiKey.id??null,subject:r?.credential.apiKey.subject??null,scope:r?.credential.apiKey.scopes??[],name:r===void 0?null:oe(r.credential.apiKey.name,[r.credential.secret]),status:r?.credential.apiKey.status??null,expiresAt:i,metadataSource:r===void 0?null:n?.state===`verified`?`clerk`:`store-cache`,live:n===null?null:{state:n.state,summary:n.summary},expiresInDay:ma(i),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function ua(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:Te(n.credential),renewable:n===void 0?null:n.credential.tokens.refresh_token!==void 0,identity:n===void 0?null:Ee(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}}function da(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)throw Error(`permission probe returned no JSON response`);let t=s.safeParse(e.response);if(!t.success)throw t.error;return t.data}function fa(e,t){let{expiresAt:n,expiresInDay:r}=la(e,t);return n!==null&&r!==null&&new Date(n).getTime()<=Date.now()?` (cached expiry passed ${Math.abs(r)}d ago; \`auth status\` re-checks it with aVenture sign-in)`:``}var pa=864e5;function ma(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/pa)}var ha=7;function ga(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,ha)}\u2026${e.slice(-4)}`}var _a=13,va=14;function ya(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.apiKey.host}`+(e.apiVersion===null?` (api build unavailable)`:` (api ${e.apiVersion})`),``,...xa(e.oauth,e.cliName,e.refresh),...Ca(e.apiKey,e.oauth,e.cliName),``,U(`Providers`,Ea(e.providers)),U(`Environment`,Da(e.resolved)),U(`Selected`,Oa(e.resolved,e.refresh,e.cliName)),...ba(e.live),...e.systemOk?[]:[U(`System`,`uptime read failed`)]].join(`
|
|
18
|
+
`)}function ba(e){if(e===null)return[];let t=W(`local credential provenance was captured before verification`);if(e.error!==null)return[``,U(`Live probe`,`${e.scope} permission probe failed`),t,W(e.error)];if(e.authorization===null)return[];let n=e.authorization.permissionGrant,r=e.identity;return[``,U(`Live probe`,`${e.scope} permission probe succeeded`),t,W(`operation access ${e.authorization.operationAccess}; ${n.role.length} role; ${n.permission.length} permission`),...r===null?[W(e.scope===`read`?`identity not requested for a read-scope credential`:`identity unavailable in this build`)]:[U(`Live account`,r.nameFull??r.email??r.clerkUserId??r.id)],W(`no API operation was executed or individually authorized`)]}function U(e,t){return` ${e.padEnd(_a)}${t}`}function W(e){return` ${``.padEnd(_a)}${e}`}function xa(e,t,n){switch(e.state){case`found`:{let{credential:r,provider:i}=e.stored,a=Ee(r);return[U(`OAuth`,`${a.email??a.subject??`unknown identity`} via ${i}`),W(Sa(r,t,n))]}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 Sa(e,t,n){return Te(e)?e.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:n.failure===null?n.materialized===`api-key`?`access token expired and renewal failed; the API key is in use — \`${t} auth login\` renews OAuth`:`access token expired — not renewed while AUTH_TOKEN is set in the environment`:`access token expired — ${n.failure}`:`access token valid until ${e.expiresAt}`}function Ca(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`?`API key`:`Signed in`,e.subject??`unknown subject`),W(`via ${e.provider??`unknown store`}`),U(`Key`,`${e.name??`unnamed`} ${ga(e.apiKeyId)}`),...wa(e,n),U(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function wa(e,t){let n=e.live,r=e.expiresInDay,i=e.expiresAt;if(n?.state===`invalid`)return[U(`Key state`,`rejected by aVenture sign-in \u2014 ${n.summary}`),W(`run \`${t} auth logout\`, then \`${t} auth login --key\``)];let a=n?.state===`verified`;return[U(`Key state`,a?`${e.status??`unknown`}, verified by aVenture sign-in now`:`${e.status??`unknown`} when stored`),...i===null||r===null?[W(`no expiry recorded`)]:[W(Ta(i,r,a?`expires`:`cached expiry`))],...a?[]:[W(n===null?"aVenture sign-in owns the live verdict — `auth status` re-checks it":`aVenture sign-in could not be reached \u2014 ${n.summary}`)]]}function Ta(e,t,n){let r=e.slice(0,10);return new Date(e).getTime()<=Date.now()?`${n} ${r} passed ${Math.abs(t)}d ago`:t<=va?`${n} ${r}, ${t}d away`:`${n} ${r}`}function Ea(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`browser sign-in`:`no browser sign-in`,t?`oauth ${Ae(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function Da(e){return`${g.authToken}=${e.present?e.source??`resolved`:`unset`}`}function Oa(e,t,n){return e.present||t.materialized===`env`?`${g.authToken} from the environment`:t.materialized===`oauth`?`saved OAuth access token`:t.materialized===`api-key`?`saved API key`:`none \u2014 sign in with \`${n} auth login\``}var ka=`# >>> aventure-cli completion setup (managed by aventure-cli) >>>`,Aa=`# <<< aventure-cli completion setup (managed by aventure-cli) <<<`,ja=`.aventure-cli-completion.bak`;function Ma(e,t){e.command(`install`).summary(`install shell completion loaders`).description(`Install managed shell completion loaders for supported shells.`).action(()=>za([])),e.command(`uninstall`).summary(`remove shell completion loaders`).description(`Remove managed shell completion loaders installed by ${t}.`).action(()=>za([`--uninstall`]))}function Na(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=La(),n=await Ia({rcFile:j(It(),`.zshrc`),installerPath:t,mode:e.uninstall?`uninstall`:`install`,dryRun:e.dryRun,prompter:e.yes||e.dryRun?void 0:Xa});M.stdout.write(`${n.message}\n`),!n.cancelled&&!e.dryRun&&za(e.uninstall?[`--uninstall`]:[])})}function Pa(e,t=`fpath-only`){return[ka,`# installer: ${e}`,'fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath)',...t===`fpath-and-compinit`?[`autoload -Uz compinit`,`compinit`]:[],Aa].join(`
|
|
19
|
+
`)}function Fa(){let e=za([`--status`],`pipe`);if(e.status!==0)return{refreshed:!1,message:`completion status exited ${e.status??1}`};if(!Ba(e.stdout??``))return{refreshed:!1,message:`no managed shell completions found`};let t=za([],`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 Ia({rcFile:e,installerPath:t,mode:n,dryRun:r=!1,prompter:i}){let a=Va(e),o=a.length===0?[]:a.split(`
|
|
20
|
+
`),s=Ha(o,e);if(n===`uninstall`&&s===null)return{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:a};let c=n===`install`?Ua(o,s,t,e):Wa(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}: unchanged; pass --yes to apply without a prompt`,content:a}:(qa(e,c),{changed:!0,cancelled:!1,message:`${e}: updated`,content:c})}function La(e=M.argv[1]){let t=e===void 0?``:Ra(e),n=j(A(t),`..`,`..`,`scripts`,`install-zsh-completion-loader.mjs`);return yt(n)?n:j(A(t),`..`,`scripts`,`install-zsh-completion-loader.mjs`)}function Ra(e){try{return Tt(e)}catch{return j(e)}}function za(e,t=`inherit`){let n=ht(M.execPath,[La(),...e],{encoding:t===`pipe`?`utf8`:void 0,stdio:t});if(n.error!==void 0)throw n.error;if(t===`inherit`){n.status!==0&&(M.exitCode=n.status??1);return}return{stdout:n.stdout?.toString(),stderr:n.stderr?.toString(),status:n.status}}function Ba(e){return e.split(/\r?\n/u).some(e=>e.trim().endsWith(`: managed`))}function Va(e){return yt(e)?(Ja(e),Ct(e,`utf8`)):``}function Ha(e,t){let n=Ga(e,ka),r=Ga(e,Aa);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 Ua(e,t,n,r){let i=t===null?[...e]:[...e.slice(0,t[0]),...e.slice(t[1]+1)],a=Ka(i),o=Pa(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 Ya([...i.slice(0,c),...o,...i.slice(c)])}function Wa(e,t){return Ya(t===null?e:[...e.slice(0,t[0]),...e.slice(t[1]+1)])}function Ga(e,t){return e.flatMap((e,n)=>e===t?[n]:[])}function Ka(e){return e.findIndex(e=>/^\s*(autoload\s+.*\bcompinit\b|compinit(?:\s|$))/.test(e))}function qa(e,t){xt(A(e),{recursive:!0}),yt(e)&&(Ja(e),Ja(`${e}${ja}`),vt(e,`${e}${ja}`));let n=j(A(e),`.${gt(e)}.${M.pid}.tmp`);Ja(n),kt(n,t,{mode:420}),Et(n,e)}function Ja(e){if(yt(e)&&bt(e).isSymbolicLink())throw Error(`refusing to write symlink: ${e}`)}function Ya(e){let t=e.join(`
|
|
22
|
+
`);return t.length===0||t.endsWith(`
|
|
23
|
+
`)?t:`${t}\n`}async function Xa(e){if(!M.stdin.isTTY)return!1;let t=Bt({input:M.stdin,output:M.stdout});try{let n=await t.question(`${e} [y/N] `);return/^(y|yes)$/i.test(n.trim())}finally{t.close()}}var Za=new Intl.Collator(void 0,{numeric:!0}),Qa=2e4;function $a(e,t=x()){let n=t.registry===``?`Requires npm authentication for @aventurevc packages.`:`Installs from npm.`;O(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`,`(rebuild that checkout instead). ${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=>I({mode:D(e)},eo()))}function eo(e,t=`apply`){let r=e;try{r??=x(process.argv[1])}catch(e){return o(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,s=r.registry===``?``:h,c=r.registry===``&&i===`@aventurevc/aventure-cli`,l=to([`view`,s,`version`,`--silent`,`--global`],r,{timeout:Qa});if(!l.ok)return{...l,data:null};let u=(l.data??``).trim();if(u===``)return o(`npm view ${s} returned empty version`,[`empty_stdout`]);let d=c||Za.compare(a,u)<0,f={targetPackage:s,runningPackage:i,currentVersion:a,latestVersion:u,upgradeAvailable:d,upgradeInstalled:!1};if(t===`check`)return n(`${i}@${a} → ${s}@${u} (${d?`available`:`up to date`})`,f);if(!d)return n(`${i}@${a} already matches ${s}@${u}`,f);if(r.workingTreeRoot!==null)return o(`Refusing to install over the working-tree build at ${r.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);let p=io(r),m=p===null?[]:[`--prefix`,p.installPrefix],g=p===null?null:j(p.installPrefix,`lib`,`node_modules`,...s.split(`/`)),_=c?no(p,s,u):[];if(c){let e=to([`uninstall`,`-g`,...m,h],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return o(`Cannot remove the retired ${h}: ${e.summary}`,[...e.warnings,..._])}let v;try{v=ao(r,p)}catch(e){return o(`Cannot prepare MCP-owned CLI bins: ${co(e)}`,[`npm install was not run`])}let y=to([`install`,`-g`,...m,`${s}@${u}`],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!y.ok){let e=oo(v,g);return e===null?{...y,warnings:[...y.warnings,..._],data:null}:o(`${y.summary}; MCP-owned CLI bin restoration failed`,[...y.warnings,e])}let b=p===null?void 0:ro(p.installPrefix,s,u);if(b?.ok===!1){let e=oo(v,g);return e===null?{...b,warnings:[...b.warnings,..._],data:null}:o(`${b.summary}; MCP-owned CLI bin restoration failed`,[...b.warnings,e])}let ee=so(v);if(ee!==null)return o(`${s} upgraded but MCP CLI bin backup cleanup failed`,[ee]);let S=lo();return n(`${s} upgraded to ${u}`,{...f,upgradeInstalled:!0,installPrefix:p?.installPrefix,verifiedVersion:b?.data??void 0,completionRefreshed:S.refreshed,completionRefreshMessage:S.message})}function to(e,t,r={}){let i={...process.env};t.registry===``?i.NODE_AUTH_TOKEN??=i.GH_PACKAGES_TOKEN:delete i.GH_PACKAGES_TOKEN;let a=[...e,`--@aventurevc:registry=${t.registry}`],s=ht(`npm`,a,{env:i,encoding:`utf8`,...r});if(s.error)return s.signal===`SIGTERM`&&r.timeout!==void 0?o(`npm ${e[0]??``} did not answer within ${r.timeout}ms`,[`timeout`]):o(`npm ${e[0]??``} failed to start: ${s.error.message}`,[`spawn_error`]);if(s.status!==0){let t=(s.stderr??``).trim().split(`
|
|
25
|
+
`).slice(-3).join(` | `);return o(`npm ${e.join(` `)} exited ${s.status}`,[t||`no stderr`])}return n(`npm ok`,s.stdout??``)}function no(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${h}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function ro(e,t,r){let i;try{let n=x(j(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));i=j(e,`bin`,n.bin[0])}catch(e){return o(`updated ${t} verification failed: ${co(e)}`,[`invalid_package_metadata`])}let a=ht(process.execPath,[i,`--version`],{encoding:`utf8`});if(a.error)return o(`updated ${t} verification failed: ${a.error.message}`,[`spawn_error`]);let s=(a.stdout??``).trim();if(a.status!==0||s!==r){let e=(a.stderr??``).trim().split(`
|
|
26
|
+
`).slice(-3).join(` | `);return o(`updated ${t} verification expected ${r} but active bin reported ${s||`empty output`}`,[e||`active bin: ${i}`])}return n(`active CLI version verified`,s)}function io(e){let t=`${_t}lib${_t}node_modules${_t}${e.name.replace(`/`,_t)}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:{installPrefix:e.packageRoot.slice(0,n)}}function ao(e,t){if(e.name!==`@aventurevc/mcp-server`)return{backup:[],backupDirectory:null};if(t===null)throw Error(`the running MCP package is not in a verifiable global npm prefix`);if(!e.entryPath.startsWith(`${e.packageRoot}${_t}`))throw Error(`the running CLI entry is outside the MCP package root`);let n=e.bin.filter(e=>e===`aventure`||e===`aventure-cli`).flatMap(n=>{let r=j(t.installPrefix,`bin`,n),i=bt(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=Tt(r)}catch(e){throw Error(`${r} has a missing target`,{cause:e})}if(a!==e.entryPath)throw Error(`${r} is not owned by the running MCP CLI`);return{binPath:r,linkTarget:wt(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=St(j(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:j(r,gt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(Et(e.binPath,e.backupPath),a.push(e),wt(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=oo({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 oo(e,t){let n=[];for(let r of e.backup.toReversed())try{let e=bt(r.binPath,{throwIfNoEntry:!1});if(e!==void 0){if(!e.isSymbolicLink())throw Error(`${r.binPath} is not a symlink`);let n=j(A(r.binPath),wt(r.binPath));if(t===null||n!==t&&!n.startsWith(`${t}${_t}`))throw Error(`${r.binPath} is not owned by the standalone CLI package`);Ot(r.binPath)}Et(r.backupPath,r.binPath)}catch(e){n.push(co(e))}if(e.backupDirectory!==null)try{Dt(e.backupDirectory)}catch(e){n.push(co(e))}return n.length===0?null:n.join(`; `)}function so(e){let t=[];for(let n of e.backup)try{Ot(n.backupPath)}catch(e){t.push(co(e))}if(e.backupDirectory!==null)try{Dt(e.backupDirectory)}catch(e){t.push(co(e))}return t.length===0?null:t.join(`; `)}function co(e){return e instanceof Error?e.message:String(e)}function lo(){try{return Fa()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var uo=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers its generated status operation`},{name:`auth`,purpose:`which credential scope materialized locally, never the secret`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}],fo=`operationFingerprint`;function po(e,t=x().bin[0]){O(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: [...] }`:",...uo.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),I({mode:D(e)},await mo(t))})}async function mo(e){let t=go(),r=_o(e),[i,a]=await Promise.all([vo(e),yo(t,e)]),s=[r.check,i,a.check,await xo(e),Do(t,a.servedFingerprint,r.upgradeAvailable,e)],c={pass:ho(s,`pass`),fail:ho(s,`fail`),skip:ho(s,`skip`)},l=s.filter(e=>e.status===`fail`).map(e=>e.message),u={ok:l.length===0,check:s},d=[`doctor: ${c.pass} pass, ${c.fail} fail, ${c.skip} skip`,...s.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
28
|
+
`);return u.ok?n(d,u,{counts:c}):{...o(d,l,{counts:c}),data:u}}function ho(e,t){return e.filter(e=>e.status===t).length}function G(e,t,n){return{name:e,status:t,message:n}}function go(){return k.find(e=>e.intent===`status`&&e.resource===`status`)}function _o(e){let t=x(),n=eo(t,`check`);if(!n.ok||n.data===null)return{check:G(`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?G(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):G(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function vo(e){try{let{EntityDetailSchema:e}=await import(`./detail-C462_tj4.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return G(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return G(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${E(t)}.`)}}async function yo(e,t){if(e===void 0)return{check:G(`api-host`,`skip`,`No status operation resolved from the generated catalog; fix the catalog check first.`),servedFingerprint:null};let n;try{n=i().host}catch(e){return{check:G(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${E(e)}.`),servedFingerprint:null}}let r=await S({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>o(E(e)));return r.ok?{check:G(`api-host`,`pass`,`${e.method} ${e.path} answered at ${n}.`),servedFingerprint:bo(r.data)}:{check:G(`api-host`,`fail`,r.httpStatus===401?`Replace or unset the credential ${n} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} returned ${r.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} at ${n} returned ${r.summary}.`),servedFingerprint:null}}function bo(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[fo];return typeof n==`string`&&n.length>0?n:null}async function xo(e){let t=Oe(),[n,r]=await Promise.all([So(),Co()]);if(r.state===`unavailable`&&r.cause===`environment`)return G(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;return!i&&n.state===`invalid`?G(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`):!i&&n.state===`found`&&Te(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0?G(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`):!i&&!a&&n.state===`unavailable`?G(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${g.authToken} through the environment — ${n.summary}.`):i||n.state===`found`||a?G(`auth`,`pass`,`Credential source available: ${wo(t,n,r)}.`):r.state===`unavailable`?G(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${g.authToken} through the environment — ${r.summary}.`):G(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${g.authToken} in the environment.`)}async function So(){let e;try{e=Ne(i().host)}catch(e){return{state:`unavailable`,summary:E(e)}}return await Pe(e)}async function Co(){let e;try{e=Be(i().host)}catch(e){return{state:`unavailable`,summary:E(e),cause:`environment`}}try{return await ze(e)}catch(e){return{state:`unavailable`,summary:E(e),cause:`storage`}}}function wo(e,t,n){return[Da(e),`oauth=${Eo(t)}`,`api-key=${To(n)}`].join(` `)}function To(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=Be(i().host);return`${e.stored.activation}${fa(t,e)}`}function Eo(e){switch(e.state){case`found`:return Te(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function Do(e,t,n,r){let i=k.length;if(e===void 0)return G(`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 G(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${$e}.`);if(t===`a0e928da9fa359c8`)return G(`catalog`,`pass`,`${i} generated operations match the set the API serves (${$e}).`);let a=`This catalog describes a different operation set than the API serves (${$e} vs ${t})`;return n===!0?G(`catalog`,`fail`,`${a}: run \`${r} update\`.`):G(`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 Oo=z(B,`oauth`),ko=[z(B,`start`),z(B,`poll`),z(B,`acknowledge`)],Ao=z(B,`revoke`);function jo(e,t=x().bin[0]){let n=Fo(e);po(n,t);let r=[`${Oo.description} Default method: OAuth in your browser.`,`With --key: ${ko.map(({description:e})=>e).join(` `)}`].join(`
|
|
29
|
+
`);O(Po(n,[Oo,...ko],r)).action(Mo),O(Po(n,[Ao],Ao.description)).action(No),O(n.command(`status`).summary(`Keep saved credentials current and report them with API build and uptime`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,` - system: GET /v1/status response (uptime SLA)`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
|
|
30
|
+
`)).addOption(new v(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Io(this),I({mode:D(e)},await Lo(t,e.verify))}),n.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${g.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
|
|
31
|
+
`)).action(async function(){Io(this);let e=await ia(t),n=process.env[g.authToken]?.trim();if(e.failure===null&&n!==void 0&&n.length>0){process.stdout.write(`${n}\n`);return}I({mode:`text`},e.failure===null?Go(`auth token: no credentials resolved`,null,t,{oauth:!0,apiKey:!0}):o(`auth token: ${e.failure}`))})}async function Mo(e){Io(this);let t=D(e);if(e.providers===!0){I({mode:t},await zo());return}I({mode:t},e.key===!0?await qi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await pt({noBrowser:!e.browser}))}async function No(e){Io(this),I({mode:D(e)},await Fi({forgetLocal:e.forgetLocal===!0}))}function Po(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Fo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${Oo.command}\`: ${Oo.summary}; \`--key\` ${ko[0].summary.toLowerCase()}.`,`\`${Ao.command}\`: ${Ao.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build and uptime.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
|
|
32
|
+
`))}function Io(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function Lo(e,t){let r;try{r=Ne(i().host)}catch(e){return o(`auth status: invalid API host — ${E(e)}`)}let a=Oe(),s=ia(e),[c,l,u]=await Promise.all([Wo(`/v1/status`,`GET /v1/status`),Wo(`/info`,`GET /info`),Bo()]),d=await s,[f,p]=await Promise.all([Pe(r),Ro(r)]),m=t===void 0?null:await aa(t,f,p.inspection,d),h=x().version,_=la(r,p.inspection,p.verification),v=ya({cliName:e,cliVersion:h,apiVersion:l.ok?Ho(l.data):null,oauth:f,apiKey:_,providers:u,resolved:a,refresh:d,systemOk:c.ok,live:m}),y={cli:{version:h},api:l.ok?l.data??null:null,auth:{[g.authToken]:a},selected:d.materialized,oauth:ua(r,f),apiKey:_,providers:u,live:m,system:c.ok?c.data??null:null,...l.ok?{}:{apiError:l.summary},...c.ok?{}:{systemError:c.summary}};return d.failure===null?!l.ok&&l.httpStatus===401?{...o(`auth status: the API rejected the selected credential (401) | ${v}`,[`Replace or unset ${g.authToken}, or run \`${e} auth login\`.`]),data:y}:m!==null&&m.error!==null?{...o(`auth status: ${m.scope} permission probe failed — ${m.error}`,[m.error]),data:y}:m!==null||a.present||f.state===`found`||p.inspection.state===`found`?n(v,y):Go(`auth status: no credentials resolved | ${v}`,y,e,{oauth:f.state===`missing`,apiKey:p.inspection.state===`missing`}):{...o(`auth status: ${d.failure} | ${v}`,[d.failure]),data:y}}async function Ro(e){let t=await Vo(e);if(t.state!==`found`)return{inspection:t,verification:null};let{stored:n,verification:r}=await Mi(t.stored);return{inspection:{state:`found`,stored:n},verification:r}}async function zo(){let e=await Bo();return e.state===`found`?n(`Sign-in providers for the selected API host`,e.catalog):o(`auth login --providers: ${e.summary}`)}async function Bo(){try{return{state:`found`,catalog:await ft()}}catch(e){return{state:`unavailable`,summary:E(e)}}}async function Vo(e){try{return await ze(e)}catch(e){return{state:`invalid`,summary:E(e)}}}function Ho(e){if(!Uo(e))return null;let t=si.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 Uo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Wo(e,t){return await S({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>o(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}function Go(e,t,n,r){return{...o(e,[...r.apiKey?[`For an API key (works over SSH), run \`${n} auth login --key\`.`]:[],...r.oauth?[`For OAuth, run \`${n} auth login\`; without a browser it prints a device code.`]:[],`For non-interactive use, set ${g.authToken} to an aVenture API key (create one at ${de}/settings/api-keys).`]),data:t}}function Ko(e,t=k,n=x().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(()=>{M.stdout.write(Jo(e,i,t))});Ma(r,n),Na(r,n)}function qo(){return x().bin}function Jo(e,t,n=k,r=qo()){let i=rs(n);return t===`fish`?[`# fish completions for ${r.join(`, `)}`,...Xo(e),...r.map(e=>`complete -c ${K(e)} -e`),`${gs(r)} -f`,...Zo(e,r),...Qo(e,i,r),``].join(`
|
|
33
|
+
`):Yo(e,t,i,r)}function Yo(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=os(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}`),`)`,``,...ls(t),...t===`bash`?[a,``]:[``]].join(`
|
|
34
|
+
`)}function Xo(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${$o(e).filter(e=>e.required||e.optional).flatMap(e=>fs(e)??[]).map(K).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
|
|
35
|
+
set -l expected $argv
|
|
36
|
+
set -l actual (__aventure_cli_command_path)
|
|
37
|
+
if test (count $actual) -ne (count $expected)
|
|
38
|
+
return 1
|
|
39
|
+
end
|
|
40
|
+
if test (count $expected) -eq 0
|
|
41
|
+
return 0
|
|
42
|
+
end
|
|
43
|
+
for index in (seq (count $expected))
|
|
44
|
+
if test $actual[$index] != $expected[$index]
|
|
45
|
+
return 1
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
return 0
|
|
49
|
+
end
|
|
50
|
+
`].flatMap(e=>e.split(`
|
|
51
|
+
`))}function Zo(e,t){return as(e).map(e=>`${gs(t)} -f -n ${K(_s(e.parentPath))} -a ${K(e.name)} -d ${K(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function Qo(e,t,n){return ps(e).flatMap(e=>{let r=hs(e),i=r.length===0?void 0:_s(r);return $o(e).flatMap(e=>{let a=t.get(is(r,e));return cs(a)?es(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function $o(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function es(e,t,n,r){let i=fs(e);if(i===void 0)return[];let a=e.argChoices??ss(n),o=[`-l ${K(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${K(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${K(t)}`,c=e.required||e.optional?ts(a,ns(i,n)):`-f`,l=`${gs(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${K(vs(e.description))}`]:a.map(t=>`${l} -a ${K(t)} -d ${K(vs(e.description))}`)}function ts(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function ns(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 rs(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...vn(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`);return[[is(e.cliPath,n),t]]})))}function is(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):fs(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 as(e){return ps(e).flatMap(e=>e.commands.map(t=>({parentPath:hs(e),name:t.name(),description:vs(t.summary()||t.description()||t.name())})))}function os(e,t){let n=[],r=[];for(let i of ps(e)){let e=hs(i);for(let a of $o(i)){let i=fs(a);if(i===void 0)continue;let o=t.get(is(e,a));if(!cs(o))continue;let s=a.argChoices??ss(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&ns(i,o)&&(c=`file`)),n.push(us([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(us([e.join(` `),`--${i}`,t,a.description]))}}return[as(e).map(e=>us([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 ss(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 cs(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function ls(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 us(e){return`$'${e.map(ds).join(`|`)}'`}function ds(e){return vs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function fs(e){return e.long?.replace(/^--/,``)}function ps(e){return[e,...e.commands.filter(ms).flatMap(e=>ps(e))]}var ms=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function hs(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function gs(e){return`complete ${e.map(e=>`-c ${K(e)}`).join(` `)}`}function _s(e){return[`__aventure_cli_path_is`,...e.map(K)].join(` `)}function vs(e){return e.replace(/\s+/g,` `).trim()}function K(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function ys(e,t){if(e!==t)return;let n=bs(t);n!==void 0&&t.error(`error: ${Ss(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function bs(e){if(!process.argv.includes(`--`)&&e.args.some(xs))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function xs(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function Ss(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Cs(e){return e.message.match(/required option '([^']+)' not specified/iu)?.[1]?.split(/\s+/u)[0]}function ws(e){return e.message.match(/unknown option '([^']+)'/iu)?.[1]}function Ts(e){return e.message.match(/unknown command '([^']+)'/iu)?.[1]}function q(e){return e.flags.split(` `)[0]??e.flags}function Es(e,t){let n=Cs(t);if(n===void 0)return;let r=e.options.findIndex(e=>q(e)===n);if(r<0)return;let i=e.options.slice(r+1).filter(e=>e.mandatory).map(t=>[q(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.`}var Ds=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`]];function Os(e){let t=new Set(e.options.map(q)),n=process.argv.slice(2).filter(e=>e.startsWith(`--`)).map(e=>e.split(`=`)[0]??e).filter(e=>!t.has(e)).flatMap(e=>{let n=Ds.find(t=>t.includes(e))?.find(e=>t.has(e));return n===void 0?[]:[`use ${n}, not ${e}`]});return n.length===0?void 0:`hint: ${n.join(`; `)}`}function J(e){let t=[];for(let n=e;n!==null&&n.parent!==null;n=n.parent)t.unshift(n.name());return t}function ks(e){return e.commands.length===0?[e]:e.commands.flatMap(ks)}function As(e,t){return J(t).slice(J(e).length)}function Y(e){let t=e;for(;t.parent!==null;)t=t.parent;return t}function js(e,t){return t.toSorted((t,n)=>{let r=As(e,t),i=As(e,n),a=+![`get`,`list`].includes(r.at(-1)??``),o=+![`get`,`list`].includes(i.at(-1)??``);return r.length-i.length||a-o})[0]}function X(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function Ms(e,t){let n=J(e),r=process.argv.slice(2+n.length);return[Y(e).name(),...n,...As(e,t),...r].map(X).join(` `)}function Ns(e,t){let n=ws(t);if(n===void 0||e.commands.length===0)return;let r=js(e,ks(e).filter(e=>e.options.some(e=>q(e)===n)));if(r!==void 0)return`hint: run: ${Ms(e,r)}`}function Z(e){return e!==void 0&&Object.hasOwn(nt,e)}function Ps(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 Fs(e,t){let n=J(e),r=[...n.slice(1),t];if(!Z(n.at(0))||!Z(r.at(0)))return;let i=Ps(Y(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 Is(e,t){let[n]=J(e);if(!Z(n))return;let r=[n,t];return Ps(Y(e),r)?.commands.length===0?r:void 0}function Ls(e){let[t,...n]=e.args;if(t===void 0)return[];let r=ks(Y(e)).map(J),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 Rs(e,t){let n=process.argv.slice(2+J(e).length);if(!(t.length===0||t.some((e,t)=>n[t]!==e)))return zs(e,t)}function zs(e,t,n=[]){let r=J(e),i=Ze(k).map(e=>e.cliPath).filter(e=>e[0]!==r[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: ${[Y(e).name(),...a,...n].map(X).join(` `)}`}function Bs(e,t,n){if(!Hs(t))return;let r=e.args.slice(n.length),i=r.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${[Y(e).name(),...t,...i<0?[]:r.slice(i)].map(X).join(` `)}`}function Vs(e){let t=J(e);if(t.at(1)!==void 0&&Z(t.at(0)))return`hint: inspect generated command group: ${[Y(e).name(),...t,`--help`].map(X).join(` `)}`}function Hs(e,t){let n=e.join(` `);return k.some(e=>e.cliPath.join(` `)===n?t===void 0||r(e.intent)===t:!1)}function Us(e){let t=J(e).join(` `),n=Ze(k),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:xr(r.operationId,n,Y(e).name()).map(e=>`hint: ${e}`)}function Ws(e){let t=J(e);if(Z(t.at(0))&&Hs(t))return`hint: inspect generated command: ${[Y(e).name(),...t,`--help`].map(X).join(` `)}`}function Gs(e){let t=new Set,n=[];for(let i of k){let a=Ps(e,i.cliPath);if(a===void 0)continue;let o=a.options.map(q);if(r(i.intent))n.push(o);else for(let e of o)t.add(e)}let[i=[],...a]=n;return new Set(i.filter(e=>!t.has(e)&&a.every(t=>t.includes(e))))}function Ks(e,t){let n=J(e);if(Hs(n,!1)&&Gs(Y(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function qs(e,t,n=!0){let r=Y(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=J(e).at(0),c=a.options.find(e=>q(e)===`--root`),l=n&&c!==void 0&&Z(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(q(c),l);let u=Ze(k),d=sr({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?Rr(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(X).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
|
|
52
|
+
`).filter(Boolean).map(e=>` ${e}`)].join(`
|
|
53
|
+
`)}function Js(e){if(e.commands.length>0&&!Hs(J(e)))return;let t=e.options.flatMap(e=>e.hidden?[]:[q(e)]);return`hint: ${J(e).join(` `)} accepts: ${t.join(` `)}`}function Ys(e,t){let n=Ts(t);if(n===void 0||t.message.includes(`
|
|
54
|
+
(Did you mean `))return;let r=Ls(e),i=Rs(e,r);if(i!==void 0)return i;let a=J(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Hs(o)?o:void 0)??Fs(e,n)??Is(e,n);if(s!==void 0)return Bs(e,s,r)??qs(e,s.join(` `),!1);let c=r.join(` `)||n,l=Vs(e)??qs(e,c),u=[...J(e),...r.slice(1)];return[l,r.length===J(e).length+J(e).length&&J(e).at(-1)===J(e).at(0)?Bs(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Bs(e,u,r):void 0].filter(e=>e!==void 0).join(`
|
|
55
|
+
`)||void 0}function Xs(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[Os(e),bs(e),Es(e,t),...Us(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=bs(e)??Ws(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=ws(t),r=Os(e)??Ns(e,t)??(n!==void 0&&!t.message.includes(`
|
|
56
|
+
(Did you mean `)?Ks(e,n)??zs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??Js(e)??qs(e,J(e).slice(1).join(` `)||n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=Ys(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}process.exit(t.exitCode)}}var Zs=class extends v{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 Qs(e){e.showHelpAfterError(!1).exitOverride(Xs(e)),e.commands.length===0?e.hook(`preAction`,ys):e.addHelpOption(new Zs(e));for(let t of e.commands)Qs(t)}function $s(e,t=new Date){let n=nc(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 ec(e){return`${JSON.stringify(e,null,2)}\n`}function tc(e,t){let n=j(e),r=ec(t);return xt(A(n),{recursive:!0}),kt(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function nc(t){return t.map(t=>({operationId:t.operationId,method:t.method,path:t.path,resource:t.resource,intent:t.intent,cliCommand:t.projection.cliPath.join(` `),cliPath:t.projection.cliPath,mcpTool:e(t.intent),bodySchemaName:t.requestBody?.[0]?.schemaName??null,bodySchemaImport:t.requestBody?.[0]?.schemaImport??null,auth:t.projection.auth,scope:t.projection.scope,destructive:t.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var rc=`Match only the first canonical or CLI-alias command segment`,ic=[`text`,`lines`,`compact`,`json`,`ndjson`];function ac(e,t,n=x().bin[0]){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(`
|
|
57
|
+
`));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${jr(n)}\n`),oc(r,t,n),sc(r,t,n),cc(r,t,n),lc(r)}function oc(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>`,rc).addOption(new v(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new v(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new v(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new v(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new v(`--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 v(`--format <format>`,`Text/file render format`).choices(ic)).option(`--output <path>`,`Write rendered output to a file`);O(r),r.action(function(e){let r=this.optsWithGlobals(),i=D(r,`text`);Pr(Nr(r,e),t,i,n)})}function sc(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 v(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);O(r),r.action(function(){let e=this.optsWithGlobals();Fr(e,t,D(e,`text`),n)})}function cc(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>`,rc).addOption(new v(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new v(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new v(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new v(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new v(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new v(`--format <format>`,`Text/file render format`).choices(ic)).option(`--output <path>`,`Write rendered output to a file`);O(r),r.action(function(){let e=this.optsWithGlobals();Pr(e,t,D(e,`text`),n)})}function lc(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`);O(t),t.action(function(){let e=this.optsWithGlobals(),t=D(e,`text`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){I({mode:t},n(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:ot.length}}));return}let r=$s(ot);if(e.output!==void 0){let i=tc(e.output,r);I({mode:t},n(`Unified operations JSON written`,{outputPath:i.target,byteLength:i.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:i.totalOperations}}));return}if(t===`text`){process.stdout.write(ec(r));return}I({mode:t},n(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var uc=x(Nt(import.meta.url)),Q=uc.bin[0];function dc(e,t){y({component:Q,event:`fatal`,message:e.message,error:e}),process.stderr.write(`${Q} fatal (${t}): ${e.stack??e.message}\n`);let n=e instanceof ee?{httpStatus:e.problem.status,problem:e.problem}:{};Zn({...o(`${Q} ${t}: ${e.message}`,[e.name||`Error`],n),counts:{exitCode:1}}),process.exit(1)}function fc(e){return Ue[at(e,nt)??`cli`]}function pc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:fc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>tt(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)mc(e,t,r,a,i.has(t.cliPath.join(` `)))}function mc(e,t,n,i,a){let s=t.cliPath,c=e,l=``,d=!n.has(s[0]??``);for(let e of s.slice(0,-1)){l=l===``?e:`${l} ${e}`;let t=d&&l===e||!i.has(l);c=hc(c,e,l,t)}let f=s.at(-1)??t.operationId,p=c.commands.find(e=>e.name()===f)??c.command(f,t.deprecated===!0?{hidden:!0}:{}),m=t.requestBody?.flatMap(({parameter:e})=>e)??[];p.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...m].some(e=>u(e.schemaType,e.itemSchemaType))?se:``].filter(Boolean).join(`
|
|
58
|
+
`));let h=Xe(t);for(let e of t.parameters)gc(p,e,a||e===h);if(kn(p,t),r(t.intent)&&p.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),O(p),p.hook(`preAction`,e=>Qe(e,t)),t.explain===!0&&p.option(`--explain`,`Print the search strategy and parsed constraints before the results`),h!==void 0){p.argument(`[text...]`,h.description||`Same as ${Je(h.flag)}.`),p.action(async function(e){let n=this.optsWithGlobals(),r=D(n),i=Ye(h,e,n);if(!i.ok||i.data===null)return I({mode:r},i);let a=et(t,i.data);if(a.length>0)return I({mode:r},o(`missing required options: ${a.join(`, `)}`));let s=await _c(t,i.data,r),c=ii(t,i.data,s);if(c!==null)return I({mode:r},c);n.explain===!0&&s.ok&&tr(r,s.data),s.ok&&s.data instanceof Uint8Array?process.stdout.write(s.data):I({mode:r},s)});return}p.action(async function(){let e=this.optsWithGlobals(),n=D(e),r=et(t,e);if(r.length>0)return I({mode:n},o(`missing required options: ${r.join(`, `)}`));let i=await _c(t,e,n),a=ii(t,e,i);if(a!==null)return I({mode:n},a);e.explain===!0&&i.ok&&tr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):I({mode:n},i)})}function hc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=nt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function gc(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 v(t.flag,r);i!==void 0&&a.default(i);let o=new v(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 _c(e,t,n){if(t.environment!==void 0){let e=ue(t.environment);if(e===null)return o(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${d().join(`, `)}`]);process.env.API_ENV=e}let r=await Pn(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]]})),s=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 S({method:e.method,path:re(e.operationId,i),searchParams:a,headers:s,body:r.data,contentType:qe(e,t),auth:e.auth,responseFormat:We(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0})}process.on(`uncaughtException`,e=>dc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>dc(e instanceof Error?e:Error(String(e)),`unhandledRejection`));var vc=Ke(process.argv.slice(2),k),yc=vc===`required`?k:Ze(k),$=new ie;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(Yr).version(uc.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.
|
|
59
|
+
`,`Mutations execute directly; --execute is a deprecated no-op.
|
|
60
|
+
The aVenture MCP server tools execute through this same CLI.`].join(`
|
|
61
|
+
`)).addOption(new v(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${ce})`).choices([...d()])).showHelpAfterError(`(run \`${Q} --help\` for usage)`),pc($,yc),jo($,Q),$a($,uc),Ko($,yc,Q),ac($,yc,Q),Gr($,yc,Q);for(let e of $.commands)e.helpGroup()||e.helpGroup(fc(e.name()).heading);if(Qs($),vc===`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 Fe(),await Le())}))}}var bc=new Set($.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));$.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find which one of that record a name, URL, or id refers to`],[`get`,` get Read one record`],[`list`,` list Read many records (news)`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>bc.has(e)?[t]:[]),``,`Account (free or paid; every command that calls aVenture needs one):`,` Create one at ${de}/sign-up, then run: ${Q} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Profile views, searches, and web searches count toward your monthly allowance.`,` Usage and upgrades: ${de}/settings/subscription`,` Plans and prices: ${Q} billing plans list`,` 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`,` --all-fields --text plus the detail fields it hides by default
|
|
62
|
+
`,`Exit codes:`,` 0 envelope.ok === true
|
|
63
|
+
1 envelope.ok === false
|
|
64
|
+
`,`Examples:`,` $ ${Q} auth login`,` $ ${Q} lookup "Stripe"`,` $ ${Q} search "fintech companies in Austin"`,` $ ${Q} entities lookup-exact get --url https://stripe.com\n`,`Run \`${Q} <command> --help\` for its subcommands and options,`,`or \`${Q} help <command>\` for its full documentation.`].join(`
|
|
65
|
+
`));try{await $.parseAsync()}catch(e){dc(e instanceof Error?e:Error(String(e)),`parseAsync`)}export{};
|