@aventurevc/aventure-cli 0.8.7 → 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,S as t,st as n,w as r}from"./auth-BkmEH7-r.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-CtBuc7ot.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(`
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.7",
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": "91e9736f0c618dae8c4fd562febd915161903fcd",
36
+ "commit": "9325ac0c14e2f9dab0ec3caaed1c986e5ce30075",
37
37
  "openapiPath": "openapi/openapi.json",
38
- "openapiSha256": "6387b5ea24df6a72843a74b5fd66d40b4cb91f534e19113821d8bd199ff4032a"
38
+ "openapiSha256": "eb614e781ce21d29b0217a31ae2b11558139311520753e68c72cee0e0f44c600"
39
39
  },
40
40
  "scripts": {}
41
41
  }
@@ -1,4 +0,0 @@
1
- import{F as e,M as t,N as n,R as r,V as i,X as a,Y as o,a as s,d as c,j as l,m as u,nt as d,r as f}from"./auth-BkmEH7-r.js";import{C as p,a as m,c as ee,k as h,v as te}from"./person-owner-BqBLyw4S.js";import{execFile as ne}from"node:child_process";import{dirname as g,join as _}from"node:path";import{chmod as re,mkdir as v,readFile as ie,rename as ae,rm as y,stat as oe,writeFile as se}from"node:fs/promises";import{AsyncLocalStorage as ce}from"node:async_hooks";import{randomUUID as b}from"node:crypto";import{homedir as le,platform as x}from"node:os";import{setTimeout as ue}from"node:timers/promises";function S(e,t=[]){let n=e instanceof Error?e.message:String(e);return u(n,t)}function de(e,t=[]){let n=u(e.title,t),r=u(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function fe(){if(x()===`win32`){let e=process.env.APPDATA??_(le(),`AppData`,`Roaming`);return _(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??_(le(),`.config`);return _(e,`aventure`,`config.json`)}function pe(){let e=process.env[a.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function C(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}function w(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(ge(t)?t:`${_e(t)}://${t}`),r=T(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 me(e){return{...e,host:w(e.host).origin}}function he(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 ge(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function _e(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return T(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function T(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var ve=2;function ye(e,t){return D(e,t).redactedUrl}async function be(e,t,n){let r=D(e,t);return await E(new URL(r.openerUrl),n)}async function E(e,t){let n=t.environment??process.env,r=t.operatingSystem??x(),i=O(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=xe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await Se(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=T(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!==ve||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 xe(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 Se(e,t){return new Promise((n,r)=>{ne(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var Ce=100,we=3e4,Te=6e4,k=new ce;function A(){return _(g(fe()),`credentials.json`)}function Ee(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=``]=S(e,t).trim().split(`
2
- `,1);return r&&r!==n?`${n}: ${r}`:n}async function I(e,t){let n=x(),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(C(e,`ENOENT`))return{};throw e}let n;try{n=JSON.parse(t)}catch(t){return await De(e,t)}return ke(n)?n:await De(e,void 0)}async function De(e,t){let n=`${e}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await ae(e,n)}catch(t){if(C(t,`ENOENT`))return{};throw Error(`${e} is not a valid credential file and could not be moved aside`,{cause:t})}return i({component:`aventure-cli`,event:`credential_file_quarantined`,message:`${e} is not a valid credential file; moved it to ${n} and continuing with an empty file store`,...t===void 0?{}:{error:t}}),{}}async function R(e){if(k.getStore()===!0)return await e();let t=`${A()}.lock`;await v(g(t),{recursive:!0,mode:448});let n=Date.now()+we,r=b();for(;;){try{await se(t,r,{flag:`wx`,mode:384});break}catch(e){if(!C(e,`EEXIST`))throw e}if(await oe(t).then(e=>Date.now()-e.mtimeMs,()=>0)>Te)await y(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await ue(Ce)}try{return await k.run(!0,e)}finally{await ie(t,`utf8`).catch(()=>``)===r&&await y(t,{force:!0})}}async function z(e,t,n){await R(async()=>await Oe(e,t,n))}async function Oe(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 y(r,{force:!0});return}await v(g(r),{recursive:!0,mode:448});let o=`${r}.${b()}.tmp`;await se(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await re(o,384),await ae(o,r)}function ke(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 Ae=te({createdAt:h({offset:!0}),description:p().nullish(),expiresAt:h({offset:!0}).nullish(),id:p().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:h({offset:!0}).nullish(),name:p(),revocationReason:p().nullish(),scopes:ee(p()),status:m([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:p(),updatedAt:h({offset:!0})}),B=`vc.aventure.aventure-cli`,V=`aventure-cli-personal-v1`;async function je(e,t,n){let r=U(e),i=Fe(t,n),a;try{a=await M(B,r,i)}catch(e){throw Error(`${S(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 Pe(S(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,...Ie(r.value)}}}async function Me(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 Pe(S(e))}}async function Ne(e){await N(B,U(e))}function U(e){return w(e).host}function Pe(e){return{state:`unavailable`,summary:e,cause:`storage`}}function Fe(e,t){return`${V}:${t}\n${JSON.stringify(e.apiKey)}\n${e.secret}`}function Ie(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=Ae.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 Le(e){if(Re())return;let t=U(d().host);try{let n=await H(t);if(n.state===`unavailable`){r(ze(`keyring`,Error(n.summary)));return}n.state===`found`&&n.stored.activation===`active`&&!Re()&&(process.env[a.authToken]=n.stored.credential.secret,e?.(`api-key`))}catch(e){i(ze(`parse`,e))}}function Re(){return(process.env[a.authToken]?.trim().length??0)>0}function ze(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 Be=s.omit({mcpResource:!0}),W=`vc.aventure.aventure-cli.oauth`,Ve=`oauth:`,He=6e4;function Ue(e,t){let n=Z(t);return{client:e,expiresAt:st(ot(n)),tokens:n}}async function We(e,t){let n=q(e),r=tt(n,t),i;try{i=await M(W,X(n),r)}catch(e){throw Error(`OAuth credential could not be stored — ${S(e,[r,...Y(t.tokens)])}`,{cause:e})}return{host:n,provider:i,credential:nt(n,r)}}async function G(e){let t=q(e),n;try{n=await j(W,X(t))}catch(e){return{state:`unavailable`,summary:S(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:nt(t,r.value)}}}async function Ge(e){await N(W,X(q(e)))}async function Ke(e){try{return await G(e)}catch(e){return{state:`invalid`,summary:S(e)}}}async function qe(e){let t=await Ke(e);if(t.state!==`missing`)return t;let n=await Je(e);return n.state===`unavailable`?n:n.keyringFailure===void 0?{state:`missing`}:{state:`missing`,keyringFailure:n.keyringFailure}}async function Je(e){let t=q(e);try{return{state:`available`,...await P(W,X(t))}}catch(e){return{state:`unavailable`,summary:S(e)}}}function Ye(e){return K(e.authorizationServer,`authorization server`)}function Xe(e){if(URL.canParse(e.resource)&&new URL(e.resource).protocol===`http:`){let t=w(e.resource);if(t.isLoopback)return new URL(t.origin)}return K(e.resource,`resource`)}function Ze(e){if(e.clientId.trim()!==e.clientId||e.clientId.length===0)throw Error(`OAuth client ID must not be blank`);return e.clientId}function Qe(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 w(e).host}function J(e){return new Date(e.expiresAt).getTime()-He<=Date.now()}function $e(e){let t=et(e.tokens.id_token)??et(e.tokens.access_token),n=t?.email;return{subject:t?.sub??null,email:typeof n==`string`?n:null}}function et(e){if(e!==void 0)try{return l(e)}catch{return}}function Y(e){return[e.access_token,e.refresh_token,e.id_token]}function X(e){return`${Ve}${e}`}function tt(e,t){return JSON.stringify({client:rt(e,t.client),expiresAt:ct(t.expiresAt),tokens:Z(t.tokens)})}function nt(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`OS OAuth credential entry failed schema validation`,{cause:e})}if(!ut(n))throw Error(`OS OAuth credential entry failed schema validation`);return{client:rt(e,it(n.client)),expiresAt:ct(n.expiresAt),tokens:Z(at(n.tokens))}}function rt(e,t){if(q(t.resource)!==e)throw Error(`OAuth client resource must match the credential API host`);return t}function it(e){let t=Be.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed canonical client validation`,{cause:t.error});return t.data}function at(e){let t=f.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(!lt(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&&!lt(e.refresh_token))throw Error(`OAuth token response has an invalid refresh token`);return ot(e),e}function ot(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 st(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 ct(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 lt(e){return e.trim()===e&&e.length>0}function ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function dt(r,o){if($())return;let s=async(e,t,n,a=!1)=>{if(await Le(o),!$())throw a?t:pt(e,r,t,n);i({component:`aventure-cli`,event:`oauth_credential_bypassed`,message:`OAuth sign-in is unavailable (${e}); using the stored API key.`,...t===void 0?{}:{error:Error(S(t,Q(n)))}})},l=async(e,t,n)=>{let r=await G(e.host).catch(()=>void 0);if(r?.state===`found`&&r.stored.credential.tokens.access_token!==e.credential.tokens.access_token)return await u(r.stored,!1);try{await Ge(e.host)}catch(n){i({component:`aventure-cli`,event:`oauth_credential_retire_failed`,message:`the saved OAuth credential is dead (${t}) but could not be removed`,error:Error(S(n,Q(e)))})}await s(t,n,e)},u=async(r,i)=>{let u=(e,t)=>i?l(r,e,t):s(e,t,r),d=r.credential;if(J(d)){if(d.tokens.refresh_token===void 0)return await u(`the saved OAuth credential has expired`);try{d=await ft(r)}catch(t){return t instanceof n?await u(`Clerk rejected the saved refresh token`,t):await s(`the saved OAuth credential could not be renewed`,t,r,!(t instanceof e))}}let f;try{f=await c(d.tokens.access_token,new URL(d.client.resource))!==null}catch(e){return e instanceof t?await u(`the saved OAuth credential is malformed`,e):await s(`the saved OAuth credential could not be verified`,e,r,!0)}if(!f)return await u(`the saved OAuth credential was rejected`);$()||(process.env[a.authToken]=d.tokens.access_token,o?.(`oauth`))},f;try{f=q(d().host)}catch(e){throw pt(`the API host could not select its OAuth credential`,r,e)}let p;try{p=await G(f)}catch(e){return await s(`the saved OAuth credential is invalid or expired`,e)}if(p.state!==`missing`){if(p.state===`unavailable`)return await s(`the saved OAuth credential could not be read`,Error(p.summary));await u(p.stored,!0)}}async function ft(e){return await R(async()=>{let t=await G(e.host),n=t.state===`found`?t.stored:e;if(!J(n.credential))return n.credential;let{renewOAuthTokens:r}=await import(`./oauth-login-D-tNp610.js`),a=Ue(n.credential.client,await r(n));try{await We(e.host,a)}catch(e){i({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(S(e,Y(a.tokens)))})}return a})}function Q(e){return e===void 0?[]:Y(e.credential.tokens)}function $(){return(process.env[a.authToken]?.trim().length??0)>0}function pt(e,t,n,r){let i=n===void 0?``:` — ${S(n,Q(r))}`,a=t??o().bin[0];return Error(`OAuth sign-in is required: ${e}. Run \`${a} auth login\` before retrying.${i}`)}export{me as A,je as C,be as D,E,S as M,de as N,ye as O,H as S,Ee as T,We as _,Ge as a,Ne as b,J as c,$e as d,Xe as f,K as g,Je as h,Ue as i,pe as j,he as k,Ye as l,Y as m,ft as n,Ke as o,Qe as p,q as r,qe as s,dt as t,Ze as u,Le as v,Ae as w,Me as x,U as y};
@@ -1 +0,0 @@
1
- import{i as e}from"./oauth-login-DZHht6I9.js";export{e as renewOAuthTokens};