@aventurevc/aventure-cli 0.8.6 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{E as e,O as t,ot as n,w as r}from"./auth-0-uOs6jd.js";import{C as i,a,c as o,v as s}from"./person-owner-BqBLyw4S.js";import{a as c,i as l,n as u,t as d}from"./text-field-Cqpkg-8K.js";function f(e,t,n=t.inputName){if(t.in===`body`)return n;let r=re.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?y(v(n!==`id`&&n!==`slug`?n:`${h(e.path)}${_(n)}`),t):r.inputName}function p(e,t,n=ee(e)){return m(g(e,t),new Set(n))}function m(e,t){if(!t.has(e))return e;let n=`body${_(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function h(e){return ie.find(([,t])=>t.test(e))?.[0]??`record`}function g(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=te(t);return y(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?v(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ee(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>f(e,t)))}function _(e){return e.replace(/^./u,e=>e.toUpperCase())}function v(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function te(e){let t=v(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?ne(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function ne(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function y(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var re=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],ie=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];function ae(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>b(t,f(e,t))),r=(t?.parameter??[]).map(t=>b(t,p(e,t)));return{selector:n.filter(e=>e.location===`path`||x(e)),pagination:n.filter(S),filter:[...n.filter(C),...r.filter(C)],body:r.filter(e=>!C(e))}}function b(t,n){return{name:t.in===`body`?n:t.name,flag:e(n),required:t.required,location:t.in,description:t.description||`${t.name} ${t.in} parameter`}}function x(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function S(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function C(e){return e.location!==`path`&&!x(e)&&!S(e)}var w=`aventure`,oe={high:60,medium:30},se={high:20,medium:10};function ce(e){let{contract:n,guidance:r,enumQueryFlag:i}=e,a=n.requestBody?.[0],o=i?.inputName??null,s=D(n.parameter,o),c=D(a?.parameter??[],null),l=s.map(e=>fe(n,e)),u=c.map(e=>pe(n,e)),d=a?.requiredPath??[],f=new Set((a?.parameter??[]).map(({name:e})=>e)),m=d.filter(e=>!f.has(e)&&!c.some(({name:t})=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`))),h=a?.required===!0&&a.kind===`json`&&(u.length===0||m.length>0),g=[w,...n.projection.cliPath,...i===null?[]:[i.flag],...l,...u,...h?[`--from-file "<path>"`]:[]];return{intent:n.intent,operationId:n.operationId,recommendedCommand:g.join(` `),useFor:r.useFor,...r.notFor===``?{}:{notFor:r.notFor},apiRoute:`${n.method} ${n.path}`,mcpTool:t(n.intent),missingInputs:[...s.map(e=>e.name),...c.map(e=>p(n,e)),...m,...h?[`fromFile`]:[]],pathInput:E(n.parameter,`path`),queryInput:E(n.parameter,`query`),bodyInput:(a?.parameter??[]).map(e=>e.name),operationDescription:n.description,bodySchemaName:a?.schemaName??null,bodyKind:a?.kind??null,bodyRequired:a?.required??!1,requiredBodyPath:d,confidence:e.confidence,alternatives:e.alternatives}}function le(e){let t=T(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function T(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}function ue(e,t){if(e===0)return`low`;let n=e-t;return e>=oe.high&&n>=se.high?`high`:e>=oe.medium&&n>=se.medium?`medium`:`low`}function de(e,t,n=[]){return{intent:`unknown`,operationId:``,recommendedCommand:``,useFor:e,notFor:t,apiRoute:``,mcpTool:``,missingInputs:n,pathInput:[],queryInput:[],bodyInput:[],operationDescription:``,bodySchemaName:null,bodyKind:null,bodyRequired:!1,requiredBodyPath:[],confidence:`low`,alternatives:[]}}function E(e,t){return e.flatMap(e=>e.in===t?(e.itemProperty??[e]).map(e=>e.name):[])}function D(e,t){return e.filter(e=>e.required&&e.schemaDefault===void 0&&(t===null||e.inputName!==t))}function fe(t,n){let i=f(t,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${e(i)} ${r(`<${a}>`)}`}function pe(t,n){let i=p(t,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${e(i)} ${r(`<${a}>`)}`}var O=2,me=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`)),he=new Set([`delete`,`remove`,`destroy`,`purge`,`erase`,`drop`,`detach`,`unlink`]),ge=new Set([`create`,`add`,`update`,`edit`,`set`,`change`,`modify`,`upload`,`attach`,`merge`,`link`,`join`,`write`,`import`,`publish`,`verify`]),_e=new Set([`list`,`get`,`show`,`view`,`browse`,`fetch`,`read`,`lookup`,`find`,`count`,`inspect`]);function ve(e){let t=t=>[...e].some(e=>t.has(e));return t(he)?`delete`:t(ge)?`write`:t(_e)?`read`:`neutral`}function k(e,t){let n=N(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&k(e,`person`),A(e,ye(n),n),A(e,be(n),n))}function ye(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=O&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;if(e.length>O&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function be(e){return e===`person`?`people`:e.length>=O&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e)?`${e.slice(0,-1)}ies`:e.endsWith(`s`)?void 0:`${e}s`}function A(e,t,n){t!==void 0&&t!==n&&t.length>=O&&/^[a-z]+$/u.test(t)&&e.add(t)}function j(e){let t=new Set(M(e)),n=Array.from(t);for(let e of n)k(t,e);return t}function xe(e){return M(e).map(j)}function Se(e,t){if(e.length===0)return!1;let n=j(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function M(e){return N(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!me.has(e))}function N(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}var Ce=20,we=15,Te=30,Ee=2;function P(e,t,n){let r=N(e.trim());if(r.length===0)return t.map(e=>({item:e,score:1}));let i=j(r),a=xe(r);return t.map(e=>{let t=n(e);return{item:e,fields:t,score:je(r,i,a,t)}}).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function De(e){return{...e,cliPath:e.projection.cliPath,enumParameter:e.parameter.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:e.parameter.flatMap(e=>[e.name,e.inputName]),parameterDescription:[...e.parameter,...e.requestBody??[],...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({description:e})=>e)}}function Oe(e,t){let n=e.q?.trim()??``,r=P(n,t.filter(t=>ke(e,t)),De).map(({item:e,score:t})=>({contract:e,score:t})),i=r.map(({contract:e})=>e),a=e.limit===void 0||!Number.isFinite(e.limit)?Ce:e.limit,o=Math.min(i.length,Math.max(0,Math.trunc(a)));if(e.resolve!==!0){let e=r.slice(0,o).map(({contract:e})=>Ae(e));return{summary:`Operation catalog matches`,data:e,counts:{totalOperations:t.length,matched:i.length,returned:e.length}}}if(n.length===0)return F(t.length,i.length,`Provide q to get a generated command recommendation`,`Catalog listing; omit resolve to browse operations`,[`q`]);let s=j(N(n)),c=ve(s),l=r.filter(({contract:e})=>c===`delete`?!0:e.intent===`delete`||e.projection.destructive?!1:c!==`read`||e.projection.scope!==`write`).toSorted((e,t)=>t.score-e.score||Number(e.contract.projection.scope===`write`)-Number(t.contract.projection.scope===`write`)||e.contract.path.length-t.contract.path.length||e.contract.operationId.localeCompare(t.contract.operationId)),u=l[0];if(u===void 0)return F(t.length,i.length,`No generated operation matched this query`,`See generated operation descriptions`);let d=l.slice(1).map(({contract:e})=>`${w} ${e.projection.cliPath.join(` `)}`).filter((e,t,n)=>n.indexOf(e)===t).slice(0,2),f=u.contract;return{summary:`How-to command recommendation`,data:ce({contract:f,guidance:le(f),confidence:ue(u.score,l[1]?.score??0),alternatives:d,enumQueryFlag:Ie(s,f)}),counts:{totalOperations:t.length,matched:i.length,returned:1}}}function F(e,t,n,r,i=[]){return{summary:`How-to command recommendation`,data:de(n,r,i),counts:{totalOperations:e,matched:t,returned:0}}}function ke(e,t){let n=e.root?.trim().toLowerCase();return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Ae(e){let t=e.requestBody?.[0];return{operationId:e.operationId,method:e.method,path:e.path,cli:e.projection.cliPath.join(` `),resource:e.resource,intent:e.intent,scope:e.projection.scope,bodySchemaName:t?.schemaName??null,bodyKind:t?.kind??null,bodyRequired:t?.required??!1,requiredBodyPath:t?.requiredPath??[],argument:ae(e)}}function je(e,t,n,r){let i=Pe(r),a=Me(r),o=0;i.some(t=>t===e)&&(o+=100),i.some(t=>t.includes(e))&&(o+=40),o+=Ne(e,i);let s=new Set(i.flatMap(M));for(let e of t)i.some(t=>t===e)?o+=20:s.has(e)&&(o+=8);for(let e of r.cliPath){let n=new Set;k(n,e),[...n].some(e=>t.has(e))&&(o+=we)}Se(n,a)&&(o+=200),r.parameterName.some(t=>N(t)===e)&&(o+=Te);let c=new Set(r.parameterDescription.flatMap(M));for(let e of t)c.has(e)&&(o+=Ee);return o+=Re(t,r.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(r.operationId)&&(o+=30),o-=Fe(e,t,r.description),o}function Me(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(N).filter(e=>e.length>0)}function Ne(e,t){let n=M(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Pe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,T(e.description).useFor||e.description].map(N).filter(e=>e.length>0))]}function Fe(e,t,n){let r=N(T(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(M(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Ie(t,n){for(let i of n.parameter){if(i.in!==`query`)continue;let a=Le(t,i);if(a!==null){let t=f(n,i);return{inputName:i.inputName,flag:`${e(t)} ${r(a,i.schemaType,i.itemSchemaType)}`}}}return null}function Le(e,t){return(t.itemSchemaEnum??t.schemaEnum??[]).find(t=>ze(e,t))??null}function Re(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>ze(e,t))&&(n+=i?40:10);return n}function ze(e,t){let n=M(t);return n.length>0&&n.every(t=>e.has(t))}var Be=a([`HIGH`,`MEDIUM`,`LOW`]),Ve=a([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`]),He=s({excerpt:i(),sourceId:i(),sourceType:Ve,sourceVersion:i().nullish()}),Ue=s({answer:i(),citation:o(He),confidence:Be}),We=a([`auto`,`exact`,`keyword`,`semantic`,`natural`]),Ge=s({modeRequested:We,modeUsed:We}),I=120,L=30,R=8,z=10,Ke=2,qe=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Je=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]),B=[`interpretation`,`confidence`,`unsupported`,`execution`,`fallbackUsed`],Ye=new Map(c.map(({operationId:e,projection:t})=>[e,`${w} ${t.cliPath.join(` `)}`]));function Xe(e,t){if(typeof e==`string`)return e;let n=U(e);if(n===null)return null;let{response:r,hiddenNote:i}=l(n.operationId,n.response),a={...n,response:r},o=at(a.response);if(o!==null)return`${ft(o).join(`
1
+ import{E as e,S as t,st as n,w as r}from"./auth-SNOCQjGu.js";import{C as i,a,c as o,v as s}from"./person-owner-BqBLyw4S.js";import{a as c,i as l,n as u,t as d}from"./text-field-Boi8bbqF.js";function f(e,t,n=t.inputName){if(t.in===`body`)return n;let r=re.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?y(v(n!==`id`&&n!==`slug`?n:`${h(e.path)}${_(n)}`),t):r.inputName}function p(e,t,n=ee(e)){return m(g(e,t),new Set(n))}function m(e,t){if(!t.has(e))return e;let n=`body${_(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function h(e){return ie.find(([,t])=>t.test(e))?.[0]??`record`}function g(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=te(t);return y(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?v(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ee(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>f(e,t)))}function _(e){return e.replace(/^./u,e=>e.toUpperCase())}function v(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function te(e){let t=v(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?ne(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function ne(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function y(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var re=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],ie=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];function ae(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>b(t,f(e,t))),r=(t?.parameter??[]).map(t=>b(t,p(e,t)));return{selector:n.filter(e=>e.location===`path`||x(e)),pagination:n.filter(S),filter:[...n.filter(C),...r.filter(C)],body:r.filter(e=>!C(e))}}function b(e,t){return{name:e.in===`body`?t:e.name,flag:r(t),required:e.required,location:e.in,description:e.description||`${e.name} ${e.in} parameter`}}function x(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function S(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function C(e){return e.location!==`path`&&!x(e)&&!S(e)}var w=`aventure`,oe={high:60,medium:30},se={high:20,medium:10};function ce(t){let{contract:n,guidance:r,enumQueryFlag:i}=t,a=n.requestBody?.[0],o=i?.inputName??null,s=D(n.parameter,o),c=D(a?.parameter??[],null),l=s.map(e=>fe(n,e)),u=c.map(e=>pe(n,e)),d=a?.requiredPath??[],f=new Set((a?.parameter??[]).map(({name:e})=>e)),m=d.filter(e=>!f.has(e)&&!c.some(({name:t})=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`))),h=a?.required===!0&&a.kind===`json`&&(u.length===0||m.length>0),g=[w,...n.projection.cliPath,...i===null?[]:[i.flag],...l,...u,...h?[`--from-file "<path>"`]:[]];return{intent:n.intent,operationId:n.operationId,recommendedCommand:g.join(` `),useFor:r.useFor,...r.notFor===``?{}:{notFor:r.notFor},apiRoute:`${n.method} ${n.path}`,mcpTool:e(n.intent),missingInputs:[...s.map(e=>e.name),...c.map(e=>p(n,e)),...m,...h?[`fromFile`]:[]],pathInput:E(n.parameter,`path`),queryInput:E(n.parameter,`query`),bodyInput:(a?.parameter??[]).map(e=>e.name),operationDescription:n.description,bodySchemaName:a?.schemaName??null,bodyKind:a?.kind??null,bodyRequired:a?.required??!1,requiredBodyPath:d,confidence:t.confidence,alternatives:t.alternatives}}function le(e){let t=T(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function T(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}function ue(e,t){if(e===0)return`low`;let n=e-t;return e>=oe.high&&n>=se.high?`high`:e>=oe.medium&&n>=se.medium?`medium`:`low`}function de(e,t,n=[]){return{intent:`unknown`,operationId:``,recommendedCommand:``,useFor:e,notFor:t,apiRoute:``,mcpTool:``,missingInputs:n,pathInput:[],queryInput:[],bodyInput:[],operationDescription:``,bodySchemaName:null,bodyKind:null,bodyRequired:!1,requiredBodyPath:[],confidence:`low`,alternatives:[]}}function E(e,t){return e.flatMap(e=>e.in===t?(e.itemProperty??[e]).map(e=>e.name):[])}function D(e,t){return e.filter(e=>e.required&&e.schemaDefault===void 0&&(t===null||e.inputName!==t))}function fe(e,n){let i=f(e,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${r(i)} ${t(`<${a}>`)}`}function pe(e,n){let i=p(e,n),a=`${i}${n.schemaType===`array`?`...`:``}`;return`${r(i)} ${t(`<${a}>`)}`}var O=2,me=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`)),he=new Set([`delete`,`remove`,`destroy`,`purge`,`erase`,`drop`,`detach`,`unlink`]),ge=new Set([`create`,`add`,`update`,`edit`,`set`,`change`,`modify`,`upload`,`attach`,`merge`,`link`,`join`,`write`,`import`,`publish`,`verify`]),_e=new Set([`list`,`get`,`show`,`view`,`browse`,`fetch`,`read`,`lookup`,`find`,`count`,`inspect`]);function ve(e){let t=t=>[...e].some(e=>t.has(e));return t(he)?`delete`:t(ge)?`write`:t(_e)?`read`:`neutral`}function k(e,t){let n=N(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&k(e,`person`),A(e,ye(n),n),A(e,be(n),n))}function ye(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=O&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;if(e.length>O&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function be(e){return e===`person`?`people`:e.length>=O&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e)?`${e.slice(0,-1)}ies`:e.endsWith(`s`)?void 0:`${e}s`}function A(e,t,n){t!==void 0&&t!==n&&t.length>=O&&/^[a-z]+$/u.test(t)&&e.add(t)}function j(e){let t=new Set(M(e)),n=Array.from(t);for(let e of n)k(t,e);return t}function xe(e){return M(e).map(j)}function Se(e,t){if(e.length===0)return!1;let n=j(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function M(e){return N(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!me.has(e))}function N(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}var Ce=20,we=15,Te=30,Ee=2;function P(e,t,n){let r=N(e.trim());if(r.length===0)return t.map(e=>({item:e,score:1}));let i=j(r),a=xe(r);return t.map(e=>{let t=n(e);return{item:e,fields:t,score:je(r,i,a,t)}}).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function De(e){return{...e,cliPath:e.projection.cliPath,enumParameter:e.parameter.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:e.parameter.flatMap(e=>[e.name,e.inputName]),parameterDescription:[...e.parameter,...e.requestBody??[],...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({description:e})=>e)}}function Oe(e,t){let n=e.q?.trim()??``,r=P(n,t.filter(t=>ke(e,t)),De).map(({item:e,score:t})=>({contract:e,score:t})),i=r.map(({contract:e})=>e),a=e.limit===void 0||!Number.isFinite(e.limit)?Ce:e.limit,o=Math.min(i.length,Math.max(0,Math.trunc(a)));if(e.resolve!==!0){let e=r.slice(0,o).map(({contract:e})=>Ae(e));return{summary:`Operation catalog matches`,data:e,counts:{totalOperations:t.length,matched:i.length,returned:e.length}}}if(n.length===0)return F(t.length,i.length,`Provide q to get a generated command recommendation`,`Catalog listing; omit resolve to browse operations`,[`q`]);let s=j(N(n)),c=ve(s),l=r.filter(({contract:e})=>c===`delete`?!0:e.intent===`delete`||e.projection.destructive?!1:c!==`read`||e.projection.scope!==`write`).toSorted((e,t)=>t.score-e.score||Number(e.contract.projection.scope===`write`)-Number(t.contract.projection.scope===`write`)||e.contract.path.length-t.contract.path.length||e.contract.operationId.localeCompare(t.contract.operationId)),u=l[0];if(u===void 0)return F(t.length,i.length,`No generated operation matched this query`,`See generated operation descriptions`);let d=l.slice(1).map(({contract:e})=>`${w} ${e.projection.cliPath.join(` `)}`).filter((e,t,n)=>n.indexOf(e)===t).slice(0,2),f=u.contract;return{summary:`How-to command recommendation`,data:ce({contract:f,guidance:le(f),confidence:ue(u.score,l[1]?.score??0),alternatives:d,enumQueryFlag:Ie(s,f)}),counts:{totalOperations:t.length,matched:i.length,returned:1}}}function F(e,t,n,r,i=[]){return{summary:`How-to command recommendation`,data:de(n,r,i),counts:{totalOperations:e,matched:t,returned:0}}}function ke(e,t){let n=e.root?.trim().toLowerCase();return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Ae(e){let t=e.requestBody?.[0];return{operationId:e.operationId,method:e.method,path:e.path,cli:e.projection.cliPath.join(` `),resource:e.resource,intent:e.intent,scope:e.projection.scope,bodySchemaName:t?.schemaName??null,bodyKind:t?.kind??null,bodyRequired:t?.required??!1,requiredBodyPath:t?.requiredPath??[],argument:ae(e)}}function je(e,t,n,r){let i=Pe(r),a=Me(r),o=0;i.some(t=>t===e)&&(o+=100),i.some(t=>t.includes(e))&&(o+=40),o+=Ne(e,i);let s=new Set(i.flatMap(M));for(let e of t)i.some(t=>t===e)?o+=20:s.has(e)&&(o+=8);for(let e of r.cliPath){let n=new Set;k(n,e),[...n].some(e=>t.has(e))&&(o+=we)}Se(n,a)&&(o+=200),r.parameterName.some(t=>N(t)===e)&&(o+=Te);let c=new Set(r.parameterDescription.flatMap(M));for(let e of t)c.has(e)&&(o+=Ee);return o+=Re(t,r.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(r.operationId)&&(o+=30),o-=Fe(e,t,r.description),o}function Me(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(N).filter(e=>e.length>0)}function Ne(e,t){let n=M(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Pe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,T(e.description).useFor||e.description].map(N).filter(e=>e.length>0))]}function Fe(e,t,n){let r=N(T(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(M(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Ie(e,n){for(let i of n.parameter){if(i.in!==`query`)continue;let a=Le(e,i);if(a!==null){let e=f(n,i);return{inputName:i.inputName,flag:`${r(e)} ${t(a,i.schemaType,i.itemSchemaType)}`}}}return null}function Le(e,t){return(t.itemSchemaEnum??t.schemaEnum??[]).find(t=>ze(e,t))??null}function Re(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>ze(e,t))&&(n+=i?40:10);return n}function ze(e,t){let n=M(t);return n.length>0&&n.every(t=>e.has(t))}var Be=a([`HIGH`,`MEDIUM`,`LOW`]),Ve=a([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`]),He=s({excerpt:i(),sourceId:i(),sourceType:Ve,sourceVersion:i().nullish()}),Ue=s({answer:i(),citation:o(He),confidence:Be}),We=a([`auto`,`exact`,`keyword`,`semantic`,`natural`]),Ge=s({modeRequested:We,modeUsed:We}),I=120,L=30,R=8,z=10,Ke=2,qe=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Je=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]),B=[`interpretation`,`confidence`,`unsupported`,`execution`,`fallbackUsed`],Ye=new Map(c.map(({operationId:e,projection:t})=>[e,`${w} ${t.cliPath.join(` `)}`]));function Xe(e,t){if(typeof e==`string`)return e;let n=U(e);if(n===null)return null;let{response:r,hiddenNote:i}=l(n.operationId,n.response),a={...n,response:r},o=at(a.response);if(o!==null)return`${ft(o).join(`
2
2
  `)}\n`;let s=a.summary??t??a.operationId??`OpenAPI call succeeded`,c=$e(a);return`${[...ft([s,`${a.method} ${a.endpoint}`,...c].filter(e=>e.length>0)),...i].join(`
3
3
  `)}\n`}function Ze(e){let t=U(e)?.response,n=t!==void 0&&X(t)?t.interpretation:void 0;if(n===void 0||!X(n))return null;let r=Ge.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=K(n.filter??null),{unsupported:s,fallbackUsed:c}=n;return`${[`strategy: requested=${i} used=${a}`,...o!==void 0&&X(o)?[`constraints:`,...Object.entries(o).map(([e,t])=>` ${e}: ${Qe(t)}`)]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``].filter(Boolean).join(`
4
4
  `)}\n`}var Qe=e=>Z(e)?u(e):Array.isArray(e)&&e.every(Z)?e.map(e=>u(e)).join(`, `):JSON.stringify(e);function $e(e){let{response:t,method:n,endpoint:r,nextCursor:i,httpStatus:a}=e;if(t===void 0)return a===void 0?[]:[`status=${a} no response body`];let o=a===void 0||n===`GET`?``:`status=${a}`,s=X(t)&&!J(t)?ot(t):null,c=s===null?void 0:it(s.context)?K(s.context):s.context;return[o,...J(t)?V(t,r,i):s===null?ct(t)?H(t.filter,t.meta):lt(t)?H([...t.arrayFilterEntry,...t.rangeFilterEntry],t.filtersMeta):ut(t)?nt(t):W(t,``):[...V(s.page,r,i),...c===void 0?[]:W(c,``)]].filter(Boolean)}function V(e,t,n){let r=rt(t);return[`rows=${e.numberOfElements??e.content.length}${e.number===void 0?``:` page=${e.number}`}${e.size===void 0?``:` size=${e.size}`}${e.totalElements===void 0?``:` total=${e.totalElements}`}${e.totalPages===void 0?``:` totalPages=${e.totalPages}`}`,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${$(n)}`,...et(e.content)].filter(Boolean)}function et(e){let t=e.filter(X);if(t.length===0)return e.length===0?[`(empty)`]:G(e,``);let n=tt(t);if(n.length===0)return G(e.slice(0,L),``);let r=t.slice(0,L).map(e=>{let t=q(e);return n.map(e=>t[e]??``)}),i=n.map(e=>e.split(`.`).at(-1)??e),a=i.map((e,t)=>{let n=r.map(e=>e[t]??``),i=Math.max(e.length,...n.map(e=>e.length));return e===`id`||e.endsWith(`Id`)?i:Math.min(32,i)}),o=e=>e.map((e,t)=>dt(e,a[t]??12).padEnd(a[t]??12)).join(` `),s=[o(i),o(a.map(e=>`-`.repeat(e)))];return r.forEach(e=>s.push(o(e))),t.length>L&&s.push(`... ${t.length-L} more rows`),s}function tt(e){let t=new Set(e.flatMap(e=>Object.keys(q(e)))),n=qe.filter(e=>t.has(e)),r=[...t].filter(e=>!n.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,R-n.length);return[...n,...r].slice(0,R)}function H(e,t){let n=t!==void 0&&X(t)?t:{},r=[`total`,`limit`].flatMap(e=>typeof n[e]==`number`?[` ${e}=${n[e]}`]:[]).join(``),i=[`filters=${e.length}${r}`];for(let t of e){let e=t.choiceOption.length,n=t.choiceOptionTotal===null?`unknown (degraded)`:t.choiceOptionTotal??e,r=t.choiceOptionTruncated===!0?` truncated`:``;i.push(`- ${t.filterKey} (${t.label}): choices ${e}/${n}${r}`),t.choiceOption.slice(0,z).forEach(e=>{i.push(` ${Q(t.filterKey)} ${$(e.value)}`)}),e>z&&i.push(` ... ${e-z} more shown`)}return i}function nt(e){let t=Q(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,z).map(e=>`${t} ${$(e)}`),e.result.length>z?`... ${e.result.length-z} more matches`:``].filter(Boolean)}function rt(e){let t=e.indexOf(`?`);return t<0?[]:[...new URLSearchParams(e.slice(t+1)).entries()].filter(([e,t])=>!Je.has(e)&&t.length>0).map(([e,t])=>`${Q(e)} ${$(t)}`)}function U(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`method`),r=Reflect.get(e,`endpoint`);if(typeof t!=`string`||typeof r!=`string`)return null;let i=Reflect.get(e,`operationId`),a=Reflect.get(e,`summary`),o=Reflect.get(e,`httpStatus`),s=Reflect.get(e,`nextCursor`),c=Reflect.get(e,`response`),l=c===void 0?void 0:n.safeParse(c);return l!==void 0&&!l.success?null:{method:t,endpoint:r,httpStatus:typeof o==`number`?o:void 0,operationId:typeof i==`string`?i:void 0,summary:typeof a==`string`?a:void 0,nextCursor:typeof s==`string`&&s.length>0?s:void 0,response:l?.data}}function W(e,t,n){if(e===void 0)return[];if(Z(e))return[`${t}${d(e,n)}`];if(Array.isArray(e))return G(e,t,n);let r=[];for(let[n,i]of Object.entries(e)){if(Z(i)){r.push(`${t}${n}: ${d(i,n)}`);continue}r.push(`${t}${n}:`);for(let e of W(i,`${t} `,n))r.push(e)}return r.length===0?[`${t}(empty)`]:r}function G(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(Z(i)){r.push(`${t}- ${d(i,n)}`);continue}r.push(`${t}-`);for(let e of W(i,`${t} `))r.push(e)}return r}function it(e){let t=e.interpretation;return t!==void 0&&X(t)}function K(e){if(Z(e))return e===null||typeof e==`string`&&e.trim().length===0?void 0:e;if(Array.isArray(e)){let t=e.flatMap(e=>{let t=K(e);return t===void 0?[]:[t]});return t.length===0?void 0:t}let t=Object.entries(e).flatMap(([e,t])=>{let n=K(t);return n===void 0?[]:[[e,n]]});if(t.length!==0)return Object.fromEntries([...B.flatMap(e=>t.filter(([t])=>t===e)),...t.filter(([e])=>!B.includes(e))])}function at(e){let t=Ue.safeParse(e);if(!t.success)return null;let{answer:n,citation:r,confidence:i}=t.data,a=n.trimEnd().split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aventurevc/aventure-cli",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "private": false,
5
5
  "description": "Command-line access to aVenture research data on companies, people, funding, and news.",
6
6
  "homepage": "https://docs.aventure.vc/cli",
@@ -29,13 +29,13 @@
29
29
  "@napi-rs/keyring": "1.3.0"
30
30
  },
31
31
  "engines": {
32
- "node": ">=24.18.0 <25"
32
+ "node": ">=24.18.0"
33
33
  },
34
34
  "aventurePublicApi": {
35
35
  "repository": "aventurevc/aventure-docs",
36
- "commit": "f046d139e6a3788991694acac36fee1d3c18c56a",
36
+ "commit": "9325ac0c14e2f9dab0ec3caaed1c986e5ce30075",
37
37
  "openapiPath": "openapi/openapi.json",
38
- "openapiSha256": "28049a589711fb31150b89dbb1a6b800dcbaa2f7c629a2d2b326e41b42049bbe"
38
+ "openapiSha256": "eb614e781ce21d29b0217a31ae2b11558139311520753e68c72cee0e0f44c600"
39
39
  },
40
40
  "scripts": {}
41
41
  }
@@ -1,4 +0,0 @@
1
- import{B as e,J as t,L as n,N as r,Y as i,a,d as o,m as s,o as c,r as l,tt as u,y as d}from"./auth-0-uOs6jd.js";import{C as f,a as p,c as m,k as h,v as ee}from"./person-owner-BqBLyw4S.js";import{execFile as te}from"node:child_process";import{dirname as g,join as _}from"node:path";import{chmod as ne,mkdir as re,readFile as ie,rename as ae,rm as v,stat as oe,writeFile as y}from"node:fs/promises";import{AsyncLocalStorage as se}from"node:async_hooks";import{randomUUID as b}from"node:crypto";import{homedir as x,platform as S}from"node:os";import{setTimeout as ce}from"node:timers/promises";function C(e,t=[]){let n=e instanceof Error?e.message:String(e);return s(n,t)}function le(e,t=[]){let n=s(e.title,t),r=s(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function ue(){if(S()===`win32`){let e=process.env.APPDATA??_(x(),`AppData`,`Roaming`);return _(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??_(x(),`.config`);return _(e,`aventure`,`config.json`)}function de(){let e=process.env[i.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function w(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}function T(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(me(t)?t:`${he(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 fe(e){return{...e,host:T(e.host).origin}}function pe(e){let t=T(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 me(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function he(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 ge=2;function _e(e,t){return D(e,t).redactedUrl}async function ve(e,t,n){let r=D(e,t);return await ye(new URL(r.openerUrl),n)}async function ye(e,t){let n=t.environment??process.env,r=t.operatingSystem??S(),i=O(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=be(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await xe(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function D(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!==ge||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 O(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 be(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 xe(e,t){return new Promise((n,r)=>{te(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var Se=100,Ce=3e4,we=6e4,k=new se;function A(){return _(g(ue()),`credentials.json`)}function Te(e){return`OS keyring is unusable (${e}); the credential will be stored in ${A()} (mode 0600).\n`}async function j(e,t){let n;try{let n=await(await I(e,t)).getPassword()??void 0;if(n!==void 0)return{record:{provider:`keyring`,value:n}}}catch(e){n=F(e)}let r=(await L())[e]?.[t];return{...r===void 0?{}:{record:{provider:`file`,value:r}},...n===void 0?{}:{keyringFailure:n}}}async function M(e,t,n){let r;try{let i=await I(e,t);if(await i.setPassword(n),await i.getPassword()===n)return await z(e,t,void 0),`keyring`;r=`Error: keyring readback did not match`}catch(e){r=F(e,[n])}if(await z(e,t,n),(await L())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function N(e,t){try{let n=await I(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 (${F(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${F(r)})`,r===void 0?void 0:{cause:r})}finally{await z(e,t,void 0)}}async function P(e,t){let n=`${t}:probe:${b()}`,r=`aventure-cli-credential-probe:${b()}`,i;try{let t=await I(e,n);await t.setPassword(r);let a=await(await I(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await I(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=F(e,[r])}try{await R(async()=>{await z(e,n,r);let t=(await L())[e]?.[n];if(await z(e,n,void 0),t!==r)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${i}; file ${A()}: ${F(e,[r])})`,{cause:e})}return{provider:`file`,keyringFailure:i}}function F(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=C(e,t).trim().split(`
2
- `,1);return r&&r!==n?`${n}: ${r}`:n}async function I(e,t){let n=S(),r=n===`linux`||n===`freebsd`?O(!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 L(){let e=A(),t;try{t=await ie(e,`utf8`)}catch(e){if(w(e,`ENOENT`))return{};throw e}let n;try{n=JSON.parse(t)}catch(t){return await Ee(e,t)}return Oe(n)?n:await Ee(e,void 0)}async function Ee(t,n){let r=`${t}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await ae(t,r)}catch(e){if(w(e,`ENOENT`))return{};throw Error(`${t} is not a valid credential file and could not be moved aside`,{cause:e})}return e({component:`aventure-cli`,event:`credential_file_quarantined`,message:`${t} is not a valid credential file; moved it to ${r} and continuing with an empty file store`,...n===void 0?{}:{error:n}}),{}}async function R(e){if(k.getStore()===!0)return await e();let t=`${A()}.lock`;await re(g(t),{recursive:!0,mode:448});let n=Date.now()+Ce,r=b();for(;;){try{await y(t,r,{flag:`wx`,mode:384});break}catch(e){if(!w(e,`EEXIST`))throw e}if(await oe(t).then(e=>Date.now()-e.mtimeMs,()=>0)>we)await v(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await ce(Se)}try{return await k.run(!0,e)}finally{await ie(t,`utf8`).catch(()=>``)===r&&await v(t,{force:!0})}}async function z(e,t,n){await R(async()=>await De(e,t,n))}async function De(e,t,n){let r=A(),i=await L(),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 v(r,{force:!0});return}await re(g(r),{recursive:!0,mode:448});let o=`${r}.${b()}.tmp`;await y(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await ne(o,384),await ae(o,r)}function Oe(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 ke=ee({createdAt:h({offset:!0}),description:f().nullish(),expiresAt:h({offset:!0}).nullish(),id:f().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:h({offset:!0}).nullish(),name:f(),revocationReason:f().nullish(),scopes:m(f()),status:p([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:f(),updatedAt:h({offset:!0})}),B=`vc.aventure.aventure-cli`,V=`aventure-cli-personal-v1`;async function Ae(e,t,n){let r=U(e),i=Pe(t,n),a;try{a=await M(B,r,i)}catch(e){throw Error(`${C(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 H(e){let t=U(e),n;try{n=await j(B,t)}catch(e){return Ne(C(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,...Fe(r.value)}}}async function je(e){let t=await H(e);if(t.state!==`missing`)return t;try{let{keyringFailure:t}=await P(B,U(e));return t===void 0?{state:`missing`}:{state:`missing`,keyringFailure:t}}catch(e){return Ne(C(e))}}async function Me(e){await N(B,U(e))}function U(e){return T(e).host}function Ne(e){return{state:`unavailable`,summary:e,cause:`storage`}}function Pe(e,t){return`${V}:${t}\n${JSON.stringify(e.apiKey)}\n${e.secret}`}function Fe(e){let t=e.indexOf(`
3
- `),n=t<0?-1:e.indexOf(`
4
- `,t+1),r=t<0?e:e.slice(0,t),i=r===`${V}:active`?`active`:`pending`;if(t<0||n<0||r!==`${V}:pending`&&r!==`${V}: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=ke.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 Ie(t){if(Le())return;let r=U(u().host);try{let e=await H(r);if(e.state===`unavailable`){n(Re(`keyring`,Error(e.summary)));return}e.state===`found`&&e.stored.activation===`active`&&!Le()&&(process.env[i.authToken]=e.stored.credential.secret,t?.(`api-key`))}catch(t){e(Re(`parse`,t))}}function Le(){return(process.env[i.authToken]?.trim().length??0)>0}function Re(e,t){return{component:`aventure-cli`,event:`api_key_materialization_unavailable`,message:`saved API key could not be loaded; continuing with environment auth`,fields:{source:e},error:t}}var ze=a.omit({mcpResource:!0}),W=`vc.aventure.aventure-cli.oauth`,Be=`oauth:`,Ve=6e4;function He(e,t){let n=Z(t);return{client:e,expiresAt:ot(at(n)),tokens:n}}async function Ue(e,t){let n=q(e),r=et(n,t),i;try{i=await M(W,X(n),r)}catch(e){throw Error(`OAuth credential could not be stored — ${C(e,[r,...Y(t.tokens)])}`,{cause:e})}return{host:n,provider:i,credential:tt(n,r)}}async function G(e){let t=q(e),n;try{n=await j(W,X(t))}catch(e){return{state:`unavailable`,summary:C(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,credential:tt(t,r.value)}}}async function We(e){await N(W,X(q(e)))}async function Ge(e){try{return await G(e)}catch(e){return{state:`invalid`,summary:C(e)}}}async function Ke(e){let t=await Ge(e);if(t.state!==`missing`)return t;let n=await qe(e);return n.state===`unavailable`?n:n.keyringFailure===void 0?{state:`missing`}:{state:`missing`,keyringFailure:n.keyringFailure}}async function qe(e){let t=q(e);try{return{state:`available`,...await P(W,X(t))}}catch(e){return{state:`unavailable`,summary:C(e)}}}function Je(e){return K(e.authorizationServer,`authorization server`)}function Ye(e){if(URL.canParse(e.resource)&&new URL(e.resource).protocol===`http:`){let t=T(e.resource);if(t.isLoopback)return new URL(t.origin)}return K(e.resource,`resource`)}function Xe(e){if(e.clientId.trim()!==e.clientId||e.clientId.length===0)throw Error(`OAuth client ID must not be blank`);return e.clientId}function Ze(e){if(e.scope.length===0||e.scope.some(e=>e.trim()!==e||e.length===0)||new Set(e.scope).size!==e.scope.length)throw Error(`OAuth scope must contain unique non-blank values`);return e.scope}function K(e,t,n=!1){let r;try{r=new URL(e)}catch(e){throw Error(`OAuth ${t} is not a valid URL`,{cause:e})}if(r.protocol!==`https:`||r.username.length>0||r.password.length>0||!n&&r.search.length>0||r.hash.length>0)throw Error(`OAuth ${t} must be an HTTPS URL without credentials${n?``:`, query`} or fragment`);return r}function q(e){return T(e).host}function J(e){return new Date(e.expiresAt).getTime()-Ve<=Date.now()}function Qe(e){let t=$e(e.tokens.id_token)??$e(e.tokens.access_token),n=t?.email;return{subject:t?.sub??null,email:typeof n==`string`?n:null}}function $e(e){if(e!==void 0)try{return d(e)}catch{return}}function Y(e){return[e.access_token,e.refresh_token,e.id_token]}function X(e){return`${Be}${e}`}function et(e,t){return JSON.stringify({client:nt(e,t.client),expiresAt:st(t.expiresAt),tokens:Z(t.tokens)})}function tt(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`OS OAuth credential entry failed schema validation`,{cause:e})}if(!lt(n))throw Error(`OS OAuth credential entry failed schema validation`);return{client:nt(e,rt(n.client)),expiresAt:st(n.expiresAt),tokens:Z(it(n.tokens))}}function nt(e,t){if(q(t.resource)!==e)throw Error(`OAuth client resource must match the credential API host`);return t}function rt(e){let t=ze.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed canonical client validation`,{cause:t.error});return t.data}function it(e){let t=l.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed OAuth token validation`,{cause:t.error});return t.data}function Z(e){if(!ct(e.access_token)||e.token_type.trim().toLowerCase()!==`bearer`)throw Error(`OAuth token response must contain a bearer access token`);if(e.refresh_token!==void 0&&!ct(e.refresh_token))throw Error(`OAuth token response has an invalid refresh token`);return at(e),e}function at(e){let t=e.expires_in;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<=0)throw Error(`OAuth token response must contain a positive expires_in`);return t}function ot(e){let t=new Date(Date.now()+e*1e3);if(!Number.isFinite(t.getTime()))throw Error(`OAuth token response has an expiry outside the supported date range`);return t.toISOString()}function st(e){if(typeof e!=`string`)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);return e}function ct(e){return e.trim()===e&&e.length>0}function lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function ut(t,n){if($())return;let a=async(r,i,a)=>{if(await Ie(n),!$())throw i instanceof c?i:ft(r,t,i,a);e({component:`aventure-cli`,event:`oauth_credential_bypassed`,message:`OAuth sign-in is unavailable (${r}); using the stored API key.`,...i===void 0?{}:{error:Error(C(i,Q(a)))}})},s=async(t,n,r)=>{let i=await G(t.host).catch(()=>void 0);if(i?.state===`found`&&i.stored.credential.tokens.access_token!==t.credential.tokens.access_token)return await l(i.stored,!1);try{await We(t.host)}catch(r){e({component:`aventure-cli`,event:`oauth_credential_retire_failed`,message:`the saved OAuth credential is dead (${n}) but could not be removed`,error:Error(C(r,Q(t)))})}await a(n,r,t)},l=async(e,t)=>{let c=(n,r)=>t?s(e,n,r):a(n,r,e),l=e.credential;if(J(l)){if(l.tokens.refresh_token===void 0)return await c(`the saved OAuth credential has expired`);try{l=await dt(e)}catch(t){return t instanceof r?await c(`Clerk rejected the saved refresh token`,t):await a(`the saved OAuth credential could not be renewed`,t,e)}}let u;try{u=await o(l.tokens.access_token,new URL(l.client.resource))!==null}catch(t){return await a(`the saved OAuth credential could not be verified`,t,e)}if(!u)return await c(`the saved OAuth credential was rejected`);$()||(process.env[i.authToken]=l.tokens.access_token,n?.(`oauth`))},d;try{d=q(u().host)}catch(e){throw ft(`the API host could not select its OAuth credential`,t,e)}let f;try{f=await G(d)}catch(e){return await a(`the saved OAuth credential is invalid or expired`,e)}if(f.state!==`missing`){if(f.state===`unavailable`)return await a(`the saved OAuth credential could not be read`,Error(f.summary));await l(f.stored,!0)}}async function dt(t){return await R(async()=>{let n=await G(t.host),r=n.state===`found`?n.stored:t;if(!J(r.credential))return r.credential;let{renewOAuthTokens:i}=await import(`./oauth-login-Dx7imwax.js`),a=He(r.credential.client,await i(r));try{await Ue(t.host,a)}catch(t){e({component:`aventure-cli`,event:`oauth_credential_store_failed`,message:`renewed OAuth credential could not be stored; this command uses it and the next one falls back to the API key or sign-in`,error:Error(C(t,Y(a.tokens)))})}return a})}function Q(e){return e===void 0?[]:Y(e.credential.tokens)}function $(){return(process.env[i.authToken]?.trim().length??0)>0}function ft(e,n,r,i){let a=r===void 0?``:` — ${C(r,Q(i))}`,o=n??t().bin[0];return Error(`OAuth sign-in is required: ${e}. Run \`${o} auth login\` before retrying.${a}`)}export{fe as A,Ae as C,ve as D,ye as E,C as M,le as N,_e as O,H as S,Te as T,Ue as _,We as a,Me as b,J as c,Qe as d,Ye as f,K as g,qe as h,He as i,de as j,pe as k,Je as l,Y as m,dt as n,Ge as o,Ze as p,q as r,Ke as s,ut as t,Xe as u,Ie as v,ke as w,je as x,U as y};
@@ -1 +0,0 @@
1
- import{i as e}from"./oauth-login-CYcAZMgE.js";export{e as renewOAuthTokens};