@aventurevc/aventure-cli 0.8.214 → 0.8.216

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.
Files changed (31) hide show
  1. package/dist/aventure-cli/index.js +1 -1
  2. package/dist/aventure-cli/unified-operations.json +1 -1
  3. package/dist/chunks/api-key-bearer-credential-C1_p7wsQ.js +1 -0
  4. package/dist/chunks/{api-key-bearer-credential-B5cWfTvy.js → api-key-bearer-credential-D8URNZHF.js} +1 -1
  5. package/dist/chunks/aventure-cli-DVdHbYPm.js +67 -0
  6. package/dist/chunks/{cli-help-policy-DtEA5aUs.js → cli-help-policy-DAMlMsef.js} +1 -1
  7. package/dist/chunks/{contract-B2e_hJVZ.js → contract-pPG4fNo5.js} +4 -4
  8. package/dist/chunks/dist-c8HUJZnY.js +108 -0
  9. package/dist/chunks/oauth-bearer-credential-Bd5t1ijb.js +8 -0
  10. package/dist/chunks/oauth-bearer-credential-CllNkwOL.js +1 -0
  11. package/dist/chunks/oauth-login-BD9dHEqU.js +1 -0
  12. package/dist/chunks/{oauth-login-Cr4KzZ0g.js → oauth-login-CxrOU9W-.js} +3 -3
  13. package/dist/chunks/openapi-commands-DRdfnVqt.js +1 -0
  14. package/dist/chunks/{openapi-commands-BPCqSbwO.js → openapi-commands-LRvurPYF.js} +1 -1
  15. package/dist/chunks/provider-catalog-Bgp_118N.js +1 -0
  16. package/dist/chunks/response-problem-CLwmyQLg.js +1 -0
  17. package/dist/chunks/{startup-auth-C0lEZxWc.js → startup-auth-B-pDC8t2.js} +1 -1
  18. package/dist/chunks/startup-auth-CAHK_djA.js +1 -0
  19. package/dist/chunks/tool-policy-kgp10gPN.js +1 -0
  20. package/package.json +3 -3
  21. package/dist/chunks/api-key-bearer-credential-CSbp5pO2.js +0 -1
  22. package/dist/chunks/aventure-cli-CYajAVv4.js +0 -67
  23. package/dist/chunks/dist-W6a2lhH8.js +0 -108
  24. package/dist/chunks/oauth-bearer-credential-CB5C3dLM.js +0 -8
  25. package/dist/chunks/oauth-bearer-credential-COLM0m6U.js +0 -1
  26. package/dist/chunks/oauth-login-DAAmiJQD.js +0 -1
  27. package/dist/chunks/openapi-commands-Cg31tun5.js +0 -1
  28. package/dist/chunks/provider-catalog-Bj9bossW.js +0 -1
  29. package/dist/chunks/response-problem-D1QJ3hMo.js +0 -1
  30. package/dist/chunks/startup-auth-CUgM9jUM.js +0 -1
  31. package/dist/chunks/tool-policy-Bs4Jo1cv.js +0 -1
