@aventurevc/aventure-cli 0.8.222 → 0.8.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aventure-cli/command-catalog.compact.txt +1 -1
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/api-key-bearer-credential-CxR6Q2DS.js +1 -0
- package/dist/chunks/{api-key-bearer-credential-8FeXnis3.js → api-key-bearer-credential-eFCSZ-cX.js} +1 -1
- package/dist/chunks/{aventure-cli-CgRAnND4.js → aventure-cli-D2Y6FMAQ.js} +7 -7
- package/dist/chunks/{cli-help-policy-Bh7GbTIq.js → cli-help-policy-BIiQwYpQ.js} +1 -1
- package/dist/chunks/contract-CU2UugQ0.js +16 -0
- package/dist/chunks/detail-BsTee2g2.js +1 -0
- package/dist/chunks/detail-jqEwPPHS.js +1 -0
- package/dist/chunks/{dist-Y8BzTddB.js → dist-Cf8kXL-8.js} +11 -8
- package/dist/chunks/logging-3qS9h4q4.js +1 -0
- package/dist/chunks/{logging-DTNdmwAo.js → logging-Cbl234V4.js} +1 -1
- package/dist/chunks/mcp-generation-contract-N93eBv4f.js +1 -0
- package/dist/chunks/mcp-generation-contract-mTifVDpF.js +1 -0
- package/dist/chunks/{oauth-bearer-credential-C3Ecq5KV.js → oauth-bearer-credential-CKwu5Ed_.js} +2 -2
- package/dist/chunks/oauth-bearer-credential-DfvI7VbW.js +1 -0
- package/dist/chunks/{oauth-login-DIqqLJ1E.js → oauth-login-B5IM3hvP.js} +3 -3
- package/dist/chunks/oauth-login-DTbseCcZ.js +1 -0
- package/dist/chunks/openapi-commands-BtVr86uS.js +1 -0
- package/dist/chunks/openapi-commands-DtqjXQlN.js +1 -0
- package/dist/chunks/{output-mode-Df4yQqaM.js → output-mode-3tDGwmsL.js} +1 -1
- package/dist/chunks/output-mode-CP43axpn.js +1 -0
- package/dist/chunks/{output-spill-CuPzxAFT.js → output-spill-CqEdAEnD.js} +1 -1
- package/dist/chunks/provider-catalog-crNc-lAb.js +1 -0
- package/dist/chunks/{response-problem-z9UkqQAr.js → response-problem-l5WiBcon.js} +1 -1
- package/dist/chunks/{result-envelope-Bf2rWJBp.js → result-envelope-Bl_1n5Tb.js} +1 -1
- package/dist/chunks/startup-auth-Bwq9U0fl.js +1 -0
- package/dist/chunks/startup-auth-S6FZrxDX.js +1 -0
- package/dist/chunks/text-field-BGnJUpd7.js +1 -0
- package/dist/chunks/text-field-jFKOGMzr.js +3 -0
- package/dist/chunks/{tool-policy-REHUxPRf.js → tool-policy-BUHiyuYu.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/api-key-bearer-credential-DySxz5iw.js +0 -1
- package/dist/chunks/contract-G_MHsm5B.js +0 -15
- package/dist/chunks/detail-BqdugX6O.js +0 -1
- package/dist/chunks/detail-KtYIbiXI.js +0 -1
- package/dist/chunks/logging-DatXGr57.js +0 -1
- package/dist/chunks/mcp-generation-contract-DcfwD65r.js +0 -1
- package/dist/chunks/mcp-generation-contract-DqEtjdmL.js +0 -1
- package/dist/chunks/oauth-bearer-credential-DNL0dR_C.js +0 -1
- package/dist/chunks/oauth-login-DwJjc3TV.js +0 -1
- package/dist/chunks/openapi-commands-CTiB3Trt.js +0 -1
- package/dist/chunks/openapi-commands-Da2LuJv2.js +0 -1
- package/dist/chunks/output-mode-CRiu6Wks.js +0 -1
- package/dist/chunks/provider-catalog-BKnKJLra.js +0 -1
- package/dist/chunks/startup-auth-BWM6WOUw.js +0 -1
- package/dist/chunks/startup-auth-D_RAhhtv.js +0 -1
- package/dist/chunks/text-field-BoNdbrtA.js +0 -3
- package/dist/chunks/text-field-CxrRvM47.js +0 -1
|
@@ -67,7 +67,7 @@ aventure entities fundraise-investor-joins list · List the Investors in a Fundi
|
|
|
67
67
|
aventure entities fundraise-rounds get · Get One Funding Round · --entity-id --fundraise-round-id
|
|
68
68
|
aventure entities fundraise-rounds list · List a Company's Funding Rounds · --entity-id
|
|
69
69
|
aventure entities investments list · List the Investments a Company Made · --entity-id
|
|
70
|
-
aventure entities investor-activity get · Get Investor
|
|
70
|
+
aventure entities investor-activity get · Get Investor Portfolio Counts and Stage Mix · --entity-id
|
|
71
71
|
aventure entities investors list · List a Company's Investors · --entity-id
|
|
72
72
|
aventure entities logo get · Get a Company Logo · --entity-id
|
|
73
73
|
aventure entities lookup-exact get · Read Full Entity Detail by aVenture Profile URL, Slug, Website, or Domain · -
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{enableCompileCache as e}from"node:module";e();var{CommanderError:t}=await import(`../chunks/commander-Cj79cOD4.js`),{logWarn:n,setStderrLogging:r}=await import(`../chunks/logging-
|
|
2
|
+
import{enableCompileCache as e}from"node:module";e();var{CommanderError:t}=await import(`../chunks/commander-Cj79cOD4.js`),{logWarn:n,setStderrLogging:r}=await import(`../chunks/logging-3qS9h4q4.js`),{readRuntimePackage:i}=await import(`../chunks/package-N5oYCiVc.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-DfvI7VbW.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-CxR6Q2DS.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-Bwq9U0fl.js`),{setTextAllFields:u}=await import(`../chunks/text-field-BGnJUpd7.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-CP43axpn.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-BtVr86uS.js`),p=process.argv.slice(2);d(p)&&r(!1),p.includes(`--all-fields`)&&u(!0);try{a();let e=l(p,f);if(e===`stored`||e===`optional`)try{await(e===`stored`?s():o()),await c()}catch(e){n({component:i().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-D2Y6FMAQ.js`)}catch(e){if(!(e instanceof t))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"generatedFrom": "MCP_GENERATION_CONTRACT",
|
|
4
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"generatedAt": "2026-10-21T16:51:29.908Z",
|
|
5
5
|
"totalOperations": 137,
|
|
6
6
|
"note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
|
|
7
7
|
"operations": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./api-key-bearer-credential-eFCSZ-cX.js";export{e as materializeCliApiKeyBearerCredential};
|
package/dist/chunks/{api-key-bearer-credential-8FeXnis3.js → api-key-bearer-credential-eFCSZ-cX.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as e,g as t,o as n,r,x as i}from"./logging-
|
|
1
|
+
import{f as e,g as t,o as n,r,x as i}from"./logging-Cbl234V4.js";import{i as a,l as o,o as s,w as c,y as l}from"./person-owner-BJgNYLKX.js";import{a as u}from"./package-DPDX5zmx.js";import{i as d}from"./response-problem-l5WiBcon.js";import{execFile as f}from"node:child_process";import{dirname as p,join as m}from"node:path";import{homedir as h,platform as g}from"node:os";import{setTimeout as _}from"node:timers/promises";import{randomUUID as v}from"node:crypto";import{AsyncLocalStorage as ee}from"node:async_hooks";import{chmod as te,mkdir as y,readFile as b,rename as x,rm as S,stat as ne,writeFile as C}from"node:fs/promises";function w(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(ae(t)?t:`${oe(t)}://${t}`),r=E(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function T(e){let n=w(e);return n.isLoopback?w(t()).host:n.host}function re(e){return{...e,host:w(e.host).origin}}function ie(e){let t=w(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function ae(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function oe(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return E(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function E(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var D=l({createdAt:a({offset:!0}),description:c().nullish(),expiresAt:a({offset:!0}).nullish(),id:c().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:a({offset:!0}).nullish(),name:c(),revocationReason:c().nullish(),scopes:o(c()),status:s([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:c(),updatedAt:a({offset:!0})});function O(e,t=[]){let n=e instanceof Error?e.message:String(e);return d(n,t)}function se(e,t=[]){let n=d(e.title,t),r=d(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function ce(){if(g()===`win32`){let e=process.env.APPDATA??m(h(),`AppData`,`Roaming`);return m(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??m(h(),`.config`);return m(e,`aventure`,`config.json`)}function le(){let t=process.env[e.authToken];return typeof t==`string`&&t.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function k(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var ue=2;function de(e,t){return j(e,t).redactedUrl}async function fe(e,t,n){let r=j(e,t);return await A(new URL(r.openerUrl),n)}async function A(e,t){let n=t.environment??process.env,r=t.operatingSystem??g(),i=M(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=pe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await me(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function j(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=E(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==ue||u.length!==1||u[0]!==n||d.length!==1||f.length===0||i.length===0||f===i)throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let p;try{p=decodeURIComponent(r)}catch{throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`)}if(r.includes(i)||p.includes(i))throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let m=new URL(a);return m.hash=new URLSearchParams({cliAuthorizationId:n,browserSecret:`<redacted>`}).toString(),{openerUrl:r,redactedUrl:m.toString()}}function M(e,t,n){return e?`--no-browser was set`:n===`darwin`&&t.CODEX_SESSION_ID?`macOS Codex browser process boundary`:t.SSH_CONNECTION||t.SSH_CLIENT||t.SSH_TTY?`SSH/headless session detected`:(n===`linux`||n===`freebsd`)&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?`no graphical display detected`:null}function pe(e,t){return e===`darwin`?{command:`open`,arguments:[t]}:e===`win32`?{command:`rundll32.exe`,arguments:[`url.dll,FileProtocolHandler`,t]}:e===`linux`||e===`freebsd`?{command:`xdg-open`,arguments:[t]}:null}function me(e,t){return new Promise((n,r)=>{f(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var he=100,N=3e4,ge=6e4,P=new ee;function F(){return m(p(ce()),`credentials.json`)}function I(e){return`OS keyring is unusable (${e}); the credential will be stored in ${F()} (mode 0600).\n`}async function L(e,t){let n=(await W())[e]?.[t];if(n!==void 0)return{record:{provider:`file`,value:n}};try{let n=await(await U(e,t)).getPassword()??void 0;return n===void 0?{}:{record:{provider:`keyring`,value:n}}}catch(e){return{keyringFailure:H(e)}}}async function R(e,t,n){if((await W())[e]?.[t]!==void 0)return await z(e,t,n,`file store holds this account`);let r;try{let i=await U(e,t);if(await i.setPassword(n),await i.getPassword()===n)return await q(e,t,void 0),`keyring`;r=`Error: keyring readback did not match`}catch(e){r=H(e,[n])}return await z(e,t,n,r)}async function z(e,t,n,r){if(await q(e,t,n),(await W())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function B(e,t){try{let n=await U(e,t),r;try{await n.deleteCredential()}catch(e){r=e}let i;try{i=await n.getPassword()??void 0}catch(e){throw Error(`OS keyring removal outcome is unknown (${H(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${H(r)})`,r===void 0?void 0:{cause:r})}finally{await q(e,t,void 0)}}async function V(e,t){let n=`${t}:probe:${v()}`,r=`aventure-cli-credential-probe:${v()}`,i;try{let t=await U(e,n);await t.setPassword(r);let a=await(await U(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await U(e,n)).getPassword()??void 0;if(a!==r)i=`Error: probe readback did not match`;else if(!o||s!==void 0)i=`Error: probe cleanup was not confirmed`;else return{provider:`keyring`}}catch(e){i=H(e,[r])}try{await K(async()=>{await q(e,n,r);let t=(await W())[e]?.[n];if(await q(e,n,void 0),t!==r)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${i}; file ${F()}: ${H(e,[r])})`,{cause:e})}return{provider:`file`,keyringFailure:i}}function H(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=O(e,t).trim().split(`
|
|
2
2
|
`,1);return r&&r!==n?`${n}: ${r}`:n}async function U(e,t){let n=g(),r=n===`linux`||n===`freebsd`?M(!1,process.env,n):null;if(r!==null)throw Error(`OS keyring unlock prompt is unreachable (${r})`);let{AsyncEntry:i}=await import(`@napi-rs/keyring`);return new i(e,t)}async function W(){let e=F(),t;try{t=await b(e,`utf8`)}catch(e){if(k(e,`ENOENT`))return{};throw e}let n;try{n=JSON.parse(t)}catch(t){return await G(e,t)}return ve(n)?n:await G(e,void 0)}async function G(e,t){let r=`${e}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await x(e,r)}catch(t){if(k(t,`ENOENT`))return{};throw Error(`${e} is not a valid credential file and could not be moved aside`,{cause:t})}return n({component:u().bin[0],event:`credential_file_quarantined`,message:`${e} is not a valid credential file; moved it to ${r} and continuing with an empty file store`,...t===void 0?{}:{error:t}}),{}}async function K(e){if(P.getStore()===!0)return await e();let t=`${F()}.lock`;await y(p(t),{recursive:!0,mode:448});let n=Date.now()+N,r=v();for(;;){try{await C(t,r,{flag:`wx`,mode:384});break}catch(e){if(!k(e,`EEXIST`))throw e}if(await ne(t).then(e=>Date.now()-e.mtimeMs,()=>0)>ge)await S(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await _(he)}try{return await P.run(!0,e)}finally{await b(t,`utf8`).catch(()=>``)===r&&await S(t,{force:!0})}}async function q(e,t,n){await K(async()=>await _e(e,t,n))}async function _e(e,t,n){let r=F(),i=await W(),a={...i[e]};if(n===void 0?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,Object.keys(i).length===0){await S(r,{force:!0});return}await y(p(r),{recursive:!0,mode:448});let o=`${r}.${v()}.tmp`;await C(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await te(o,384),await x(o,r)}function ve(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`))}var J=`vc.aventure.aventure-cli`,Y=`aventure-cli-personal-v1`;async function ye(e,t,n){let r=T(e),i=Se(t,n),a;try{a=await R(J,r,i)}catch(e){throw Error(`${O(e,[i,t.secret])}; broker acknowledgment was withheld. Re-run auth status before retrying.`,{cause:e})}return{host:r,provider:a,activation:n,credential:t}}async function X(e){let t=T(e),n;try{n=await L(J,t)}catch(e){return Z(O(e))}let{record:r,keyringFailure:i}=n;return r===void 0?i===void 0?{state:`missing`}:{state:`missing`,keyringFailure:i}:{state:`found`,stored:{host:t,provider:r.provider,...Ce(r.value)}}}async function be(e){let t=await X(e);if(t.state!==`missing`)return t;try{let{keyringFailure:t}=await V(J,T(e));return t===void 0?{state:`missing`}:{state:`missing`,keyringFailure:t}}catch(e){return Z(O(e))}}async function xe(e){await B(J,T(e))}function Z(e){return{state:`unavailable`,summary:e,cause:`storage`}}function Se(e,t){return`${Y}:${t}\n${JSON.stringify(e.apiKey)}\n${e.secret}`}function Ce(e){let t=e.indexOf(`
|
|
3
3
|
`),n=t<0?-1:e.indexOf(`
|
|
4
4
|
`,t+1),r=t<0?e:e.slice(0,t),i=r===`${Y}:active`?`active`:`pending`;if(t<0||n<0||r!==`${Y}:pending`&&r!==`${Y}:active`)throw Error(`OS credential entry has an unsupported format`);let a=e.slice(n+1);if(a.length===0)throw Error(`OS credential entry has an empty secret`);let o;try{o=JSON.parse(e.slice(t+1,n))}catch(e){throw Error(`OS credential entry failed canonical schema validation`,{cause:e})}let s=D.safeParse(o);if(!s.success)throw Error(`OS credential entry failed canonical schema validation`,{cause:s.error});return{activation:i,credential:{apiKey:s.data,secret:a}}}async function we(t){if(Q())return;let a=T(i().host);try{let n=await X(a);if(n.state===`unavailable`){r($(`keyring`,Error(n.summary)));return}n.state===`found`&&n.stored.activation===`active`&&!Q()&&(process.env[e.authToken]=n.stored.credential.secret,t?.(`api-key`))}catch(e){n($(`parse`,e))}}function Q(){return(process.env[e.authToken]?.trim().length??0)>0}function $(e,t){return{component:u().bin[0],event:`api_key_materialization_unavailable`,message:`saved API key could not be loaded; continuing with environment auth`,fields:{source:e},error:t}}export{re as S,se as _,ye as a,w as b,V as c,R as d,A as f,O as g,le as h,X as i,L as l,de as m,xe as n,B as o,fe as p,be as r,I as s,we as t,K as u,D as v,T as x,ie as y};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a,f as o,h as s,i as c,m as l,o as u,v as d,x as f}from"./logging-DTNdmwAo.js";import{b as p,c as m,i as h,s as g,t as ee,v as te,x as ne,y as re}from"./tool-policy-REHUxPRf.js";import{M as ie,O as ae,i as _,o as oe,v as se,w as v,y}from"./person-owner-BJgNYLKX.js";import{Ar as ce,Br as le,Kr as ue,Mr as de,Pr as fe,Rr as pe,Wr as me,jr as he,kr as ge}from"./dist-Y8BzTddB.js";import{c as b,f as _e,n as ve,r as x}from"./result-envelope-Bf2rWJBp.js";import{a as S,n as ye,r as be,t as xe}from"./package-DPDX5zmx.js";import{a as Se,i as Ce}from"./response-problem-z9UkqQAr.js";import{n as we,r as Te}from"./output-spill-CuPzxAFT.js";import{_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,i as Me,l as Ne,m as Pe,n as C,o as Fe,r as Ie,s as Le,u as Re}from"./contract-G_MHsm5B.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-Bh7GbTIq.js";import{S as Ke,_ as qe,a as Je,g as w,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as T,y as it}from"./api-key-bearer-credential-8FeXnis3.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-C3Ecq5KV.js";import{n as ht,r as gt,t as _t}from"./oauth-login-DIqqLJ1E.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-D_RAhhtv.js";import{n as Ot,t as E}from"./openapi-commands-Da2LuJv2.js";import{i as D,r as kt,t as O}from"./output-mode-Df4yQqaM.js";import{spawnSync as At}from"node:child_process";import{basename as k,dirname as A,relative as jt,resolve as j,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as M,lstatSync as Pt,mkdirSync as Ft,mkdtempSync as It,readFileSync as Lt,readdirSync as Rt,readlinkSync as zt,realpathSync as Bt,renameSync as Vt,symlinkSync as Ht,writeFileSync as Ut}from"node:fs";import N,{stderr as P,stdin as Wt}from"node:process";import{TextDecoder as Gt,inspect as Kt}from"node:util";import{homedir as qt,hostname as Jt,platform as Yt}from"node:os";import{fileURLToPath as Xt}from"node:url";import{setTimeout as Zt}from"node:timers/promises";import{randomUUID as Qt,webcrypto as $t}from"node:crypto";import{readFile as en}from"node:fs/promises";import{createInterface as tn}from"node:readline/promises";function nn(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function rn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!vn(n,r.name))continue;let a=_n(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 an(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 on(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return Sn(e,t,n);for(let[r,i]of n.entries()){let n=Sn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function sn(e,t,n,r){return Sn(e,t,r,n)}function cn(e){let t=[];for(let n of e.split(`.`)){let e=wn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function ln(e,t){let n=cn(t);if(n===null)return null;let r=gn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:hn(r)}:null}function un(e,t){if(F(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var dn=/^(?<row>\d+):(?<item>.*)$/su;function fn(e,t){let n=cn(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=dn.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 pn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&cn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function mn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=ln(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||fn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function hn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function gn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function _n(e,t){if(!F(t))return gn(e,t.split(`.`))}function vn(e,t){return bn(e,t.split(`.`))}function yn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&vn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function bn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=wn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>bn(e,r)):bn(a,r)}function F(e){return e.split(`.`).some(e=>wn(e).isArray)}function xn(e,t){return e.parameter.length===0||!I(t)?null:En(t,[],Tn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=wn(o),c=e===i.length-1,l=Cn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function Cn(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return I(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return I(s)?b(`Body path stepped`,s):o()}function wn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function Tn(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 En(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=En(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!Dn(a,n)){if(!On(e))continue;let t=kn(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=En(i,e,n);if(o!==null)return o}return null}function Dn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function On(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function kn(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:An(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 An(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}var jn=e=>Array.isArray(e)&&!Object.isFrozen(e);function Mn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=fe(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!jn(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);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?Bn(r,i):r===void 0?i===void 0?0:1:-1})}function Nn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function Pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Rn(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 In(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Ln(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Rn(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${zn(e,t)}`}function zn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=cn(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 Bn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Vn(e){let t;try{t=e===`-`?await Hn():await en(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function Hn(){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 Un=`--content-type`;function Wn(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Un)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Un} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Kn(a)))}if(ur(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,Ln(r,r.requiredPath)).argParser(Jn(`--from-file`)))}let o=Nn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Pn(n),a.length>1?Fn(n):Rn(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?In(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Gn):F(i.name)||i.schemaType===`array`?o.argParser(qn):o.argParser(Jn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}lr(e,n,o)}function Gn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Kn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Un} was already given; pass it once.`);let i=te(e,t);if(!i.ok)throw new n(i.summary);return t}}function qn(e,t){return[...t??[],e]}function Jn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Yn(e,t){let n=wt(e,t),r=te(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=Xn(e,i,t);if(a!==null)return x(a);let o=nn(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Zn(i,t);if(s!==null)return x(s);let c=await tr(t);if(!c.ok)return x(c.summary,c.warnings);let l=yn(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=er(e.operationId,i,c.data);if(!u.ok)return u;let d=rn(e.operationId,i,c.data);if(d!==null)return x(d);let f=nr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(cr(e.operationId,i)):b(`No body`,void 0);let p=ir(e.operationId,i,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let m=$n(i,p.data);if(m.length>0)return x(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?an(i).filter(e=>!vn(h,e)):[];return g.length>0?x(Qn(e.operationId,i,g)):p}function Xn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Un} ${i.join(` or `)}.`}return null}function Zn(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Qn(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 $n(e,t){return I(t)?e.parameter.filter(e=>e.required&&!vn(t,e.name)).map(L):[]}function er(e,t,n){let r=xn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function tr(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await Vn(t);if(!n.ok)return x(n.summary,n.warnings);let r=_e.safeParse(n.data);return r.success?b(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function nr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=un(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=rr(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=mn(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function rr(e,t,n,r,i){let a=fn(r,i);if(a===null){let e=or(r,i);return e.ok?on(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=pn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=sr(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=sn(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function ir(e,t,n,r){if(n===void 0)return b(`Direct body parsed`,r);if(r===void 0)return b(`Input parsed`,n);if(I(n)&&I(r))try{return b(`Input parsed`,ar(t,n,r))}catch(t){return x(`${e} ${t instanceof Error?t.message:String(t)}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ar(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ar(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:Le.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function or(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return sr(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=sr(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function sr(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function cr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=an(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function lr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Un,location:`body`}),ur(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Mn(e.options,r)}function ur(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function dr(e,t){let n=t.data,r=`jobId`,i=`statusUrl`,a=t.rolloverJob?.jobId??(typeof n==`object`&&n&&r in n&&typeof n[r]==`string`?n[r]:void 0),o=t.rolloverJob?.statusUrl??t.headers.location??(typeof n==`object`&&n&&i in n&&typeof n[i]==`string`?n[i]:void 0),s=t.headers[`retry-after`],c=`Pending: ${e.operationId??`request`}${a===void 0?``:` job ${a}`} is still running.`+(s===void 0?``:` Retry-After: ${s}.`)+(o===void 0?``:` Poll GET ${o} for the result.`);return{...e,summary:c,warnings:[...e.warnings,c],ids:a===void 0?e.ids:[...new Set([...e.ids,a])],references:o===void 0?e.references:[...new Set([...e.references,o])]}}function fr(e){let t=ve(e,hr(e));return xr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function pr(e){let t=ve(e,hr(e));xr(t);let n=De(E,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=mr(t);r.push(n.endsWith(`
|
|
1
|
+
import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a,f as o,h as s,i as c,m as l,o as u,v as d,x as f}from"./logging-Cbl234V4.js";import{S as p,a as m,b as h,c as g,l as ee,t as te,x as ne,y as re}from"./tool-policy-BUHiyuYu.js";import{M as ie,O as ae,i as _,o as oe,v as se,w as v,y}from"./person-owner-BJgNYLKX.js";import{Ar as ce,Br as le,Jr as ue,Mr as de,Pr as fe,Rr as pe,Xr as me,jr as he,kr as ge}from"./dist-Cf8kXL-8.js";import{c as b,f as _e,n as ve,r as x}from"./result-envelope-Bl_1n5Tb.js";import{a as S,n as ye,r as be,t as xe}from"./package-DPDX5zmx.js";import{a as Se,i as Ce}from"./response-problem-l5WiBcon.js";import{n as we,r as Te}from"./output-spill-CqEdAEnD.js";import{_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,i as Me,l as Ne,m as Pe,n as C,o as Fe,r as Ie,s as Le,u as Re}from"./contract-CU2UugQ0.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-BIiQwYpQ.js";import{S as Ke,_ as qe,a as Je,g as w,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as T,y as it}from"./api-key-bearer-credential-eFCSZ-cX.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-CKwu5Ed_.js";import{n as ht,r as gt,t as _t}from"./oauth-login-B5IM3hvP.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-S6FZrxDX.js";import{n as Ot,t as E}from"./openapi-commands-DtqjXQlN.js";import{i as D,r as kt,t as O}from"./output-mode-3tDGwmsL.js";import{spawnSync as At}from"node:child_process";import{basename as k,dirname as A,relative as jt,resolve as j,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as M,lstatSync as Pt,mkdirSync as Ft,mkdtempSync as It,readFileSync as Lt,readdirSync as Rt,readlinkSync as zt,realpathSync as Bt,renameSync as Vt,symlinkSync as Ht,writeFileSync as Ut}from"node:fs";import N,{stderr as P,stdin as Wt}from"node:process";import{TextDecoder as Gt,inspect as Kt}from"node:util";import{homedir as qt,hostname as Jt,platform as Yt}from"node:os";import{fileURLToPath as Xt}from"node:url";import{setTimeout as Zt}from"node:timers/promises";import{randomUUID as Qt,webcrypto as $t}from"node:crypto";import{readFile as en}from"node:fs/promises";import{createInterface as tn}from"node:readline/promises";function nn(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function rn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!vn(n,r.name))continue;let a=_n(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 an(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 on(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return Sn(e,t,n);for(let[r,i]of n.entries()){let n=Sn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function sn(e,t,n,r){return Sn(e,t,r,n)}function cn(e){let t=[];for(let n of e.split(`.`)){let e=wn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function ln(e,t){let n=cn(t);if(n===null)return null;let r=gn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:hn(r)}:null}function un(e,t){if(F(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var dn=/^(?<row>\d+):(?<item>.*)$/su;function fn(e,t){let n=cn(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=dn.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 pn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&cn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function mn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=ln(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||fn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function hn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function gn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function _n(e,t){if(!F(t))return gn(e,t.split(`.`))}function vn(e,t){return bn(e,t.split(`.`))}function yn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&vn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function bn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=wn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>bn(e,r)):bn(a,r)}function F(e){return e.split(`.`).some(e=>wn(e).isArray)}function xn(e,t){return e.parameter.length===0||!I(t)?null:En(t,[],Tn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=wn(o),c=e===i.length-1,l=Cn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function Cn(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return I(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return I(s)?b(`Body path stepped`,s):o()}function wn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function Tn(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 En(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=En(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!Dn(a,n)){if(!On(e))continue;let t=kn(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=En(i,e,n);if(o!==null)return o}return null}function Dn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function On(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function kn(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:An(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 An(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}var jn=e=>Array.isArray(e)&&!Object.isFrozen(e);function Mn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=fe(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!jn(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);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?Bn(r,i):r===void 0?i===void 0?0:1:-1})}function Nn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function Pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Rn(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 In(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Ln(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Rn(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${zn(e,t)}`}function zn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=cn(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 Bn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Vn(e){let t;try{t=e===`-`?await Hn():await en(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function Hn(){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 Un=`--content-type`;function Wn(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Un)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Un} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Kn(a)))}if(ur(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,Ln(r,r.requiredPath)).argParser(Jn(`--from-file`)))}let o=Nn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Pn(n),a.length>1?Fn(n):Rn(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?In(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Gn):F(i.name)||i.schemaType===`array`?o.argParser(qn):o.argParser(Jn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}lr(e,n,o)}function Gn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Kn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Un} was already given; pass it once.`);let i=re(e,t);if(!i.ok)throw new n(i.summary);return t}}function qn(e,t){return[...t??[],e]}function Jn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Yn(e,t){let n=wt(e,t),r=re(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=Xn(e,i,t);if(a!==null)return x(a);let o=nn(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Zn(i,t);if(s!==null)return x(s);let c=await tr(t);if(!c.ok)return x(c.summary,c.warnings);let l=yn(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=er(e.operationId,i,c.data);if(!u.ok)return u;let d=rn(e.operationId,i,c.data);if(d!==null)return x(d);let f=nr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(cr(e.operationId,i)):b(`No body`,void 0);let p=ir(e.operationId,i,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let m=$n(i,p.data);if(m.length>0)return x(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?an(i).filter(e=>!vn(h,e)):[];return g.length>0?x(Qn(e.operationId,i,g)):p}function Xn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Un} ${i.join(` or `)}.`}return null}function Zn(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Qn(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 $n(e,t){return I(t)?e.parameter.filter(e=>e.required&&!vn(t,e.name)).map(L):[]}function er(e,t,n){let r=xn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function tr(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await Vn(t);if(!n.ok)return x(n.summary,n.warnings);let r=_e.safeParse(n.data);return r.success?b(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function nr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=un(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=rr(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=mn(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function rr(e,t,n,r,i){let a=fn(r,i);if(a===null){let e=or(r,i);return e.ok?on(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=pn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=sr(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=sn(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function ir(e,t,n,r){if(n===void 0)return b(`Direct body parsed`,r);if(r===void 0)return b(`Input parsed`,n);if(I(n)&&I(r))try{return b(`Input parsed`,ar(t,n,r))}catch(t){return x(`${e} ${t instanceof Error?t.message:String(t)}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ar(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ar(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:Le.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function or(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return sr(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=sr(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function sr(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function cr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=an(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function lr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Un,location:`body`}),ur(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Mn(e.options,r)}function ur(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function dr(e,t){let n=t.data,r=`jobId`,i=`statusUrl`,a=t.rolloverJob?.jobId??(typeof n==`object`&&n&&r in n&&typeof n[r]==`string`?n[r]:void 0),o=t.rolloverJob?.statusUrl??t.headers.location??(typeof n==`object`&&n&&i in n&&typeof n[i]==`string`?n[i]:void 0),s=t.headers[`retry-after`],c=`Pending: ${e.operationId??`request`}${a===void 0?``:` job ${a}`} is still running.`+(s===void 0?``:` Retry-After: ${s}.`)+(o===void 0?``:` Poll GET ${o} for the result.`);return{...e,summary:c,warnings:[...e.warnings,c],ids:a===void 0?e.ids:[...new Set([...e.ids,a])],references:o===void 0?e.references:[...new Set([...e.references,o])]}}function fr(e){let t=ve(e,hr(e));return xr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function pr(e){let t=ve(e,hr(e));xr(t);let n=De(E,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=mr(t);r.push(n.endsWith(`
|
|
2
2
|
`)?n.slice(0,-1):n),r.push(...e),process.stdout.write(le(r.join(`
|
|
3
|
-
`)
|
|
4
|
-
`)
|
|
3
|
+
`),{appendNewline:!0,preservedTrailerLines:e.length}));return}let i=t.ok?`OK`:`FAIL`;r.push(`[${i}] ${t.summary}`),!t.ok&&t.problem!==void 0&&r.push(..._r(t.problem)),r.push(...mr(t)),process.stdout.write(le(r.join(`
|
|
4
|
+
`),{appendNewline:!0}))}function mr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function R(e,t){let n=Te(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?ve(n,hr(n)):n;xr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?we(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?fr(n):n;e.mode===`text`&&pr(r),r.ok||(process.exitCode=1)}function hr(e){let t=Me(e,E);if(t.write===!0||!e.ok)return t;let n=Ie(e,E);return n===void 0?t:{...t,exactRecovery:`Inline output is truncated. ${n}`}}function gr(e,t){if(typeof t==`object`&&t&&`httpStatus`in t&&t.httpStatus===202)return;let n=Fe(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
|
|
5
5
|
`),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function _r(e){let t=[];typeof e.code==`string`&&t.push(` code: ${e.code}`),typeof e.detail==`string`&&t.push(` detail: ${e.detail}`),typeof e.hint==`string`&&t.push(` hint: ${e.hint}`),typeof e.suggestion==`string`&&t.push(` suggestion: ${e.suggestion}`);let n=Object.entries(e.suggestions??{});if(n.length>0){let e=n.map(([e,t])=>`${e}=${t}`).join(`; `);t.push(` suggestions: ${e}`)}return typeof e.requiredRole==`string`&&t.push(` requiredRole: ${e.requiredRole}`),t.push(...vr(e),...yr(`unknownParameters`,e.unknownParameters),...yr(`validParameters`,e.validParameters),...br(e.resolution)),t}function vr(e){let t=[];return 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?[` meter: ${t.join(` `)}`]:[]}function yr(e,t){return t!=null&&t.length>0?[` ${e}: ${t.join(`, `)}`]:[]}function br(e){if(e==null)return[];let t=[`action=${e.action}`];return 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}`),[` resolution: ${t.join(` `)}`]}function xr(e){if(e.ok&&e.warnings.length===0)return;let t=e.truncation===void 0?e.warnings:[...e.warnings,`omitted: ${e.truncation.omitted.join(`, `)}`,`recovery: ${e.truncation.recovery}`];u({component:S().bin[0],event:e.ok?`command_warning`:`command_failed`,message:t.length>0?t.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function Sr(e,t,n=S().bin[0]){let r=e.limit===void 0?void 0:Number(e.limit);if(r!==void 0&&(e.limit?.trim()===``||!Number.isInteger(r)||r<0))return x(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=je(t,n),a=Oe(e.root??``),o=[...new Set(i.map(({cli:e})=>Oe(e.path.at(0)??``)))].toSorted();if(a.length>0&&!o.includes(a))return x(`Unknown --root value: ${JSON.stringify(e.root)}`,[`Pass one of: ${o.join(`, `)}.`]);let s=Pe(e.q??``,i.filter(t=>Er(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]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)],responseFieldLevel:Ee(e.operationId)})).map(({item:e})=>e),c=s.slice(0,r);return b(`Operation catalog matches`,{operation:c,count:{totalOperations:t.length,matched:s.length,returned:c.length}})}function Cr(e,t,n=S().bin[0]){let r=je(t,n),i=e.operationId===void 0?wr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=jr(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return x(`${i} is a command group; show one of its subcommands.`,[`Run \`${n} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let o=i.split(` `),s=new Set([...[...o.keys()].map(e=>o.slice(e+1).join(` `)),...o.slice(1).map((e,t)=>o.toSpliced(t,2,`${o[t]}-${e}`).join(` `))]),c=Sr({q:e.command??e.operationId},t,n),l=[...r.filter(({cli:e})=>e.path.length>1&&s.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...c.data?.operation??[]];return x(`Generated operation not found`,[...[...new Set(l.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${n} command-catalog search "<text>"\`.`])}return b(`Generated operation detail`,{operation:i,usage:Or(i,r)})}function wr(e,t){if(t===void 0)return;let{bin:n}=S(),r=jr(t,n);return e.find(e=>jr(e.cli.command,n)===r)}var Tr=(e,t)=>e===void 0||e===`all`||e===`any`||e===String(t);function Er(e,t){return(t.root===void 0||Dr(e,t.root))&&Tr(t.scope,e.scope)&&Tr(t.mutates,e.mutates)&&Tr(t.destructive,e.destructive)&&Tr(t.intent,e.intent)&&Tr(t.method,e.method)}function Dr(e,t){let n=Oe(t);return n.length===0||Oe(e.cli.path.at(0)??``)===n}function Or(e,t){let n=ke(e);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 (CLI-only operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,...e.successResponse===void 0?[]:[`success: ${e.successResponse}`],...[!0,!1].flatMap(t=>[`path`,`query`,`header`,`body`].map(r=>{let i=n.filter(e=>e.required===t&&e.location===r),a=Ar(`${t?`required`:`optional`} ${r} flags`,i);return t&&r===`body`&&e.body.kind===`json`&&i.length>0?`${a} (required unless --from-file sets JSON key(s) ${i.map(({wireName:e})=>e).join(`, `)})`:a})),...Ae(e,t),...kr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
6
6
|
`)}function kr(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}function Ar(e,t){return`${e}: ${t.length===0?`none`:t.map(e=>e.name).join(` `)}`}function jr(e,t=S().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var Mr=`dist/aventure-cli/command-catalog.compact.txt`,Nr=` · `,Pr=`-`;function Fr(e=S().bin[0]){return j(Ir(A(Xt(import.meta.url)),e),Mr)}function Ir(e,t){let n=e;for(;;){if(M(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 Lr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Rr(e,t,n,r=S().bin[0]){let i=Sr(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Br({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Ur(i.data,Hr(e.format,`lines`)),summary:`Generated operation matches`})}function zr(e,t,n,r=S().bin[0]){let i=Cr(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Br({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Wr(i.data,Hr(e.format,`usage`)),summary:`Generated operation detail`})}function Br(e){let t=e.mode,n=Hr(e.opts.format,e.defaultFormat),r=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&r&&(n===`json`||n===`ndjson`)){R({mode:t},x(`--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 i=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.matched===0&&(r||e.opts.format===void 0||n===`text`)?`No generated operations matched.`:e.rendered,a=i.endsWith(`
|
|
7
7
|
`)?i:`${i}\n`;if(e.opts.output!==void 0){Ut(e.opts.output,a),R({mode:t},b(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(a,`utf8`),format:n},{counts:Yr(e.data)}));return}if(t===`text`){Vr(e.summary,a);return}R({mode:t},b(e.summary,e.data,{counts:Yr(e.data)}))}function Vr(e,t){let n=Te(b(e,t));if(!n.ok||n.data===null){R({mode:`text`},n);return}process.stdout.write(n.data.endsWith(`
|
|
@@ -11,7 +11,7 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a
|
|
|
11
11
|
`)}function Wr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?Jr(e.operation):t===`compact`?Gr(e.operation):e.usage}function Gr(e){let t=Kr(e);return[e.cli.command,e.summary,t.length===0?Pr:t.join(` `)].join(Nr)}function Kr(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function qr(e){return e.map(e=>`${e.cli.command}\n ${Jr(e)}`).join(`
|
|
12
12
|
`)}function Jr(e){let t=Kr(e);return[z(`operationId`,e.operationId),z(`scope`,e.scope),z(`mutates`,String(e.mutates)),z(`destructive`,String(e.destructive)),z(`intent`,e.intent),z(`resource`,e.resource),z(`cli`,e.cli.command),e.mcpTool===null?``:z(`mcpTool`,e.mcpTool),z(`method`,e.method),z(`path`,e.path),z(`auth`,e.auth),z(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),z(`requiredFlags`,t.join(` `)),z(`bodyKind`,e.body.kind??``),z(`bodyRequired`,String(e.body.required)),z(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function z(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function Yr(e){return`count`in e?e.count:{returned:1}}function Xr(e,t,n=S().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.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(`
|
|
13
13
|
`)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new Zr(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=ri(t);i!==void 0&&r.option(`--ask <question>`,i.summary),O(r),r.action(async function(r){let a=this.optsWithGlobals();if(a.help&&r.length===0){this.outputHelp();return}if(!a.help&&i!==void 0&&a.ask!==void 0){let e=D(a);if(r.length>0){R({mode:e},x(`Use either a command path or --ask, not both.`));return}R({mode:e},await si(i,a.ask,a.environment,e));return}let o=oi(e,r),s=t.find(t=>o!==void 0&&oi(e,t.cliPath)===o);if(a.help||o!==void 0&&s===void 0){o===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),o.outputHelp();return}let c=s===void 0?ai(r,t):b(`Resolved by command path`,{operationId:s.operationId});if(c.ok&&c.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!c.ok||c.data===null){R({mode:D(a)},c);return}zr({...a,...c.data},t,D(a,`text`),n)}),ni(e,t,n)}var Zr=class extends t{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,$r=6,ei={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!Ue.has(e.name())):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(Qr)}${e}\n${ti(n,a,i)}`}};function ti(e,t,n){return n.boxWrap(e,t-$r).replace(/^/gmu,` `.repeat($r))}function ni(e,t,n){for(let r of t){let i=oi(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=Ne(r.operationId,t,n),[c,...l]=kr(r.errorResponse),u=l.map(t=>ti(t.trimStart(),o,e).replace(/^ +/u,` `.repeat(Qr))),d=c===void 0?[]:[``,c,...u];return`\n${[...s,...d].join(`
|
|
14
|
-
`)}\n`})}}function ri(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&ci(e)!==void 0});return n.length===0?t:void 0}var ii='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ai(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?b(`Resolved by route`,{operationId:i.operationId}):x(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[ii]);let o=re.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return b(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=p(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return b(`Resolved by route template`,{operationId:l.operationId});let u=he({method:s,path:c});return!u.ok||u.data===null?x(u.summary,[...u.warnings,ii]):b(`Resolved by method and path`,{operationId:u.data.operation.operationId})}function oi(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 si(e,t,n,r){let i=ci(e);if(i===void 0)return x(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let a=await Yn(e,{[i.optionKey]:t});return a.ok?await de({method:e.method,path:ce(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:kt(r)?`json`:`auto`}):a}function ci(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 li(e,t,n){if(e.cliPath[0]!==`lookup`||!ui(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?x(i):x(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ui(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function di(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}var fi=y({artifact:v().nullish(),group:v().nullish(),name:v().nullish(),revision:v().nullish(),time:_({offset:!0}).nullish(),version:v().nullish()}),pi=y({build:fi}),mi=oe([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),hi=oe([`RSA_OAEP_256_A256_GCM_V1`]),gi=y({clientLabel:v().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:mi.nullish(),encryptionAlgorithm:hi.nullish(),encryptionPublicKey:v().min(344).max(12e3).nullish()}),_i=32;async function vi(){let e=await $t.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await $t.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function yi(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=bi(n,`wrapped key`,128,1024),s=bi(r,`nonce`,12,12),c=bi(i,`ciphertext`,1,65536),l=bi(a,`authentication tag`,16,16),u;try{u=await $t.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!==_i)throw Error(`broker credential used an invalid AES-256 key`);let e=await $t.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 $t.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Gt(`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 bi(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 xi=oe([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),Si=oe([`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`]),Ci=y({approvedAt:_({offset:!0}).nullish(),clientLabel:v(),clientPlatform:mi,comparisonCode:v(),consumedAt:_({offset:!0}).nullish(),createdAt:_({offset:!0}),expiresAt:_({offset:!0}),id:ae(),intervalSeconds:se().int().min(1),keyReadyAt:_({offset:!0}).nullish(),status:xi,terminalAt:_({offset:!0}).nullish(),terminalReason:Si.nullish(),updatedAt:_({offset:!0})}),wi=y({algorithm:hi,authenticationTag:v(),ciphertext:v(),nonce:v(),wrappedKey:v()}),Ti=y({delivery:wi.nullish(),expiresAt:_({offset:!0}),status:xi,terminalReason:Si.nullish()}),Ei=y({comparisonCode:v(),expiresAt:_({offset:!0}),id:ae(),intervalSeconds:se().int().min(1),pollSecret:v(),verificationUrl:v()}),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. Use --no-browser for OAuth device authorization only when the issuer advertises device-grant support; otherwise use --key --no-browser for API-key approval.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Use OAuth device authorization only when the issuer advertises device-grant support: print a sign-in URL and code, then wait for approval. Otherwise use --key --no-browser for API-key approval.`},{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 API-key approval URL and wait for approval 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.`}]}],Di=C(B,`start`),Oi=C(B,`poll`),ki=C(B,`acknowledge`),V=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${qe(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Fi(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},Ai=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${w(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function ji(e){let t=await ue(Ke(f()),{method:Di.method,path:ne(Di.path,{},Di.operationId),headers:{},contentType:`application/json`,body:e},Ei);if(t.ok&&t.redirect)throw new V(`start`,Ii(t.status));if(!t.ok)throw new V(`start`,t.problem);return Li(t.data)}async function Mi(e,t){let n=me(Oi.operationId),r=await ue(Ke(f()),{method:Oi.method,path:ne(Oi.path,{cliAuthorizationId:e},Oi.operationId),headers:{[n]:t}},Ti);if(r.ok&&r.redirect)throw new V(`poll`,Ii(r.status),[t]);if(!r.ok)throw new V(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Pi(r.headers[`retry-after`])}}async function Ni(e,t){let n=me(ki.operationId),r;try{r=await ue(Ke(f()),{method:ki.method,path:ne(ki.path,{cliAuthorizationId:e},ki.operationId),headers:{[n]:t}},Ci)}catch(e){throw new Ai(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new V(`acknowledge`,Ii(r.status),[t]);if(!r.ok)throw new V(`acknowledge`,r.problem,[t]);return r.data}function Pi(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Fi(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Ii(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Li(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())})`},[Kt.custom]:{enumerable:!1,value:a}})}async function Ri(e){let t=await zi(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await Je(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 — ${w(n,[e.credential.secret])}`}}}}async function zi(e){let t=Ke(f()),n;try{n=await ue(t,{method:`GET`,path:ce(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},rt)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${w(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: ${qe(n.problem,[e])}`}}var Bi=C(B,`revoke`);async function Vi(e){let t;try{t=T(f().host)}catch(e){return x(`auth logout: invalid API host — ${w(e)}`)}let n=await Hi(t),r=await Gi(t,e),i=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],a={host:t,revoked:!1,forgotten:!1,oauth:n};return r===null?n.state===`missing`?b(`No CLI credential is stored for this API host.`,a):n.state===`failed`?{...x(`auth logout: ${i[0]}`),data:a}:b(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,a,{warnings:i}):{...r,data:{...r.data??a,oauth:n},warnings:[...r.warnings,...i]}}async function Hi(e){let t=await dt(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Wi(t.stored):{revoked:!1};try{await at(e)}catch(e){return{state:`failed`,summary:w(e)}}return{state:`forgotten`,...n}}async function Ui(e){let t=Reflect.get(await _t(e),`revocation_endpoint`);return typeof t==`string`?ct(t,`revocation endpoint`,!0):void 0}async function Wi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Ui(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:mt(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:w(e,ut(n))}}}async function Gi(e,t){let n;try{n=await Xe(e)}catch(e){return x(`auth logout: stored credential could not be read — ${w(e)}`)}if(n.state===`unavailable`)return{...x(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await Ki(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...x(`auth logout: remote revocation was not confirmed; local credential preserved — ${i.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:qi(r,!1,!1)};try{await Qe(r.host)}catch(e){return{...x(`auth logout: local credential removal failed — ${w(e,[r.credential.secret])}`,[a?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:qi(r,a,!1)}}return b(a?`API key revoked remotely and removed locally.`:o?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,qi(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Ki(e){let t=Ke(f());try{let n=await ue(t,{method:Bi.method,path:ne(Bi.path,{},Bi.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},rt);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:qe(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:w(t,[e.credential.secret])}}}function qi(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Ji=`RSA_OAEP_256_A256_GCM_V1`,Yi=1,Xi=30,H=S().bin[0],Zi=`The local record remains pending and unavailable to ordinary commands. Re-run \`${H} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Qi(e){if(!Wt.isTTY)return x(`${H} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=f().host;t=T(e),n=it(e)}catch(e){return x(`auth login --key: invalid environment configuration — ${w(e)}`)}for(;;){let e;try{e=await et(t)}catch(e){return x(`auth login --key: credential storage could not be inspected — ${w(e)}`)}if(e.state===`unavailable`)return x(`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&&P.write(tt(e.keyringFailure));break}let n=await $i(e.stored);if(n!==null)return n}let r;try{r=await vi()}catch(e){return x(`auth login --key: ephemeral encryption key could not be created — ${w(e)}`)}let i=gi.safeParse({clientLabel:e.clientLabel?.trim()||(Jt().trim()||H).slice(0,120),clientPlatform:ra(),encryptionAlgorithm:Ji,encryptionPublicKey:r.publicKey});if(!i.success)return x(`auth login --key: ${ie(i.error)}`);let a;try{a=await ji(i.data)}catch(e){return x(`auth login --key: could not start browser authorization — ${w(e)}`)}let o;try{o=Ze(a,n)}catch(e){return x(`auth login --key: unsafe browser authorization URL rejected — ${w(e)}`)}if(!na(await $e(a,n,{noBrowser:e.noBrowser}),a,o))return x(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[o]});let s;try{s=await ta(a)}catch(e){return x(`auth login --key: authorization did not complete — ${w(e)}`,[],{references:[o]})}if(s.algorithm!==Ji)return x(`auth login --key: broker selected an unsupported encryption algorithm`);let c;try{c=await yi(r.privateKey,s)}catch(e){return x(`auth login --key: encrypted credential could not be opened — ${w(e)}`)}let l=await zi(c);if(l.state!==`verified`)return x(`auth login --key: decrypted credential was neither stored nor acknowledged — ${l.summary}`);let u;try{u=await Je(t,{apiKey:l.apiKey,secret:c},`pending`)}catch(e){return x(`auth login --key: credential could not be durably stored — ${w(e)}`)}let d;try{d=await ea(a)}catch(e){return U(u,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${w(e,[a.pollSecret])}`,Zi)}if(d.status!==`CONSUMED`)return U(u,!0,`auth login --key: broker returned ${d.status} after acknowledgment`,Zi);let p=await zi(c);if(p.state!==`verified`||!sa(p.apiKey,u.credential.apiKey))return U(u,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${p.summary}`,Zi);try{let e=await Je(t,{apiKey:p.apiKey,secret:c},`active`);return b(`API key stored; authenticated identity and broker acknowledgment verified.`,oa(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return U(u,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${w(e)}`,Zi)}}async function $i(e){let t=await zi(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?b(`API key is already stored and its authenticated identity was verified.`,oa(e,!0),{ids:[e.credential.apiKey.id]}):U(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${H} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&sa(t.apiKey,e.credential.apiKey))try{let n=await Je(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return b(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,oa(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return U(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${w(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${H} 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 U(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 \`${H} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Ki(e);if(n.outcome===`unconfirmed`)return U(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await Qe(e.host)}catch(t){return U(e,!1,`auth login --key: stale pending credential could not be removed — ${w(t,[e.credential.secret])}`)}return P.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
14
|
+
`)}\n`})}}function ri(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&ci(e)!==void 0});return n.length===0?t:void 0}var ii='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ai(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?b(`Resolved by route`,{operationId:i.operationId}):x(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[ii]);let o=h.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return b(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=ne(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return b(`Resolved by route template`,{operationId:l.operationId});let u=he({method:s,path:c});return!u.ok||u.data===null?x(u.summary,[...u.warnings,ii]):b(`Resolved by method and path`,{operationId:u.data.operation.operationId})}function oi(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 si(e,t,n,r){let i=ci(e);if(i===void 0)return x(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let a=await Yn(e,{[i.optionKey]:t});return a.ok?await de({method:e.method,path:ce(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:kt(r)?`json`:`auto`}):a}function ci(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 li(e,t,n){if(e.cliPath[0]!==`lookup`||!ui(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?x(i):x(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ui(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function di(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}var fi=y({artifact:v().nullish(),group:v().nullish(),name:v().nullish(),revision:v().nullish(),time:_({offset:!0}).nullish(),version:v().nullish()}),pi=y({build:fi}),mi=oe([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),hi=oe([`RSA_OAEP_256_A256_GCM_V1`]),gi=y({clientLabel:v().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:mi.nullish(),encryptionAlgorithm:hi.nullish(),encryptionPublicKey:v().min(344).max(12e3).nullish()}),_i=32;async function vi(){let e=await $t.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await $t.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function yi(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=bi(n,`wrapped key`,128,1024),s=bi(r,`nonce`,12,12),c=bi(i,`ciphertext`,1,65536),l=bi(a,`authentication tag`,16,16),u;try{u=await $t.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!==_i)throw Error(`broker credential used an invalid AES-256 key`);let e=await $t.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 $t.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Gt(`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 bi(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 xi=oe([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),Si=oe([`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`]),Ci=y({approvedAt:_({offset:!0}).nullish(),clientLabel:v(),clientPlatform:mi,comparisonCode:v(),consumedAt:_({offset:!0}).nullish(),createdAt:_({offset:!0}),expiresAt:_({offset:!0}),id:ae(),intervalSeconds:se().int().min(1),keyReadyAt:_({offset:!0}).nullish(),status:xi,terminalAt:_({offset:!0}).nullish(),terminalReason:Si.nullish(),updatedAt:_({offset:!0})}),wi=y({algorithm:hi,authenticationTag:v(),ciphertext:v(),nonce:v(),wrappedKey:v()}),Ti=y({delivery:wi.nullish(),expiresAt:_({offset:!0}),status:xi,terminalReason:Si.nullish()}),Ei=y({comparisonCode:v(),expiresAt:_({offset:!0}),id:ae(),intervalSeconds:se().int().min(1),pollSecret:v(),verificationUrl:v()}),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. Use --no-browser for OAuth device authorization only when the issuer advertises device-grant support; otherwise use --key --no-browser for API-key approval.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Use OAuth device authorization only when the issuer advertises device-grant support: print a sign-in URL and code, then wait for approval. Otherwise use --key --no-browser for API-key approval.`},{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 API-key approval URL and wait for approval 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.`}]}],Di=C(B,`start`),Oi=C(B,`poll`),ki=C(B,`acknowledge`),V=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${qe(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Fi(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},Ai=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${w(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function ji(e){let t=await me(Ke(f()),{method:Di.method,path:p(Di.path,{},Di.operationId),headers:{},contentType:`application/json`,body:e},Ei);if(t.ok&&t.redirect)throw new V(`start`,Ii(t.status));if(!t.ok)throw new V(`start`,t.problem);return Li(t.data)}async function Mi(e,t){let n=ue(Oi.operationId),r=await me(Ke(f()),{method:Oi.method,path:p(Oi.path,{cliAuthorizationId:e},Oi.operationId),headers:{[n]:t}},Ti);if(r.ok&&r.redirect)throw new V(`poll`,Ii(r.status),[t]);if(!r.ok)throw new V(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Pi(r.headers[`retry-after`])}}async function Ni(e,t){let n=ue(ki.operationId),r;try{r=await me(Ke(f()),{method:ki.method,path:p(ki.path,{cliAuthorizationId:e},ki.operationId),headers:{[n]:t}},Ci)}catch(e){throw new Ai(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new V(`acknowledge`,Ii(r.status),[t]);if(!r.ok)throw new V(`acknowledge`,r.problem,[t]);return r.data}function Pi(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Fi(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Ii(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Li(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())})`},[Kt.custom]:{enumerable:!1,value:a}})}async function Ri(e){let t=await zi(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await Je(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 — ${w(n,[e.credential.secret])}`}}}}async function zi(e){let t=Ke(f()),n;try{n=await me(t,{method:`GET`,path:ce(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},rt)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${w(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: ${qe(n.problem,[e])}`}}var Bi=C(B,`revoke`);async function Vi(e){let t;try{t=T(f().host)}catch(e){return x(`auth logout: invalid API host — ${w(e)}`)}let n=await Hi(t),r=await Gi(t,e),i=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],a={host:t,revoked:!1,forgotten:!1,oauth:n};return r===null?n.state===`missing`?b(`No CLI credential is stored for this API host.`,a):n.state===`failed`?{...x(`auth logout: ${i[0]}`),data:a}:b(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,a,{warnings:i}):{...r,data:{...r.data??a,oauth:n},warnings:[...r.warnings,...i]}}async function Hi(e){let t=await dt(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Wi(t.stored):{revoked:!1};try{await at(e)}catch(e){return{state:`failed`,summary:w(e)}}return{state:`forgotten`,...n}}async function Ui(e){let t=Reflect.get(await _t(e),`revocation_endpoint`);return typeof t==`string`?ct(t,`revocation endpoint`,!0):void 0}async function Wi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Ui(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:mt(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:w(e,ut(n))}}}async function Gi(e,t){let n;try{n=await Xe(e)}catch(e){return x(`auth logout: stored credential could not be read — ${w(e)}`)}if(n.state===`unavailable`)return{...x(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await Ki(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...x(`auth logout: remote revocation was not confirmed; local credential preserved — ${i.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:qi(r,!1,!1)};try{await Qe(r.host)}catch(e){return{...x(`auth logout: local credential removal failed — ${w(e,[r.credential.secret])}`,[a?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:qi(r,a,!1)}}return b(a?`API key revoked remotely and removed locally.`:o?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,qi(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Ki(e){let t=Ke(f());try{let n=await me(t,{method:Bi.method,path:p(Bi.path,{},Bi.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},rt);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:qe(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:w(t,[e.credential.secret])}}}function qi(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Ji=`RSA_OAEP_256_A256_GCM_V1`,Yi=1,Xi=30,H=S().bin[0],Zi=`The local record remains pending and unavailable to ordinary commands. Re-run \`${H} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Qi(e){if(!Wt.isTTY)return x(`${H} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=f().host;t=T(e),n=it(e)}catch(e){return x(`auth login --key: invalid environment configuration — ${w(e)}`)}for(;;){let e;try{e=await et(t)}catch(e){return x(`auth login --key: credential storage could not be inspected — ${w(e)}`)}if(e.state===`unavailable`)return x(`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&&P.write(tt(e.keyringFailure));break}let n=await $i(e.stored);if(n!==null)return n}let r;try{r=await vi()}catch(e){return x(`auth login --key: ephemeral encryption key could not be created — ${w(e)}`)}let i=gi.safeParse({clientLabel:e.clientLabel?.trim()||(Jt().trim()||H).slice(0,120),clientPlatform:ra(),encryptionAlgorithm:Ji,encryptionPublicKey:r.publicKey});if(!i.success)return x(`auth login --key: ${ie(i.error)}`);let a;try{a=await ji(i.data)}catch(e){return x(`auth login --key: could not start browser authorization — ${w(e)}`)}let o;try{o=Ze(a,n)}catch(e){return x(`auth login --key: unsafe browser authorization URL rejected — ${w(e)}`)}if(!na(await $e(a,n,{noBrowser:e.noBrowser}),a,o))return x(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[o]});let s;try{s=await ta(a)}catch(e){return x(`auth login --key: authorization did not complete — ${w(e)}`,[],{references:[o]})}if(s.algorithm!==Ji)return x(`auth login --key: broker selected an unsupported encryption algorithm`);let c;try{c=await yi(r.privateKey,s)}catch(e){return x(`auth login --key: encrypted credential could not be opened — ${w(e)}`)}let l=await zi(c);if(l.state!==`verified`)return x(`auth login --key: decrypted credential was neither stored nor acknowledged — ${l.summary}`);let u;try{u=await Je(t,{apiKey:l.apiKey,secret:c},`pending`)}catch(e){return x(`auth login --key: credential could not be durably stored — ${w(e)}`)}let d;try{d=await ea(a)}catch(e){return U(u,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${w(e,[a.pollSecret])}`,Zi)}if(d.status!==`CONSUMED`)return U(u,!0,`auth login --key: broker returned ${d.status} after acknowledgment`,Zi);let p=await zi(c);if(p.state!==`verified`||!sa(p.apiKey,u.credential.apiKey))return U(u,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${p.summary}`,Zi);try{let e=await Je(t,{apiKey:p.apiKey,secret:c},`active`);return b(`API key stored; authenticated identity and broker acknowledgment verified.`,oa(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return U(u,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${w(e)}`,Zi)}}async function $i(e){let t=await zi(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?b(`API key is already stored and its authenticated identity was verified.`,oa(e,!0),{ids:[e.credential.apiKey.id]}):U(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${H} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&sa(t.apiKey,e.credential.apiKey))try{let n=await Je(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return b(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,oa(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return U(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${w(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${H} 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 U(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 \`${H} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Ki(e);if(n.outcome===`unconfirmed`)return U(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await Qe(e.host)}catch(t){return U(e,!1,`auth login --key: stale pending credential could not be removed — ${w(t,[e.credential.secret])}`)}return P.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
15
15
|
`:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
|
|
16
16
|
`),null}async function ea(e){let t=new Date(e.expiresAt).getTime(),n=ia(e.intervalSeconds);for(;;)try{return await Ni(e.id,e.pollSecret)}catch(e){if(e instanceof V){if(!e.retryable)throw e;n=ia(e.retryAfterSeconds??n)}else if(!(e instanceof Ai))throw e;if(Date.now()>=t)throw e;P.write(`Broker acknowledgment was interrupted; retrying.
|
|
17
17
|
`),await aa(n,t)}}async function ta(e){let t=new Date(e.expiresAt).getTime(),n=ia(e.intervalSeconds),r;for(P.write(`Waiting for browser approval...
|
|
@@ -27,7 +27,7 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a
|
|
|
27
27
|
`)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>R({mode:D(e)},oo(void 0,`apply`,e.release)))}function oo(e,t=`apply`,n){let r=e;try{r??=S(process.argv[1])}catch(e){return x(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,o=r.registry===``?``:ye,s=r.registry===``&&i===`@aventurevc/aventure-cli`,c=n;if(c===void 0){let e=so([`view`,o,`version`,`--silent`,`--global`],r,{timeout:ro});if(!e.ok)return{...e,data:null};if(c=(e.data??``).trim(),c===``)return x(`npm view ${o} returned empty version`,[`empty_stdout`])}let l=n!==void 0||s||no.compare(a,c)<0,u={targetPackage:o,runningPackage:i,currentVersion:a,latestVersion:c,upgradeAvailable:l,upgradeInstalled:!1};if(t===`check`)return b(`${i}@${a} → ${o}@${c} (${l?`available`:`up to date`})`,u);if(r.workingTreeRoot!==null)return x(`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"]);try{let e=uo(r),t=j(e,...io),i=k(o),s=j(t,`${i}-current`),l=o===``?[o,``]:[o,be],d=fo(e,r),f=n??[c,d?.version??a].reduce((e,t)=>no.compare(e,t)<0?t:e,a);Ft(t,{recursive:!0});let p=[lo(r),...M(s)?[Bt(s)]:[],...Rt(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>j(t,e.name))],m,h=null,g=!1;for(let t of new Set(p.filter(t=>t!==e))){let e=co(t,l,f,r.registry);if(e.ok&&e.data!==null){m=t,h=e.data;break}}if(m===void 0){m=It(j(t,`${i}-${encodeURIComponent(f)}-`));let e=so([`install`,`-g`,`--prefix`,m,...l.map(e=>`${e}@${f}`)],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,data:null};g=!0;let n=co(m,l,f,r.registry);if(!n.ok)return{...n,data:null};h=n.data}if(h===null)throw Error(`release verification produced no package`);let ee=po(m,e,s,h,n),te=ho();return b(`${o} active at ${ee}`,{...u,upgradeInstalled:g||n!==void 0||d?.version!==ee,installPrefix:e,verifiedVersion:ee,completionRefreshed:te.refreshed,completionRefreshMessage:te.message})}catch(e){return x(`${o} update failed: ${mo(e)}`,[`existing releases were preserved`])}}function so(e,t,n={}){let r={...process.env};t.registry===``?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let i=[...e,`--@aventurevc:registry=${t.registry}`],a=At(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?x(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):x(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
|
|
28
28
|
`).slice(-3).join(` | `);return x(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return b(`npm ok`,a.stdout??``)}function co(e,t,n,r){try{let i=t.map(t=>{let i=S(j(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));if(i.name!==t||i.version!==n||i.registry!==r)throw Error(`${t} does not match ${n} from ${r}`);for(let t of i.bin)if(!Bt(j(e,`bin`,t)).startsWith(`${i.packageRoot}${Mt}`))throw Error(`${t} escapes ${i.packageRoot}`);return i});for(let t of i){let r=j(e,`bin`,t.bin[0]),i=At(process.execPath,[r,`--version`],{encoding:`utf8`,timeout:ro});if(i.error)throw Error(`${t.name} verification failed: ${i.error.message}`);let a=(i.stdout??``).trim();if(i.status!==0||a!==n)throw Error(`${t.name} expected ${n} but reported ${a||`empty output`}`)}return b(`CLI and MCP release verified`,i)}catch(t){return x(`release verification failed: ${mo(t)}`,[`release prefix: ${e}`])}}function lo(e){let t=A(e.packageRoot),n=A(t),r=A(n);if(k(t)!==e.name.split(`/`)[0]||k(n)!==`node_modules`||k(r)!==`lib`)throw Error(`the running package is not in a verifiable global npm prefix; npm install was not run`);if(!e.entryPath.startsWith(`${e.packageRoot}${Mt}`))throw Error(`the running entry escapes its package root`);return A(r)}function uo(e){let t=lo(e),n=`${Mt}${io.join(Mt)}${Mt}`,r=t.lastIndexOf(n);return r<0?t:t.slice(0,r)}function fo(e,t){let n=t.registry===``?k(``):xe,r=j(e,`bin`,n);if(!M(r))return null;let i=S(r);if(i.registry!==t.registry)throw Error(`${r} belongs to another product`);return i}function po(e,t,n,r,i){let a=r[0];if(a===void 0)throw Error(`release contains no CLI`);let o=j(t,`bin`);Ft(o,{recursive:!0});let s=r.flatMap(e=>e.bin.filter((e,t)=>{let n=j(o,e);if(!M(n)||S(n).registry===a.registry)return!0;if(a.registry!==``&&t>0)return!1;throw Error(`${n} belongs to another product`)}));if(!M(n)){let t=It(j(A(n),`${k(n)}-seed-`));Ft(j(t,`bin`));for(let n of s){let r=j(o,n);Ht(Bt(M(r)?r:j(e,`bin`,n)),j(t,`bin`,n))}try{Ht(jt(A(n),t),n)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`EEXIST`))throw e}}if(!Pt(n).isSymbolicLink())throw Error(`${n} is not a release symlink`);for(let e of s){let t=jt(o,j(n,`bin`,e)),r=j(o,`.${e}-${Qt()}`);Ht(t,r),Vt(r,j(o,e))}for(let e of s){let t=j(o,e);if(!Pt(t).isSymbolicLink()||j(o,zt(t))!==j(n,`bin`,e))throw Error(`${t} does not follow the product current pointer`)}let c=fo(t,a);if(i===void 0&&c!==null&&no.compare(c.version,a.version)>0)return c.version;let l=`${n}-${Qt()}`;return Ht(jt(A(n),e),l),Vt(l,n),a.version}function mo(e){return e instanceof Error?e.message:String(e)}function ho(){try{return Ba()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var go=[{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`},{name:`auth`,purpose:`which credential signs in, as which account and role, never secrets`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}];function _o(e,t=S().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: [...] }`:",...go.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable) or a`,`warned one (the account read failed) does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
|
|
29
29
|
`))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),R({mode:D(e)},await vo(t))})}async function vo(e){let t=bo(),n=xo(e),[r,i]=await Promise.all([So(e),Co(t,e)]),a=[n.check,r,i.check,await To(e),Mo(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:yo(a,`pass`),warn:yo(a,`warn`),fail:yo(a,`fail`),skip:yo(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.warn} warn, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
30
|
-
`);return c.ok?b(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function yo(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function bo(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function xo(e){let t=S(),n=oo(t,`check`);if(!n.ok||n.data===null)return{check:K(`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?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function So(e){try{let{EntityDetailSchema:e}=await import(`./detail-
|
|
30
|
+
`);return c.ok?b(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function yo(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function bo(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function xo(e){let t=S(),n=oo(t,`check`);if(!n.ok||n.data===null)return{check:K(`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?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function So(e){try{let{EntityDetailSchema:e}=await import(`./detail-jqEwPPHS.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return K(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return K(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${w(t)}.`)}}async function Co(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:K(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${w(e)}.`),servedFingerprint:null}}let i=await de({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>x(w(e)));return i.ok?{check:K(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:wo(i.data)}:{check:K(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function wo(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.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function To(e){let t=Ye(),[n,r]=await Promise.all([Do(),Oo()]);if(r.state===`unavailable`&&r.cause===`environment`)return K(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return K(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&ot(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return K(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${o.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await Eo(e,t);return K(`auth`,i.status,`Credential source available: ${ko(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${o.authToken} through the environment — ${r.summary}.`):K(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${o.authToken} in the environment.`)}async function Eo(e,t){let n=T(f().host),r=await la(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await ca(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${w(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function Do(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e)}}return await ft(e)}async function Oo(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e),cause:`environment`}}try{return await et(e)}catch(e){return{state:`unavailable`,summary:w(e),cause:`storage`}}}function ko(e,t,n){return[Ma(e),`oauth=${jo(t)}`,`api-key=${Ao(n)}`].join(` `)}function Ao(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=T(f().host);return`${e.stored.activation}${_a(t,e)}`}function jo(e){switch(e.state){case`found`:return ot(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 Mo(e,t,n,r){let i=E.length;if(e===void 0)return K(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return K(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ot}.`);if(t===`00e46a6dabbc62cc`)return K(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ot}).`);let a=`This catalog describes a different operation set than the API serves (${Ot} vs ${t})`;return n===!0?K(`catalog`,`fail`,`${a}: run \`${r} update\`.`):K(`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 No=C(B,`oauth`),Po=[C(B,`start`),C(B,`poll`),C(B,`acknowledge`)],Fo=C(B,`revoke`);function Io(e,n=S().bin[0]){let r=Bo(e);_o(r,n);let i=[`${No.description} Default method: OAuth in your browser.`,`With --key: ${Po.map(({description:e})=>e).join(` `)}`].join(`
|
|
31
31
|
`);O(zo(r,[No,...Po],i)).action(Lo),O(zo(r,[Fo],Fo.description)).action(Ro),O(r.command(`status`).summary(`Keep saved credentials current and report them`).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`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
|
|
32
32
|
`)).addOption(new t(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Vo(this),R({mode:D(e)},await Ho(n,e.verify))}),r.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${o.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
|
|
33
33
|
`)).action(async function(){Vo(this);let e=await la(n),t=process.env[o.authToken]?.trim();if(e.failure===null&&t!==void 0&&t.length>0){process.stdout.write(`${t}\n`);return}R({mode:`text`},e.failure===null?Xo(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):x(`auth token: ${e.failure}`))})}async function Lo(e){Vo(this);let t=D(e);if(e.providers===!0){R({mode:t},await Wo());return}R({mode:t},e.key===!0?await Qi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await gt({noBrowser:!e.browser}))}async function Ro(e){Vo(this),R({mode:D(e)},await Vi({forgetLocal:e.forgetLocal===!0}))}function zo(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 Bo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${No.command}\`: ${No.summary}; \`--key\` ${Po[0].summary.toLowerCase()}.`,`\`${Fo.command}\`: ${Fo.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build metadata.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
|
|
@@ -55,8 +55,8 @@ end
|
|
|
55
55
|
`)}function tc(e,t=``){if(e.commands.length>0&&!Js(Y(e)))return;let n=e.options.flatMap(e=>e.hidden?[]:[J(e)]),r=xt(E),i=Re(t,r,Y(e),X(e).name());return`${i===void 0?``:`hint: an id you already hold is read with: ${i}\n`}hint: ${Y(e).join(` `)} accepts: ${n.join(` `)}`}function nc(e,t){let n=js(t,`unknown command`);if(n===void 0||t.message.includes(`
|
|
56
56
|
(Did you mean `))return;let r=Ws(e),i=process.argv.slice(2+Y(e).length);if(r.length>0&&r.every((e,t)=>i[t]===e)){let t=Gs(e,r);if(t!==void 0)return t}let a=Y(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Js(o)?o:void 0)??Hs(e,n)??Us(e,n);if(s!==void 0)return Ks(e,s,r)??ec(e,s.join(` `),!1);let c=r.join(` `)||n,l=qs(e)??ec(e,c),u=[...a,...r.slice(1)];return[l,r.length===a.length+a.length&&a.at(-1)===a.at(0)?Ks(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Ks(e,u,r):void 0].filter(e=>e!==void 0).join(`
|
|
57
57
|
`)||void 0}function rc(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`)}let r=Ps(e);for(let e of r)process.stderr.write(`error: unknown option '${e}'\n`);for(let n of[Fs(e)??(r.length>0?tc(e):void 0),Os(e),Ms(e,t),...Xs(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Os(e)??Zs(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=js(t,`unknown option`),r=Fs(e)??Bs(e,t)??(n!==void 0&&!t.message.includes(`
|
|
58
|
-
(Did you mean `)?$s(e,n)??Gs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??tc(e,n)??ec(e,Y(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=nc(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.helpDisplayed`){let[n]=e.args;if(n?.startsWith(`-`)===!1&&e.registeredArguments.length===0){let r=[X(e).name(),...Y(e)].join(` `);t.exitCode=1,process.stderr.write(`hint: ${r} takes no '${n}' subcommand; the help shown is for ${r}\n`)}}throw t}}var ic=class extends t{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 ac(e){e.showHelpAfterError(!1).exitOverride(rc(e)),e.commands.length===0?e.hook(`preAction`,Ds):e.registeredArguments.length===0&&!Ys(Y(e))&&e.addHelpOption(new ic(e));for(let t of e.commands)ac(t)}function oc(e,t=new Date){let n=lc(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 sc(e){return`${JSON.stringify(e,null,2)}\n`}function cc(e,t){let n=j(e),r=sc(t);return Ft(A(n),{recursive:!0}),Ut(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function lc(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,mcpTool:
|
|
59
|
-
`));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 ${Fr(n)}\n`),pc(r,t,n),mc(r,t,n),hc(r,t,n),gc(r)}function pc(e,n,r){let i=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>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--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 t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(e){let t=this.optsWithGlobals(),i=D(t,`text`),a=Lr(t,e);Rr(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function mc(e,n,r){let i=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 ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();zr(e,n,D(e,`text`),r)})}function hc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();Rr(e,n,D(e,`text`),r)})}function gc(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(async function(){let e=this.optsWithGlobals(),t=D(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-
|
|
58
|
+
(Did you mean `)?$s(e,n)??Gs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??tc(e,n)??ec(e,Y(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=nc(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.helpDisplayed`){let[n]=e.args;if(n?.startsWith(`-`)===!1&&e.registeredArguments.length===0){let r=[X(e).name(),...Y(e)].join(` `);t.exitCode=1,process.stderr.write(`hint: ${r} takes no '${n}' subcommand; the help shown is for ${r}\n`)}}throw t}}var ic=class extends t{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 ac(e){e.showHelpAfterError(!1).exitOverride(rc(e)),e.commands.length===0?e.hook(`preAction`,Ds):e.registeredArguments.length===0&&!Ys(Y(e))&&e.addHelpOption(new ic(e));for(let t of e.commands)ac(t)}function oc(e,t=new Date){let n=lc(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 sc(e){return`${JSON.stringify(e,null,2)}\n`}function cc(e,t){let n=j(e),r=sc(t);return Ft(A(n),{recursive:!0}),Ut(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function lc(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,mcpTool:ee(e.intent),bodySchemaName:e.requestBody?.[0]?.schemaName??null,bodySchemaImport:e.requestBody?.[0]?.schemaImport??null,auth:e.projection.auth,scope:e.projection.scope,destructive:e.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var uc=`Match only the first canonical or CLI-alias command segment`,dc=[`text`,`lines`,`compact`,`json`,`ndjson`];function fc(e,t,n=S().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(`
|
|
59
|
+
`));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 ${Fr(n)}\n`),pc(r,t,n),mc(r,t,n),hc(r,t,n),gc(r)}function pc(e,n,r){let i=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>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--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 t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(e){let t=this.optsWithGlobals(),i=D(t,`text`),a=Lr(t,e);Rr(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function mc(e,n,r){let i=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 ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();zr(e,n,D(e,`text`),r)})}function hc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();Rr(e,n,D(e,`text`),r)})}function gc(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(async function(){let e=this.optsWithGlobals(),t=D(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-N93eBv4f.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},b(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=oc(n);if(e.output!==void 0){let n=cc(e.output,r);R({mode:t},b(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){Vr(`Unified operations JSON`,sc(r));return}R({mode:t},b(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var _c=S(Xt(import.meta.url)),Q=_c.bin[0];function vc(e,t){let n=e instanceof Error?e:Error(String(e));c({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof ge?{httpStatus:n.problem.status,problem:n.problem}:{};fr({...x(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function yc(e){return Ge[Ve(e,vt)??`cli`]}function bc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:yc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>Et(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)xc(e,t,r,a,i.has(t.cliPath.join(` `)))}function xc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=Sc(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.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,...d].some(e=>m(e.schemaType,e.itemSchemaType))?te:``].filter(Boolean).join(`
|
|
60
60
|
`));let f=Dt(t);for(let e of t.parameters)Cc(u,e,i||e===f);if(Wn(u,t),g(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),O(u),u.hook(`preAction`,e=>St(e,t)),t.explain===!0&&u.option(`--explain`,`Print the search strategy and parsed constraints before the results`),f!==void 0){u.argument(`[text...]`,f.description||`Same as ${Tt(f.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),r=D(n),i=bt(f,e,n);if(!i.ok||i.data===null)return R({mode:r},i);let a=yt(t,i.data);if(a.length>0)return R({mode:r},x(`missing required options: ${a.join(`, `)}`));let o=await wc(t,i.data,r),s=li(t,i.data,o);if(s!==null)return R({mode:r},s);n.explain===!0&&o.ok&&gr(r,o.data),o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):R({mode:r},o)});return}u.action(async function(){let e=this.optsWithGlobals(),n=D(e),r=yt(t,e);if(r.length>0)return R({mode:n},x(`missing required options: ${r.join(`, `)}`));let i=await wc(t,e,n),a=li(t,e,i);if(a!==null)return R({mode:n},a);e.explain===!0&&i.ok&&gr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):R({mode:n},i)})}function Sc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=vt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function Cc(e,n,r=!1){let i=n.description||`${n.name} ${n.location} parameter`,a=n.defaultValue===void 0?void 0:typeof n.defaultValue==`string`||typeof n.defaultValue==`boolean`?n.defaultValue:[...n.defaultValue];if(n.legacyFlag!==void 0){let o=new t(n.flag,i);a!==void 0&&o.default(a);let s=new t(n.legacyFlag,i).conflicts(n.optionKey);e.addOption(o).addOption(s),e.hook(`preAction`,e=>{let t=e.opts(),i=t[n.optionKey],a=t[s.attributeName()];if(a!==void 0){(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`);return}!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(a!==void 0){e.option(n.flag,i,a);return}if(n.required&&!r){e.requiredOption(n.flag,i);return}e.option(n.flag,i)}async function wc(e,t,n){if(t.environment!==void 0){let e=d(t.environment);if(e===null)return x(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${a().join(`, `)}`]);process.env.API_ENV=e}let r=await Yn(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)]})),o=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 di(e,await de({method:e.method,path:ce(e.operationId,i),searchParams:o,headers:s,body:r.data,contentType:wt(e,t),auth:e.auth,responseFormat:kt(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0,pendingResult:dr}))}process.on(`uncaughtException`,e=>vc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>vc(e,`unhandledRejection`));var Tc=Ct(process.argv.slice(2),E),Ec=Tc===`required`?E:xt(E),$=new Es;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(ei).version(_c.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.
|
|
61
61
|
`,`Mutations execute directly; --execute is a deprecated no-op.
|
|
62
62
|
The aVenture MCP server tools execute through this same CLI.`].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e}from"./tool-policy-BUHiyuYu.js";function t(t,n,r,i){let a=t===`array`?n:t,o=t===`array`?`...`:``;return r===`uuid`||r===`date-time`||r===`date`?`${r}${o}`:a===`boolean`?`true|false${o}`:a===`integer`||a===`number`?`${a}${o}`:`${e(i)}${o}`}function n(e,t){let n=s(e);if(t===void 0||t.length===0)return n;let r=`Allowed values: ${t.join(`, `)}`;return n===``?`${r}.`:`${n} ${r}.`}var r={path:{heading:`Path parameters:`,rank:0},header:{heading:`Request headers:`,rank:1},input:{heading:`Input:`,rank:2},body:{heading:`Body fields:`,rank:3},option:{heading:`Options:`,rank:1/0}};function i(e){return o(e).rank}function a(e){return o(e).heading}function o(e){return e.location===`path`?r.path:e.location===`header`?r.header:e.inputType===`file`||e.schemaFormat===`binary`?r.input:e.location===`body`?r.body:r.option}var s=e=>e===``||/[.!?]$/u.test(e)?e:`${e}.`,c={researchData:{heading:`Research data commands:`,rank:0},account:{heading:`Account commands:`,rank:1},administration:{heading:`Administration commands:`,rank:2},cli:{heading:`CLI commands:`,rank:3}};function l(e,t){return e!==void 0&&u(e,t)===`administration`}function u(e,t){return t?.[e]?.section??d[e]}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,directory:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,"research-runs":`researchData`,provenance:`administration`,billing:`account`,harness:`administration`,jobs:`administration`,operations:`administration`,metrics:`cli`,inference:`administration`,web:`researchData`,contacts:`administration`,"url-types":`researchData`,"unique-ids":`researchData`,research:`administration`,status:`cli`,agents:`cli`,help:`cli`},f=new Set([`metrics`]);export{n as a,a as c,u as i,s as l,f as n,t as o,l as r,i as s,c as t};
|