@@ -0,0 +1 @@
1
+ import{w as e,y as t}from"./person-owner-BJgNYLKX.js";import{Yr as n}from"./dist-c8HUJZnY.js";var r=t({clerkPublishableKey:e().nullish(),oauthClient:n.nullish()});export{r as t};
@@ -0,0 +1 @@
1
+ import{S as e,w as t}from"./person-owner-BJgNYLKX.js";import{d as n,f as r,i}from"./result-envelope-HCfZHr9Q.js";function a(e,t,n=[]){return i(`${e}: ${t.status} ${t.title}`,[...n],{httpStatus:t.status,problem:t})}function o(e){let t=[],n=[];for(let[r,i]of Object.entries(e)){let e=r.toLowerCase();(e===`warning`||e.startsWith(`x-contract-warning-`))&&(t.push(`${s(e)}: ${i}`),e===`x-contract-warning-key`&&n.push(i))}return{warnings:t,omitted:n}}function s(e){return e.split(`-`).map(e=>e===`x`?`X`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`).join(`-`)}var c=/(?:authorization|api-key|secret|token)/iu,l=/^x-cli-[a-z0-9-]*secret$/iu;function u(n,i,a={}){let o=h(a);o.length>0&&(i=d(i,o));let s=e(t(),r).safeParse(i);if(!s.success)return{status:n,title:`HTTP ${n}`,type:`about:blank`,code:void 0,detail:typeof i==`string`?i:void 0};let c=f(s.data),l=typeof c.status==`number`?c.status:n;return{...c,status:l,title:typeof c.title==`string`?c.title:`HTTP ${l}`,type:typeof c.type==`string`?c.type:`about:blank`,detail:typeof c.detail==`string`?c.detail:void 0}}function d(e,t){return typeof e==`string`?g(e,t):typeof e!=`object`||!e?e:Array.isArray(e)?e.map(e=>d(e,t)):Object.fromEntries(Object.entries(e).map(([e,n])=>[g(e,t),d(n,t)]))}function f(e){let t=n.safeParse(e);if(t.success)return e;let r=new Set(t.error.issues.map(e=>String(e.path[0])));return Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)))}function p(e,t){if(m(t))return{status:e.status,title:`CLI authorization broker request failed`};let n=h(t),r={};for(let[t,i]of Object.entries(e))i!=null&&(r[t]=typeof i==`object`?JSON.stringify(d(i,n)):typeof i==`string`?g(i,n):i);return r}function m(e){return Object.keys(e).some(e=>l.test(e))}function h(e){let t=[];for(let[n,r]of Object.entries(e)){if(!c.test(n))continue;let e=r.trim();if(e.length===0)continue;t.push(e);let i=e.indexOf(` `);if(i>0){let n=e.slice(i+1).trim();n.length>0&&t.push(n)}}return t}function g(e,t){let n=e;for(let e of t)e!=null&&e.length>0&&(n=n.replaceAll(e,`<redacted>`));return n}function _(e,t){if(m(t))return{status:e.status,title:`CLI authorization broker request failed`,type:`about:blank`,detail:`Broker diagnostic text was suppressed at the CLI credential boundary.`,...y(e)};let n=h(t);if(n.length===0)return e;let r=t=>{let r=e[t];return typeof r==`string`?{[t]:g(r,n)}:{}},i=t=>{let r=e[t];return r==null?{}:{[t]:Object.fromEntries(Object.entries(r).map(([e,t])=>[g(e,n),g(t,n)]))}},a=t=>{let r=e[t];return Array.isArray(r)?{[t]:r.map(e=>g(e,n))}:{}};return{status:e.status,title:g(e.title,n),type:g(e.type,n),...r(`detail`),...r(`hint`),...r(`field`),...r(`suggestion`),...r(`requiredRole`),...r(`existingRecordId`),...i(`suggestions`),...i(`error`),...a(`unknownParameters`),...a(`validParameters`),...e.details===void 0?{}:{details:e.details},...e.resolution===void 0?{}:{resolution:e.resolution},...e.code===void 0?{}:{code:e.code},...e.disposition==null?{}:{disposition:e.disposition},...Array.isArray(e.proseViolation)?{proseViolation:e.proseViolation.map(e=>({...e,passage:g(e.passage,n),reason:g(e.reason,n)}))}:{},...r(`traceId`),...r(`spanId`),...e.limitType===void 0?{}:{limitType:e.limitType},...e.allowanceType===void 0?{}:{allowanceType:e.allowanceType},...e.limit===void 0?{}:{limit:e.limit},...e.used===void 0?{}:{used:e.used},...e.remaining===void 0?{}:{remaining:e.remaining},...e.resetAt===void 0?{}:{resetAt:e.resetAt},...e.windowSeconds===void 0?{}:{windowSeconds:e.windowSeconds},...e.filedRunId?{filedRunId:e.filedRunId}:{},...y(e)}}function v(e,t){if(x(e.retryAfterSeconds)!==void 0)return e;let n=b(t.get(`retry-after`));return n===void 0?e:{...e,retryAfterSeconds:n}}function y(e){let t=x(e.retryAfterSeconds);return t===void 0?{}:{retryAfterSeconds:t}}function b(e){let t=e?.trim()??``;if(/^\d+$/u.test(t))return x(Number(t));let n=/[a-z]/iu.test(t)?new Date(t).getTime():NaN;return Number.isNaN(n)?void 0:x(Math.ceil((n-Date.now())/1e3))}function x(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:void 0}export{h as a,b as c,g as i,x as l,u as n,_ as o,a as r,o as s,p as t,v as u};
@@ -1 +1 @@
1
- import{n as e,o as t,t as n}from"./commander-BB7CDPLs.js";import{_ as r,x as i}from"./logging-RiG2UJwJ.js";import{_ as a}from"./tool-policy-Bs4Jo1cv.js";import{i as o,l as s}from"./result-envelope-HCfZHr9Q.js";import{r as c}from"./cli-help-policy-DtEA5aUs.js";function l(e,t){return e.parameters.filter(e=>e.required&&t[e.optionKey]===void 0).map(e=>e.flag)}function u(e,t){return(e.requestBody?.length??0)>1&&typeof t.contentType==`string`?t.contentType:void 0}var d=e=>typeof e==`string`&&e.trim()===``;function f(e,t){let n=new Set([...t.parameters,...(t.requestBody??[]).flatMap(({parameter:e})=>e)].filter(e=>e.required).map(e=>e.optionKey));for(let t of e.options){let r=t.attributeName(),i=e.getOptionValue(r);if(!(Array.isArray(i)?i.some(d):d(i)))continue;let a=Array.isArray(i)?i.filter(e=>!d(e)):[];if(a.length>0){e.setOptionValue(r,a);continue}n.has(r)&&e.error(`error: option '${t.flags}' requires a value`),e.setOptionValue(r,void 0)}}function p(e){return e.split(` `)[0]??e}function m(e){if(e.requestBody===void 0||e.requestBody.length===0){let[t,n]=e.parameters.filter(e=>e.required);return n===void 0&&t?.schemaType===`string`?t:void 0}if(e.requestBody.length!==1||e.parameters.some(e=>e.required))return;let t=e.requestBody[0]?.parameter??[],n=t.filter(e=>e.required);if(n.length===1&&n[0]?.schemaType===`string`)return n[0];if(n.length!==0||e.intent!==`search`)return;let r=t.filter(e=>{let t=e.name.split(`.`).at(-1);return e.schemaType===`string`&&(t===`query`||t===`search`)});return r.length===1?r[0]:void 0}function h(e,t,n){let r=t.join(` `).trim();return r.length===0?s(`No positional text`,n):n[e.optionKey]===void 0?s(`Positional text parsed`,{...n,[e.optionKey]:r}):o(`Unexpected argument "${r}": ${p(e.flag)} already sets this value, and this command has no subcommand by that name. Drop "${r}".`)}var g={addresses:{summary:`List Address Links`,section:`administration`},"addresses links":{summary:`Returns entity and person association ids, owner ids, and nullable roles for a physical address, including historical associations`},agents:{summary:`Deprecated: Answer a Natural-Language Platform Help Question`,section:`cli`},"agents help":{summary:`Deprecated: use help ask (POST /v1/help) with the same body`},auth:{summary:`Sign-in, session, API key, and CLI authorization endpoints`,section:`account`},"auth api-key":{summary:`Get Current API Key`},"auth me":{summary:`Current User Permissions`},"auth me permissions":{summary:`Returns the current caller's resolved roles and permissions`},"auth providers":{summary:`Get the Sign-In Options`},billing:{summary:`Plans, prices, subscription, usage, and upgrades`,section:`account`},"billing additional-usage":{summary:`Update Additional Usage Settings`},"billing ai-credits":{summary:`Read the Current AI Credit Allowance`},"billing checkout-sessions":{summary:`Create or Recover a Checkout Session`},"billing credit-purchases":{summary:`Read a Prepaid Credit Purchase Confirmation`},"billing plan-change-previews":{summary:`Preview a Subscription Plan Change`},"billing plan-changes":{summary:`Change the Subscription Plan`},"billing plans":{summary:`List Subscription Tiers and Plans`},"billing portal-sessions":{summary:`Create a Hosted Billing Portal Session`},"billing subscription":{summary:`Read the Current Billing Subscription`},"billing subscription next-charge":{summary:`Preview the Next Subscription Charge`},"billing subscription payment-profile":{summary:`Read Your Card on File and Introductory Offer`},directory:{summary:`List Shared Directory Views`,section:`researchData`},"directory shared":{summary:`Share a Directory View`},"directory shared slug":{summary:`Read a Shared Directory View by Slug`},enrichments:{summary:`Enrich Many Companies and People`,section:`researchData`},entities:{summary:`Companies and funds: people, funding, and news`,section:`researchData`},"entities acquisitions":{summary:`Acquisitions a company made or was part of`},"entities addresses":{summary:`A company's recorded office and headquarters addresses`},"entities blog-posts":{summary:`External blog and article links for entities and people`},"entities brand":{summary:`Get a Company's Names, Logos, Links, and Tags`},"entities classifications":{summary:`Classification tags on a company, and suggested tags`},"entities classifications catalog":{summary:`Get the Company Classification Taxonomy`},"entities classifications suggestions":{summary:`Suggest Classifications for a Company`},"entities classifications tags":{summary:`List Classification Tags`},"entities content":{summary:`Publications about one company or person, and platform-wide publication search`},"entities content facets":{summary:`Count a Company's Publications`},"entities employee-counts":{summary:`List a Company's Headcount Over Time`},"entities enrichments":{summary:`Enrich One Company, Product, or Service`},"entities filters":{summary:`Filter options for company listings: available values, refinement, and option search`},"entities fundraise-investor-joins":{summary:`List the Investors in a Funding Round`},"entities fundraise-rounds":{summary:`List a Company's Funding Rounds`},"entities investments":{summary:`List the Investments a Company Made`},"entities investor-activity":{summary:`Get Investor Activity`},"entities investors":{summary:`List a Company's Investors`},"entities logo":{summary:`Get a Company Logo`},"entities lookup-exact":{summary:`Read Full Entity Detail by aVenture Profile URL, Slug, Website, or Domain`},"entities people":{summary:`People linked to companies, and the role each one holds`},"entities person-investors":{summary:`List Person Investors`},"entities relationships":{summary:`Relationships between companies, investors, and other organizations`},"entities relationships types":{summary:`List Entity Relationship Types`},"entities repositories":{summary:`List a Company's GitHub Repositories`},"entities research":{summary:`Get the Research Gathered About a Company`},"entities research-details":{summary:`List Research Details`},"entities research-details types":{summary:`List the Accepted Research Detail Types`},"entities research-snippets":{summary:`List Research Snippets`},"entities research-snippets types":{summary:`List the Accepted Research Snippet Types`},"entities search":{summary:`Search Companies, Products, and Services`},"entities search jobs":{summary:`Get an Async Semantic Entity Search`},"entities sec":{summary:`Get SEC EDGAR Facts for a Public Company`},"entities similar":{summary:`Similar companies and lean similar-company summaries by id`},"entities similar summary":{summary:`Get Similar Company Summaries by ID`},"entities slug":{summary:`Get a Company's Slug`},"entities texts":{summary:`Descriptions and other written text for companies and people`},"entities texts types":{summary:`List the Accepted Company Text Types`},"entities trending-news":{summary:`List Trending News About a Company`},"entities types":{summary:`List the Accepted typeRecord Values`},"entities unique-ids":{summary:`External identifiers and the records they name`},"entities urls":{summary:`Websites, social profiles, and other URLs for companies and people`},"entities valuations":{summary:`List a Company's Valuation Over Time`},help:{summary:`Answer a Natural-Language Platform Help Question`,section:`cli`},lookup:{summary:`Read a Company, Product, Service, or Person Identity`,section:`researchData`},"lookup-from-file":{summary:`Identify a Company, Product, Service, or Person by Name, URL, or ID`,section:`researchData`},"lookup-jobs":{summary:`Async article and bulk name identification`,section:`researchData`},"lookup-mentions":{summary:`Identify Every Company and Person a Page or Screenshot Names`,section:`researchData`},metrics:{summary:`Get Platform Totals for Companies, Funding, and People`,section:`cli`},news:{summary:`News linked to the companies and people in it`,section:`researchData`},"news feedback":{summary:`Submit News Feedback`},"news related-entities":{summary:`List the Entities a News Article Is About`},"news subscriptions":{summary:`List Entity News Subscriptions`},"news subscriptions test-events":{summary:`Send a Test News Event`},"news thumbnail":{summary:`Get News Thumbnail`},people:{summary:`Founders and investors, and what they back`,section:`researchData`},"people addresses":{summary:`A person's recorded addresses`},"people blog-posts":{summary:`External blog and article links for entities and people`},"people content":{summary:`Publications about one company or person, and platform-wide publication search`},"people content facets":{summary:`Count a Person's Publications`},"people enrichments":{summary:`Enrich One Person`},"people entities":{summary:`People linked to companies, and the role each one holds`},"people filters":{summary:`Filter options for people listings and option search`},"people graph":{summary:`Get Person Graph`},"people investments":{summary:`List a Person's Investments`},"people investor-activity":{summary:`Get Person Investor Activity`},"people lookup-exact":{summary:`Read One Person's Full Detail by aVenture Profile URL, Slug, or URL`},"people photo":{summary:`Get Person Photo`},"people repositories":{summary:`List a Person's GitHub Repositories`},"people similar":{summary:`List People Similar to One Person`},"people texts":{summary:`Descriptions and other written text for companies and people`},"people texts types":{summary:`List the Accepted Person Text Types`},"people unique-ids":{summary:`External identifiers and the records they name`},"people urls":{summary:`Websites, social profiles, and other URLs for companies and people`},"research-runs":{summary:`Research requests you file for a company, Product, Service, or person, and their progress`,section:`researchData`},"research-runs presets":{summary:`List Research Presets`},resolve:{summary:`Deprecated: Resolve an Entity or Person by Identifier Token`,section:`researchData`},search:{summary:`Search Companies, People, and News Together`,section:`researchData`},"search link":{summary:`Search From a Page URL`},"search link jobs":{summary:`Get a Link Search Job`},"search natural":{summary:`Find companies and people in natural language`},"search shared":{summary:`Search companies, people, and news, or by URL`},"search shared slug":{summary:`Read a Shared Search by Slug`},"unique-ids":{summary:`External identifiers and the records they name`,section:`researchData`},"unique-ids types":{summary:`List the Accepted Unique Identifier Types`},"url-types":{summary:`List URL Types`,section:`researchData`},web:{summary:`Search the Live Web`,section:`researchData`},"web searches":{summary:`Get an Async Web Search Job`},"web searches jobs":{summary:"Reads the web-search job a `Prefer: respond-async` search accepted"}};function _(e){return b(e,v())}function v(){return!!i().userBearerToken?.trim()}function y(e){return v()||!c(e,g)}function b(e,t){return t?e:e.filter(e=>!c(e.cliPath[0],g)||e.visibility!==`private`).map(x)}function x(e){let t=e.parameters.filter(S),n=e.requestBody?.map(e=>{let t=e.parameter.filter(S);return t.length===e.parameter.length?e:{...e,parameter:t}}),r=n?.every((t,n)=>t===e.requestBody?.[n]);return t.length===e.parameters.length&&r!==!1?e:{...e,parameters:t,requestBody:n}}var S=e=>e.visibility!==`private`;function C(i,o){let s=i.indexOf(`--`),l=i.slice(0,s===-1?i.length:s);if(l.some(e=>e===`--version`||e===`-V`))return`none`;let d=new n().exitOverride().configureOutput({writeErr:()=>void 0}).addOption(new e(`--environment <environment>`,`route all API calls to a mapped API environment`).choices([...r()])).addOption(new e(`--content-type <media-type>`)).addOption(new e(`--ask <question>`)),f=d.parseOptions([...i]).operands,p=d.opts().environment;p!==void 0&&(process.env.API_ENV=p);let m=o.find(e=>w(f,e.cliPath)),h=m===void 0?void 0:u(m,d.opts());if(m!==void 0&&h!==void 0){let e=a(m.requestBody??[],h);if(!e.ok)throw new t(e.summary)}let _=f.at(0);if(_===void 0)return`stored`;if(_===`update`||_===`auth`&&m===void 0)return`none`;let v=d.opts().ask;return l.some(e=>e===`--help`||e===`-h`)?(m??(_===`help`&&v===void 0?o.find(e=>w(f.slice(1),e.cliPath)):void 0))!==void 0||c(_,g)?`stored`:`none`:c(_,g)?`required`:_===`help`?m===void 0?v===void 0?`stored`:f.length===1?`required`:`none`:`required`:_===`agents`&&f[1]===`setup`?`required`:[`command-catalog`,`completion`].includes(_)?`optional`:_===`batch`?`required`:m===void 0?`optional`:`required`}function w(e,t){return t.every((t,n)=>e[n]===t)}export{g as a,l as c,h as d,_ as i,f as l,C as n,u as o,b as r,p as s,y as t,m as u};
1
+ import{n as e,o as t,t as n}from"./commander-BB7CDPLs.js";import{_ as r,x as i}from"./logging-RiG2UJwJ.js";import{v as a}from"./tool-policy-kgp10gPN.js";import{i as o,l as s}from"./result-envelope-HCfZHr9Q.js";import{r as c}from"./cli-help-policy-DAMlMsef.js";function l(e,t){return e.parameters.filter(e=>e.required&&t[e.optionKey]===void 0).map(e=>e.flag)}function u(e,t){return(e.requestBody?.length??0)>1&&typeof t.contentType==`string`?t.contentType:void 0}var d=e=>typeof e==`string`&&e.trim()===``;function f(e,t){let n=new Set([...t.parameters,...(t.requestBody??[]).flatMap(({parameter:e})=>e)].filter(e=>e.required).map(e=>e.optionKey));for(let t of e.options){let r=t.attributeName(),i=e.getOptionValue(r);if(!(Array.isArray(i)?i.some(d):d(i)))continue;let a=Array.isArray(i)?i.filter(e=>!d(e)):[];if(a.length>0){e.setOptionValue(r,a);continue}n.has(r)&&e.error(`error: option '${t.flags}' requires a value`),e.setOptionValue(r,void 0)}}function p(e){return e.split(` `)[0]??e}function m(e){if(e.requestBody===void 0||e.requestBody.length===0){let[t,n]=e.parameters.filter(e=>e.required);return n===void 0&&t?.schemaType===`string`?t:void 0}if(e.requestBody.length!==1||e.parameters.some(e=>e.required))return;let t=e.requestBody[0]?.parameter??[],n=t.filter(e=>e.required);if(n.length===1&&n[0]?.schemaType===`string`)return n[0];if(n.length!==0||e.intent!==`search`)return;let r=t.filter(e=>{let t=e.name.split(`.`).at(-1);return e.schemaType===`string`&&(t===`query`||t===`search`)});return r.length===1?r[0]:void 0}function h(e,t,n){let r=t.join(` `).trim();return r.length===0?s(`No positional text`,n):n[e.optionKey]===void 0?s(`Positional text parsed`,{...n,[e.optionKey]:r}):o(`Unexpected argument "${r}": ${p(e.flag)} already sets this value, and this command has no subcommand by that name. Drop "${r}".`)}var g={addresses:{summary:`List Address Links`,section:`administration`},"addresses links":{summary:`Returns entity and person association ids, owner ids, and nullable roles for a physical address, including historical associations`},agents:{summary:`Deprecated: Answer a Natural-Language Platform Help Question`,section:`cli`},"agents help":{summary:`Deprecated: use help ask (POST /v1/help) with the same body`},auth:{summary:`Sign-in, session, API key, and CLI authorization endpoints`,section:`account`},"auth api-key":{summary:`Get Current API Key`},"auth me":{summary:`Current User Permissions`},"auth me permissions":{summary:`Returns the current caller's resolved roles and permissions`},"auth providers":{summary:`Get the Sign-In Options`},billing:{summary:`Plans, prices, subscription, usage, and upgrades`,section:`account`},"billing additional-usage":{summary:`Update Additional Usage Settings`},"billing ai-credits":{summary:`Read the Current AI Credit Allowance`},"billing checkout-sessions":{summary:`Create or Recover a Checkout Session`},"billing credit-purchases":{summary:`Read a Prepaid Credit Purchase Confirmation`},"billing plan-change-previews":{summary:`Preview a Subscription Plan Change`},"billing plan-changes":{summary:`Change the Subscription Plan`},"billing plans":{summary:`List Subscription Tiers and Plans`},"billing portal-sessions":{summary:`Create a Hosted Billing Portal Session`},"billing subscription":{summary:`Read the Current Billing Subscription`},"billing subscription next-charge":{summary:`Preview the Next Subscription Charge`},"billing subscription payment-profile":{summary:`Read Your Card on File and Introductory Offer`},directory:{summary:`List Shared Directory Views`,section:`researchData`},"directory shared":{summary:`Share a Directory View`},"directory shared slug":{summary:`Read a Shared Directory View by Slug`},enrichments:{summary:`Enrich Many Companies and People`,section:`researchData`},entities:{summary:`Companies and funds: people, funding, and news`,section:`researchData`},"entities acquisitions":{summary:`Acquisitions a company made or was part of`},"entities addresses":{summary:`A company's recorded office and headquarters addresses`},"entities blog-posts":{summary:`External blog and article links for entities and people`},"entities brand":{summary:`Get a Company's Names, Logos, Links, and Tags`},"entities classifications":{summary:`Classification tags on a company, and suggested tags`},"entities classifications catalog":{summary:`Get the Company Classification Taxonomy`},"entities classifications suggestions":{summary:`Suggest Classifications for a Company`},"entities classifications tags":{summary:`List Classification Tags`},"entities content":{summary:`Publications about one company or person, and platform-wide publication search`},"entities content facets":{summary:`Count a Company's Publications`},"entities employee-counts":{summary:`List a Company's Headcount Over Time`},"entities enrichments":{summary:`Enrich One Company, Product, or Service`},"entities filters":{summary:`Filter options for company listings: available values, refinement, and option search`},"entities fundraise-investor-joins":{summary:`List the Investors in a Funding Round`},"entities fundraise-rounds":{summary:`List a Company's Funding Rounds`},"entities investments":{summary:`List the Investments a Company Made`},"entities investor-activity":{summary:`Get Investor Activity`},"entities investors":{summary:`List a Company's Investors`},"entities logo":{summary:`Get a Company Logo`},"entities lookup-exact":{summary:`Read Full Entity Detail by aVenture Profile URL, Slug, Website, or Domain`},"entities people":{summary:`People linked to companies, and the role each one holds`},"entities person-investors":{summary:`List Person Investors`},"entities relationships":{summary:`Relationships between companies, investors, and other organizations`},"entities relationships types":{summary:`List Entity Relationship Types`},"entities repositories":{summary:`List a Company's GitHub Repositories`},"entities research":{summary:`Get the Research Gathered About a Company`},"entities research-details":{summary:`List Research Details`},"entities research-details types":{summary:`List the Accepted Research Detail Types`},"entities research-snippets":{summary:`List Research Snippets`},"entities research-snippets types":{summary:`List the Accepted Research Snippet Types`},"entities search":{summary:`Search Companies, Products, and Services`},"entities search jobs":{summary:`Get an Async Semantic Entity Search`},"entities sec":{summary:`Get SEC EDGAR Facts for a Public Company`},"entities similar":{summary:`Similar companies and lean similar-company summaries by id`},"entities similar summary":{summary:`Get Similar Company Summaries by ID`},"entities slug":{summary:`Get a Company's Slug`},"entities texts":{summary:`Descriptions and other written text for companies and people`},"entities texts types":{summary:`List the Accepted Company Text Types`},"entities trending-news":{summary:`List Trending News About a Company`},"entities types":{summary:`List the Accepted typeRecord Values`},"entities unique-ids":{summary:`External identifiers and the records they name`},"entities urls":{summary:`Websites, social profiles, and other URLs for companies and people`},"entities valuations":{summary:`List a Company's Valuation Over Time`},help:{summary:`Answer a Natural-Language Platform Help Question`,section:`cli`},lookup:{summary:`Read a Company, Product, Service, or Person Identity`,section:`researchData`},"lookup-from-file":{summary:`Identify a Company, Product, Service, or Person by Name, URL, or ID`,section:`researchData`},"lookup-jobs":{summary:`Async article and bulk name identification`,section:`researchData`},"lookup-mentions":{summary:`Identify Every Company and Person a Page or Screenshot Names`,section:`researchData`},metrics:{summary:`Get Platform Totals for Companies, Funding, and People`,section:`cli`},news:{summary:`News linked to the companies and people in it`,section:`researchData`},"news feedback":{summary:`Submit News Feedback`},"news related-entities":{summary:`List the Entities a News Article Is About`},"news subscriptions":{summary:`List Entity News Subscriptions`},"news subscriptions test-events":{summary:`Send a Test News Event`},"news thumbnail":{summary:`Get News Thumbnail`},people:{summary:`Founders and investors, and what they back`,section:`researchData`},"people addresses":{summary:`A person's recorded addresses`},"people blog-posts":{summary:`External blog and article links for entities and people`},"people content":{summary:`Publications about one company or person, and platform-wide publication search`},"people content facets":{summary:`Count a Person's Publications`},"people enrichments":{summary:`Enrich One Person`},"people entities":{summary:`People linked to companies, and the role each one holds`},"people filters":{summary:`Filter options for people listings and option search`},"people graph":{summary:`Get Person Graph`},"people investments":{summary:`List a Person's Investments`},"people investor-activity":{summary:`Get Person Investor Activity`},"people lookup-exact":{summary:`Read One Person's Full Detail by aVenture Profile URL, Slug, or URL`},"people photo":{summary:`Get Person Photo`},"people repositories":{summary:`List a Person's GitHub Repositories`},"people similar":{summary:`List People Similar to One Person`},"people texts":{summary:`Descriptions and other written text for companies and people`},"people texts types":{summary:`List the Accepted Person Text Types`},"people unique-ids":{summary:`External identifiers and the records they name`},"people urls":{summary:`Websites, social profiles, and other URLs for companies and people`},"research-runs":{summary:`Research requests you file for a company, Product, Service, or person, and their progress`,section:`researchData`},"research-runs presets":{summary:`List Research Presets`},resolve:{summary:`Deprecated: Resolve an Entity or Person by Identifier Token`,section:`researchData`},search:{summary:`Search Companies, People, and News Together`,section:`researchData`},"search link":{summary:`Search From a Page URL`},"search link jobs":{summary:`Get a Link Search Job`},"search natural":{summary:`Find companies and people in natural language`},"search shared":{summary:`Search companies, people, and news, or by URL`},"search shared slug":{summary:`Read a Shared Search by Slug`},"unique-ids":{summary:`External identifiers and the records they name`,section:`researchData`},"unique-ids types":{summary:`List the Accepted Unique Identifier Types`},"url-types":{summary:`List URL Types`,section:`researchData`},web:{summary:`Search the Live Web`,section:`researchData`},"web searches":{summary:`Get an Async Web Search Job`},"web searches jobs":{summary:"Reads the web-search job a `Prefer: respond-async` search accepted"}};function _(e){return b(e,v())}function v(){return!!i().userBearerToken?.trim()}function y(e){return v()||!c(e,g)}function b(e,t){return t?e:e.filter(e=>!c(e.cliPath[0],g)||e.visibility!==`private`).map(x)}function x(e){let t=e.parameters.filter(S),n=e.requestBody?.map(e=>{let t=e.parameter.filter(S);return t.length===e.parameter.length?e:{...e,parameter:t}}),r=n?.every((t,n)=>t===e.requestBody?.[n]);return t.length===e.parameters.length&&r!==!1?e:{...e,parameters:t,requestBody:n}}var S=e=>e.visibility!==`private`;function C(i,o){let s=i.indexOf(`--`),l=i.slice(0,s===-1?i.length:s);if(l.some(e=>e===`--version`||e===`-V`))return`none`;let d=new n().exitOverride().configureOutput({writeErr:()=>void 0}).addOption(new e(`--environment <environment>`,`route all API calls to a mapped API environment`).choices([...r()])).addOption(new e(`--content-type <media-type>`)).addOption(new e(`--ask <question>`)),f=d.parseOptions([...i]).operands,p=d.opts().environment;p!==void 0&&(process.env.API_ENV=p);let m=o.find(e=>w(f,e.cliPath)),h=m===void 0?void 0:u(m,d.opts());if(m!==void 0&&h!==void 0){let e=a(m.requestBody??[],h);if(!e.ok)throw new t(e.summary)}let _=f.at(0);if(_===void 0)return`stored`;if(_===`update`||_===`auth`&&m===void 0)return`none`;let v=d.opts().ask;return l.some(e=>e===`--help`||e===`-h`)?(m??(_===`help`&&v===void 0?o.find(e=>w(f.slice(1),e.cliPath)):void 0))!==void 0||c(_,g)?`stored`:`none`:c(_,g)?`required`:_===`help`?m===void 0?v===void 0?`stored`:f.length===1?`required`:`none`:`required`:_===`agents`&&f[1]===`setup`?`required`:[`command-catalog`,`completion`].includes(_)?`optional`:_===`batch`?`required`:m===void 0?`optional`:`required`}function w(e,t){return t.every((t,n)=>e[n]===t)}export{g as a,l as c,h as d,_ as i,f as l,C as n,u as o,b as r,p as s,y as t,m as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./startup-auth-B-pDC8t2.js";export{e as commandAuthMaterializationMode};
@@ -0,0 +1 @@
1
+ import{A as e,O as t,S as n,_ as r,b as i,d as a,h as o,i as s,l as c,n as l,p as u,w as d,x as ee}from"./esm-CFkfzPrU.js";import{n as te}from"./commander-BB7CDPLs.js";import{$ as f,A as p,B as ne,C as re,D as ie,E as m,F as h,G as ae,L as oe,N as se,O as ce,U as le,V as ue,W as de,X as fe,Y as pe,Z as g,_t as me,at as he,ct as ge,gt as _e,it as ve,j as ye,k as be,mt as _,nt as xe,pt as Se,rt as Ce,s as we,st as v,tt as Te,ut as y,vt as Ee,w as De}from"./logging-RiG2UJwJ.js";import{C as b,S as x,T as S,g as C,h as Oe,l as w,o as T,u as E,v as D,w as O,y as k}from"./person-owner-BJgNYLKX.js";import{f as A,i as j,l as M}from"./result-envelope-HCfZHr9Q.js";import{a as ke}from"./package-DPDX5zmx.js";import{basename as Ae,extname as je}from"node:path";import{AsyncLocalStorage as Me}from"node:async_hooks";import{readFile as Ne}from"node:fs/promises";var Pe={name:`span`,countItems:e=>e.length},Fe=256,Ie=512;function Le(e,t){let n=e&255|Fe;return t&&(n|=Ie),n}function Re(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:be(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Be(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>ze(e,t)),droppedLinksCount:e.droppedLinksCount,flags:Le(n.traceFlags,e.parentSpanContext?.isRemote)}}function ze(e,t){return{attributes:e.attributes?be(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Le(e.context.traceFlags,e.context.isRemote)}}function Be(e,t){return{attributes:e.attributes?be(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Ve(e,t){return{resourceSpans:Ue(e,t)}}function He(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function Ue(e,t){let n=He(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Re(e,t));o.push({scope:ie(e[0].instrumentationScope,t),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=ce(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}l();var We={serializeRequest:e=>{let t=Ve(e,m);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return c.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};Te(),h(),p();function Ge(e){return new URL(e,`https://placeholder.invalid`).pathname}function Ke(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean);return n.length!==r.length||r.some(Je)?!1:n.every((e,t)=>qe(e)||e===r[t])}function qe(e){let t=e.slice(1,-1);return e.startsWith(`{`)&&e.endsWith(`}`)&&t.length>0&&!t.includes(`/`)&&!t.includes(`{`)&&!t.includes(`}`)}function Je(e){if(qe(e))return!0;let t=e.toLowerCase(),n=e.slice(3,-3);return t.startsWith(`%7b`)&&t.endsWith(`%7d`)&&n.length>0&&!n.includes(`/`)&&!n.includes(`%`)&&!n.includes(`{`)&&!n.includes(`}`)}var Ye=`otlp_http_span_exporter`,Xe=class extends Ee{constructor(e={}){super(De(re(e,`TRACES`,`v1/traces`,{"Content-Type":`application/json`}),We,Ye,Pe,e.selfObsMeterProvider))}},Ze=`exception`,N=Symbol.for(`nodejs.util.inspect.custom`);function Qe(e){let t={};for(let[n,r]of e.getRawAttributes())typeof r?.then!=`function`&&r!=null&&(t[n]??=r);return t}function $e(e,t,n,r,i){if(typeof n==`number`&&n<0){let t=`[${e}]`;return r?.stylize?r.stylize(t,`special`):t}return typeof i!=`function`||!r?t:`${e} ${i(t,{...r,depth:r.depth==null?r.depth:r.depth-1})}`}l();var et=class{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:u.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=f.now(),this._performanceOffset=t-(this._performanceStartTime+f.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return c.warn(`Invalid attribute key: ${e}`),this;if(!Se(t))return c.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return c.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&c.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),pe(t)&&(pe(n)||(n=t),t=void 0);let i=_(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,l=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&l>=a){s++;continue}o[e]=this._truncateToSize(t),l++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&c.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=_(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===u.UNSET||this.status.code===u.OK)return this;let t={code:e.code};return e.code===u.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&c.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){c.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=ae(this.startTime,this.endTime),this._duration[0]<0&&(c.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&c.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&c.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=f.now())return de(e+this._performanceOffset);if(typeof e==`number`)return g(e);if(e instanceof Date)return g(e.getTime());if(fe(e))return e;if(this._startTimeProvided)return g(Date.now());let t=f.now()-this._performanceStartTime;return le(this.startTime,g(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[Ce]=e:e&&(e.code?n[he]=e.code.toString():e.name&&(n[he]=e.name),e.message&&(n[Ce]=e.message),e.stack&&(n[ve]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(Ze,n,t):c.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);c.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(c.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}[N](e,t,n){return $e(`SpanImpl`,{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:Qe(this.resource)}},e,t,n)}},P;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(P||={});var tt=`otel.component.name`,nt=`otel.component.type`,rt=`otel.span.parent.origin`,it=`otel.span.sampling_result`,at=`otel.sdk.processor.span.processed`,ot=`otel.sdk.processor.span.queue.capacity`,st=`otel.sdk.processor.span.queue.size`,ct=`otel.sdk.span.live`,lt=`otel.sdk.span.started`,ut=`batching_span_processor`,dt=class{startedSpans;liveSpans;constructor(e){this.startedSpans=e.createCounter(lt,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(ct,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=pt(t);if(this.startedSpans.add(1,{[rt]:ft(e),[it]:n}),t===P.NOT_RECORD)return()=>{};let r={[it]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function ft(e){return e?e.isRemote?`remote`:`local`:`none`}function pt(e){switch(e){case P.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case P.RECORD:return`RECORD_ONLY`;case P.NOT_RECORD:return`DROP`}}var mt=`2.11.0`;l(),h();var ht=class{_sampler;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(e,t){this.instrumentationScope=e,this._sampler=t.sampler,this._spanLimits=t.spanLimits,this._resource=t.resource,this._idGenerator=t.idGenerator,this._spanProcessor=t.spanProcessor;let n=t.meterProvider.getMeter(`@opentelemetry/sdk-trace`,mt);this._tracerMetrics=new dt(n)}startSpan(e,t={},i=a.active()){t.root&&(i=s.deleteSpan(i));let l=s.getSpan(i);if(_e(i))return c.debug(`Instrumentation suppressed, returning Noop Span`),s.wrapSpanContext(n);let u=l?.spanContext(),ee=this._idGenerator.generateSpanId(),te,f,p;!u||!s.isSpanContextValid(u)?f=this._idGenerator.generateTraceId():(f=u.traceId,p=u.traceState,te=u);let ne=t.kind??o.INTERNAL,re=(t.links??[]).map(e=>({context:e.context,attributes:_(e.attributes)})),ie=_(t.attributes),m=this._sampler.shouldSample(i,f,e,ne,ie,re),h=this._tracerMetrics.startSpan(u,m.decision);p=m.traceState??p;let ae=m.decision===r.RECORD_AND_SAMPLED?d.SAMPLED:d.NONE,oe={traceId:f,spanId:ee,traceFlags:ae,traceState:p};if(m.decision===r.NOT_RECORD)return c.debug(`Recording is off, propagating context in a non-recording span`),s.wrapSpanContext(oe);let se=_(Object.assign(ie,m.attributes));return new et({resource:this._resource,scope:this.instrumentationScope,context:i,spanContext:oe,name:e,kind:ne,links:re,parentSpanContext:te,attributes:se,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:h})}startActiveSpan(e,t,n,r){let i,o,c;if(arguments.length<2)return;arguments.length===2?c=t:arguments.length===3?(i=t,c=n):(i=t,o=n,c=r);let l=o??a.active(),u=this.startSpan(e,i,l),d=s.setSpan(l,u);return a.with(d,c,void 0,u)}[N](e,t,n){return $e(`Tracer`,{instrumentationScope:this.instrumentationScope,resource:{attributes:Qe(this._resource)},spanLimits:this._spanLimits},e,t,n)}};h();var gt=class{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{y(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},F=class{shouldSample(){return{decision:P.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},I=class{shouldSample(){return{decision:P.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};l(),h();var L=class{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||=(y(Error(`ParentBasedSampler must have a root sampler configured`)),new I),this._remoteParentSampled=e.remoteParentSampled??new I,this._remoteParentNotSampled=e.remoteParentNotSampled??new F,this._localParentSampled=e.localParentSampled??new I,this._localParentNotSampled=e.localParentNotSampled??new F}shouldSample(e,t,n,r,a,o){let c=s.getSpanContext(e);return!c||!i(c)?this._root.shouldSample(e,t,n,r,a,o):c.isRemote?c.traceFlags&d.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,a,o):this._remoteParentNotSampled.shouldSample(e,t,n,r,a,o):c.traceFlags&d.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,a,o):this._localParentNotSampled.shouldSample(e,t,n,r,a,o)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};Te();var _t=new Map,vt=class{processedSpans;queueSize;queueSizeCallback;standardAttrs;droppedAttrs;constructor(e,t,n){let r=_t.get(e)??0;if(_t.set(e,r+1),this.standardAttrs={[nt]:e,[tt]:`${e}/${r}`},this.droppedAttrs={...this.standardAttrs,[xe]:`queue_full`},this.processedSpans=t.createCounter(at,{unit:`{span}`,description:`The number of spans for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter(ot,{unit:`{span}`,description:`The maximum number of spans the queue of a given instance of an SDK span processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(st,{unit:`{span}`,description:`The number of spans in the queue of a given instance of an SDK span processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(e){this.processedSpans.add(e,this.droppedAttrs)}finishSpans(e,t){if(!t){this.processedSpans.add(e,this.standardAttrs);return}let n={...this.standardAttrs,[xe]:t.name};this.processedSpans.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};l(),h();var yt=class{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_metrics;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(e){this._exporter=e.exporter,this._maxExportBatchSize=e.maxExportBatchSize??512,this._maxQueueSize=e.maxQueueSize??2048,this._scheduledDelayMillis=e.scheduledDelayMillis??5e3,this._exportTimeoutMillis=e.exportTimeoutMillis??3e4,this._shutdownOnce=new oe(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(c.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let n=e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-trace`):t();this._metrics=new vt(ut,n,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&d.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>(this._metrics.shutdown(),this._exporter.shutdown()))}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&c.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++,this._metrics.dropSpans(1);return}this._droppedSpansCount>0&&(c.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);a.with(me(a.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,i=>{clearTimeout(n),this._metrics.finishSpans(r.length,i.error),i.code===ue.SUCCESS?e():t(i.error??Error(`BatchSpanProcessor: span export failed`))}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??=[],a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{y(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,y(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},bt=class extends yt{onShutdown(){}},xt=8,St=16,Ct=class{generateTraceId=wt(St);generateSpanId=wt(xt)},R=Buffer.allocUnsafe(St);function wt(e){return function(){for(let t=0;t<e/4;t++)R.writeUInt32BE(Math.random()*2**32>>>0,t*4);for(let t=0;t<e&&!(R[t]>0);t++)t===e-1&&(R[e-1]=1);return R.toString(`hex`,0,e)}}l();var z;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(z||={});var Tt=class{_resource;_activeSpanProcessor;_forceFlushTimeoutMillis;_tracerOptions;_tracers=new Map;constructor(e={}){this._forceFlushTimeoutMillis=e.forceFlushTimeoutMillis??3e4,this._resource=e.resource??ye();let n=e.spanProcessors??[];this._activeSpanProcessor=new gt(n),this._tracerOptions={resource:this._resource,sampler:e.sampler??new L({root:new I}),spanLimits:{attributeCountLimit:e.spanLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.spanLimits?.attributeValueLengthLimit??1/0,eventCountLimit:e.spanLimits?.eventCountLimit??128,linkCountLimit:e.spanLimits?.linkCountLimit??128,attributePerEventCountLimit:e.spanLimits?.attributePerEventCountLimit??128,attributePerLinkCountLimit:e.spanLimits?.attributePerLinkCountLimit??128},idGenerator:e.idGenerator||new Ct,spanProcessor:this._activeSpanProcessor,meterProvider:e.meterProvider??{getMeter(){return t()}}}}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new ht({name:e,version:t,schemaUrl:n?.schemaUrl},this._tracerOptions)),this._tracers.get(r)}forceFlush(e){let t=e?.timeoutMillis??this._forceFlushTimeoutMillis,n=this._activeSpanProcessor._spanProcessors.map(e=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${t} ms`)),r=z.timeout},t);e.forceFlush().then(()=>{clearTimeout(i),r!==z.timeout&&(r=z.resolved,n(r))}).catch(e=>{clearTimeout(i),r=z.error,n(e)})}));return new Promise((e,t)=>{Promise.all(n).then(n=>{let r=n.filter(e=>e!==z.resolved);r.length>0?t(r):e()}).catch(e=>t([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}[N](e,t,n){let r=this._activeSpanProcessor._spanProcessors;return $e(`TracerProvider`,{resource:{attributes:Qe(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:r.map(e=>e.constructor?.name??`SpanProcessor`)},e,t,n)}};l();var Et=class{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=this._ratio===1?4294967296:Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:ee(t)&&this._accumulate(t)<this._upperBound?P.RECORD_AND_SAMPLED:P.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}};l(),h();var B;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(B||={});var V=1;function Dt(){return{sampler:Ot(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:v(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:v(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128},spanLimits:{attributeValueLengthLimit:v(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:v(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??128,linkCountLimit:v(`OTEL_SPAN_LINK_COUNT_LIMIT`)??128,eventCountLimit:v(`OTEL_SPAN_EVENT_COUNT_LIMIT`)??128,attributePerEventCountLimit:v(`OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT`)??128,attributePerLinkCountLimit:v(`OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT`)??128}}}function Ot(){let e=ge(`OTEL_TRACES_SAMPLER`)??B.ParentBasedAlwaysOn;switch(e){case B.AlwaysOn:return new I;case B.AlwaysOff:return new F;case B.ParentBasedAlwaysOn:return new L({root:new I});case B.ParentBasedAlwaysOff:return new L({root:new F});case B.TraceIdRatio:return new Et(kt());case B.ParentBasedTraceIdRatio:return new L({root:new Et(kt())});default:return c.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${B.ParentBasedAlwaysOn}".`),new L({root:new I})}}function kt(){let e=v(`OTEL_TRACES_SAMPLER_ARG`);return e==null?(c.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${V}.`),V):e<0||e>1?(c.error(`OTEL_TRACES_SAMPLER_ARG=${e} was given, but it is out of range ([0..1]), defaulting to ${V}.`),V):e}h();function At(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??v(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??v(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??v(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??v(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,Object.assign({},e,{spanLimits:t})}h();var jt=class extends Tt{constructor(e={}){let t=ne({},Dt(),At(e));delete t.generalLimits,super(t)}};h();var Mt=class extends bt{constructor(e,t){t||={};for(let[e,n]of[[`maxExportBatchSize`,`OTEL_BSP_MAX_EXPORT_BATCH_SIZE`],[`maxQueueSize`,`OTEL_BSP_MAX_QUEUE_SIZE`],[`scheduledDelayMillis`,`OTEL_BSP_SCHEDULE_DELAY`],[`exportTimeoutMillis`,`OTEL_BSP_EXPORT_TIMEOUT`]])if(t[e]===void 0){let r=v(n);r!==void 0&&(t[e]=r)}super({exporter:e,...t})}};l(),p();var Nt=`aventure-mcp-server`,Pt=`aventure=mcp`,Ft=`/api/public/otel/v1/traces`,It=5e3,Lt=new Set([`langfuse.observation.input`,`langfuse.observation.output`,`langfuse.observation.status_message`]),Rt=[`OTEL_EXPORTER_OTLP_HEADERS`,`OTEL_EXPORTER_OTLP_TRACES_HEADERS`],H,U;function W(e){return e?.trim()||void 0}function zt(){let e=W(process.env.LANGFUSE_BASE_URL),t=W(process.env.LANGFUSE_PUBLIC_KEY),n=W(process.env.LANGFUSE_SECRET_KEY);if(e!==void 0&&t!==void 0&&n!==void 0){for(let e of Rt){let t=(process.env[e]??``).split(`,`).map(e=>e.split(`=`,1)[0]?.trim().toLowerCase()??``).filter(e=>e!==``&&e!==`authorization`);if(t.length>0)throw Error(`${e} sets ${t.join(`, `)}, which the Langfuse trace exporter would forward`)}return new Xe({url:new URL(Ft,e).href,headers:{Authorization:`Basic ${Buffer.from(`${t}:${n}`).toString(`base64`)}`,"x-langfuse-ingestion-version":`4`},timeoutMillis:It})}}function Bt(e){let t={};for(let[n,r]of Object.entries(e.attributes))Lt.has(n)||(t[n]=r);return{name:e.name,kind:e.kind,spanContext:()=>e.spanContext(),...e.parentSpanContext===void 0?{}:{parentSpanContext:e.parentSpanContext},startTime:e.startTime,endTime:e.endTime,status:e.status,attributes:t,links:e.links,events:e.events,duration:e.duration,ended:e.ended,resource:e.resource,instrumentationScope:e.instrumentationScope,droppedAttributesCount:e.droppedAttributesCount,droppedEventsCount:e.droppedEventsCount,droppedLinksCount:e.droppedLinksCount}}function Vt(e){return{export:(t,n)=>e.export(t.map(Bt),n),shutdown:()=>e.shutdown(),forceFlush:()=>e.forceFlush?.()??Promise.resolve()}}function Ht(){if(H!==void 0)return U;let e=W(process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT),t=[...e===void 0?[]:[Vt(new Xe({url:e,timeoutMillis:It}))],...[zt()].filter(e=>e!==void 0)];return H=new jt({sampler:new I,resource:se({...we(),"service.version":process.env.GIT_SHA??process.env.SENTRY_RELEASE??ke().version}),spanProcessors:t.map(e=>new Mt(e,{exportTimeoutMillis:It}))}),U=t.length===0?void 0:H.getTracer(Nt),U}function Ut(){Ht()}var Wt=/^00-(?<traceId>[0-9a-f]{32})-(?<spanId>[0-9a-f]{16})-(?<flags>[0-9a-f]{2})$/u,Gt=/[13579bdf]$/u;function Kt(t,n,r){let i=Ht();if(i===void 0)return;let a=Wt.exec(r??``)?.groups,c=a?.traceId===void 0||a.spanId===void 0?e:s.setSpanContext(e,{traceId:a.traceId,spanId:a.spanId,traceFlags:Gt.test(a.flags??``)?d.SAMPLED:d.NONE,isRemote:!0});return i.startSpan(t,{kind:o.SERVER,attributes:n},c)}function qt(e){let{traceId:t,spanId:n,traceFlags:r}=e.spanContext();return`00-${t}-${n}-${(r&d.SAMPLED)===0?`00`:`01`}`}function Jt(e,t,n){e.setAttributes(t),e.setStatus({code:n?u.ERROR:u.OK}),e.end()}async function Yt(){let e=H;H=void 0,U=void 0,await e?.shutdown()}var G=new Me,Xt=()=>G.getStore()?.requestId,Zt=()=>G.getStore()?.userBearerToken;function Qt(){let e=G.getStore();return{...e?.requestId===void 0?{}:{"X-Client-Request-Id":e.requestId},...e?.traceparent===void 0?{}:{traceparent:e.traceparent,tracestate:Pt}}}function $t(e,t){return G.run({...G.getStore(),requestId:e},t)}function en(e,t){return G.run({...G.getStore(),userBearerToken:e},t)}function tn(e,t){return G.run({...G.getStore(),traceparent:e},t)}k({bodyPath:O(),valueField:w(k({path:w(O().nullable()).readonly(),type:T([`object`,`array`,`string`,`number`,`integer`,`boolean`]),nullable:E()})).readonly()});var K=S([C(``),O().regex(/^(?:\/(?:[^~/]|~[01])*)+$/)]),nn=b({readOperationId:O().min(1),writePointer:K,readPointer:K,readParameter:O().min(1).optional(),submittedMap:w(b({bodyPointer:K,readPointer:K,identityPointer:K})).min(1).optional()}),q=[`get`,`post`,`put`,`patch`,`delete`],rn={get:`GET`,post:`POST`,put:`PUT`,patch:`PATCH`,delete:`DELETE`},an=e=>rn[e];function on(e){let t=e.toLowerCase(),n=q.find(e=>e===t);if(n===void 0)throw Error(`Unsupported OpenAPI method: ${e}`);return n}var sn=[`oauth`,`start`,`poll`,`acknowledge`,`revoke`],cn=b({name:O().regex(/^[A-Z][A-Z0-9_]*$/u)}),J=S([C(`private`),k({scope:O().optional(),value:O().optional()})]),Y=Oe(()=>k({$ref:O().optional(),description:O().optional(),type:S([O(),w(O())]).optional(),format:O().optional(),default:A.optional(),enum:w(A).optional(),"x-extensible-enum":w(A).optional(),"x-aventure-parsed-enum":E().optional(),readOnly:E().optional(),items:Y.optional(),minItems:D().int().nonnegative().optional(),maxItems:D().int().nonnegative().optional(),properties:x(O(),Y).optional(),required:w(O()).optional(),oneOf:w(Y).optional(),anyOf:w(Y).optional(),allOf:w(Y).optional(),propertyNames:Y.optional(),additionalProperties:S([Y,E()]).optional(),"x-aventure-visibility":J.optional(),"x-aventure-cli-conflicts":w(w(O().min(1)).min(2)).min(1).optional(),"x-aventure-env":cn.optional(),"x-aventure-detail":C(!0).optional(),"x-aventure-operation-only":w(O().min(1)).min(1).optional()})),ln=k({in:O(),name:O(),required:E().optional(),description:O().optional(),schema:Y.optional(),"x-aventure-visibility":J.optional(),"x-aventure-legacy-name":b({name:O().trim().min(1)}).optional()}).superRefine((e,t)=>{let n=e[`x-aventure-legacy-name`]?.name;n!==void 0&&(e.in!==`path`&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`],message:`x-aventure-legacy-name is valid only for path parameters`}),n===e.name&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name must differ from its canonical name`}))}),un=x(O(),k({schema:Y.optional()})),dn=k({description:O().optional(),content:un.optional(),"x-aventure-standard-response":E().optional()}),fn=k({description:O().optional(),required:E().optional(),content:un.optional()}),pn=b({auth:T([`none`,`read`]).optional(),mutates:E().optional()}).optional(),mn=O().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)* [a-z0-9]+(?:-[a-z0-9]+)*$/u),hn=O().regex(/^[a-z][A-Za-z0-9]*$/u),gn=O().regex(/^--(?:no-)?[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u),_n=b({command:mn,role:T(sn),summary:O().trim().min(1).optional(),description:O().trim().min(1).optional(),bodyOption:w(hn).min(1).optional(),localOption:w(b({optionKey:hn,flag:gn,description:O().trim().min(1)})).min(1).optional()}).superRefine((e,t)=>{let n=[e.bodyOption??[],(e.localOption??[]).map(e=>e.optionKey),(e.localOption??[]).map(e=>e.flag)].some(e=>new Set(e).size!==e.length),r=(e.localOption??[]).some(e=>new te(e.flag).attributeName()!==e.optionKey);(n||r)&&t.addIssue({code:`custom`,message:`Composite CLI options must be unique and match their local flags`})}).optional(),vn=k({operationId:O(),summary:O().optional(),description:O().optional(),tags:w(O()).optional(),deprecated:E().optional(),hidden:E().optional(),security:w(x(O(),w(O()))).optional(),parameters:w(ln).optional(),requestBody:fn.optional(),responses:x(O(),dn),"x-aventure-visibility":J.optional(),"x-aventure-tool":pn,"x-aventure-mutation-readback":nn.optional(),"x-aventure-cli-composite":_n}).superRefine((e,t)=>{let n=e.parameters??[];for(let[e,r]of n.entries()){let i=r[`x-aventure-legacy-name`]?.name;r.in===`path`&&i!==void 0&&n.some((t,n)=>n!==e&&t.in===`path`&&(t.name===i||t[`x-aventure-legacy-name`]?.name===i))&&t.addIssue({code:`custom`,path:[`parameters`,e,`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name '${i}' collides with another declared path parameter`})}}),yn=k(Object.fromEntries(q.map(e=>[e,vn.optional()]))),bn=k({$ref:O().optional(),description:O().optional(),type:S([O(),w(O())]).optional(),format:O().optional(),default:A.optional(),enum:w(A).optional(),"x-extensible-enum":w(A).optional(),"x-aventure-parsed-enum":E().optional(),readOnly:E().optional(),items:Y.optional(),minItems:D().int().nonnegative().optional(),maxItems:D().int().nonnegative().optional(),oneOf:w(Y).optional(),anyOf:w(Y).optional(),allOf:w(Y).optional(),propertyNames:Y.optional(),additionalProperties:S([Y,E()]).optional(),properties:x(O(),Y).optional(),required:w(O()).optional(),"x-aventure-visibility":J.optional(),"x-aventure-cli-conflicts":w(w(O().min(1)).min(2)).min(1).optional(),"x-aventure-env":cn.optional(),"x-aventure-detail":C(!0).optional(),"x-aventure-noun":b({one:O().trim().min(1),other:O().trim().min(1)}).optional()});k({info:k({description:O().optional()}).optional(),tags:w(k({name:O(),description:O().optional(),"x-aventure-cli":b({section:T([`researchData`,`account`,`administration`,`cli`])}).optional()})).optional(),paths:x(O(),yn),webhooks:x(O(),k({post:k({description:O(),requestBody:fn})})).optional(),components:k({schemas:x(O(),bn)})}).superRefine((e,t)=>{for(let[n,r]of Object.entries(e.paths))for(let i of q){let a=r[i]?.[`x-aventure-mutation-readback`];a!==void 0&&Sn(e.paths,a.readOperationId)===null&&t.addIssue({code:`custom`,path:[`paths`,n,i,`x-aventure-mutation-readback`,`readOperationId`],message:`mutation readback names '${a.readOperationId}', which no operation in this document emits`})}});var xn=new Set([`page`,`size`,`sort`]);function X(e){return e?.$ref?.startsWith(`#/components/schemas/`)===!0?e.$ref.slice(21):void 0}function Sn(e,t){for(let[n,r]of Object.entries(e))for(let e of q){let i=r[e];if(i?.operationId===t)return{method:e,template:n,operation:i}}return null}function Cn(e,t,n){let r=Ge(n),i=e[r]?.[t];if(i)return{method:t,template:r,operation:i};for(let[n,i]of Object.entries(e)){let e=i[t];if(e&&Ke(n,r))return{method:t,template:n,operation:e}}return null}function wn(e,t,n=e){return e.replace(/\{([^}]+)}/g,(...e)=>{let r=e[1],i=t[r];if(i==null)throw Error(`Missing path parameter '${r}' for ${n}`);return encodeURIComponent(String(i))})}function Tn(e,t,n){let r=t;for(let i of e.parameters??[]){let e=i[`x-aventure-legacy-name`]?.name;if(i.in!==`path`||e===void 0)continue;let a=t[e];if(Object.hasOwn(t,e)&&a!==void 0){if(Object.hasOwn(t,i.name))throw Error(`Path parameters '${i.name}' and legacy alias '${e}' were both supplied for ${n}`);r===t&&(r={...t}),r[i.name]=a,delete r[e]}}return r}function En(e,t){let n={};for(let r of e.parameters??[]){if(r.in!==`query`||xn.has(r.name))continue;let e=t?.[r.name]??Dn(r.schema?.default);e!==void 0&&(n[r.name]=e)}return Object.keys(n).length===0?void 0:n}function Dn(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||Array.isArray(e)&&e.every(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`))return e}var On=3e4;async function kn(e,t,n,r){let i=Pn(Z(e.requestBody?.content),n);if(!i.ok||i.data===null)return j(i.summary,i.warnings);let a=i.data;if(e.requestBody?.required===!0&&t===void 0&&a?.kind!==`multipart`)return j(`Request body is required.`);if(a?.kind===`multipart`)return await In(e.requestBody?.required===!0,a.schema,t);let o=a?.contentType??r;return M(`Request body prepared`,{...t===void 0?{}:{body:t},...o===void 0?{}:{contentType:o}})}function An(e){if(typeof e!=`string`)return M(`Request body unchanged`,e);let t=e.trimStart().slice(0,1);if(t!==`{`&&t!==`[`)return M(`Request body unchanged`,e);try{let t=A.safeParse(JSON.parse(e));if(!t.success)throw t.error;return M(`Request body parsed`,t.data)}catch(e){return j(`Request body string must be valid JSON: ${e instanceof Error?e.message:String(e)}`)}}function jn(e,t){let n=e?.schema;if(n===void 0)return!1;let r=X(n),i=n.type??(r===void 0?void 0:t[r]?.type);return Array.isArray(i)?i.includes(`array`):i===`array`}function Mn(e){return Z(e)[0]?.kind??`json`}function Nn(e){return e===void 0||Object.keys(e).length===0||Z(e).length>0}function Z(e){let t=Object.entries(e??{});return[...t.flatMap(e=>Jn(e[0])?[Fn(e,`json`)]:[]),...t.flatMap(e=>Yn(e[0])?[Fn(e,`multipart`)]:[])]}function Pn(e,t){if(t===void 0)return M(`Default request content selected`,e[0]);let n=Q(t),r=e.find(e=>Q(e.contentType)===n);return r===void 0?j(`Request Content-Type '${t}' is not supported. Supported choices: ${e.map(({contentType:e})=>e).join(`, `)||`none`}.`):M(`Explicit request content selected`,r)}function Fn(e,t){let n=e[1].schema;return{contentType:e[0],kind:t,...n===void 0?{}:{schema:n}}}async function In(e,t,n){if(!e&&n==null)return M(`Optional multipart body omitted`,{});let r=Ln(n);if(!r.ok||r.data===null)return j(r.summary,r.warnings);let i=new FormData;for(let e of Rn(t)){let t=r.data[e.name];if(t==null){if(e.required)return j(`Multipart body requires '${e.name}'.`);continue}if(Array.isArray(t)&&t.length<(e.schema.minItems??0))return j(`Multipart part '${e.name}' requires more entries.`);if(Array.isArray(t)&&t.length>(e.schema.maxItems??2**53-1))return j(`Multipart part '${e.name}' has too many entries.`);if(zn(e.schema)||Bn(e.schema)){let n=Bn(e.schema)?t:[t];if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))return j(`Multipart part '${e.name}' must contain file paths or URLs.`);for(let t of n){if(typeof t!=`string`)continue;let n=await Un(t);if(!n.ok||n.data===null)return j(n.summary,n.warnings);i.append(e.name,n.data.blob,n.data.filename)}}else if(Vn(e.schema,t)){let n=JSON.stringify(t);i.append(e.name,new Blob([n],{type:`application/json`}),`${e.name}.json`)}else{let n=Hn(i,e.name,t);if(!n.ok)return n}}return M(`Multipart body prepared`,{body:i})}function Ln(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=Object.fromEntries(Object.entries(e));return M(`Multipart input parsed`,t)}return j(`Multipart request body must be a JSON object keyed by form part name.`)}function Rn(e){let t=new Set(e?.required??[]);return Object.entries(e?.properties??{}).map(([e,n])=>({name:e,schema:n,required:t.has(e)}))}function zn(e){return e.type===`string`&&e.format===`binary`}function Bn(e){return e.type===`array`&&e.items!==void 0&&zn(e.items)}function Vn(e,t){return typeof t!=`object`||!t||Array.isArray(t)?!1:e.type===`object`||typeof e.$ref==`string`&&e.$ref.length>0}function Hn(e,t,n){if(Array.isArray(n)){for(let r of n){let n=Hn(e,t,r);if(!n.ok)return n}return M(`Multipart scalar array appended`,null)}return typeof n==`object`?j(`Multipart part '${t}' must be scalar.`):(e.append(t,String(n)),M(`Multipart scalar appended`,null))}async function Un(e){return Kn(e)?await Wn(e):Xt()===void 0?await Gn(e):j(`MCP callers cannot upload local files: pass an http(s) URL as the multipart part, or send media by sourceUrl in a JSON body. Local file paths are CLI-only.`)}async function Wn(e){let t=new AbortController,n=setTimeout(()=>t.abort(),On);try{let n=new URL(e),r=await fetch(e,{signal:t.signal});if(!r.ok)return j(`Failed to fetch media URL: ${r.status} ${r.statusText}`);let i=r.headers.get(`content-type`)?.split(`;`)[0]?.trim()??qn(n.pathname)??``,a=new Blob([await r.arrayBuffer()],{type:i});return M(`URL media fetched`,{blob:a,filename:Ae(n.pathname)||`upload`})}catch(e){return t.signal.aborted?j(`Failed to fetch media URL: timed out after ${On}ms.`):j(`Failed to fetch media URL: ${e instanceof Error?e.message:String(e)}`)}finally{clearTimeout(n)}}async function Gn(e){try{let t=qn(e)??``,n=await Ne(e);return M(`File media read`,{blob:new Blob([n],{type:t}),filename:Ae(e)})}catch(t){return j(`Failed to read media file '${e}': ${t instanceof Error?t.message:String(t)}`)}}function Kn(e){return e.startsWith(`http://`)||e.startsWith(`https://`)}function qn(e){return Xn[je(e).toLowerCase()]}function Jn(e){let t=Q(e);return t===`*/*`||t===`application/json`||t.endsWith(`+json`)}function Yn(e){return Q(e)===`multipart/form-data`}var Q=e=>e.split(`;`)[0]?.trim().toLowerCase()??``,Xn={".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`};function Zn(e,t,n){let r=new Map,i=(t,a,o)=>{let s=X(t);if(a>n||s!==void 0&&o.includes(s))return;let c=s===void 0?o:[...o,s],l=$n(e,t);for(let e of[...l.items===void 0?[]:[l.items],...l.oneOf??[],...l.anyOf??[],...l.allOf??[]])i(e,a,c);for(let[e,t]of Object.entries(l.properties??{}))r.set(e,Math.min(r.get(e)??a,a)),i(t,a+1,c)};for(let[e,n]of Object.entries(t))e.startsWith(`2`)&&i(Qn(n.content),0,[]);return r}function Qn(e){return e?.[`application/json`]?.schema??Object.values(e??{}).find(e=>e.schema!==void 0)?.schema}function $n(e,t){let n=X(t);return{...n===void 0?void 0:e.components.schemas[n],...t}}function er(e){if(e===`private`||typeof e==`object`&&(e.scope===`private`||e.value===`private`))return`private`}function tr(e){return e===`write`||e===`delete`}function nr(e,t){return e===`DELETE`||t===`delete`}var rr=`Shell-safe input: single-quote string flag values that contain $; use --from-file or stdin for JSON bodies, multiline text, and free text with currency amounts.`;function ir(e,t){let n=e===`array`?t:e;return n===void 0||n===`string`}function ar(e){let t=e.operation[`x-aventure-tool`];if(!dr(e.path,e.operation,e.method===`GET`&&t?.auth===`none`,e.includeBinary===!0))return null;let n=ur(e.operation.operationId),r=Sr(e.path,n),i=lr(r,n,e.method),a=or(e.method,e.operation);if(a===null)return null;let o=t?.auth===`read`&&i===`write`?`lookup`:i,s=e.method===`GET`||a===`read`||a===`none`;return{resource:Cr(e.path),intent:o,cliPath:r,scope:s&&!tr(o)?`read`:`write`,auth:a,visibility:er(e.operation[`x-aventure-visibility`]),mutates:t?.mutates===!0||void 0,stdinBody:e.operation.requestBody!==void 0&&Mn(e.operation.requestBody.content)===`json`,destructive:nr(e.method,o)}}function or(e,t){let n=t[`x-aventure-tool`]?.auth;if(n===`none`)return`none`;if(n===`read`)return`read`;if(e===`GET`&&(t.security?.length??0)===0)return`none`;let r=!1,i=!1,a=!1;for(let e of t.security??[]){let t=Object.keys(e);t.includes(`clientSecretAuth`)&&(r=!0),t.includes(`adminApiKeyAuth`)&&(a=!0),(t.includes(`bearerAuth`)||t.includes(`clerkApiKeyAuth`))&&(i=!0)}return e===`GET`&&r||r&&!a&&!i?`read`:a?`write`:i?`bearer`:e===`GET`?`read`:null}var sr={add:`write`,answer:`search`,ask:`search`,attach:`write`,audit:`read`,batch:`lookup`,convert:`write`,create:`write`,delete:`delete`,enrich:`write`,filter:`search`,get:`read`,import:`write`,join:`write`,list:`read`,lookup:`lookup`,merge:`write`,preview:`lookup`,reconcile:`write`,remove:`delete`,replace:`write`,resolve:`lookup`,search:`search`,status:`read`,suggest:`read`,update:`write`,upload:`write`},cr=`status`;function lr(e,t,n){if(e.length===1&&e[0]===cr)return`status`;let r=Object.hasOwn(sr,t)?sr[t]:void 0;return r===void 0?n===`GET`?`read`:n===`DELETE`?`delete`:`write`:r}function ur(e){let t=/^[a-z]+/u.exec(e)?.[0];if(t===void 0)throw Error(`operationId '${e}' has no verb`);return t}function dr(e,t,n,r){return fr(e)&&t.hidden!==!0&&(n||!pr.some(t=>t.test(e)))&&Nn(t.requestBody?.content)&&(vr(t.responses)||r&&_r(t))}function fr(e){return e.startsWith(`/v1/`)||e.startsWith(`/v2/`)}var pr=[/^\/v1\/auth\/(?:session|login|ui|registrations|password-resets|cli-authorizations)(?:\/|$)/u,/^\/v1\/addresses\/locations(?:\/|$)/u,/^\/v1\/entities\/\{entityId\}\/sites$/u,/^\/v1\/(?:chat\/completions|embeddings)$/u,/^\/v1\/observability(?:\/|$)/u,/^\/v1\/media\/identicons(?:\/|$)/u];function mr(e){return e!==`/v1/auth/api-key`&&!/^\/v1\/sitemap(?:\/|$)/u.test(e)}var hr=/(?:^|-)(?:runs|jobs)$/u;function gr(e){switch(e.intent){case`read`:case`lookup`:case`search`:case`status`:case`job`:return e.intent;case`write`:{let t=ur(e.operationId);return t===`enrich`||t===`create`&&hr.test(e.cliPath.at(-2)??``)?`job`:null}case`delete`:return null;default:{let t=e.intent;throw Error(`No public MCP intent for ${String(t)}`)}}}function _r(e){let t=Object.entries(e.responses).filter(([e])=>e.startsWith(`2`));return t.length>0&&t.every(([,e])=>Object.values(e.content??{}).some(e=>xr(e.schema)))}function vr(e){return Object.entries(e).filter(([e])=>e.startsWith(`2`)).every(([,e])=>yr(e.content))}function yr(e){if(e===void 0)return!0;let t=Object.entries(e);return t.length===0||t.some(([e,t])=>br(e)&&!xr(t.schema))}function br(e){return e===`*/*`||e===`application/json`||e.endsWith(`+json`)}function xr(e){return e?.format===`byte`||e?.format===`binary`}function Sr(e,t){let n=Er(e).map($),r=n.length===1&&t===`get`&&!e.includes(`{`),i=n.some(e=>e.split(`-`).includes(t));return r||i?n:[...n,t]}function Cr(e){return $(Er(e).at(0)??`system`)}function wr(e){return`aventure_${e}`}function $(e){return e.replace(/([a-z0-9])([A-Z])/gu,`$1-$2`).replace(/[^A-Za-z0-9]+/gu,`-`).replace(/^-+|-+$/gu,``).toLowerCase()}var Tr=e=>`--${$(e)}`;function Er(e){return Dr(e).filter(e=>!Or(e)&&!kr(e))}function Dr(e){return e.split(`/`).filter(e=>e.length>0)}function Or(e){return/^v\d+$/u.test(e)}function kr(e){return e.startsWith(`{`)&&e.endsWith(`}`)}export{Zt as A,Sn as C,X as D,Cn as E,Yt as F,Kt as I,Ut as L,tn as M,en as N,Xt as O,Jt as P,qt as R,Tn as S,En as T,jn as _,Tr as a,an as b,wr as c,gr as d,ar as f,Z as g,kn as h,ir as i,$t as j,Qt as k,mr as l,An as m,sr as n,nr as o,Zn as p,_r as r,tr as s,rr as t,$ as u,Pn as v,on as w,wn as x,q as y,Ge as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aventurevc/aventure-cli",
3
- "version": "0.8.214",
3
+ "version": "0.8.216",
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",
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "aventurePublicApi": {
35
35
  "repository": "aventurevc/aventure-docs",
36
- "commit": "0d82cba184032897cb96c23e390fa420497713f7",
36
+ "commit": "95058e986481a486ee7656eb086b40d01b3a93ae",
37
37
  "openapiPath": "openapi/openapi.json",
38
- "openapiSha256": "570c9a76fec96fbf74c0b615d450e3065cdb67431079e8f5f11b35a1676a830b"
38
+ "openapiSha256": "86c4e934171cea9a9782afe5cd16209de753a04fae65a46612615875a4a034e9"
39
39
  },
40
40
  "scripts": {}
41
41
  }
@@ -1 +0,0 @@
1
- import{t as e}from"./api-key-bearer-credential-B5cWfTvy.js";export{e as materializeCliApiKeyBearerCredential};
@@ -1,67 +0,0 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a,f as o,h as s,i as c,m as l,o as u,v as d,x as f}from"./logging-RiG2UJwJ.js";import{_ as p,b as m,c as h,i as g,s as _,t as ee,v as te,y as ne}from"./tool-policy-Bs4Jo1cv.js";import{M as re,O as ie,i as v,o as ae,v as oe,w as y,y as b}from"./person-owner-BJgNYLKX.js";import{Ar as se,Br as ce,Fr as le,Hr as ue,Kr as de,Mr as fe,Nr as pe,jr as me,kr as he}from"./dist-W6a2lhH8.js";import{f as ge,i as x,l as S,r as _e}from"./result-envelope-HCfZHr9Q.js";import{a as C,n as ve,r as ye,t as be}from"./package-DPDX5zmx.js";import{i as xe,r as Se}from"./response-problem-D1QJ3hMo.js";import{n as Ce,r as we}from"./output-spill-ClPBdb4v.js";import{a as Te,c as Ee,d as De,g as Oe,i as ke,l as Ae,n as w,o as je,p as Me,r as Ne,s as Pe,u as Fe,y as Ie}from"./contract-B2e_hJVZ.js";import{a as Le,c as Re,i as ze,l as Be,n as Ve,s as He,t as Ue}from"./cli-help-policy-DtEA5aUs.js";import{S as We,_ as Ge,a as Ke,g as T,h as qe,i as Je,m as Ye,n as Xe,p as Ze,r as Qe,s as $e,t as et,v as tt,x as E,y as nt}from"./api-key-bearer-credential-B5cWfTvy.js";import{a as rt,c as it,d as at,g as ot,l as st,m as ct,o as lt,s as ut,t as dt,u as ft}from"./oauth-bearer-credential-CB5C3dLM.js";import{n as pt,r as mt,t as ht}from"./oauth-login-Cr4KzZ0g.js";import{a as gt,c as _t,d as vt,i as yt,l as bt,n as xt,o as St,s as Ct,t as wt,u as Tt}from"./startup-auth-C0lEZxWc.js";import{n as Et,t as D}from"./openapi-commands-BPCqSbwO.js";import{i as O,r as Dt,t as k}from"./output-mode-DZfuZSC9.js";import{spawnSync as Ot}from"node:child_process";import{basename as A,dirname as j,relative as kt,resolve as M,sep as At}from"node:path";import{copyFileSync as jt,existsSync as N,lstatSync as Mt,mkdirSync as Nt,mkdtempSync as Pt,readFileSync as Ft,readdirSync as It,readlinkSync as Lt,realpathSync as Rt,renameSync as zt,symlinkSync as Bt,writeFileSync as Vt}from"node:fs";import P,{stderr as F,stdin as Ht}from"node:process";import{TextDecoder as Ut,inspect as Wt}from"node:util";import{homedir as Gt,hostname as Kt,platform as qt}from"node:os";import{fileURLToPath as Jt}from"node:url";import{setTimeout as Yt}from"node:timers/promises";import{randomUUID as Xt,webcrypto as Zt}from"node:crypto";import{readFile as Qt}from"node:fs/promises";import{createInterface as $t}from"node:readline/promises";function en(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return S(`Environment-bound options applied`,r)}function tn(e,t,n){if(!L(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!gn(n,r.name))continue;let a=hn(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function nn(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function rn(e,t,n,r=!1){if(r||!I(t)||!Array.isArray(n))return bn(e,t,n);for(let[r,i]of n.entries()){let n=bn(e,t,i,r);if(!n.ok)return n}return S(`Body value assigned`,null)}function an(e,t,n,r){return bn(e,t,r,n)}function on(e){let t=[];for(let n of e.split(`.`)){let e=Sn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function sn(e,t){let n=on(t);if(n===null)return null;let r=mn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:pn(r)}:null}function cn(e,t){if(I(e.name)||e.schemaType===`array`)return S(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return S(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?S(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var ln=/^(?<row>\d+):(?<item>.*)$/su;function un(e,t){let n=on(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=ln.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function dn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&on(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function fn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=sn(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||un(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function pn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function mn(e,t){let n=e;for(let e of t){if(!L(n))return;n=n[e]??null}return n}function hn(e,t){if(!I(t))return mn(e,t.split(`.`))}function gn(e,t){return vn(e,t.split(`.`))}function _n(e,t,n){if(!L(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&gn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function vn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=Sn(n);if(!L(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>vn(e,r)):vn(a,r)}function I(e){return e.split(`.`).some(e=>Sn(e).isArray)}function yn(e,t){return e.parameter.length===0||!L(t)?null:wn(t,[],Cn(e.parameter))}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=Sn(o),c=e===i.length-1,l=xn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return S(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function xn(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,S(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,S(`Body path created`,e)}return L(c)?S(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,S(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,S(`Body path created`,n)}return L(s)?S(`Body path stepped`,s):o()}function Sn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function Cn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function wn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=wn(r,t,n);if(e!==null)return e}return null}if(!L(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!Tn(a,n)){if(!En(e))continue;let t=Dn(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=wn(i,e,n);if(o!==null)return o}return null}function Tn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function En(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function Dn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:On(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function On(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}var kn=e=>Array.isArray(e)&&!Object.isFrozen(e);function An(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Re(e)),t.description=le(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!kn(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?Rn(r,i):r===void 0?i===void 0?0:1:-1})}function jn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function Mn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Nn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:In(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function Pn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Fn(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?Be(n):`${Be(n)} Required JSON paths: ${r.join(`, `)}.`}function In(e,t){let n=Le(t.description,void 0),r=e.kind!==`multipart`&&I(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${Ln(e,t)}`}function Ln(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=on(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function Rn(e,t){return He(e)-He(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function zn(e){let t;try{t=e===`-`?await Bn():await Qt(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return S(`No input provided`,null);let e=JSON.parse(t);return S(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function Bn(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var Vn=`--content-type`;function Hn(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Vn)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Vn} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Wn(a)))}if(cr(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,Fn(r,r.requiredPath)).argParser(Kn(`--from-file`)))}let o=jn(a).filter(e=>i(R(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Rn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Mn(n),a.length>1?Nn(n):In(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Pn(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Un):I(i.name)||i.schemaType===`array`?o.argParser(Gn):o.argParser(Kn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}sr(e,n,o)}function Un(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Wn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Vn} was already given; pass it once.`);let i=p(e,t);if(!i.ok)throw new n(i.summary);return t}}function Gn(e,t){return[...t??[],e]}function Kn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function qn(e,t){let n=St(e,t),r=p(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return S(`No body`,void 0);let a=Jn(e,i,t);if(a!==null)return x(a);let o=en(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Yn(i,t);if(s!==null)return x(s);let c=await $n(t);if(!c.ok)return x(c.summary,c.warnings);let l=_n(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=Qn(e.operationId,i,c.data);if(!u.ok)return u;let d=tn(e.operationId,i,c.data);if(d!==null)return x(d);let f=er(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(or(e.operationId,i)):S(`No body`,void 0);let m=nr(e.operationId,i,c.data,f.data);if(!m.ok||m.data===void 0)return m;if(i.schemaType===`array`&&!Array.isArray(m.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!L(m.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let h=Zn(i,m.data);if(h.length>0)return x(`${e.operationId} requires body option(s): ${h.join(`, `)}`);let g=m.data,_=L(g)?nn(i).filter(e=>!gn(g,e)):[];return _.length>0?x(Xn(e.operationId,i,_)):m}function Jn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${R(t)} requires ${Vn} ${i.join(` or `)}.`}return null}function Yn(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Xn(e,t,n){let r=`${e} requires JSON body path(s): ${n.join(`, `)}`;return t.kind===`multipart`?`${r}. ${n.includes(`body`)?`For multipart --from-file, wrap the endpoint JSON under top-level "body".`:`For multipart --from-file, put the missing nested path(s) inside top-level "body".`}`:r}function Zn(e,t){return L(t)?e.parameter.filter(e=>e.required&&!gn(t,e.name)).map(R):[]}function Qn(e,t,n){let r=yn(t,n);if(r===null)return S(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function $n(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return S(`No body file`,void 0);let n=await zn(t);if(!n.ok)return x(n.summary,n.warnings);let r=ge.safeParse(n.data);return r.success?S(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function er(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=cn(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=tr(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return S(`No direct body options`,void 0);let a=fn(e,t,n,r);return a===null?S(`Direct body options parsed`,r):a}function tr(e,t,n,r,i){let a=un(r,i);if(a===null){let e=ir(r,i);return e.ok?rn(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${R(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=dn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${R(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=ar(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=an(n,r.name,e,i);if(!a.ok)return a}return S(`Body value assigned`,null)}var R=e=>e.flag.split(` `)[0]??e.name;function nr(e,t,n,r){if(n===void 0)return S(`Direct body parsed`,r);if(r===void 0)return S(`Input parsed`,n);if(L(n)&&L(r))try{return S(`Input parsed`,rr(t,n,r))}catch(t){return x(`${e} ${t instanceof Error?t.message:String(t)}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function rr(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(L(n)&&L(a))i[t]=rr(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:je.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function ir(e,t){if(typeof t==`boolean`)return S(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return ar(e.name,e.schemaType,t??``);let n=[],r=I(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=ar(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return S(`Body value parsed`,n)}function ar(e,t,n){if(t===`boolean`)return n===`true`?S(`Body value parsed`,!0):n===`false`?S(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):S(`Body value parsed`,i)}return S(`Body value parsed`,n)}function or(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(R).join(`, `)}`;let r=nn(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(R).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function sr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Vn,location:`body`}),cr(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),An(e.options,r)}function cr(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function lr(e){let t=_e(e,Ne(e,D));return vr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function ur(e){let t=_e(e,Ne(e,D));vr(t);let n=ke(D,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=dr(t);r.push(n.endsWith(`
2
- `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(ue(r.join(`
3
- `),!0,!0,e.length));return}let i=t.ok?`OK`:`FAIL`;r.push(`[${i}] ${t.summary}`),!t.ok&&t.problem!==void 0&&r.push(...mr(t.problem)),r.push(...dr(t)),process.stdout.write(ue(r.join(`
4
- `),!0))}function dr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function z(e,t){let n=we(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?_e(n,fr(n)):n;vr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?Ce(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?lr(n):n;e.mode===`text`&&ur(r),r.ok||(process.exitCode=1)}function fr(e){let t=Ne(e,D);if(t.write===!0||!e.ok)return t;let n=t.exactRecovery??`Refetch a narrower result: use ids/references, a more specific list read (e.g. entities relationships list, entities people list, or news list --owner-entity-id), filters, or smaller pages with page and size.`;return{...t,exactRecovery:`--data printed this truncated result envelope (truncated: true), not the bare payload, so payload paths read as null; rerun with --to-file <path> for the whole payload, or --data-full in a bounded program. ${n}`}}function pr(e,t){let n=Te(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
5
- `),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function mr(e){let t=[];typeof e.code==`string`&&t.push(` code: ${e.code}`),typeof e.detail==`string`&&t.push(` detail: ${e.detail}`),typeof e.hint==`string`&&t.push(` hint: ${e.hint}`),typeof e.suggestion==`string`&&t.push(` suggestion: ${e.suggestion}`);let n=Object.entries(e.suggestions??{});if(n.length>0){let e=n.map(([e,t])=>`${e}=${t}`).join(`; `);t.push(` suggestions: ${e}`)}return typeof e.requiredRole==`string`&&t.push(` requiredRole: ${e.requiredRole}`),t.push(...hr(e),...gr(`unknownParameters`,e.unknownParameters),...gr(`validParameters`,e.validParameters),..._r(e.resolution)),t}function hr(e){let t=[];return typeof e.limitType==`string`&&t.push(`limitType=${e.limitType}`),typeof e.used==`number`&&t.push(`used=${e.used}`),typeof e.limit==`number`&&t.push(`limit=${e.limit}`),typeof e.remaining==`number`&&t.push(`remaining=${e.remaining}`),typeof e.resetAt==`string`&&t.push(`resetAt=${e.resetAt}`),typeof e.windowSeconds==`number`&&t.push(`windowSeconds=${e.windowSeconds}`),typeof e.retryAfterSeconds==`number`&&t.push(`retryAfterSeconds=${e.retryAfterSeconds}`),t.length>0?[` meter: ${t.join(` `)}`]:[]}function gr(e,t){return t!=null&&t.length>0?[` ${e}: ${t.join(`, `)}`]:[]}function _r(e){if(e==null)return[];let t=[`action=${e.action}`];return typeof e.parameter==`string`&&t.push(`parameter=${e.parameter}`),typeof e.fieldPath==`string`&&t.push(`fieldPath=${e.fieldPath}`),typeof e.endpoint==`string`&&t.push(`endpoint=${e.endpoint}`),e.acceptedValue!==null&&e.acceptedValue!==void 0&&e.acceptedValue.length>0&&t.push(`acceptedValue=${e.acceptedValue.join(`, `)}`),typeof e.retryable==`boolean`&&t.push(`retryable=${e.retryable}`),[` resolution: ${t.join(` `)}`]}function vr(e){if(e.ok&&e.warnings.length===0)return;let t=e.truncation===void 0?e.warnings:[...e.warnings,`omitted: ${e.truncation.omitted.join(`, `)}`,`recovery: ${e.truncation.recovery}`];u({component:C().bin[0],event:e.ok?`command_warning`:`command_failed`,message:t.length>0?t.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function yr(e,t,n=C().bin[0]){let r=e.limit===void 0?void 0:Number(e.limit);if(r!==void 0&&(e.limit?.trim()===``||!Number.isInteger(r)||r<0))return x(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=De(t,n),a=Ie(e.root??``),o=[...new Set(i.map(({cli:e})=>Ie(e.path.at(0)??``)))].toSorted();if(a.length>0&&!o.includes(a))return x(`Unknown --root value: ${JSON.stringify(e.root)}`,[`Pass one of: ${o.join(`, `)}.`]);let s=Me(e.q??``,i.filter(t=>Cr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)],responseFieldLevel:Oe(e.operationId)})).map(({item:e})=>e),c=s.slice(0,r);return S(`Operation catalog matches`,{operation:c,count:{totalOperations:t.length,matched:s.length,returned:c.length}})}function br(e,t,n=C().bin[0]){let r=De(t,n),i=e.operationId===void 0?xr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=Or(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return x(`${i} is a command group; show one of its subcommands.`,[`Run \`${n} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let o=i.split(` `),s=new Set([...[...o.keys()].map(e=>o.slice(e+1).join(` `)),...o.slice(1).map((e,t)=>o.toSpliced(t,2,`${o[t]}-${e}`).join(` `))]),c=yr({q:e.command??e.operationId},t,n),l=[...r.filter(({cli:e})=>e.path.length>1&&s.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...c.data?.operation??[]];return x(`Generated operation not found`,[...[...new Set(l.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${n} command-catalog search "<text>"\`.`])}return S(`Generated operation detail`,{operation:i,usage:Tr(i,r)})}function xr(e,t){if(t===void 0)return;let{bin:n}=C(),r=Or(t,n);return e.find(e=>Or(e.cli.command,n)===r)}var Sr=(e,t)=>e===void 0||e===`all`||e===`any`||e===String(t);function Cr(e,t){return(t.root===void 0||wr(e,t.root))&&Sr(t.scope,e.scope)&&Sr(t.mutates,e.mutates)&&Sr(t.destructive,e.destructive)&&Sr(t.intent,e.intent)&&Sr(t.method,e.method)}function wr(e,t){let n=Ie(t);return n.length===0||Ie(e.cli.path.at(0)??``)===n}function Tr(e,t){let n=Pe(e);return[`cli: ${e.cli.command}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (CLI-only operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,...e.successResponse===void 0?[]:[`success: ${e.successResponse}`],...[!0,!1].flatMap(t=>[`path`,`query`,`header`,`body`].map(r=>{let i=n.filter(e=>e.required===t&&e.location===r),a=Dr(`${t?`required`:`optional`} ${r} flags`,i);return t&&r===`body`&&e.body.kind===`json`&&i.length>0?`${a} (required unless --from-file sets JSON key(s) ${i.map(({wireName:e})=>e).join(`, `)})`:a})),...Fe(e,t),...Er(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
6
- `)}function Er(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}function Dr(e,t){return`${e}: ${t.length===0?`none`:t.map(e=>e.name).join(` `)}`}function Or(e,t=C().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var kr=`dist/aventure-cli/command-catalog.compact.txt`,Ar=` · `,jr=`-`;function Mr(e=C().bin[0]){return M(Nr(j(Jt(import.meta.url)),e),kr)}function Nr(e,t){let n=e;for(;;){if(N(M(n,`package.json`)))return n;let r=j(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Pr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Fr(e,t,n,r=C().bin[0]){let i=yr(e,t,r);if(!i.ok||i.data===null){z({mode:n},i);return}Lr({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Br(i.data,zr(e.format,`lines`)),summary:`Generated operation matches`})}function Ir(e,t,n,r=C().bin[0]){let i=br(e,t,r);if(!i.ok||i.data===null){z({mode:n},i);return}Lr({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Vr(i.data,zr(e.format,`usage`)),summary:`Generated operation detail`})}function Lr(e){let t=e.mode,n=zr(e.opts.format,e.defaultFormat),r=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&r&&(n===`json`||n===`ndjson`)){z({mode:t},x(`--text or --all-fields cannot be combined with --format json or ndjson`,[`Omit the text flag for machine output, or use --format lines, compact, or text.`]));return}let i=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.matched===0&&(r||e.opts.format===void 0||n===`text`)?`No generated operations matched.`:e.rendered,a=i.endsWith(`
7
- `)?i:`${i}\n`;if(e.opts.output!==void 0){Vt(e.opts.output,a),z({mode:t},S(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(a,`utf8`),format:n},{counts:Kr(e.data)}));return}if(t===`text`){Rr(e.summary,a);return}z({mode:t},S(e.summary,e.data,{counts:Kr(e.data)}))}function Rr(e,t){let n=we(S(e,t));if(!n.ok||n.data===null){z({mode:`text`},n);return}process.stdout.write(n.data.endsWith(`
8
- `)?n.data:`${n.data}\n`)}function zr(e,t){return e??t}function Br(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
9
- `):t===`text`?Wr(e.operation):t===`compact`?e.operation.map(Hr).join(`
10
- `):e.operation.map(Gr).join(`
11
- `)}function Vr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?Gr(e.operation):t===`compact`?Hr(e.operation):e.usage}function Hr(e){let t=Ur(e);return[e.cli.command,e.summary,t.length===0?jr:t.join(` `)].join(Ar)}function Ur(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function Wr(e){return e.map(e=>`${e.cli.command}\n ${Gr(e)}`).join(`
12
- `)}function Gr(e){let t=Ur(e);return[B(`operationId`,e.operationId),B(`scope`,e.scope),B(`mutates`,String(e.mutates)),B(`destructive`,String(e.destructive)),B(`intent`,e.intent),B(`resource`,e.resource),B(`cli`,e.cli.command),e.mcpTool===null?``:B(`mcpTool`,e.mcpTool),B(`method`,e.method),B(`path`,e.path),B(`auth`,e.auth),B(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),B(`requiredFlags`,t.join(` `)),B(`bodyKind`,e.body.kind??``),B(`bodyRequired`,String(e.body.required)),B(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function B(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function Kr(e){return`count`in e?e.count:{returned:1}}function qr(e,t,n=C().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show full documentation for a command, or ask a question`).description([`Show a command's full documentation offline. Select it by command path,`,"operationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.","`help ask <question>` or `help --ask <question>` answers a platform question."].join(`
13
- `)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new Jr(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=ei(t);i!==void 0&&r.option(`--ask <question>`,i.summary),k(r),r.action(async function(r){let a=this.optsWithGlobals();if(a.help&&r.length===0){this.outputHelp();return}if(!a.help&&i!==void 0&&a.ask!==void 0){let e=O(a);if(r.length>0){z({mode:e},x(`Use either a command path or --ask, not both.`));return}z({mode:e},await ii(i,a.ask,a.environment,e));return}let o=ri(e,r),s=t.find(t=>o!==void 0&&ri(e,t.cliPath)===o);if(a.help||o!==void 0&&s===void 0){o===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),o.outputHelp();return}let c=s===void 0?ni(r,t):S(`Resolved by command path`,{operationId:s.operationId});if(c.ok&&c.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!c.ok||c.data===null){z({mode:O(a)},c);return}Ir({...a,...c.data},t,O(a,`text`),n)}),$r(e,t,n)}var Jr=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},Yr=2,Xr=6,Zr={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!Ve.has(e.name())):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(Yr)}${e}\n${Qr(n,a,i)}`}};function Qr(e,t,n){return n.boxWrap(e,t-Xr).replace(/^/gmu,` `.repeat(Xr))}function $r(e,t,n){for(let r of t){let i=ri(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=Ee(r.operationId,t,n),[c,...l]=Er(r.errorResponse),u=l.map(t=>Qr(t.trimStart(),o,e).replace(/^ +/u,` `.repeat(Yr))),d=c===void 0?[]:[``,c,...u];return`\n${[...s,...d].join(`
14
- `)}\n`})}}function ei(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&ai(e)!==void 0});return n.length===0?t:void 0}var ti='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ni(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?S(`Resolved by route`,{operationId:i.operationId}):x(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[ti]);let o=te.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return S(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=ne(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return S(`Resolved by route template`,{operationId:l.operationId});let u=fe({method:s,path:c});return!u.ok||u.data===null?x(u.summary,[...u.warnings,ti]):S(`Resolved by method and path`,{operationId:u.data.operation.operationId})}function ri(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}async function ii(e,t,n,r){let i=ai(e);if(i===void 0)return x(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let a=await qn(e,{[i.optionKey]:t});return a.ok?await pe({method:e.method,path:se(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:Dt(r)?`json`:`auto`}):a}function ai(e){if(e.requestBody?.length!==1||e.parameters.some(e=>e.required))return;let t=(e.requestBody[0]?.parameter??[]).filter(e=>e.required);return t.length===1&&t[0]?.schemaType===`string`?t[0]:void 0}function oi(e,t,n){if(e.cliPath[0]!==`lookup`||!si(n))return null;let r=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`),i=`no record for ${r.length===0?`the given input`:r.join(`, `)}`;return n.ok?x(i):x(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function si(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function ci(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}var li=b({artifact:y().nullish(),group:y().nullish(),name:y().nullish(),revision:y().nullish(),time:v({offset:!0}).nullish(),version:y().nullish()}),ui=b({build:li}),di=ae([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),fi=ae([`RSA_OAEP_256_A256_GCM_V1`]),pi=b({clientLabel:y().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:di.nullish(),encryptionAlgorithm:fi.nullish(),encryptionPublicKey:y().min(344).max(12e3).nullish()}),mi=32;async function hi(){let e=await Zt.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await Zt.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function gi(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=_i(n,`wrapped key`,128,1024),s=_i(r,`nonce`,12,12),c=_i(i,`ciphertext`,1,65536),l=_i(a,`authentication tag`,16,16),u;try{u=await Zt.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==mi)throw Error(`broker credential used an invalid AES-256 key`);let e=await Zt.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await Zt.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Ut(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function _i(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var vi=ae([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),yi=ae([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),bi=b({approvedAt:v({offset:!0}).nullish(),clientLabel:y(),clientPlatform:di,comparisonCode:y(),consumedAt:v({offset:!0}).nullish(),createdAt:v({offset:!0}),expiresAt:v({offset:!0}),id:ie(),intervalSeconds:oe().int().min(1),keyReadyAt:v({offset:!0}).nullish(),status:vi,terminalAt:v({offset:!0}).nullish(),terminalReason:yi.nullish(),updatedAt:v({offset:!0})}),xi=b({algorithm:fi,authenticationTag:y(),ciphertext:y(),nonce:y(),wrappedKey:y()}),Si=b({delivery:xi.nullish(),expiresAt:v({offset:!0}),status:vi,terminalReason:yi.nullish()}),Ci=b({comparisonCode:y(),expiresAt:v({offset:!0}),id:ie(),intervalSeconds:oe().int().min(1),pollSecret:y(),verificationUrl:y()}),V=[{command:`auth login`,role:`oauth`,summary:`Sign In Through Your Browser`,description:`Sign in through your browser and save verified CLI access in the credential store. Use --no-browser for OAuth device authorization only when the issuer advertises device-grant support; otherwise use --key --no-browser for API-key approval.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Use OAuth device authorization only when the issuer advertises device-grant support: print a sign-in URL and code, then wait for approval. Otherwise use --key --no-browser for API-key approval.`},{optionKey:`providers`,flag:`--providers`,description:`Print the sign-in providers and CLI OAuth client, then exit without signing in.`}]},{command:`auth login`,role:`start`,summary:`Sign In With a Browser-Approved aVenture API Key`,description:`Creates a short-lived browser approval request and returns its poll credential once.`,operationId:`createCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations`,bodyOption:[{name:`clientLabel`,optionKey:`clientLabel`,flag:`--client-label <client-label>`,required:!1,description:`Label for this CLI installation.`}],localOption:[{optionKey:`key`,flag:`--key`,description:`Sign in with a browser-approved aVenture API key instead of OAuth; the approval URL opens on any device.`},{optionKey:`browser`,flag:`--no-browser`,description:`Print the API-key approval URL and wait for approval without opening a browser.`}]},{command:`auth login`,role:`poll`,summary:`Poll CLI Authorization`,description:`Returns pending state, a terminal state, or an encrypted one-time credential delivery.`,operationId:`pollCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/poll`,bodyOption:[],localOption:[]},{command:`auth login`,role:`acknowledge`,summary:`Acknowledge CLI Credential Delivery`,description:`Confirms the CLI stored the delivered API key in its credential store and clears transient delivery material.`,operationId:`acknowledgeCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/acknowledge`,bodyOption:[],localOption:[]},{command:`auth logout`,role:`revoke`,summary:`Sign Out: Revoke the API Key and Forget Stored OAuth`,description:`Revokes the aVenture API key authenticating this request and returns its metadata so the CLI can confirm revocation before deleting its saved copy.`,operationId:`revokeCurrentApiKey`,method:`DELETE`,path:`/v1/auth/api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Delete the saved key even when revocation cannot be confirmed.`}]}],wi=w(V,`start`),Ti=w(V,`poll`),Ei=w(V,`acknowledge`),H=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${Ge(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Mi(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},Di=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${T(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function Oi(e){let t=await de(We(f()),{method:wi.method,path:m(wi.path,{},wi.operationId),headers:{},contentType:`application/json`,body:e},Ci);if(t.ok&&t.redirect)throw new H(`start`,Ni(t.status));if(!t.ok)throw new H(`start`,t.problem);return Pi(t.data)}async function ki(e,t){let n=me(Ti.operationId),r=await de(We(f()),{method:Ti.method,path:m(Ti.path,{cliAuthorizationId:e},Ti.operationId),headers:{[n]:t}},Si);if(r.ok&&r.redirect)throw new H(`poll`,Ni(r.status),[t]);if(!r.ok)throw new H(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:ji(r.headers[`retry-after`])}}async function Ai(e,t){let n=me(Ei.operationId),r;try{r=await de(We(f()),{method:Ei.method,path:m(Ei.path,{cliAuthorizationId:e},Ei.operationId),headers:{[n]:t}},bi)}catch(e){throw new Di(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new H(`acknowledge`,Ni(r.status),[t]);if(!r.ok)throw new H(`acknowledge`,r.problem,[t]);return r.data}function ji(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Mi(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Ni(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Pi(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[Wt.custom]:{enumerable:!1,value:a}})}async function Fi(e){let t=await Ii(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await Ke(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`),verification:t}}catch(n){return{stored:e,verification:{state:`unavailable`,summary:`${t.summary}, but the cached metadata could not be updated — ${T(n,[e.credential.secret])}`}}}}async function Ii(e){let t=We(f()),n;try{n=await de(t,{method:`GET`,path:se(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},tt)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${T(t,[e])}`}}return n.ok&&n.redirect?{state:`unavailable`,summary:`identity verification returned unexpected redirect ${n.status}`}:n.ok?n.data.status===`ACTIVE`?{state:`verified`,summary:`API key verified by aVenture sign-in`,apiKey:n.data}:{state:`invalid`,summary:`API key is not active`}:{state:n.problem.status===401||n.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${Ge(n.problem,[e])}`}}var Li=w(V,`revoke`);async function Ri(e){let t;try{t=E(f().host)}catch(e){return x(`auth logout: invalid API host — ${T(e)}`)}let n=await zi(t),r=await Hi(t,e),i=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],a={host:t,revoked:!1,forgotten:!1,oauth:n};return r===null?n.state===`missing`?S(`No CLI credential is stored for this API host.`,a):n.state===`failed`?{...x(`auth logout: ${i[0]}`),data:a}:S(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,a,{warnings:i}):{...r,data:{...r.data??a,oauth:n},warnings:[...r.warnings,...i]}}async function zi(e){let t=await lt(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Vi(t.stored):{revoked:!1};try{await rt(e)}catch(e){return{state:`failed`,summary:T(e)}}return{state:`forgotten`,...n}}async function Bi(e){let t=Reflect.get(await ht(e),`revocation_endpoint`);return typeof t==`string`?ot(t,`revocation endpoint`,!0):void 0}async function Vi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Bi(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:ft(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:T(e,ct(n))}}}async function Hi(e,t){let n;try{n=await Je(e)}catch(e){return x(`auth logout: stored credential could not be read — ${T(e)}`)}if(n.state===`unavailable`)return{...x(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await Ui(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...x(`auth logout: remote revocation was not confirmed; local credential preserved — ${i.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:Wi(r,!1,!1)};try{await Xe(r.host)}catch(e){return{...x(`auth logout: local credential removal failed — ${T(e,[r.credential.secret])}`,[a?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:Wi(r,a,!1)}}return S(a?`API key revoked remotely and removed locally.`:o?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,Wi(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Ui(e){let t=We(f());try{let n=await de(t,{method:Li.method,path:m(Li.path,{},Li.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},tt);return n.ok&&n.redirect?{outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${n.status}`}:n.ok?n.data.id!==e.credential.apiKey.id||n.data.subject!==e.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored API key identity`}:n.data.status===`REVOKED`?{outcome:`revoked`,summary:`remote key revocation confirmed`}:{outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}:{outcome:n.problem.status===401&&n.problem.type!==`about:blank`?`rejected`:`unconfirmed`,summary:Ge(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:T(t,[e.credential.secret])}}}function Wi(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Gi=`RSA_OAEP_256_A256_GCM_V1`,Ki=1,qi=30,U=C().bin[0],Ji=`The local record remains pending and unavailable to ordinary commands. Re-run \`${U} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Yi(e){if(!Ht.isTTY)return x(`${U} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=f().host;t=E(e),n=nt(e)}catch(e){return x(`auth login --key: invalid environment configuration — ${T(e)}`)}for(;;){let e;try{e=await Qe(t)}catch(e){return x(`auth login --key: credential storage could not be inspected — ${T(e)}`)}if(e.state===`unavailable`)return x(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&F.write($e(e.keyringFailure));break}let n=await Xi(e.stored);if(n!==null)return n}let r;try{r=await hi()}catch(e){return x(`auth login --key: ephemeral encryption key could not be created — ${T(e)}`)}let i=pi.safeParse({clientLabel:e.clientLabel?.trim()||(Kt().trim()||U).slice(0,120),clientPlatform:ea(),encryptionAlgorithm:Gi,encryptionPublicKey:r.publicKey});if(!i.success)return x(`auth login --key: ${re(i.error)}`);let a;try{a=await Oi(i.data)}catch(e){return x(`auth login --key: could not start browser authorization — ${T(e)}`)}let o;try{o=Ye(a,n)}catch(e){return x(`auth login --key: unsafe browser authorization URL rejected — ${T(e)}`)}if(!$i(await Ze(a,n,{noBrowser:e.noBrowser}),a,o))return x(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[o]});let s;try{s=await Qi(a)}catch(e){return x(`auth login --key: authorization did not complete — ${T(e)}`,[],{references:[o]})}if(s.algorithm!==Gi)return x(`auth login --key: broker selected an unsupported encryption algorithm`);let c;try{c=await gi(r.privateKey,s)}catch(e){return x(`auth login --key: encrypted credential could not be opened — ${T(e)}`)}let l=await Ii(c);if(l.state!==`verified`)return x(`auth login --key: decrypted credential was neither stored nor acknowledged — ${l.summary}`);let u;try{u=await Ke(t,{apiKey:l.apiKey,secret:c},`pending`)}catch(e){return x(`auth login --key: credential could not be durably stored — ${T(e)}`)}let d;try{d=await Zi(a)}catch(e){return W(u,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${T(e,[a.pollSecret])}`,Ji)}if(d.status!==`CONSUMED`)return W(u,!0,`auth login --key: broker returned ${d.status} after acknowledgment`,Ji);let p=await Ii(c);if(p.state!==`verified`||!ia(p.apiKey,u.credential.apiKey))return W(u,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${p.summary}`,Ji);try{let e=await Ke(t,{apiKey:p.apiKey,secret:c},`active`);return S(`API key stored; authenticated identity and broker acknowledgment verified.`,ra(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return W(u,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${T(e)}`,Ji)}}async function Xi(e){let t=await Ii(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?S(`API key is already stored and its authenticated identity was verified.`,ra(e,!0),{ids:[e.credential.apiKey.id]}):W(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${U} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&ia(t.apiKey,e.credential.apiKey))try{let n=await Ke(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return S(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,ra(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return W(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${T(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${U} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return W(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${U} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Ui(e);if(n.outcome===`unconfirmed`)return W(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await Xe(e.host)}catch(t){return W(e,!1,`auth login --key: stale pending credential could not be removed — ${T(t,[e.credential.secret])}`)}return F.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
15
- `:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
16
- `),null}async function Zi(e){let t=new Date(e.expiresAt).getTime(),n=ta(e.intervalSeconds);for(;;)try{return await Ai(e.id,e.pollSecret)}catch(e){if(e instanceof H){if(!e.retryable)throw e;n=ta(e.retryAfterSeconds??n)}else if(!(e instanceof Di))throw e;if(Date.now()>=t)throw e;F.write(`Broker acknowledgment was interrupted; retrying.
17
- `),await na(n,t)}}async function Qi(e){let t=new Date(e.expiresAt).getTime(),n=ta(e.intervalSeconds),r;for(F.write(`Waiting for browser approval...
18
- `);Date.now()<t;){let i;try{i=await ki(e.id,e.pollSecret)}catch(e){if(e instanceof H){if(!e.retryable)throw e;n=ta(e.retryAfterSeconds??n)}r=e,F.write(`Authorization poll was interrupted; retrying.
19
- `),await na(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=ta(i.retryAfterSeconds??n),await na(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:case`REVOKED`:throw Error(Se(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${T(r,[e.pollSecret])}`)}function $i(e,t,n){let r=e.state===`opened`;return!r&&!F.isTTY?!1:(F.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...F.isTTY?[`Open this one-time approval URL in your browser:`,t.verificationUrl]:[`Approval reference: ${n}`],`Comparison code: ${t.comparisonCode}`,`Confirm that the browser shows the same code before approving.`,``].join(`
20
- `)),!0)}function ea(){switch(qt()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function ta(e){return Math.min(qi,Math.max(Ki,e))}async function na(e,t){let n=t-Date.now();n>0&&await Yt(Math.min(e*1e3,n))}function ra(e,t){return{host:e.host,provider:e.provider,apiKeyId:e.credential.apiKey.id,name:Se(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function W(e,t,n,r){return{...x(n,r===void 0?[]:[r]),data:ra(e,t)}}function ia(e,t){return e.expiresAt===null||e.expiresAt===void 0||t.expiresAt===null||t.expiresAt===void 0?!1:new Date(e.expiresAt)>new Date(t.expiresAt)}async function aa(){return null}async function oa(e){let t=null,n=e=>{t=e};try{await dt(e,n),await et(n)}catch(e){return{materialized:t,failure:T(e)}}return{materialized:t,failure:null}}async function sa(e,t,n,r){if(r.failure!==null)return{scope:e,selected:null,identity:null,authorization:null,error:r.failure};let i=null,a=null,o,s=e=>{o=e,a=ca(e.credential,r.materialized)};try{let t=await pe({method:`POST`,path:`/v1/auth/me/permissions`,body:{operation:[]},auth:e,requesterScope:e,responseFormat:`json`,onAuthPrepared:s});if(!t.ok)throw Error(la(t));if(a===null)throw Error(`Live permission probe did not prepare a credential`);if(i=pa(t.data),e===`read`)return{scope:e,selected:a,identity:null,authorization:i,error:null};if(o===void 0)throw Error(`Live permission probe did not retain its prepared credential`);let n=await aa(e,o);return{scope:e,selected:a,identity:n,authorization:i,error:null}}catch(r){return{scope:e,selected:a,identity:null,authorization:i,error:T(r,ua(t,n,o))}}}function ca(e,t){if(e===null)return null;let n=t??qe().source;if(n===null)throw Error(`Prepared credential has no local provenance`);return{credential:e,source:n}}function la(e){return[e.summary,...e.warnings].join(` — `)}function ua(e,t,n){return[f().userBearerToken,...xe(n?.headers??{}),...e.state===`found`?ct(e.stored.credential.tokens):[],t.state===`found`?t.stored.credential.secret:void 0]}function da(e,t,n=null){let r=t.state===`found`?t.stored:void 0,i=r?.credential.apiKey.expiresAt??null;return{host:e,present:r!==void 0,provider:r?.provider??null,activation:r?.activation??null,apiKeyId:r?.credential.apiKey.id??null,subject:r?.credential.apiKey.subject??null,scope:r?.credential.apiKey.scopes??[],name:r===void 0?null:Se(r.credential.apiKey.name,[r.credential.secret]),status:r?.credential.apiKey.status??null,expiresAt:i,metadataSource:r===void 0?null:n?.state===`verified`?`clerk`:`store-cache`,live:n===null?null:{state:n.state,summary:n.summary},expiresInDay:ga(i),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function fa(e,t){let n=t.state===`found`?t.stored:void 0;return{host:e,present:n!==void 0,provider:n?.provider??null,expiresAt:n?.credential.expiresAt??null,expired:n===void 0?null:it(n.credential),renewable:n===void 0?null:n.credential.tokens.refresh_token!==void 0,identity:n===void 0?null:at(n.credential),client:n?.credential.client??null,storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function pa(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)throw Error(`permission probe returned no JSON response`);let t=ce.safeParse(e.response);if(!t.success)throw t.error;return t.data}function ma(e,t){let{expiresAt:n,expiresInDay:r}=da(e,t);return n!==null&&r!==null&&new Date(n).getTime()<=Date.now()?` (cached expiry passed ${Math.abs(r)}d ago; \`auth status\` re-checks it with aVenture sign-in)`:``}var ha=864e5;function ga(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/ha)}var _a=7;function va(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,_a)}\u2026${e.slice(-4)}`}var ya=13,ba=14;function xa(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.apiKey.host}`+(e.apiVersion===null?` (api build unavailable)`:` (api ${e.apiVersion})`),``,...Ca(e.oauth,e.cliName,e.refresh),...Ta(e.apiKey,e.oauth,e.cliName),``,G(`Providers`,Oa(e.providers)),G(`Environment`,ka(e.resolved)),G(`Selected`,Aa(e.resolved,e.refresh,e.cliName)),...Sa(e.live)].join(`
21
- `)}function Sa(e){if(e===null)return[];let t=K(`local credential provenance was captured before verification`);if(e.error!==null)return[``,G(`Live probe`,`${e.scope} permission probe failed`),t,K(e.error)];if(e.authorization===null)return[];let n=e.authorization.permissionGrant,r=e.identity;return[``,G(`Live probe`,`${e.scope} permission probe succeeded`),t,K(`operation access ${e.authorization.operationAccess}; ${n.role.length} role; ${n.permission.length} permission`),...r===null?[K(e.scope===`read`?`identity not requested for a read-scope credential`:`identity unavailable in this build`)]:[G(`Live account`,r.nameFull??r.email??r.clerkUserId??r.id)],K(`no API operation was executed or individually authorized`)]}function G(e,t){return` ${e.padEnd(ya)}${t}`}function K(e){return` ${``.padEnd(ya)}${e}`}function Ca(e,t,n){switch(e.state){case`found`:{let{credential:r,provider:i}=e.stored,a=at(r);return[G(`OAuth`,`${a.email??a.subject??`unknown identity`} via ${i}`),K(wa(r,t,n))]}case`missing`:return[G(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[K(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[G(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[G(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function wa(e,t,n){return it(e)?e.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:n.failure===null?n.materialized===`api-key`?`access token expired and renewal failed; the API key is in use — \`${t} auth login\` renews OAuth`:`access token expired — not renewed while AUTH_TOKEN is set in the environment`:`access token expired — ${n.failure}`:`access token valid until ${e.expiresAt}`}function Ta(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[G(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[K(`stored credential invalid: ${e.error}`)]]:[G(`Signed in`,`credential storage unavailable`),K(r)]}return[G(t.state===`found`?`API key`:`Signed in`,e.subject??`unknown subject`),K(`via ${e.provider??`unknown store`}`),G(`Key`,`${e.name??`unnamed`} ${va(e.apiKeyId)}`),...Ea(e,n),G(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function Ea(e,t){let n=e.live,r=e.expiresInDay,i=e.expiresAt;if(n?.state===`invalid`)return[G(`Key state`,`rejected by aVenture sign-in \u2014 ${n.summary}`),K(`run \`${t} auth logout\`, then \`${t} auth login --key\``)];let a=n?.state===`verified`;return[G(`Key state`,a?`${e.status??`unknown`}, verified by aVenture sign-in now`:`${e.status??`unknown`} when stored`),...i===null||r===null?[K(`no expiry recorded`)]:[K(Da(i,r,a?`expires`:`cached expiry`))],...a?[]:[K(n===null?"aVenture sign-in owns the live verdict — `auth status` re-checks it":`aVenture sign-in could not be reached \u2014 ${n.summary}`)]]}function Da(e,t,n){let r=e.slice(0,10);return new Date(e).getTime()<=Date.now()?`${n} ${r} passed ${Math.abs(t)}d ago`:t<=ba?`${n} ${r}, ${t}d away`:`${n} ${r}`}function Oa(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`browser sign-in`:`no browser sign-in`,t?`oauth ${st(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function ka(e){return`${o.authToken}=${e.present?e.source??`resolved`:`unset`}`}function Aa(e,t,n){return e.present||t.materialized===`env`?`${o.authToken} from the environment`:t.materialized===`oauth`?`saved OAuth access token`:t.materialized===`api-key`?`saved API key`:`none \u2014 sign in with \`${n} auth login\``}var ja=`# >>> aventure-cli completion setup (managed by aventure-cli) >>>`,Ma=`# <<< aventure-cli completion setup (managed by aventure-cli) <<<`,Na=`.aventure-cli-completion.bak`;function Pa(e,t){e.command(`install`).summary(`install shell completion loaders`).description(`Install managed shell completion loaders for supported shells.`).action(()=>Va([])),e.command(`uninstall`).summary(`remove shell completion loaders`).description(`Remove managed shell completion loaders installed by ${t}.`).action(()=>Va([`--uninstall`]))}function Fa(e,t){e.command(`setup`).summary(`configure zsh completion startup`).description(`Configure ~/.zshrc so zsh loads ${t} completion loaders.`).option(`--dry-run`,`print the managed zshrc block without writing`).option(`--yes`,`apply without prompting`).option(`--uninstall`,`remove the managed zshrc block`).action(async e=>{let t=za(),n=await Ra({rcFile:M(Gt(),`.zshrc`),installerPath:t,mode:e.uninstall?`uninstall`:`install`,dryRun:e.dryRun,prompter:e.yes||e.dryRun?void 0:Qa});P.stdout.write(`${n.message}\n`),!n.cancelled&&!e.dryRun&&Va(e.uninstall?[`--uninstall`]:[])})}function Ia(e,t=`fpath-only`){return[ja,`# installer: ${e}`,'fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath)',...t===`fpath-and-compinit`?[`autoload -Uz compinit`,`compinit`]:[],Ma].join(`
22
- `)}function La(){let e=Va([`--status`],`pipe`);if(e.status!==0)return{refreshed:!1,message:`completion status exited ${e.status??1}`};if(!Ha(e.stdout??``))return{refreshed:!1,message:`no managed shell completions found`};let t=Va([],`pipe`);return t.status===0?{refreshed:!0,message:(t.stdout??``).trim()||`shell completions refreshed`}:{refreshed:!1,message:`completion refresh exited ${t.status??1}`}}async function Ra({rcFile:e,installerPath:t,mode:n,dryRun:r=!1,prompter:i}){let a=Ua(e),o=a.length===0?[]:a.split(`
23
- `),s=Wa(o,e);if(n===`uninstall`&&s===null)return{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:a};let c=n===`install`?Ga(o,s,t,e):Ka(o,s);return c===a?{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:c}:r?{changed:!0,cancelled:!1,message:c,content:c}:i!==void 0&&!await i(`Update ${e}?`)?{changed:!0,cancelled:!0,message:`${e}: unchanged; pass --yes to apply without a prompt`,content:a}:(Ya(e,c),{changed:!0,cancelled:!1,message:`${e}: updated`,content:c})}function za(e=P.argv[1]){let t=e===void 0?``:Ba(e),n=M(j(t),`..`,`..`,`scripts`,`install-zsh-completion-loader.mjs`);return N(n)?n:M(j(t),`..`,`scripts`,`install-zsh-completion-loader.mjs`)}function Ba(e){try{return Rt(e)}catch{return M(e)}}function Va(e,t=`inherit`){let n=Ot(P.execPath,[za(),...e],{encoding:t===`pipe`?`utf8`:void 0,stdio:t});if(n.error!==void 0)throw n.error;if(t===`inherit`){n.status!==0&&(P.exitCode=n.status??1);return}return{stdout:n.stdout?.toString(),stderr:n.stderr?.toString(),status:n.status}}function Ha(e){return e.split(/\r?\n/u).some(e=>e.trim().endsWith(`: managed`))}function Ua(e){return N(e)?(Xa(e),Ft(e,`utf8`)):``}function Wa(e,t){let n=qa(e,ja),r=qa(e,Ma);if(n.length===0&&r.length===0)return null;let[i]=n,[a]=r;if(n.length!==1||r.length!==1||i===void 0||a===void 0||i>=a)throw Error(`${t} has malformed managed completion setup markers; fix manually before retrying.`);return[i,a]}function Ga(e,t,n,r){let i=t===null?[...e]:[...e.slice(0,t[0]),...e.slice(t[1]+1)],a=Ja(i),o=Ia(n,a===-1?`fpath-and-compinit`:`fpath-only`).split(`
24
- `),s=t===null?a:t[0],c=s===-1?i.length:s;if(t!==null&&a!==-1&&a<c)throw Error(`${r} runs compinit before the managed block; move the block above compinit manually.`);return Za([...i.slice(0,c),...o,...i.slice(c)])}function Ka(e,t){return Za(t===null?e:[...e.slice(0,t[0]),...e.slice(t[1]+1)])}function qa(e,t){return e.flatMap((e,n)=>e===t?[n]:[])}function Ja(e){return e.findIndex(e=>/^\s*(autoload\s+.*\bcompinit\b|compinit(?:\s|$))/.test(e))}function Ya(e,t){Nt(j(e),{recursive:!0}),N(e)&&(Xa(e),Xa(`${e}${Na}`),jt(e,`${e}${Na}`));let n=M(j(e),`.${A(e)}.${P.pid}.tmp`);Xa(n),Vt(n,t,{mode:420}),zt(n,e)}function Xa(e){if(N(e)&&Mt(e).isSymbolicLink())throw Error(`refusing to write symlink: ${e}`)}function Za(e){let t=e.join(`
25
- `);return t.length===0||t.endsWith(`
26
- `)?t:`${t}\n`}async function Qa(e){if(!P.stdin.isTTY)return!1;let t=$t({input:P.stdin,output:P.stdout});try{let n=await t.question(`${e} [y/N] `);return/^(y|yes)$/i.test(n.trim())}finally{t.close()}}var $a=new Intl.Collator(void 0,{numeric:!0}),eo=2e4,to=[`lib`,`aventurevc-releases`];function no(e,t=C()){let n=t.registry===``?`Requires npm authentication for @aventurevc packages.`:`Installs from npm.`;k(e.command(`update`).summary(`Check for or install the latest release`).description([`Compare the running CLI version against the latest published`,`release and install it into the active published bin prefix.`,``,`Refuses to install when the running binary is the working-tree build`,`(rebuild that checkout instead). ${n}`,`--execute is deprecated, accepted, and ignored; update executes by its verb.`].join(`
27
- `)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>z({mode:O(e)},ro(void 0,`apply`,e.release)))}function ro(e,t=`apply`,n){let r=e;try{r??=C(process.argv[1])}catch(e){return x(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,o=r.registry===``?``:ve,s=r.registry===``&&i===`@aventurevc/aventure-cli`,c=n;if(c===void 0){let e=io([`view`,o,`version`,`--silent`,`--global`],r,{timeout:eo});if(!e.ok)return{...e,data:null};if(c=(e.data??``).trim(),c===``)return x(`npm view ${o} returned empty version`,[`empty_stdout`])}let l=n!==void 0||s||$a.compare(a,c)<0,u={targetPackage:o,runningPackage:i,currentVersion:a,latestVersion:c,upgradeAvailable:l,upgradeInstalled:!1};if(t===`check`)return S(`${i}@${a} → ${o}@${c} (${l?`available`:`up to date`})`,u);if(r.workingTreeRoot!==null)return x(`Refusing to install over the working-tree build at ${r.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);try{let e=so(r),t=M(e,...to),i=A(o),s=M(t,`${i}-current`),l=o===``?[o,``]:[o,ye],d=co(e,r),f=n??[c,d?.version??a].reduce((e,t)=>$a.compare(e,t)<0?t:e,a);Nt(t,{recursive:!0});let p=[oo(r),...N(s)?[Rt(s)]:[],...It(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>M(t,e.name))],m,h=null,g=!1;for(let t of new Set(p.filter(t=>t!==e))){let e=ao(t,l,f,r.registry);if(e.ok&&e.data!==null){m=t,h=e.data;break}}if(m===void 0){m=Pt(M(t,`${i}-${encodeURIComponent(f)}-`));let e=io([`install`,`-g`,`--prefix`,m,...l.map(e=>`${e}@${f}`)],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,data:null};g=!0;let n=ao(m,l,f,r.registry);if(!n.ok)return{...n,data:null};h=n.data}if(h===null)throw Error(`release verification produced no package`);let _=lo(m,e,s,h,n),ee=fo();return S(`${o} active at ${_}`,{...u,upgradeInstalled:g||n!==void 0||d?.version!==_,installPrefix:e,verifiedVersion:_,completionRefreshed:ee.refreshed,completionRefreshMessage:ee.message})}catch(e){return x(`${o} update failed: ${uo(e)}`,[`existing releases were preserved`])}}function io(e,t,n={}){let r={...process.env};t.registry===``?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let i=[...e,`--@aventurevc:registry=${t.registry}`],a=Ot(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?x(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):x(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
28
- `).slice(-3).join(` | `);return x(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return S(`npm ok`,a.stdout??``)}function ao(e,t,n,r){try{let i=t.map(t=>{let i=C(M(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));if(i.name!==t||i.version!==n||i.registry!==r)throw Error(`${t} does not match ${n} from ${r}`);for(let t of i.bin)if(!Rt(M(e,`bin`,t)).startsWith(`${i.packageRoot}${At}`))throw Error(`${t} escapes ${i.packageRoot}`);return i});for(let t of i){let r=M(e,`bin`,t.bin[0]),i=Ot(process.execPath,[r,`--version`],{encoding:`utf8`,timeout:eo});if(i.error)throw Error(`${t.name} verification failed: ${i.error.message}`);let a=(i.stdout??``).trim();if(i.status!==0||a!==n)throw Error(`${t.name} expected ${n} but reported ${a||`empty output`}`)}return S(`CLI and MCP release verified`,i)}catch(t){return x(`release verification failed: ${uo(t)}`,[`release prefix: ${e}`])}}function oo(e){let t=j(e.packageRoot),n=j(t),r=j(n);if(A(t)!==e.name.split(`/`)[0]||A(n)!==`node_modules`||A(r)!==`lib`)throw Error(`the running package is not in a verifiable global npm prefix; npm install was not run`);if(!e.entryPath.startsWith(`${e.packageRoot}${At}`))throw Error(`the running entry escapes its package root`);return j(r)}function so(e){let t=oo(e),n=`${At}${to.join(At)}${At}`,r=t.lastIndexOf(n);return r<0?t:t.slice(0,r)}function co(e,t){let n=t.registry===``?A(``):be,r=M(e,`bin`,n);if(!N(r))return null;let i=C(r);if(i.registry!==t.registry)throw Error(`${r} belongs to another product`);return i}function lo(e,t,n,r,i){let a=r[0];if(a===void 0)throw Error(`release contains no CLI`);let o=M(t,`bin`);Nt(o,{recursive:!0});let s=r.flatMap(e=>e.bin.filter((e,t)=>{let n=M(o,e);if(!N(n)||C(n).registry===a.registry)return!0;if(a.registry!==``&&t>0)return!1;throw Error(`${n} belongs to another product`)}));if(!N(n)){let t=Pt(M(j(n),`${A(n)}-seed-`));Nt(M(t,`bin`));for(let n of s){let r=M(o,n);Bt(Rt(N(r)?r:M(e,`bin`,n)),M(t,`bin`,n))}try{Bt(kt(j(n),t),n)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`EEXIST`))throw e}}if(!Mt(n).isSymbolicLink())throw Error(`${n} is not a release symlink`);for(let e of s){let t=kt(o,M(n,`bin`,e)),r=M(o,`.${e}-${Xt()}`);Bt(t,r),zt(r,M(o,e))}for(let e of s){let t=M(o,e);if(!Mt(t).isSymbolicLink()||M(o,Lt(t))!==M(n,`bin`,e))throw Error(`${t} does not follow the product current pointer`)}let c=co(t,a);if(i===void 0&&c!==null&&$a.compare(c.version,a.version)>0)return c.version;let l=`${n}-${Xt()}`;return Bt(kt(j(n),e),l),zt(l,n),a.version}function uo(e){return e instanceof Error?e.message:String(e)}function fo(){try{return La()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var po=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers`},{name:`auth`,purpose:`which credential signs in, as which account and role, never secrets`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}];function mo(e,t=C().bin[0]){k(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",...po.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable) or a`,`warned one (the account read failed) does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
29
- `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),z({mode:O(e)},await ho(t))})}async function ho(e){let t=_o(),n=vo(e),[r,i]=await Promise.all([yo(e),bo(t,e)]),a=[n.check,r,i.check,await So(e),ko(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:go(a,`pass`),warn:go(a,`warn`),fail:go(a,`fail`),skip:go(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.warn} warn, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
30
- `);return c.ok?S(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function go(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function _o(){return D.find(e=>e.intent===`status`&&e.resource===`status`)}function vo(e){let t=C(),n=ro(t,`check`);if(!n.ok||n.data===null)return{check:q(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?q(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):q(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function yo(e){try{let{EntityDetailSchema:e}=await import(`./detail-ClQGKFTZ.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return q(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return q(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${T(t)}.`)}}async function bo(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${T(e)}.`),servedFingerprint:null}}let i=await pe({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>x(T(e)));return i.ok?{check:q(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:xo(i.data)}:{check:q(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function xo(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function So(e){let t=qe(),[n,r]=await Promise.all([wo(),To()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return q(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&it(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return q(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${o.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await Co(e,t);return q(`auth`,i.status,`Credential source available: ${Eo(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${o.authToken} through the environment — ${r.summary}.`):q(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${o.authToken} in the environment.`)}async function Co(e,t){let n=E(f().host),r=await oa(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await aa(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${T(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function wo(){let e;try{e=E(f().host)}catch(e){return{state:`unavailable`,summary:T(e)}}return await ut(e)}async function To(){let e;try{e=E(f().host)}catch(e){return{state:`unavailable`,summary:T(e),cause:`environment`}}try{return await Qe(e)}catch(e){return{state:`unavailable`,summary:T(e),cause:`storage`}}}function Eo(e,t,n){return[ka(e),`oauth=${Oo(t)}`,`api-key=${Do(n)}`].join(` `)}function Do(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=E(f().host);return`${e.stored.activation}${ma(t,e)}`}function Oo(e){switch(e.state){case`found`:return it(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function ko(e,t,n,r){let i=D.length;if(e===void 0)return q(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return q(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Et}.`);if(t===`1a411ff24ca61b64`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Et}).`);let a=`This catalog describes a different operation set than the API serves (${Et} vs ${t})`;return n===!0?q(`catalog`,`fail`,`${a}: run \`${r} update\`.`):q(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var Ao=w(V,`oauth`),jo=[w(V,`start`),w(V,`poll`),w(V,`acknowledge`)],Mo=w(V,`revoke`);function No(e,n=C().bin[0]){let r=Lo(e);mo(r,n);let i=[`${Ao.description} Default method: OAuth in your browser.`,`With --key: ${jo.map(({description:e})=>e).join(` `)}`].join(`
31
- `);k(Io(r,[Ao,...jo],i)).action(Po),k(Io(r,[Mo],Mo.description)).action(Fo),k(r.command(`status`).summary(`Keep saved credentials current and report them`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
32
- `)).addOption(new t(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Ro(this),z({mode:O(e)},await zo(n,e.verify))}),r.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${o.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
33
- `)).action(async function(){Ro(this);let e=await oa(n),t=process.env[o.authToken]?.trim();if(e.failure===null&&t!==void 0&&t.length>0){process.stdout.write(`${t}\n`);return}z({mode:`text`},e.failure===null?qo(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):x(`auth token: ${e.failure}`))})}async function Po(e){Ro(this);let t=O(e);if(e.providers===!0){z({mode:t},await Vo());return}z({mode:t},e.key===!0?await Yi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await mt({noBrowser:!e.browser}))}async function Fo(e){Ro(this),z({mode:O(e)},await Ri({forgetLocal:e.forgetLocal===!0}))}function Io(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Lo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${Ao.command}\`: ${Ao.summary}; \`--key\` ${jo[0].summary.toLowerCase()}.`,`\`${Mo.command}\`: ${Mo.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build metadata.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
34
- `))}function Ro(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function zo(e,t){let n;try{n=E(f().host)}catch(e){return x(`auth status: invalid API host — ${T(e)}`)}let r=qe(),i=oa(e),[a,s]=await Promise.all([Ko(`/info`,`GET /info`),Ho()]),c=await i,[l,u]=await Promise.all([ut(n),Bo(n)]),d=t===void 0?null:await sa(t,l,u.inspection,c),p=C().version,m=da(n,u.inspection,u.verification),h=xa({cliName:e,cliVersion:p,apiVersion:a.ok?Wo(a.data):null,oauth:l,apiKey:m,providers:s,resolved:r,refresh:c,live:d}),g={cli:{version:p},api:a.ok?a.data??null:null,auth:{[o.authToken]:r},selected:c.materialized,oauth:fa(n,l),apiKey:m,providers:s,live:d,...a.ok?{}:{apiError:a.summary}};return c.failure===null?!a.ok&&a.httpStatus===401?{...x(`auth status: the API rejected the selected credential (401) | ${h}`,[`Replace or unset ${o.authToken}, or run \`${e} auth login\`.`]),data:g}:d!==null&&d.error!==null?{...x(`auth status: ${d.scope} permission probe failed — ${d.error}`,[d.error]),data:g}:d!==null||r.present||l.state===`found`||u.inspection.state===`found`?S(h,g):qo(`auth status: no credentials resolved | ${h}`,g,e,{oauth:l.state===`missing`,apiKey:u.inspection.state===`missing`}):{...x(`auth status: ${c.failure} | ${h}`,[c.failure]),data:g}}async function Bo(e){let t=await Uo(e);if(t.state!==`found`)return{inspection:t,verification:null};let{stored:n,verification:r}=await Fi(t.stored);return{inspection:{state:`found`,stored:n},verification:r}}async function Vo(){let e=await Ho();return e.state===`found`?S(`Sign-in providers for the selected API host`,e.catalog):x(`auth login --providers: ${e.summary}`)}async function Ho(){try{return{state:`found`,catalog:await pt()}}catch(e){return{state:`unavailable`,summary:T(e)}}}async function Uo(e){try{return await Qe(e)}catch(e){return{state:`invalid`,summary:T(e)}}}function Wo(e){if(!Go(e))return null;let t=ui.safeParse(Reflect.get(e,`response`));if(!t.success)return null;let n=t.data.build.version?.trim();return n&&n.length>0?n:null}function Go(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ko(e,t){return await pe({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>x(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}function qo(e,t,n,r){return{...x(e,[...r.apiKey?[`For an API key (works over SSH), run \`${n} auth login --key\`.`]:[],...r.oauth?[`For OAuth, run \`${n} auth login\`; without a browser it prints a device code.`]:[],`For non-interactive use, set ${o.authToken} to an aVenture API key (create one at ${s}/settings/api-keys).`]),data:t}}function Jo(e,t=D,n=C().bin[0]){let r=e.command(`completion`).summary(`Generate shell completion scripts`).description(`Generate shell completion scripts for the aVenture CLI.`);for(let i of[`bash`,`fish`,`zsh`])r.command(i).summary(`Print ${i} shell completions`).description(`Print ${i} completion definitions for ${n}.`).action(()=>{P.stdout.write(Xo(e,i,t))});Pa(r,n),Fa(r,n)}function Yo(){return C().bin}function Xo(e,t,n=D,r=Yo()){let i=as(n);return t===`fish`?[`# fish completions for ${r.join(`, `)}`,...Qo(e),...r.map(e=>`complete -c ${J(e)} -e`),`${vs(r)} -f`,...$o(e,r),...es(e,i,r),``].join(`
35
- `):Zo(e,t,i,r)}function Zo(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=cs(e,n);return[...t===`zsh`?[`#compdef ${r.join(` `)}`]:[],`# ${t} completions for ${r.join(`, `)}`,`${i}_aventure_cli_commands=(`,...o.map(e=>` ${e}`),`)`,`${i}_aventure_cli_options=(`,...s.map(e=>` ${e}`),`)`,`${i}_aventure_cli_values=(`,...c.map(e=>` ${e}`),`)`,``,...ds(t),...t===`bash`?[a,``]:[``]].join(`
36
- `)}function Qo(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${ts(e).filter(e=>e.required||e.optional).flatMap(e=>ms(e)??[]).map(J).join(` `)}\n set -l tokens (commandline -xpc)\n if test (count $tokens) -gt 0\n set -e tokens[1]\n end\n set -l path\n set -l skip_next 0\n for token in $tokens\n if test $skip_next -eq 1\n set skip_next 0\n continue\n end\n if string match -q -- '--*=*' $token\n set -l name (string replace -r '^--([^=]+)=.*$' '$1' -- $token)\n contains -- $name $global_value_options; and continue\n end\n if string match -q -- '--*' $token\n set -l name (string replace -r '^--' '' -- $token)\n if contains -- $name $global_value_options\n set skip_next 1\n continue\n end\n break\n end\n if string match -q -- '-*' $token\n break\n end\n set -a path $token\n end\n printf '%s\\n' $path\nend\n`,`function __aventure_cli_path_is
37
- set -l expected $argv
38
- set -l actual (__aventure_cli_command_path)
39
- if test (count $actual) -ne (count $expected)
40
- return 1
41
- end
42
- if test (count $expected) -eq 0
43
- return 0
44
- end
45
- for index in (seq (count $expected))
46
- if test $actual[$index] != $expected[$index]
47
- return 1
48
- end
49
- end
50
- return 0
51
- end
52
- `].flatMap(e=>e.split(`
53
- `))}function $o(e,t){return ss(e).map(e=>`${vs(t)} -f -n ${J(ys(e.parentPath))} -a ${J(e.name)} -d ${J(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function es(e,t,n){return hs(e).flatMap(e=>{let r=_s(e),i=r.length===0?void 0:ys(r);return ts(e).flatMap(e=>{let a=t.get(os(r,e));return us(a)?ns(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function ts(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function ns(e,t,n,r){let i=ms(e);if(i===void 0)return[];let a=e.argChoices??ls(n),o=[`-l ${J(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${J(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${J(t)}`,c=e.required||e.optional?rs(a,is(i,n)):`-f`,l=`${vs(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${J(bs(e.description))}`]:a.map(t=>`${l} -a ${J(t)} -d ${J(bs(e.description))}`)}function rs(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function is(e,t){return e===`from-file`?!0:t===void 0||t.some(({location:e})=>e!==`body`)?!1:t.every(({schemaFormat:e})=>e===`binary`)?!0:t.length===1&&[`file`,`path`].includes(e.split(`-`).at(-1)??``)}function as(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...jn(e.requestBody??[]).map(({variant:e})=>e.map(({parameter:e})=>e))].flatMap(t=>{let n=t[0];if(n===void 0)throw Error(`Generated CLI option has no parameter`);return[[os(e.cliPath,n),t]]})))}function os(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):ms(t);if(`flag`in t&&(n===void 0||n.length===0||n===t.flag))throw Error(`Cannot render completion for option flag: ${t.flag}`);return`${e.join(`\0`)}\u0000${n??``}`}function ss(e){return hs(e).flatMap(e=>e.commands.map(t=>({parentPath:_s(e),name:t.name(),description:bs(t.summary()||t.description()||t.name())})))}function cs(e,t){let n=[],r=[];for(let i of hs(e)){let e=_s(i);for(let a of ts(i)){let i=ms(a);if(i===void 0)continue;let o=t.get(os(e,a));if(!us(o))continue;let s=a.argChoices??ls(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&is(i,o)&&(c=`file`)),n.push(fs([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(fs([e.join(` `),`--${i}`,t,a.description]))}}return[ss(e).map(e=>fs([e.parentPath.join(` `),e.name,e.description])).toSorted((e,t)=>e.localeCompare(t)),n.toSorted((e,t)=>e.localeCompare(t)),r.toSorted((e,t)=>e.localeCompare(t))]}function ls(e){let t=e?.[0]?.choices;if(e!==void 0&&t!==void 0)return e.every(e=>e.choices?.length===t.length&&e.choices.every((e,n)=>e===t[n]))?t:void 0}function us(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function ds(e){let t=e===`bash`,n=t?`COMP_WORDS`:`words`,r=t?`COMP_CWORD`:`CURRENT`,i=t?"${path[*]}":"${(j: :)path}",a=t?'"${_aventure_cli_options[@]}"':`$_aventure_cli_options`,o=t?'"${_aventure_cli_values[@]}"':`$_aventure_cli_values`,s=t?'"${_aventure_cli_commands[@]}"':`$_aventure_cli_commands`;return[`function _aventure_cli {`,` local current="\${${n}[${r}]}" previous="\${${n}[${r}-1]}" row row_path long short description mode name value option token key prefix candidate file_current`,...t?[` COMPREPLY=()`]:[],` local index=${t?1:2} skip_next=0; local -a path names descriptions`,` while (( index < ${r} )); do`,` token="\${${n}[index]}"; (( skip_next )) && { skip_next=0; (( index++ )); continue; }`,` if [[ "$token" == -* && "$token" != "-" && "$token" != "--" ]]; then`,` option="\${token%%=*}"; key="${i}"; mode=''`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && break; mode=''; done`,` [[ -n "$mode" && "$mode" != none && "$token" != *=* ]] && skip_next=1`,` elif [[ "$token" != -* ]]; then path+=("$token"); fi`,` (( index++ ))`,` done`,` key="${i}"`,` if [[ "$current" == --*=* || ( "$previous" == -* && "$current" != -* ) ]]; then`,` option="$previous"; prefix=''; file_current="$current"; [[ "$current" == --*=* ]] && { option="\${current%%=*}"; prefix="$option="; file_current="\${current#*=}"; }`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && { option="$long"; break; }; mode=''; done`,t?` [[ "$mode" == file ]] && { while IFS= read -r candidate; do COMPREPLY+=("$prefix$candidate"); done < <(compgen -f -- "$file_current"); return 0; }`:` [[ "$mode" == file ]] && { _files; return 0; }`,t?` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { candidate="$prefix$value"; [[ "$candidate" == "$current"* ]] && COMPREPLY+=("$candidate"); }; done`:` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { names+=("$prefix$value"); descriptions+=("$description"); }; done`,` elif [[ "$current" == -* ]]; then`,` for row in ${a}; do`,` IFS='|' read -r row_path long short description mode <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$long" == "$current"* ]] && COMPREPLY+=("$long"); [[ -n "$short" && "$short" == "$current"* ]] && COMPREPLY+=("$short"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$long"); descriptions+=("$description"); [[ -n "$short" ]] && { names+=("$short"); descriptions+=("$description"); }; }`,` done`,` elif [[ "$previous" != -* ]]; then`,` for row in ${s}; do`,` IFS='|' read -r row_path name description <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$name" == "$current"* ]] && COMPREPLY+=("$name"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$name"); descriptions+=("$description"); }`,` done`,` fi`,...t?[]:[" (( ${#names} )) && compadd -d descriptions -a names"],` return 0`,`}`,...t?[]:[`_aventure_cli "$@"`]]}function fs(e){return`$'${e.map(ps).join(`|`)}'`}function ps(e){return bs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function ms(e){return e.long?.replace(/^--/,``)}function hs(e){return[e,...e.commands.filter(gs).flatMap(e=>hs(e))]}var gs=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function _s(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function vs(e){return`complete ${e.map(e=>`-c ${J(e)}`).join(` `)}`}function ys(e){return[`__aventure_cli_path_is`,...e.map(J)].join(` `)}function bs(e){return e.replace(/\s+/g,` `).trim()}function J(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function xs(e,t){if(e!==t)return;let n=Ss(t);n!==void 0&&t.error(`error: ${ws(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function Ss(e){if(!process.argv.includes(`--`)&&e.args.some(Cs))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function Cs(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function ws(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Ts(e,t){return e.message.match(RegExp(`${t} '([^']+)'`,`iu`))?.[1]?.split(/\s+/u)[0]}function Y(e){return e.flags.split(` `)[0]??e.flags}function Es(e,t){let n=Ts(t,`required option`),r=e.options.findIndex(e=>Y(e)===n);if(r<0)return;let i=new Set((Ws(X(e))?.parameters??[]).flatMap(e=>e.location===`path`?[e.optionKey]:[])),a=e.options.slice(r+1).find(t=>{let n=e.getOptionValue(t.attributeName());return i.has(t.attributeName())&&typeof n==`string`&&n!==``});if(a!==void 0)return`hint: ${n} is still required for this nested command; supplied child selector ${Y(a)} does not replace the parent selector.`}var Ds=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`],[`--transaction-id`,`--fundraise-round-id`]];function Os(e){let t=new Set(e.options.map(Y)),n=process.argv.indexOf(`--`),r=new Set(n<0?process.argv:process.argv.slice(0,n));return e.args.filter(e=>r.has(e)&&/^--[^-=]/u.test(e)).map(e=>e.split(`=`)[0]??e).filter(e=>!t.has(e))}function ks(e){let t=Ws(X(e))?.parameters??[],n=Os(e).flatMap(n=>{let r=Ds.find(e=>e.includes(n))?.find(t=>e.options.some(e=>Y(e)===t))??t.filter(({name:e})=>`--${e.replace(/[A-Z]/gu,`-$&`).toLowerCase()}`===n).map(e=>e.flag.split(` `)[0])[0];return r===void 0?[]:[`use ${r}, not ${n}`]});return n.length===0?void 0:`hint: ${n.join(`; `)}`}function X(e){return e.parent===null?[]:[...X(e.parent),e.name()]}function As(e){return e.commands.length===0?[e]:e.commands.flatMap(As)}function Z(e){return e.parent===null?e:Z(e.parent)}function js(e,t){let n=t=>{let n=X(t).slice(X(e).length);return n.length*2+ +![`get`,`list`].includes(n.at(-1)??``)};return t.toSorted((e,t)=>n(e)-n(t))[0]}function Ms(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function Ns(e,t){let n=[...e.options,...e.createHelp().visibleOptions(e)];for(let t=e.parent;t!==null;t=t.parent)n.push(...t.options);let r=t,i;for(let e=0;e<t.length;e++){let a=t[e];if(a===void 0||a===`--`)break;if(!a.startsWith(`-`)||a===`-`||i?.variadic&&Number.isFinite(Number(a)))continue;let o=a.indexOf(`=`),s=o<0?a:a.slice(0,o);if(i=n.find(e=>e.short===s||e.long===s),i===void 0||o>=0&&!i.required&&!i.optional){r=[`--help`];break}o<0&&(i.required||i.optional&&!t[e+1]?.startsWith(`-`))&&e++}return[Z(e).name(),...X(e),...r].map(Ms).join(` `)}function Ps(e,t){let n=Ts(t,`unknown option`);if(n===void 0||e.commands.length===0)return;let r=js(e,As(e).filter(e=>e.options.some(e=>Y(e)===n)));return r===void 0?void 0:`hint: run: ${Ns(r,process.argv.slice(2+X(e).length))}`}function Fs(e){return e!==void 0&&Object.hasOwn(gt,e)}function Is(e,t){return t.reduce((e,t)=>e?.commands.find(e=>e.name()===t),e)}function Ls(e,t){let n=X(e),r=[...n.slice(1),t];if(!Fs(n.at(0))||!Fs(r.at(0)))return;let i=Is(Z(e),r);if(i===void 0)return;let a=i;for(let e of process.argv.slice(2+n.length+1)){if(e.startsWith(`-`))break;let t=a.commands.find(t=>t.name()===e);if(t===void 0)break;r.push(e),a=t}return r}function Rs(e,t){let[n]=X(e);if(n===void 0||!Fs(n))return;let r=[n,t];return Is(Z(e),r)?.commands.length===0?r:void 0}function zs(e){let[t,...n]=e.args;if(t===void 0)return[];let r=As(Z(e)).map(X),i=n.findIndex((e,t)=>{let i=[...n.slice(0,t),e];return!r.some(e=>e.some((t,n)=>t===i[0]&&i.every((t,r)=>e[n+r]===t)))});return[t,...i<0?n:n.slice(0,i)]}function Bs(e,t,n=[]){let r=X(e),i=yt(D).map(e=>e.cliPath).filter(e=>e[0]!==r[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a===void 0)return;let o=Is(Z(e),a);return o===void 0?void 0:`hint: run: ${Ns(o,n)}`}function Vs(e,t,n){if(!Us(t))return;let r=Is(Z(e),t);if(r===void 0)return;let i=e.args.slice(n.length),a=i.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${Ns(r,a<0?[]:i.slice(a))}`}function Hs(e){let t=X(e);if(t.at(1)!==void 0&&Fs(t.at(0)))return`hint: inspect generated command group: ${[Z(e).name(),...t,`--help`].map(Ms).join(` `)}`}function Us(e,t){let n=Ws(e);return n!==void 0&&(t===void 0||_(n.intent)===t)}function Ws(e){return D.find(t=>t.cliPath.join(` `)===e.join(` `))}function Gs(e){let t=X(e).join(` `),n=yt(D),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:Ee(r.operationId,n,Z(e).name()).map(e=>`hint: ${e}`)}function Ks(e){let t=X(e);if(Fs(t.at(0))&&Us(t))return`hint: inspect generated command: ${[Z(e).name(),...t,`--help`].map(Ms).join(` `)}`}function qs(e){let t=new Set,n=[];for(let r of D){let i=Is(e,r.cliPath);if(i===void 0)continue;let a=i.options.map(Y);if(_(r.intent))n.push(a);else for(let e of a)t.add(e)}let[r=[],...i]=n;return new Set(r.filter(e=>!t.has(e)&&i.every(t=>t.includes(e))))}function Js(e,t){let n=X(e);if(Us(n,!1)&&qs(Z(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function Ys(e,t,n=!0){let r=Z(e),i=r.commands.find(e=>e.name()===`command-catalog`),a=i?.commands.find(e=>e.name()===`search`);if(i===void 0||a===void 0)return;let o=[r.name(),i.name(),a.name(),t],s=X(e).at(0),c=a.options.find(e=>Y(e)===`--root`),l=n&&c!==void 0&&Fs(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(Y(c),l);let u=yt(D),d=yr({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?Br(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(Ms).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
54
- `).filter(Boolean).map(e=>` ${e}`)].join(`
55
- `)}function Xs(e,t=``){if(e.commands.length>0&&!Us(X(e)))return;let n=e.options.flatMap(e=>e.hidden?[]:[Y(e)]),r=yt(D),i=Ae(t,r,X(e),Z(e).name());return`${i===void 0?``:`hint: an id you already hold is read with: ${i}\n`}hint: ${X(e).join(` `)} accepts: ${n.join(` `)}`}function Zs(e,t){let n=Ts(t,`unknown command`);if(n===void 0||t.message.includes(`
56
- (Did you mean `))return;let r=zs(e),i=process.argv.slice(2+X(e).length);if(r.length>0&&r.every((e,t)=>i[t]===e)){let t=Bs(e,r);if(t!==void 0)return t}let a=X(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Us(o)?o:void 0)??Ls(e,n)??Rs(e,n);if(s!==void 0)return Vs(e,s,r)??Ys(e,s.join(` `),!1);let c=r.join(` `)||n,l=Hs(e)??Ys(e,c),u=[...a,...r.slice(1)];return[l,r.length===a.length+a.length&&a.at(-1)===a.at(0)?Vs(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Vs(e,u,r):void 0].filter(e=>e!==void 0).join(`
57
- `)||void 0}function Qs(e){return t=>{if(t.code===`commander.missingMandatoryOptionValue`){let n=e.options.filter(t=>t.mandatory&&e.getOptionValue(t.attributeName())===void 0);if(n.length>1){let e=n.map(e=>e.flags.split(`, `).at(-1)??e.flags);process.stderr.write(`error: missing required options: ${e.join(`, `)}\n`)}let r=Os(e);for(let e of r)process.stderr.write(`error: unknown option '${e}'\n`);for(let n of[ks(e)??(r.length>0?Xs(e):void 0),Ss(e),Es(e,t),...Gs(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Ss(e)??Ks(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=Ts(t,`unknown option`),r=ks(e)??Ps(e,t)??(n!==void 0&&!t.message.includes(`
58
- (Did you mean `)?Js(e,n)??Bs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??Xs(e,n)??Ys(e,X(e).slice(1).join(` `)||n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=Zs(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.helpDisplayed`){let[n]=e.args;if(n?.startsWith(`-`)===!1&&e.registeredArguments.length===0){let r=[Z(e).name(),...X(e)].join(` `);t.exitCode=1,process.stderr.write(`hint: ${r} takes no '${n}' subcommand; the help shown is for ${r}\n`)}}throw t}}var $s=class extends t{group;constructor(e){super(`-h, --help`,`display help for command`),this.group=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.group.args.at(0);return t===void 0||t.startsWith(`-`)?!0:this.group.commands.some(e=>e.name()===t||e.aliases().includes(t))}};function ec(e){e.showHelpAfterError(!1).exitOverride(Qs(e)),e.commands.length===0?e.hook(`preAction`,xs):e.registeredArguments.length===0&&!Ws(X(e))&&e.addHelpOption(new $s(e));for(let t of e.commands)ec(t)}function tc(e,t=new Date){let n=ic(e);return{schemaVersion:1,generatedFrom:`MCP_GENERATION_CONTRACT`,generatedAt:t.toISOString(),totalOperations:n.length,note:`Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.`,operations:n}}function nc(e){return`${JSON.stringify(e,null,2)}\n`}function rc(e,t){let n=M(e),r=nc(t);return Nt(j(n),{recursive:!0}),Vt(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function ic(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,mcpTool:h(e.intent),bodySchemaName:e.requestBody?.[0]?.schemaName??null,bodySchemaImport:e.requestBody?.[0]?.schemaImport??null,auth:e.projection.auth,scope:e.projection.scope,destructive:e.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var ac=`Match only the first canonical or CLI-alias command segment`,oc=[`text`,`lines`,`compact`,`json`,`ndjson`];function sc(e,t,n=C().bin[0]){let r=e.command(`command-catalog`).summary(`LLM agent only: search generated CLI metadata`).description([`LLM agent only: search and dump generated ${n} command metadata.`,`This is read-only command metadata derived from the generated OpenAPI command specs.`,`Use --format lines for rg/grep/ag/ack and --format ndjson|json for ast-grep/sg/parsers.`,"Use --format compact for one `cli · summary · requiredFlags` row per operation."].join(`
59
- `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Mr(n)}\n`),cc(r,t,n),lc(r,t,n),uc(r,t,n),dc(r)}function cc(e,n,r){let i=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,ac).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new t(`--format <format>`,`Text/file render format`).choices(oc)).option(`--output <path>`,`Write rendered output to a file`);k(i),i.action(function(e){let t=this.optsWithGlobals(),i=O(t,`text`),a=Pr(t,e);Fr(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function lc(e,n,r){let i=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);k(i),i.action(function(){let e=this.optsWithGlobals();Ir(e,n,O(e,`text`),r)})}function uc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,ac).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(oc)).option(`--output <path>`,`Write rendered output to a file`);k(i),i.action(function(){let e=this.optsWithGlobals();Fr(e,n,O(e,`text`),r)})}function dc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);k(t),t.action(async function(){let e=this.optsWithGlobals(),t=O(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-DWJuv2GM.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){z({mode:t},S(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=tc(n);if(e.output!==void 0){let n=rc(e.output,r);z({mode:t},S(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){Rr(`Unified operations JSON`,nc(r));return}z({mode:t},S(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var fc=C(Jt(import.meta.url)),Q=fc.bin[0];function pc(e,t){let n=e instanceof Error?e:Error(String(e));c({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof he?{httpStatus:n.problem.status,problem:n.problem}:{};lr({...x(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function mc(e){return Ue[ze(e,gt)??`cli`]}function hc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:mc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>wt(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)gc(e,t,r,a,i.has(t.cliPath.join(` `)))}function gc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=_c(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>g(e.schemaType,e.itemSchemaType))?ee:``].filter(Boolean).join(`
60
- `));let f=Tt(t);for(let e of t.parameters)vc(u,e,i||e===f);if(Hn(u,t),_(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),k(u),u.hook(`preAction`,e=>bt(e,t)),t.explain===!0&&u.option(`--explain`,`Print the search strategy and parsed constraints before the results`),f!==void 0){u.argument(`[text...]`,f.description||`Same as ${Ct(f.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),r=O(n),i=vt(f,e,n);if(!i.ok||i.data===null)return z({mode:r},i);let a=_t(t,i.data);if(a.length>0)return z({mode:r},x(`missing required options: ${a.join(`, `)}`));let o=await yc(t,i.data,r),s=oi(t,i.data,o);if(s!==null)return z({mode:r},s);n.explain===!0&&o.ok&&pr(r,o.data),o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):z({mode:r},o)});return}u.action(async function(){let e=this.optsWithGlobals(),n=O(e),r=_t(t,e);if(r.length>0)return z({mode:n},x(`missing required options: ${r.join(`, `)}`));let i=await yc(t,e,n),a=oi(t,e,i);if(a!==null)return z({mode:n},a);e.explain===!0&&i.ok&&pr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):z({mode:n},i)})}function _c(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=gt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function vc(e,n,r=!1){let i=n.description||`${n.name} ${n.location} parameter`,a=n.defaultValue===void 0?void 0:typeof n.defaultValue==`string`||typeof n.defaultValue==`boolean`?n.defaultValue:[...n.defaultValue];if(n.legacyFlag!==void 0){let o=new t(n.flag,i);a!==void 0&&o.default(a);let s=new t(n.legacyFlag,i).conflicts(n.optionKey);e.addOption(o).addOption(s),e.hook(`preAction`,e=>{let t=e.opts(),i=t[n.optionKey],a=t[s.attributeName()];if(a!==void 0){(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`);return}!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(a!==void 0){e.option(n.flag,i,a);return}if(n.required&&!r){e.requiredOption(n.flag,i);return}e.option(n.flag,i)}async function yc(e,t,n){if(t.environment!==void 0){let e=d(t.environment);if(e===null)return x(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${a().join(`, `)}`]);process.env.API_ENV=e}let r=await qn(e,t);if(!r.ok)return r;let i=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let n=t[e.optionKey];if(Array.isArray(n))return[e.name,n.at(0)??``];if(n===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(n)]})),o=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let n=t[e.optionKey];if(n===void 0||Array.isArray(n)&&n.length===0)return[];let r=Array.isArray(n)||typeof n==`boolean`?n:String(n);return[[e.name,r]]})),s=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let n=t[e.optionKey];return n===void 0||Array.isArray(n)&&n.length===0?[]:[[e.name,Array.isArray(n)?n.join(`,`):String(n)]]}));return ci(e,await pe({method:e.method,path:se(e.operationId,i),searchParams:o,headers:s,body:r.data,contentType:St(e,t),auth:e.auth,responseFormat:Dt(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0}))}process.on(`uncaughtException`,e=>pc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>pc(e,`unhandledRejection`));var bc=xt(process.argv.slice(2),D),xc=bc===`required`?D:yt(D),$=new i;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(Zr).version(fc.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description([`The aVenture research API from your terminal. Three records — companies,`,`people, and news — carry everything else: funding, publications, and tags.
61
- `,`Mutations execute directly; --execute is a deprecated no-op.
62
- The aVenture MCP server tools execute through this same CLI.`].join(`
63
- `)).addOption(new t(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${l})`).choices([...a()])).showHelpAfterError(`(run \`${Q} --help\` for usage)`),hc($,xc),No($,Q),no($,fc),Jo($,xc,Q),sc($,xc,Q),qr($,xc,Q);for(let e of $.commands)e.helpGroup()||e.helpGroup(mc(e.name()).heading);if(ec($),bc===`required`){let e=[$];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&(await dt(),await et())}))}}var Sc=new Set($.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));$.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find one news article; companies and people use the root lookup`],[`get`,` get Read one record`],[`list`,` list Read many records`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>Sc.has(e)?[t]:[]),``,`Authentication (every command that calls aVenture needs a credential):`,` Create one at ${s}/sign-up, then run: ${Q} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Check what this shell holds with: ${Q} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
64
- `,`Exit codes:`,` 0 envelope.ok === true
65
- 1 envelope.ok === false
66
- `,`Examples:`,` $ ${Q} auth login`,` $ ${Q} lookup --name Stripe --url https://stripe.com`,` $ ${Q} search "fintech companies in Austin"\n`,`Run \`${Q} <command> --help\` for its subcommands and options,`,`or \`${Q} help <command>\` for its full documentation.`].join(`
67
- `));try{await $.parseAsync()}catch(t){t instanceof e?process.exitCode=t.exitCode:pc(t,`parseAsync`)}export{};