@aventurevc/aventure-cli 0.8.223 → 0.8.224

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) 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/{aventure-cli-rmNB8dQG.js → aventure-cli-D2Y6FMAQ.js} +3 -3
  4. package/dist/chunks/{contract-D9Zn2i_6.js → contract-CU2UugQ0.js} +10 -10
  5. package/dist/chunks/detail-BsTee2g2.js +1 -0
  6. package/dist/chunks/detail-jqEwPPHS.js +1 -0
  7. package/dist/chunks/{dist-2SvD7GNW.js → dist-Cf8kXL-8.js} +1 -1
  8. package/dist/chunks/mcp-generation-contract-N93eBv4f.js +1 -0
  9. package/dist/chunks/mcp-generation-contract-mTifVDpF.js +1 -0
  10. package/dist/chunks/{oauth-bearer-credential-DXYDGcAM.js → oauth-bearer-credential-CKwu5Ed_.js} +2 -2
  11. package/dist/chunks/oauth-bearer-credential-DfvI7VbW.js +1 -0
  12. package/dist/chunks/{oauth-login-Dj-VWx7a.js → oauth-login-B5IM3hvP.js} +1 -1
  13. package/dist/chunks/oauth-login-DTbseCcZ.js +1 -0
  14. package/dist/chunks/openapi-commands-BtVr86uS.js +1 -0
  15. package/dist/chunks/openapi-commands-DtqjXQlN.js +1 -0
  16. package/dist/chunks/provider-catalog-crNc-lAb.js +1 -0
  17. package/package.json +3 -3
  18. package/dist/chunks/detail-BqdugX6O.js +0 -1
  19. package/dist/chunks/detail-KtYIbiXI.js +0 -1
  20. package/dist/chunks/mcp-generation-contract-a0zxpoQ8.js +0 -1
  21. package/dist/chunks/mcp-generation-contract-bL1nV_K6.js +0 -1
  22. package/dist/chunks/oauth-bearer-credential-BRjsF2n1.js +0 -1
  23. package/dist/chunks/oauth-login-Cxjt7XFG.js +0 -1
  24. package/dist/chunks/openapi-commands-BARA0Twq.js +0 -1
  25. package/dist/chunks/openapi-commands-v9rahoUV.js +0 -1
  26. package/dist/chunks/provider-catalog-CuGIJY0Q.js +0 -1
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{enableCompileCache as e}from"node:module";e();var{CommanderError:t}=await import(`../chunks/commander-Cj79cOD4.js`),{logWarn:n,setStderrLogging:r}=await import(`../chunks/logging-3qS9h4q4.js`),{readRuntimePackage:i}=await import(`../chunks/package-N5oYCiVc.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-BRjsF2n1.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-CxR6Q2DS.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-Bwq9U0fl.js`),{setTextAllFields:u}=await import(`../chunks/text-field-BGnJUpd7.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-CP43axpn.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-v9rahoUV.js`),p=process.argv.slice(2);d(p)&&r(!1),p.includes(`--all-fields`)&&u(!0);try{a();let e=l(p,f);if(e===`stored`||e===`optional`)try{await(e===`stored`?s():o()),await c()}catch(e){n({component:i().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-rmNB8dQG.js`)}catch(e){if(!(e instanceof t))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
2
+ import{enableCompileCache as e}from"node:module";e();var{CommanderError:t}=await import(`../chunks/commander-Cj79cOD4.js`),{logWarn:n,setStderrLogging:r}=await import(`../chunks/logging-3qS9h4q4.js`),{readRuntimePackage:i}=await import(`../chunks/package-N5oYCiVc.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-DfvI7VbW.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-CxR6Q2DS.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-Bwq9U0fl.js`),{setTextAllFields:u}=await import(`../chunks/text-field-BGnJUpd7.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-CP43axpn.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-BtVr86uS.js`),p=process.argv.slice(2);d(p)&&r(!1),p.includes(`--all-fields`)&&u(!0);try{a();let e=l(p,f);if(e===`stored`||e===`optional`)try{await(e===`stored`?s():o()),await c()}catch(e){n({component:i().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:e})}await import(`../chunks/aventure-cli-D2Y6FMAQ.js`)}catch(e){if(!(e instanceof t))throw e;process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "MCP_GENERATION_CONTRACT",
4
- "generatedAt": "2026-10-21T14:26:33.003Z",
4
+ "generatedAt": "2026-10-21T16:51:29.908Z",
5
5
  "totalOperations": 137,
6
6
  "note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
7
7
  "operations": [
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a,f as o,h as s,i as c,m as l,o as u,v as d,x as f}from"./logging-Cbl234V4.js";import{S as p,a as m,b as h,c as g,l as ee,t as te,x as ne,y as re}from"./tool-policy-BUHiyuYu.js";import{M as ie,O as ae,i as _,o as oe,v as se,w as v,y}from"./person-owner-BJgNYLKX.js";import{Ar as ce,Br as le,Jr as ue,Mr as de,Pr as fe,Rr as pe,Xr as me,jr as he,kr as ge}from"./dist-2SvD7GNW.js";import{c as b,f as _e,n as ve,r as x}from"./result-envelope-Bl_1n5Tb.js";import{a as S,n as ye,r as be,t as xe}from"./package-DPDX5zmx.js";import{a as Se,i as Ce}from"./response-problem-l5WiBcon.js";import{n as we,r as Te}from"./output-spill-CqEdAEnD.js";import{_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,i as Me,l as Ne,m as Pe,n as C,o as Fe,r as Ie,s as Le,u as Re}from"./contract-D9Zn2i_6.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-BIiQwYpQ.js";import{S as Ke,_ as qe,a as Je,g as w,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as T,y as it}from"./api-key-bearer-credential-eFCSZ-cX.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-DXYDGcAM.js";import{n as ht,r as gt,t as _t}from"./oauth-login-Dj-VWx7a.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-S6FZrxDX.js";import{n as Ot,t as E}from"./openapi-commands-BARA0Twq.js";import{i as D,r as kt,t as O}from"./output-mode-3tDGwmsL.js";import{spawnSync as At}from"node:child_process";import{basename as k,dirname as A,relative as jt,resolve as j,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as M,lstatSync as Pt,mkdirSync as Ft,mkdtempSync as It,readFileSync as Lt,readdirSync as Rt,readlinkSync as zt,realpathSync as Bt,renameSync as Vt,symlinkSync as Ht,writeFileSync as Ut}from"node:fs";import N,{stderr as P,stdin as Wt}from"node:process";import{TextDecoder as Gt,inspect as Kt}from"node:util";import{homedir as qt,hostname as Jt,platform as Yt}from"node:os";import{fileURLToPath as Xt}from"node:url";import{setTimeout as Zt}from"node:timers/promises";import{randomUUID as Qt,webcrypto as $t}from"node:crypto";import{readFile as en}from"node:fs/promises";import{createInterface as tn}from"node:readline/promises";function nn(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function rn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!vn(n,r.name))continue;let a=_n(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function an(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function on(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return Sn(e,t,n);for(let[r,i]of n.entries()){let n=Sn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function sn(e,t,n,r){return Sn(e,t,r,n)}function cn(e){let t=[];for(let n of e.split(`.`)){let e=wn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function ln(e,t){let n=cn(t);if(n===null)return null;let r=gn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:hn(r)}:null}function un(e,t){if(F(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var dn=/^(?<row>\d+):(?<item>.*)$/su;function fn(e,t){let n=cn(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=dn.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function pn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&cn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function mn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=ln(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||fn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function hn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function gn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function _n(e,t){if(!F(t))return gn(e,t.split(`.`))}function vn(e,t){return bn(e,t.split(`.`))}function yn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&vn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function bn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=wn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>bn(e,r)):bn(a,r)}function F(e){return e.split(`.`).some(e=>wn(e).isArray)}function xn(e,t){return e.parameter.length===0||!I(t)?null:En(t,[],Tn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=wn(o),c=e===i.length-1,l=Cn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function Cn(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return I(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return I(s)?b(`Body path stepped`,s):o()}function wn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function Tn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function En(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=En(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!Dn(a,n)){if(!On(e))continue;let t=kn(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=En(i,e,n);if(o!==null)return o}return null}function Dn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function On(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function kn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:An(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function An(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}var jn=e=>Array.isArray(e)&&!Object.isFrozen(e);function Mn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=fe(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!jn(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?Bn(r,i):r===void 0?i===void 0?0:1:-1})}function Nn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function Pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Rn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function In(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Ln(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Rn(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${zn(e,t)}`}function zn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=cn(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function Bn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Vn(e){let t;try{t=e===`-`?await Hn():await en(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function Hn(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var Un=`--content-type`;function Wn(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Un)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Un} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Kn(a)))}if(ur(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,Ln(r,r.requiredPath)).argParser(Jn(`--from-file`)))}let o=Nn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Pn(n),a.length>1?Fn(n):Rn(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?In(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Gn):F(i.name)||i.schemaType===`array`?o.argParser(qn):o.argParser(Jn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}lr(e,n,o)}function Gn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Kn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Un} was already given; pass it once.`);let i=re(e,t);if(!i.ok)throw new n(i.summary);return t}}function qn(e,t){return[...t??[],e]}function Jn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Yn(e,t){let n=wt(e,t),r=re(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=Xn(e,i,t);if(a!==null)return x(a);let o=nn(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Zn(i,t);if(s!==null)return x(s);let c=await tr(t);if(!c.ok)return x(c.summary,c.warnings);let l=yn(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=er(e.operationId,i,c.data);if(!u.ok)return u;let d=rn(e.operationId,i,c.data);if(d!==null)return x(d);let f=nr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(cr(e.operationId,i)):b(`No body`,void 0);let p=ir(e.operationId,i,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let m=$n(i,p.data);if(m.length>0)return x(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?an(i).filter(e=>!vn(h,e)):[];return g.length>0?x(Qn(e.operationId,i,g)):p}function Xn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Un} ${i.join(` or `)}.`}return null}function Zn(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Qn(e,t,n){let r=`${e} requires JSON body path(s): ${n.join(`, `)}`;return t.kind===`multipart`?`${r}. ${n.includes(`body`)?`For multipart --from-file, wrap the endpoint JSON under top-level "body".`:`For multipart --from-file, put the missing nested path(s) inside top-level "body".`}`:r}function $n(e,t){return I(t)?e.parameter.filter(e=>e.required&&!vn(t,e.name)).map(L):[]}function er(e,t,n){let r=xn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function tr(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await Vn(t);if(!n.ok)return x(n.summary,n.warnings);let r=_e.safeParse(n.data);return r.success?b(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function nr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=un(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=rr(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=mn(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function rr(e,t,n,r,i){let a=fn(r,i);if(a===null){let e=or(r,i);return e.ok?on(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=pn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=sr(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=sn(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function ir(e,t,n,r){if(n===void 0)return b(`Direct body parsed`,r);if(r===void 0)return b(`Input parsed`,n);if(I(n)&&I(r))try{return b(`Input parsed`,ar(t,n,r))}catch(t){return x(`${e} ${t instanceof Error?t.message:String(t)}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ar(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ar(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:Le.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function or(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return sr(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=sr(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function sr(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function cr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=an(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function lr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Un,location:`body`}),ur(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Mn(e.options,r)}function ur(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function dr(e,t){let n=t.data,r=`jobId`,i=`statusUrl`,a=t.rolloverJob?.jobId??(typeof n==`object`&&n&&r in n&&typeof n[r]==`string`?n[r]:void 0),o=t.rolloverJob?.statusUrl??t.headers.location??(typeof n==`object`&&n&&i in n&&typeof n[i]==`string`?n[i]:void 0),s=t.headers[`retry-after`],c=`Pending: ${e.operationId??`request`}${a===void 0?``:` job ${a}`} is still running.`+(s===void 0?``:` Retry-After: ${s}.`)+(o===void 0?``:` Poll GET ${o} for the result.`);return{...e,summary:c,warnings:[...e.warnings,c],ids:a===void 0?e.ids:[...new Set([...e.ids,a])],references:o===void 0?e.references:[...new Set([...e.references,o])]}}function fr(e){let t=ve(e,hr(e));return xr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function pr(e){let t=ve(e,hr(e));xr(t);let n=De(E,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=mr(t);r.push(n.endsWith(`
1
+ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a,f as o,h as s,i as c,m as l,o as u,v as d,x as f}from"./logging-Cbl234V4.js";import{S as p,a as m,b as h,c as g,l as ee,t as te,x as ne,y as re}from"./tool-policy-BUHiyuYu.js";import{M as ie,O as ae,i as _,o as oe,v as se,w as v,y}from"./person-owner-BJgNYLKX.js";import{Ar as ce,Br as le,Jr as ue,Mr as de,Pr as fe,Rr as pe,Xr as me,jr as he,kr as ge}from"./dist-Cf8kXL-8.js";import{c as b,f as _e,n as ve,r as x}from"./result-envelope-Bl_1n5Tb.js";import{a as S,n as ye,r as be,t as xe}from"./package-DPDX5zmx.js";import{a as Se,i as Ce}from"./response-problem-l5WiBcon.js";import{n as we,r as Te}from"./output-spill-CqEdAEnD.js";import{_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,i as Me,l as Ne,m as Pe,n as C,o as Fe,r as Ie,s as Le,u as Re}from"./contract-CU2UugQ0.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-BIiQwYpQ.js";import{S as Ke,_ as qe,a as Je,g as w,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as T,y as it}from"./api-key-bearer-credential-eFCSZ-cX.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-CKwu5Ed_.js";import{n as ht,r as gt,t as _t}from"./oauth-login-B5IM3hvP.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-S6FZrxDX.js";import{n as Ot,t as E}from"./openapi-commands-DtqjXQlN.js";import{i as D,r as kt,t as O}from"./output-mode-3tDGwmsL.js";import{spawnSync as At}from"node:child_process";import{basename as k,dirname as A,relative as jt,resolve as j,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as M,lstatSync as Pt,mkdirSync as Ft,mkdtempSync as It,readFileSync as Lt,readdirSync as Rt,readlinkSync as zt,realpathSync as Bt,renameSync as Vt,symlinkSync as Ht,writeFileSync as Ut}from"node:fs";import N,{stderr as P,stdin as Wt}from"node:process";import{TextDecoder as Gt,inspect as Kt}from"node:util";import{homedir as qt,hostname as Jt,platform as Yt}from"node:os";import{fileURLToPath as Xt}from"node:url";import{setTimeout as Zt}from"node:timers/promises";import{randomUUID as Qt,webcrypto as $t}from"node:crypto";import{readFile as en}from"node:fs/promises";import{createInterface as tn}from"node:readline/promises";function nn(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...x(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function rn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!vn(n,r.name))continue;let a=_n(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function an(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function on(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return Sn(e,t,n);for(let[r,i]of n.entries()){let n=Sn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function sn(e,t,n,r){return Sn(e,t,r,n)}function cn(e){let t=[];for(let n of e.split(`.`)){let e=wn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function ln(e,t){let n=cn(t);if(n===null)return null;let r=gn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:hn(r)}:null}function un(e,t){if(F(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var dn=/^(?<row>\d+):(?<item>.*)$/su;function fn(e,t){let n=cn(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=dn.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function pn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&cn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function mn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=ln(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||fn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function hn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function gn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function _n(e,t){if(!F(t))return gn(e,t.split(`.`))}function vn(e,t){return bn(e,t.split(`.`))}function yn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&vn(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function bn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=wn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>bn(e,r)):bn(a,r)}function F(e){return e.split(`.`).some(e=>wn(e).isArray)}function xn(e,t){return e.parameter.length===0||!I(t)?null:En(t,[],Tn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=wn(o),c=e===i.length-1,l=Cn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function Cn(e,t,n,r,i,a){let o=()=>x(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return I(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return I(s)?b(`Body path stepped`,s):o()}function wn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function Tn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function En(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=En(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!Dn(a,n)){if(!On(e))continue;let t=kn(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=En(i,e,n);if(o!==null)return o}return null}function Dn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function On(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function kn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:An(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function An(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}var jn=e=>Array.isArray(e)&&!Object.isFrozen(e);function Mn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=fe(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!jn(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?Bn(r,i):r===void 0?i===void 0?0:1:-1})}function Nn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function Pn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Fn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Rn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function In(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function Ln(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Rn(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${zn(e,t)}`}function zn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=cn(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function Bn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Vn(e){let t;try{t=e===`-`?await Hn():await en(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function Hn(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var Un=`--content-type`;function Wn(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Un)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Un} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Kn(a)))}if(ur(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,Ln(r,r.requiredPath)).argParser(Jn(`--from-file`)))}let o=Nn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Pn(n),a.length>1?Fn(n):Rn(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?In(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Gn):F(i.name)||i.schemaType===`array`?o.argParser(qn):o.argParser(Jn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}lr(e,n,o)}function Gn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Kn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Un} was already given; pass it once.`);let i=re(e,t);if(!i.ok)throw new n(i.summary);return t}}function qn(e,t){return[...t??[],e]}function Jn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Yn(e,t){let n=wt(e,t),r=re(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=Xn(e,i,t);if(a!==null)return x(a);let o=nn(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=Zn(i,t);if(s!==null)return x(s);let c=await tr(t);if(!c.ok)return x(c.summary,c.warnings);let l=yn(e.requestBody??[],i,c.data);if(l!==null)return x(l);let u=er(e.operationId,i,c.data);if(!u.ok)return u;let d=rn(e.operationId,i,c.data);if(d!==null)return x(d);let f=nr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?x(cr(e.operationId,i)):b(`No body`,void 0);let p=ir(e.operationId,i,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let m=$n(i,p.data);if(m.length>0)return x(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?an(i).filter(e=>!vn(h,e)):[];return g.length>0?x(Qn(e.operationId,i,g)):p}function Xn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Un} ${i.join(` or `)}.`}return null}function Zn(e,t){for(let n of e.cliConflicts??[]){let e=n.filter(e=>t[e]!==void 0);if(e.length>1)return`Options ${e.join(`, `)} cannot be used together.`}return null}function Qn(e,t,n){let r=`${e} requires JSON body path(s): ${n.join(`, `)}`;return t.kind===`multipart`?`${r}. ${n.includes(`body`)?`For multipart --from-file, wrap the endpoint JSON under top-level "body".`:`For multipart --from-file, put the missing nested path(s) inside top-level "body".`}`:r}function $n(e,t){return I(t)?e.parameter.filter(e=>e.required&&!vn(t,e.name)).map(L):[]}function er(e,t,n){let r=xn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function tr(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await Vn(t);if(!n.ok)return x(n.summary,n.warnings);let r=_e.safeParse(n.data);return r.success?b(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function nr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=un(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=rr(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=mn(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function rr(e,t,n,r,i){let a=fn(r,i);if(a===null){let e=or(r,i);return e.ok?on(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=pn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=sr(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=sn(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function ir(e,t,n,r){if(n===void 0)return b(`Direct body parsed`,r);if(r===void 0)return b(`Input parsed`,n);if(I(n)&&I(r))try{return b(`Input parsed`,ar(t,n,r))}catch(t){return x(`${e} ${t instanceof Error?t.message:String(t)}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ar(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ar(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:Le.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function or(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return sr(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=sr(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function sr(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function cr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=an(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function lr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Un,location:`body`}),ur(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Mn(e.options,r)}function ur(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function dr(e,t){let n=t.data,r=`jobId`,i=`statusUrl`,a=t.rolloverJob?.jobId??(typeof n==`object`&&n&&r in n&&typeof n[r]==`string`?n[r]:void 0),o=t.rolloverJob?.statusUrl??t.headers.location??(typeof n==`object`&&n&&i in n&&typeof n[i]==`string`?n[i]:void 0),s=t.headers[`retry-after`],c=`Pending: ${e.operationId??`request`}${a===void 0?``:` job ${a}`} is still running.`+(s===void 0?``:` Retry-After: ${s}.`)+(o===void 0?``:` Poll GET ${o} for the result.`);return{...e,summary:c,warnings:[...e.warnings,c],ids:a===void 0?e.ids:[...new Set([...e.ids,a])],references:o===void 0?e.references:[...new Set([...e.references,o])]}}function fr(e){let t=ve(e,hr(e));return xr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function pr(e){let t=ve(e,hr(e));xr(t);let n=De(E,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=mr(t);r.push(n.endsWith(`
2
2
  `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(le(r.join(`
3
3
  `),{appendNewline:!0,preservedTrailerLines:e.length}));return}let i=t.ok?`OK`:`FAIL`;r.push(`[${i}] ${t.summary}`),!t.ok&&t.problem!==void 0&&r.push(..._r(t.problem)),r.push(...mr(t)),process.stdout.write(le(r.join(`
4
4
  `),{appendNewline:!0}))}function mr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function R(e,t){let n=Te(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?ve(n,hr(n)):n;xr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?we(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?fr(n):n;e.mode===`text`&&pr(r),r.ok||(process.exitCode=1)}function hr(e){let t=Me(e,E);if(t.write===!0||!e.ok)return t;let n=Ie(e,E);return n===void 0?t:{...t,exactRecovery:`Inline output is truncated. ${n}`}}function gr(e,t){if(typeof t==`object`&&t&&`httpStatus`in t&&t.httpStatus===202)return;let n=Fe(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
@@ -27,7 +27,7 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{_ as a
27
27
  `)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>R({mode:D(e)},oo(void 0,`apply`,e.release)))}function oo(e,t=`apply`,n){let r=e;try{r??=S(process.argv[1])}catch(e){return x(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,o=r.registry===``?``:ye,s=r.registry===``&&i===`@aventurevc/aventure-cli`,c=n;if(c===void 0){let e=so([`view`,o,`version`,`--silent`,`--global`],r,{timeout:ro});if(!e.ok)return{...e,data:null};if(c=(e.data??``).trim(),c===``)return x(`npm view ${o} returned empty version`,[`empty_stdout`])}let l=n!==void 0||s||no.compare(a,c)<0,u={targetPackage:o,runningPackage:i,currentVersion:a,latestVersion:c,upgradeAvailable:l,upgradeInstalled:!1};if(t===`check`)return b(`${i}@${a} → ${o}@${c} (${l?`available`:`up to date`})`,u);if(r.workingTreeRoot!==null)return x(`Refusing to install over the working-tree build at ${r.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);try{let e=uo(r),t=j(e,...io),i=k(o),s=j(t,`${i}-current`),l=o===``?[o,``]:[o,be],d=fo(e,r),f=n??[c,d?.version??a].reduce((e,t)=>no.compare(e,t)<0?t:e,a);Ft(t,{recursive:!0});let p=[lo(r),...M(s)?[Bt(s)]:[],...Rt(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>j(t,e.name))],m,h=null,g=!1;for(let t of new Set(p.filter(t=>t!==e))){let e=co(t,l,f,r.registry);if(e.ok&&e.data!==null){m=t,h=e.data;break}}if(m===void 0){m=It(j(t,`${i}-${encodeURIComponent(f)}-`));let e=so([`install`,`-g`,`--prefix`,m,...l.map(e=>`${e}@${f}`)],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,data:null};g=!0;let n=co(m,l,f,r.registry);if(!n.ok)return{...n,data:null};h=n.data}if(h===null)throw Error(`release verification produced no package`);let ee=po(m,e,s,h,n),te=ho();return b(`${o} active at ${ee}`,{...u,upgradeInstalled:g||n!==void 0||d?.version!==ee,installPrefix:e,verifiedVersion:ee,completionRefreshed:te.refreshed,completionRefreshMessage:te.message})}catch(e){return x(`${o} update failed: ${mo(e)}`,[`existing releases were preserved`])}}function so(e,t,n={}){let r={...process.env};t.registry===``?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let i=[...e,`--@aventurevc:registry=${t.registry}`],a=At(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?x(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):x(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
28
28
  `).slice(-3).join(` | `);return x(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return b(`npm ok`,a.stdout??``)}function co(e,t,n,r){try{let i=t.map(t=>{let i=S(j(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));if(i.name!==t||i.version!==n||i.registry!==r)throw Error(`${t} does not match ${n} from ${r}`);for(let t of i.bin)if(!Bt(j(e,`bin`,t)).startsWith(`${i.packageRoot}${Mt}`))throw Error(`${t} escapes ${i.packageRoot}`);return i});for(let t of i){let r=j(e,`bin`,t.bin[0]),i=At(process.execPath,[r,`--version`],{encoding:`utf8`,timeout:ro});if(i.error)throw Error(`${t.name} verification failed: ${i.error.message}`);let a=(i.stdout??``).trim();if(i.status!==0||a!==n)throw Error(`${t.name} expected ${n} but reported ${a||`empty output`}`)}return b(`CLI and MCP release verified`,i)}catch(t){return x(`release verification failed: ${mo(t)}`,[`release prefix: ${e}`])}}function lo(e){let t=A(e.packageRoot),n=A(t),r=A(n);if(k(t)!==e.name.split(`/`)[0]||k(n)!==`node_modules`||k(r)!==`lib`)throw Error(`the running package is not in a verifiable global npm prefix; npm install was not run`);if(!e.entryPath.startsWith(`${e.packageRoot}${Mt}`))throw Error(`the running entry escapes its package root`);return A(r)}function uo(e){let t=lo(e),n=`${Mt}${io.join(Mt)}${Mt}`,r=t.lastIndexOf(n);return r<0?t:t.slice(0,r)}function fo(e,t){let n=t.registry===``?k(``):xe,r=j(e,`bin`,n);if(!M(r))return null;let i=S(r);if(i.registry!==t.registry)throw Error(`${r} belongs to another product`);return i}function po(e,t,n,r,i){let a=r[0];if(a===void 0)throw Error(`release contains no CLI`);let o=j(t,`bin`);Ft(o,{recursive:!0});let s=r.flatMap(e=>e.bin.filter((e,t)=>{let n=j(o,e);if(!M(n)||S(n).registry===a.registry)return!0;if(a.registry!==``&&t>0)return!1;throw Error(`${n} belongs to another product`)}));if(!M(n)){let t=It(j(A(n),`${k(n)}-seed-`));Ft(j(t,`bin`));for(let n of s){let r=j(o,n);Ht(Bt(M(r)?r:j(e,`bin`,n)),j(t,`bin`,n))}try{Ht(jt(A(n),t),n)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`EEXIST`))throw e}}if(!Pt(n).isSymbolicLink())throw Error(`${n} is not a release symlink`);for(let e of s){let t=jt(o,j(n,`bin`,e)),r=j(o,`.${e}-${Qt()}`);Ht(t,r),Vt(r,j(o,e))}for(let e of s){let t=j(o,e);if(!Pt(t).isSymbolicLink()||j(o,zt(t))!==j(n,`bin`,e))throw Error(`${t} does not follow the product current pointer`)}let c=fo(t,a);if(i===void 0&&c!==null&&no.compare(c.version,a.version)>0)return c.version;let l=`${n}-${Qt()}`;return Ht(jt(A(n),e),l),Vt(l,n),a.version}function mo(e){return e instanceof Error?e.message:String(e)}function ho(){try{return Ba()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var go=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers`},{name:`auth`,purpose:`which credential signs in, as which account and role, never secrets`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}];function _o(e,t=S().bin[0]){O(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",...go.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable) or a`,`warned one (the account read failed) does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
29
29
  `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),R({mode:D(e)},await vo(t))})}async function vo(e){let t=bo(),n=xo(e),[r,i]=await Promise.all([So(e),Co(t,e)]),a=[n.check,r,i.check,await To(e),Mo(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:yo(a,`pass`),warn:yo(a,`warn`),fail:yo(a,`fail`),skip:yo(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.warn} warn, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
30
- `);return c.ok?b(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function yo(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function bo(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function xo(e){let t=S(),n=oo(t,`check`);if(!n.ok||n.data===null)return{check:K(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function So(e){try{let{EntityDetailSchema:e}=await import(`./detail-KtYIbiXI.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return K(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return K(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${w(t)}.`)}}async function Co(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:K(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${w(e)}.`),servedFingerprint:null}}let i=await de({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>x(w(e)));return i.ok?{check:K(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:wo(i.data)}:{check:K(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function wo(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function To(e){let t=Ye(),[n,r]=await Promise.all([Do(),Oo()]);if(r.state===`unavailable`&&r.cause===`environment`)return K(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return K(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&ot(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return K(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${o.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await Eo(e,t);return K(`auth`,i.status,`Credential source available: ${ko(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${o.authToken} through the environment — ${r.summary}.`):K(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${o.authToken} in the environment.`)}async function Eo(e,t){let n=T(f().host),r=await la(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await ca(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${w(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function Do(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e)}}return await ft(e)}async function Oo(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e),cause:`environment`}}try{return await et(e)}catch(e){return{state:`unavailable`,summary:w(e),cause:`storage`}}}function ko(e,t,n){return[Ma(e),`oauth=${jo(t)}`,`api-key=${Ao(n)}`].join(` `)}function Ao(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=T(f().host);return`${e.stored.activation}${_a(t,e)}`}function jo(e){switch(e.state){case`found`:return ot(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function Mo(e,t,n,r){let i=E.length;if(e===void 0)return K(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return K(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ot}.`);if(t===`00e46a6dabbc62cc`)return K(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ot}).`);let a=`This catalog describes a different operation set than the API serves (${Ot} vs ${t})`;return n===!0?K(`catalog`,`fail`,`${a}: run \`${r} update\`.`):K(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var No=C(B,`oauth`),Po=[C(B,`start`),C(B,`poll`),C(B,`acknowledge`)],Fo=C(B,`revoke`);function Io(e,n=S().bin[0]){let r=Bo(e);_o(r,n);let i=[`${No.description} Default method: OAuth in your browser.`,`With --key: ${Po.map(({description:e})=>e).join(` `)}`].join(`
30
+ `);return c.ok?b(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function yo(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function bo(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function xo(e){let t=S(),n=oo(t,`check`);if(!n.ok||n.data===null)return{check:K(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function So(e){try{let{EntityDetailSchema:e}=await import(`./detail-jqEwPPHS.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return K(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return K(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${w(t)}.`)}}async function Co(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:K(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${w(e)}.`),servedFingerprint:null}}let i=await de({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>x(w(e)));return i.ok?{check:K(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:wo(i.data)}:{check:K(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function wo(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function To(e){let t=Ye(),[n,r]=await Promise.all([Do(),Oo()]);if(r.state===`unavailable`&&r.cause===`environment`)return K(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return K(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&ot(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return K(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${o.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await Eo(e,t);return K(`auth`,i.status,`Credential source available: ${ko(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${o.authToken} through the environment — ${r.summary}.`):K(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${o.authToken} in the environment.`)}async function Eo(e,t){let n=T(f().host),r=await la(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await ca(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${w(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function Do(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e)}}return await ft(e)}async function Oo(){let e;try{e=T(f().host)}catch(e){return{state:`unavailable`,summary:w(e),cause:`environment`}}try{return await et(e)}catch(e){return{state:`unavailable`,summary:w(e),cause:`storage`}}}function ko(e,t,n){return[Ma(e),`oauth=${jo(t)}`,`api-key=${Ao(n)}`].join(` `)}function Ao(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=T(f().host);return`${e.stored.activation}${_a(t,e)}`}function jo(e){switch(e.state){case`found`:return ot(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function Mo(e,t,n,r){let i=E.length;if(e===void 0)return K(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return K(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ot}.`);if(t===`00e46a6dabbc62cc`)return K(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ot}).`);let a=`This catalog describes a different operation set than the API serves (${Ot} vs ${t})`;return n===!0?K(`catalog`,`fail`,`${a}: run \`${r} update\`.`):K(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var No=C(B,`oauth`),Po=[C(B,`start`),C(B,`poll`),C(B,`acknowledge`)],Fo=C(B,`revoke`);function Io(e,n=S().bin[0]){let r=Bo(e);_o(r,n);let i=[`${No.description} Default method: OAuth in your browser.`,`With --key: ${Po.map(({description:e})=>e).join(` `)}`].join(`
31
31
  `);O(zo(r,[No,...Po],i)).action(Lo),O(zo(r,[Fo],Fo.description)).action(Ro),O(r.command(`status`).summary(`Keep saved credentials current and report them`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
32
32
  `)).addOption(new t(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Vo(this),R({mode:D(e)},await Ho(n,e.verify))}),r.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${o.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
33
33
  `)).action(async function(){Vo(this);let e=await la(n),t=process.env[o.authToken]?.trim();if(e.failure===null&&t!==void 0&&t.length>0){process.stdout.write(`${t}\n`);return}R({mode:`text`},e.failure===null?Xo(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):x(`auth token: ${e.failure}`))})}async function Lo(e){Vo(this);let t=D(e);if(e.providers===!0){R({mode:t},await Wo());return}R({mode:t},e.key===!0?await Qi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await gt({noBrowser:!e.browser}))}async function Ro(e){Vo(this),R({mode:D(e)},await Vi({forgetLocal:e.forgetLocal===!0}))}function zo(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Bo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${No.command}\`: ${No.summary}; \`--key\` ${Po[0].summary.toLowerCase()}.`,`\`${Fo.command}\`: ${Fo.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build metadata.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
@@ -56,7 +56,7 @@ end
56
56
  (Did you mean `))return;let r=Ws(e),i=process.argv.slice(2+Y(e).length);if(r.length>0&&r.every((e,t)=>i[t]===e)){let t=Gs(e,r);if(t!==void 0)return t}let a=Y(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Js(o)?o:void 0)??Hs(e,n)??Us(e,n);if(s!==void 0)return Ks(e,s,r)??ec(e,s.join(` `),!1);let c=r.join(` `)||n,l=qs(e)??ec(e,c),u=[...a,...r.slice(1)];return[l,r.length===a.length+a.length&&a.at(-1)===a.at(0)?Ks(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Ks(e,u,r):void 0].filter(e=>e!==void 0).join(`
57
57
  `)||void 0}function rc(e){return t=>{if(t.code===`commander.missingMandatoryOptionValue`){let n=e.options.filter(t=>t.mandatory&&e.getOptionValue(t.attributeName())===void 0);if(n.length>1){let e=n.map(e=>e.flags.split(`, `).at(-1)??e.flags);process.stderr.write(`error: missing required options: ${e.join(`, `)}\n`)}let r=Ps(e);for(let e of r)process.stderr.write(`error: unknown option '${e}'\n`);for(let n of[Fs(e)??(r.length>0?tc(e):void 0),Os(e),Ms(e,t),...Xs(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Os(e)??Zs(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=js(t,`unknown option`),r=Fs(e)??Bs(e,t)??(n!==void 0&&!t.message.includes(`
58
58
  (Did you mean `)?$s(e,n)??Gs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??tc(e,n)??ec(e,Y(e).slice(1).join(` `)||n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=nc(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.helpDisplayed`){let[n]=e.args;if(n?.startsWith(`-`)===!1&&e.registeredArguments.length===0){let r=[X(e).name(),...Y(e)].join(` `);t.exitCode=1,process.stderr.write(`hint: ${r} takes no '${n}' subcommand; the help shown is for ${r}\n`)}}throw t}}var ic=class extends t{group;constructor(e){super(`-h, --help`,`display help for command`),this.group=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.group.args.at(0);return t===void 0||t.startsWith(`-`)?!0:this.group.commands.some(e=>e.name()===t||e.aliases().includes(t))}};function ac(e){e.showHelpAfterError(!1).exitOverride(rc(e)),e.commands.length===0?e.hook(`preAction`,Ds):e.registeredArguments.length===0&&!Ys(Y(e))&&e.addHelpOption(new ic(e));for(let t of e.commands)ac(t)}function oc(e,t=new Date){let n=lc(e);return{schemaVersion:1,generatedFrom:`MCP_GENERATION_CONTRACT`,generatedAt:t.toISOString(),totalOperations:n.length,note:`Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.`,operations:n}}function sc(e){return`${JSON.stringify(e,null,2)}\n`}function cc(e,t){let n=j(e),r=sc(t);return Ft(A(n),{recursive:!0}),Ut(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function lc(e){return e.map(e=>({operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliCommand:e.projection.cliPath.join(` `),cliPath:e.projection.cliPath,mcpTool:ee(e.intent),bodySchemaName:e.requestBody?.[0]?.schemaName??null,bodySchemaImport:e.requestBody?.[0]?.schemaImport??null,auth:e.projection.auth,scope:e.projection.scope,destructive:e.projection.destructive})).toSorted((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method)||e.operationId.localeCompare(t.operationId))}var uc=`Match only the first canonical or CLI-alias command segment`,dc=[`text`,`lines`,`compact`,`json`,`ndjson`];function fc(e,t,n=S().bin[0]){let r=e.command(`command-catalog`).summary(`LLM agent only: search generated CLI metadata`).description([`LLM agent only: search and dump generated ${n} command metadata.`,`This is read-only command metadata derived from the generated OpenAPI command specs.`,`Use --format lines for rg/grep/ag/ack and --format ndjson|json for ast-grep/sg/parsers.`,"Use --format compact for one `cli · summary · requiredFlags` row per operation."].join(`
59
- `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Fr(n)}\n`),pc(r,t,n),mc(r,t,n),hc(r,t,n),gc(r)}function pc(e,n,r){let i=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(e){let t=this.optsWithGlobals(),i=D(t,`text`),a=Lr(t,e);Rr(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function mc(e,n,r){let i=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();zr(e,n,D(e,`text`),r)})}function hc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();Rr(e,n,D(e,`text`),r)})}function gc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);O(t),t.action(async function(){let e=this.optsWithGlobals(),t=D(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-bL1nV_K6.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},b(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=oc(n);if(e.output!==void 0){let n=cc(e.output,r);R({mode:t},b(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){Vr(`Unified operations JSON`,sc(r));return}R({mode:t},b(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var _c=S(Xt(import.meta.url)),Q=_c.bin[0];function vc(e,t){let n=e instanceof Error?e:Error(String(e));c({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof ge?{httpStatus:n.problem.status,problem:n.problem}:{};fr({...x(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function yc(e){return Ge[Ve(e,vt)??`cli`]}function bc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:yc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>Et(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)xc(e,t,r,a,i.has(t.cliPath.join(` `)))}function xc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=Sc(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>m(e.schemaType,e.itemSchemaType))?te:``].filter(Boolean).join(`
59
+ `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Fr(n)}\n`),pc(r,t,n),mc(r,t,n),hc(r,t,n),gc(r)}function pc(e,n,r){let i=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(e){let t=this.optsWithGlobals(),i=D(t,`text`),a=Lr(t,e);Rr(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function mc(e,n,r){let i=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();zr(e,n,D(e,`text`),r)})}function hc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,uc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(dc)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();Rr(e,n,D(e,`text`),r)})}function gc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);O(t),t.action(async function(){let e=this.optsWithGlobals(),t=D(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-N93eBv4f.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},b(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=oc(n);if(e.output!==void 0){let n=cc(e.output,r);R({mode:t},b(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){Vr(`Unified operations JSON`,sc(r));return}R({mode:t},b(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var _c=S(Xt(import.meta.url)),Q=_c.bin[0];function vc(e,t){let n=e instanceof Error?e:Error(String(e));c({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof ge?{httpStatus:n.problem.status,problem:n.problem}:{};fr({...x(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function yc(e){return Ge[Ve(e,vt)??`cli`]}function bc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:yc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>Et(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)xc(e,t,r,a,i.has(t.cliPath.join(` `)))}function xc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=Sc(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>m(e.schemaType,e.itemSchemaType))?te:``].filter(Boolean).join(`
60
60
  `));let f=Dt(t);for(let e of t.parameters)Cc(u,e,i||e===f);if(Wn(u,t),g(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),O(u),u.hook(`preAction`,e=>St(e,t)),t.explain===!0&&u.option(`--explain`,`Print the search strategy and parsed constraints before the results`),f!==void 0){u.argument(`[text...]`,f.description||`Same as ${Tt(f.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),r=D(n),i=bt(f,e,n);if(!i.ok||i.data===null)return R({mode:r},i);let a=yt(t,i.data);if(a.length>0)return R({mode:r},x(`missing required options: ${a.join(`, `)}`));let o=await wc(t,i.data,r),s=li(t,i.data,o);if(s!==null)return R({mode:r},s);n.explain===!0&&o.ok&&gr(r,o.data),o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):R({mode:r},o)});return}u.action(async function(){let e=this.optsWithGlobals(),n=D(e),r=yt(t,e);if(r.length>0)return R({mode:n},x(`missing required options: ${r.join(`, `)}`));let i=await wc(t,e,n),a=li(t,e,i);if(a!==null)return R({mode:n},a);e.explain===!0&&i.ok&&gr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):R({mode:n},i)})}function Sc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=vt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function Cc(e,n,r=!1){let i=n.description||`${n.name} ${n.location} parameter`,a=n.defaultValue===void 0?void 0:typeof n.defaultValue==`string`||typeof n.defaultValue==`boolean`?n.defaultValue:[...n.defaultValue];if(n.legacyFlag!==void 0){let o=new t(n.flag,i);a!==void 0&&o.default(a);let s=new t(n.legacyFlag,i).conflicts(n.optionKey);e.addOption(o).addOption(s),e.hook(`preAction`,e=>{let t=e.opts(),i=t[n.optionKey],a=t[s.attributeName()];if(a!==void 0){(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`);return}!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(a!==void 0){e.option(n.flag,i,a);return}if(n.required&&!r){e.requiredOption(n.flag,i);return}e.option(n.flag,i)}async function wc(e,t,n){if(t.environment!==void 0){let e=d(t.environment);if(e===null)return x(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${a().join(`, `)}`]);process.env.API_ENV=e}let r=await Yn(e,t);if(!r.ok)return r;let i=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let n=t[e.optionKey];if(Array.isArray(n))return[e.name,n.at(0)??``];if(n===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(n)]})),o=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let n=t[e.optionKey];if(n===void 0||Array.isArray(n)&&n.length===0)return[];let r=Array.isArray(n)||typeof n==`boolean`?n:String(n);return[[e.name,r]]})),s=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let n=t[e.optionKey];return n===void 0||Array.isArray(n)&&n.length===0?[]:[[e.name,Array.isArray(n)?n.join(`,`):String(n)]]}));return di(e,await de({method:e.method,path:ce(e.operationId,i),searchParams:o,headers:s,body:r.data,contentType:wt(e,t),auth:e.auth,responseFormat:kt(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0,pendingResult:dr}))}process.on(`uncaughtException`,e=>vc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>vc(e,`unhandledRejection`));var Tc=Ct(process.argv.slice(2),E),Ec=Tc===`required`?E:xt(E),$=new Es;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(ei).version(_c.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description([`The aVenture research API from your terminal. Three records — companies,`,`people, and news — carry everything else: funding, publications, and tags.
61
61
  `,`Mutations execute directly; --execute is a deprecated no-op.
62
62
  The aVenture MCP server tools execute through this same CLI.`].join(`
@@ -1,16 +1,16 @@
1
- import{n as e}from"./commander-BB7CDPLs.js";import{c as t,f as n,i as r,l as i,m as a,n as o,o as s,s as c,u as l,w as u}from"./tool-policy-BUHiyuYu.js";import{C as d,O as f,T as p,i as m,l as h,n as g,o as _,p as v,t as ee,u as y,v as b,w as x,y as S}from"./person-owner-BJgNYLKX.js";import{Br as te,Gr as ne,Hr as re,Ur as ie,Vr as ae,Wr as oe,Yr as se,zr as ce}from"./dist-2SvD7GNW.js";import{c as le,f as ue,i as de,r as C}from"./result-envelope-Bl_1n5Tb.js";import{a as fe}from"./package-DPDX5zmx.js";import{a as w,c as pe,i as me,l as he,n as T,r as ge,s as E,t as _e}from"./text-field-jFKOGMzr.js";import{A as ve,C as ye,D as be,E as xe,O as Se,S as Ce,T as D,_ as we,a as Te,b as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,j as Ne,k as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue,v as We,w as Ge,x as Ke,y as qe}from"./detail-BqdugX6O.js";import{a as Je,o as Ye}from"./cli-help-policy-BIiQwYpQ.js";import{Buffer as Xe}from"node:buffer";var O=_([`HIGH`,`MEDIUM`,`LOW`]),Ze=_([`PAID_PLAN`,`DAILY_ALLOWANCE`]),Qe=_([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),$e=Object.assign(p([Qe,x()]),{enum:Qe.enum}),et=S({billingAccess:Ze.nullish(),excerpt:x(),sourceId:x(),sourceType:$e,sourceVersion:x().nullish()}),tt=S({instruction:x(),operationId:x(),planTaskKey:h(x()).optional(),stepKey:x().optional()}),nt=S({body:x(),expectation:x(),method:h(x()),override:x(),reject:h(x()),typeCatalog:x()}),rt=S({cliCommand:x(),mcpTool:x().nullish(),step:tt,writeGuidance:nt.nullish()}),it=_([`ENTITY`,`TEXT`,`WRITER_BRIEF`]),at=Object.assign(p([it,x()]),{enum:it.enum}),ot=S({allowedValue:x().nullish(),description:x(),key:x(),required:y().default(!0).optional(),type:at}),st=S({catalogRevision:v().optional(),gateId:h(x()).optional(),input:h(ot),step:h(rt),taskKey:x().optional()}),k=_([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),ct=S({candidate:h(et),operationId:x().nullish(),outcome:k,probability:b().nullish(),taskKey:x().nullish(),taskPlan:st.nullish()}),lt=S({answer:x(),citation:h(et),confidence:O,resolution:ct.nullish()});function A(e,t,n=t.inputName){if(t.in===`body`)return n;let r=xt.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?bt(_t(n!==`id`&&n!==`slug`?n:`${pt(e.path)}${gt(n)}`),t):r.inputName}function ut(e,t,n=ht(e)){return dt(mt(e,t),new Set(n))}function dt(e,t){if(!t.has(e))return e;let n=`body${gt(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function ft(e,t,n){return`${e}[${t}].${n}`}function pt(e){return St.find(([,t])=>t.test(e))?.[0]??`record`}function mt(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=vt(t);return bt(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?_t(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ht(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>A(e,t)))}function gt(e){return e.replace(/^./u,e=>e.toUpperCase())}function _t(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function vt(e){let t=_t(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?yt(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function yt(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function bt(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var xt=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],St=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];function Ct(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>wt(t,A(e,t))),r=(t?.parameter??[]).map(t=>wt(t,ut(e,t)));return{selector:n.filter(e=>e.location===`path`||Tt(e)),pagination:n.filter(Et),filter:[...n.filter(Dt),...r.filter(Dt)],body:r.filter(e=>!Dt(e))}}function wt(e,t){let{in:n,inputName:r,...i}=e;return{...i,flag:s(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function Tt(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function Et(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function Dt(e){return e.location!==`path`&&!Tt(e)&&!Et(e)}function Ot(e){return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,scope:e.projection.scope,requiredInput:Mt(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]}}function kt(e,t){let n=e.requestBody?.[0],r=Ot(e),i=Pt(e);return t?{...r,...i===void 0?{}:{paidPlan:i},resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:Ct(e)}:{...r,optionalInput:Nt(e),arrayInput:Ft(e),...i===void 0?{}:{paidPlan:i}}}function At(e){let t=Ct(e),n=e=>e.filter(e=>e.required);return{...kt(e,!1),optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function jt(e){let{cli:t,scope:n,...r}=Ot(e),i=Pt(e);return{...r,...i===void 0?{}:{paidPlan:i},optionalDetailOmitted:!0}}function Mt(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Nt(e){let t=e.requestBody?.[0],n=new Set(t?.requiredPath??[]);return{query:e.parameter.filter(e=>e.in===`query`&&!e.required).map(({name:e})=>e),body:(t?.parameter??[]).filter(({name:e})=>!n.has(e)).map(({name:e})=>e)}}function Pt(e){return e.response.find(({status:e})=>e===`402`)?.description}function Ft(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var It=160,j=`Operation catalog matches`,Lt=[`whole`,`described`,`requiredDescribed`,`optionalNamed`],Rt=e=>`${[j,...e].join(`
2
- `)}\n`;function zt(e,t=[]){if(!Array.isArray(e)||e.length===0||!e.every(Wt))return null;let n=e,r=e=>re([j,...e,...t]);for(let e of Lt){let t=[...n.flatMap(t=>Ht(t,e)),...Vt(n,e)];if(r(t))return Rt(t)}let i=e=>[...n.slice(0,e).flatMap(e=>Ht(e,`optionalNamed`)),...Vt(n.slice(0,e),`optionalNamed`),`... ${n.length-e} more operations omitted to fit ${ce} UTF-8 bytes: ${n.slice(e).map(({operationId:e})=>e).join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`];return Rt(i([...n.keys()].findLast(e=>e>0&&r(i(e)))??1))}var Bt=`call aventure_help with q=<operationId> and limit=1; inspect structuredContent.data argument and optionalInput for the retained inputs`;function Vt(e,t){let n=e.flatMap(e=>`argument`in e?Object.values(e.argument).flat():[]),r=t===`whole`?0:n.filter(e=>e.description.length>It&&(t===`described`||e.required)).length,i=r===0?[]:[`... ${r} argument descriptions shortened; inspect structuredContent.data[].argument for full descriptions.`];if(e.some(e=>`optionalDetailOmitted`in e))return[...i,e.some(e=>`argument`in e)?`... optional argument details omitted: the full list exceeds the result cap; ${Bt}.`:`... optional inputs omitted: the full list exceeds the result cap; call aventure_help with q=<operationId> and limit=1 to read one operation's inputs.`];if(t===`whole`||!e.some(e=>`argument`in e))return[];if(t===`described`)return i;let a=t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`,o=n.filter(({required:e})=>!e).length;return[...i,`... ${o} ${a} omitted to fit ${ce} UTF-8 bytes; structuredContent carries them, and ${Bt}.`]}function Ht(e,t){let n=`argument`in e?Object.values(e.argument).flat():[],r=n.filter(({required:e})=>!e).map(({name:e})=>e);return[`${e.operationId} ${e.method} ${e.path} (aventure_${e.intent})`,` ${e.summary}`,` required: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}`,` responseContentType: ${e.responseContentType.length===0?`none`:e.responseContentType.join(`, `)}`,...`optionalInput`in e?Object.entries(e.optionalInput).filter(([,e])=>e.length>0).map(([e,t])=>` optional ${e}: ${t.join(`, `)}`):[],...`arrayInput`in e&&e.arrayInput.length>0?[` JSON array inputs: ${e.arrayInput.join(`, `)}`]:[],...`paidPlan`in e&&e.paidPlan!==void 0?[` paid plan: ${e.paidPlan}`]:[],...n.filter(({required:e})=>e||t!==`optionalNamed`).map(e=>Ut(e,e.required||t!==`requiredDescribed`,t)),...t===`optionalNamed`&&r.length>0?[` optional inputs: ${r.join(`, `)}`]:[]]}function Ut(e,t,n){let r=[e.location,e.required?`required`:void 0,e.schemaType,e.schemaFormat,e.schemaEnum===void 0?void 0:`choices: ${e.schemaEnum.join(`, `)}`,e.itemSchemaEnum===void 0?void 0:`item choices: ${e.itemSchemaEnum.join(`, `)}`,e.schemaDefault===void 0?void 0:`default: ${JSON.stringify(e.schemaDefault)}`,e.itemSchemaType===void 0?void 0:`items: ${e.itemSchemaType}${e.itemSchemaFormat===void 0?``:` (${e.itemSchemaFormat})`}`].filter(e=>e!==void 0).join(`, `),i=` ${e.name} (${r})`;return t?`${i}: ${n===`whole`||e.description.length<=It?e.description:`${e.description.slice(0,157)}...`}`:i}function Wt(e){return typeof e==`object`&&!!e&&`operationId`in e&&typeof e.operationId==`string`&&`requiredInput`in e&&Array.isArray(e.requiredInput)&&`intent`in e&&`summary`in e}function Gt(e){let t=t=>{let n=(`parameter`in e?e.parameter:e.parameters.map(e=>({...e,in:e.location,schemaDefault:e.defaultValue}))).filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map(({name:e})=>[e,`<${e}>`]);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`);return{tool:i(e.intent),arguments:{operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Kt(e.requestBody[0]?.requiredPath??[])}}}}function Kt(e){let t={},n=e.filter(t=>!e.some(e=>e.startsWith(`${t}.`)||e.startsWith(`${t}[]`)));for(let e of n){let n=e.split(`.`),r=n.slice(0,-1).reduce(qt,t);r[n.at(-1)??e]=`<${e}>`}return t}function qt(e,t){let n=t.replace(/\[\]$/u,``),r=e[n],i=Array.isArray(r)?r[0]:r;if(typeof i==`object`&&i&&!Array.isArray(i))return i;let a={};return e[n]=t.endsWith(`[]`)?[a]:a,a}function Jt(e){let t=Pt(e);return{mcpCall:Gt(e),...t===void 0?{}:{paidPlan:t}}}function Yt(e){let t=Xt(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function Xt(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}var M=2,Zt=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`));function N(e,t){let n=I(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&N(e,`person`),en(e,Qt(n),n),en(e,$t(n),n))}function Qt(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=M&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;let n=e.endsWith(`es`)?e.slice(0,-2):``;if(n.length>=M&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n))return n;if(e.length>M&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function $t(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=M&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=M&&e.endsWith(`es`)))return e.length>=M&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function en(e,t,n){t!==void 0&&t!==n&&t.length>=M&&/^[a-z]+$/u.test(t)&&e.add(t)}function P(e){let t=new Set(F(e)),n=Array.from(t);for(let e of n)N(t,e);return t}function tn(e){return F(e).map(P)}function nn(e,t){if(e.length===0)return!1;let n=P(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function F(e){return I(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!Zt.has(e))}function I(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}var rn=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,an=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,on=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,sn=250,cn=40,ln=100;function un(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(an,()=>(n.add(`uuid`),` `)).replace(rn,e=>{n.add(`url`);let t=e.replace(/^(?:https?:\/\/)?[^/]+/iu,``).replace(/[?#].*$/su,``).split(`/`).filter(e=>e.length>0).map(e=>e.toLowerCase()),i=t.at(-1);return i!==void 0&&on.test(i)&&(n.add(`slug`),t.pop()),r.push(...t.flatMap(e=>e.split(/[^a-z0-9]+/u))),` `}).split(/\s+/u).filter(e=>{let r=e.replace(/^[^a-z0-9]+|[^a-z0-9]+$/giu,``).toLowerCase(),a=on.test(r)&&!t.has(r)&&(i||/\d/u.test(r));return a&&n.add(`slug`),!a}).join(` `).trim(),kind:n,urlPathWord:r.filter(e=>e.length>0)}}function dn(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function fn(e,t){let n=new Set;for(let r of e){let e=new Set;N(e,r);let i=t.filter(({cliPath:t})=>e.has(t[0]??``)),a=i.length>0?i:t.filter(({cliPath:t})=>t.some(t=>e.has(t)));for(let{resource:e}of a)n.add(e)}return n}function pn(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(F(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>dn(t,e,n.path))&&(i+=sn,r.has(t)&&(i+=cn));if(i===0)return 0;let a=new Set(F(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return N(t,e),[...t].some(e=>a.has(e))}))&&(i+=ln),i}var mn=40,hn=4,gn=3,_n=1,vn=new Map;function yn(e){let t=vn.get(e);if(t!==void 0)return t;let n=se(),r=u(n.paths,e),i=r===null?new Map:a(n,r.operation.responses,gn);return vn.set(e,i),i}function bn(e,t,n){let r=0,i=new Map;for(let[e,a]of n){if(t.has(e.toLowerCase())&&(r+=mn*(4-a)/4),a>_n)continue;let n=new Set;for(let t of F(e))N(n,t);for(let e of n)i.set(e,Math.min(i.get(e)??a,a))}for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=_n&&(r+=hn*(2-e))}return r}var xn=5,Sn=.5,Cn=15,wn=30,Tn=2,En=100,Dn=.5;function On(e,t,n){let r=t.map(e=>({item:e,fields:n(e)})),i=un(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=fn(i.urlPathWord,r.map(({fields:e})=>e)),o=I(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=P(o),c=tn(o),l=new Set(i.text.toLowerCase().split(/[^a-z0-9]+/u));return r.map(({item:e,fields:t})=>({item:e,fields:t,score:(o.length===0?0:Mn({normalizedQuery:o,tokens:s,termForm:c,queryWord:l},t))+pn(i,a,t)})).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function kn(e){let t=e.requestBody??[],n=[...e.parameter,...t.flatMap(e=>e.parameter)];return{...e,cliPath:e.projection.cliPath,enumParameter:n.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:n.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...n,...t].map(({description:e})=>e),responseFieldLevel:yn(e.operationId)}}function An(e,t){let n=e.q?.trim()??``,r=On(n,t.filter(t=>jn(e,t)&&(n.length>0||t.deprecated!==!0)),kn),i=(r[0]?.score??0)*Sn,a=r.filter(({score:e})=>e>=i),o=e.limit===void 0||!Number.isFinite(e.limit)?xn:e.limit,s=Math.min(a.length,Math.max(0,Math.trunc(o))),c=a.slice(0,s).map(({item:e})=>e),l={totalOperations:t.length,matched:a.length,returned:c.length},u=c.length===1,d=c.map(e=>kt(e,u)),f=le(j,d,{counts:l}),p=de(f),m=u?c.map(At):c.map(jt);return{summary:j,data:p?d:m,counts:l}}function jn(e,t){let{root:n}=e;return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Mn({normalizedQuery:e,tokens:n,termForm:r,queryWord:i},a){let o=Rn(a),s=In(a),c=0;o.some(t=>t===e)&&(c+=100),o.some(t=>t.includes(e))&&(c+=40),c+=Ln(e,o);let l=new Set(o.flatMap(F)),u=new Set(s.flatMap(F));for(let e of n)o.some(t=>t===e)?c+=20:u.has(e)?c+=8:l.has(e)&&(c+=Tn);for(let e of a.cliPath){let t=new Set;N(t,e),[...t].some(e=>n.has(e))&&(c+=Cn)}nn(r,s)&&(c+=200),r.length>1&&s.some(t=>t.includes(e))&&(c+=En),a.parameterName.some(t=>I(t)===e)&&(c+=wn);let d=new Set(a.parameterDescription.flatMap(F));for(let e of n)d.has(e)&&(c+=Tn);return c+=Bn(n,a.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>n.has(e))&&/^(?:list|search)[A-Z]/u.test(a.operationId)&&(c+=30),c+=bn(r,i,a.responseFieldLevel),c-=zn(e,n,a.description),t(a.intent)&&!Fn(i)?c*Dn:c}var Nn=`edit change set fix rename link unlink mark publish correct`.split(` `),Pn=new Set([...Object.entries(o).filter(([,e])=>t(e)).map(([e])=>e),...Nn]);function Fn(e){return[...e].some(e=>Pn.has(e))}function In(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(I).filter(e=>e.length>0)}function Ln(e,t){let n=F(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Rn(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,(Xt(e.description).useFor||e.description).slice(0,240)].map(I).filter(e=>e.length>0))]}function zn(e,t,n){let r=I(Xt(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(F(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Bn(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>Vn(e,t))&&(n+=i?40:10);return n}function Vn(e,t){let n=F(t);return n.length>0&&n.every(t=>e.has(t))}function Hn(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function Un(e,t,n,r){let i=e.q?.trim()??``;if(i.length===0)return C(`Provide q to resolve a request to one operation.`);let a=n.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(a===void 0)return C(`This build ships no help resolve operation.`);let o=await r(a,{body:{question:i,resolve:!0,...e.scope===void 0?{}:{scope:e.scope===`read`?`READ`:`WRITE`}}});if(!o.ok)return{...o,data:null};let s=lt.safeParse(Hn(o));if(!s.success||s.data.resolution==null)return C(`The help resolve operation returned no resolution.`);let{answer:c,resolution:l}=s.data,u=e=>t.find(t=>t.operationId===e),d=u(l.operationId),f=l.taskPlan??void 0,p=(f?.step??[]).map(({step:e})=>({step:e,contract:u(e.operationId)})),m=[...new Set([...l.operationId!=null&&d===void 0?[l.operationId]:[],...p.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return m.some(e=>!n.some(t=>t.operationId===e))?C(`No operation on this connection answers that request.`):le(m.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${m.join(`, `)}.`,{outcome:l.outcome,probability:l.probability,answer:c,candidate:l.candidate.filter(({sourceId:e})=>n.some(({operationId:t})=>t===e)).map(({sourceId:e})=>{let t=u(e);return t===void 0?{sourceId:e}:Object.assign({sourceId:e},Jt(t))}),...d===void 0?{}:{operation:{operationId:d.operationId,apiRoute:`${d.method} ${d.path}`,...Yt(d),...Jt(d)}},...(l.taskKey,{}),...f===void 0?{}:{taskPlan:{input:f.input,step:p.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:Gt(e)})}}},{warnings:m.map(e=>n.some(t=>t.operationId===e)?`Operation ${e} is in this server's catalog, but your grant does not allow it.`:`Operation ${e} is outside this server's catalog, so no credential runs it here.`)})}var Wn=S({detail:x(),field:x().nullish(),scope:_([`entity`,`person`,`news`])}),Gn=_([`auto`,`exact`,`keyword`,`semantic`,`natural`,`hybrid`]),Kn=Object.assign(p([Gn,x()]),{enum:Gn.enum}),L=S({modeRequested:Kn,modeUsed:Kn}),qn=S({answerUnavailable:y(),entity:L,news:L,person:L,rejection:h(Wn),unavailable:h(_([`entity`,`person`,`news`]))}),Jn=S({acceleratorParticipation:h(Ae),detail:h(je)}),R=S({core:D,enrichment:xe,fundraiseRound:h(qe),provider:We.nullish(),research:Jn,semanticMatch:Re.nullish()}),Yn=_([`curated`,`semantic`,`precomputed`,`derived`,`computed`]),Xn=S({compositeScore:b().nullish(),cosineScore:b().nullish(),curatedAsOf:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),curatedRelationshipType:x().nullish(),curatedSource:x().nullish(),derivedFromEntityId:f().nullish(),matchedSectionWeight:b().nullish(),origin:Yn,rank:v(),sharedSectionCount:v().nullish()}),Zn=S({entity:R,similarity:Xn}),Qn=S({fundraiseInvestorJoin:y(),fundraiseTransaction:y(),operatingStatus:y(),relationship:y()}),$n=_([`Acquisition`,`Acquired`,`Acquired Subsidiary`]),er=_([`Announced`,`Announced; subject to approvals and closing conditions`,`Active`,`Closed`,`Completed`,`In Progress`,`Open`]),tr=S({acquiredEntity:D,acquirerEntity:D,amount:b().int().nullish(),announcedAt:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),asOf:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),completedAt:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),createdAt:m({offset:!0}).nullish(),currency:x().nullish(),dataConfidence:ye.nullish(),evidence:Qn,fundraiseTransactionId:f().nullish(),investorJoinId:f().nullish(),isCurrent:y().nullish(),publicSource:Ge.nullish(),relationshipId:v(),status:$n,transactionStatus:er.nullish(),updatedAt:m({offset:!0}).nullish()}),nr=S({amountInvested:b().nullish(),createdAt:m({offset:!0}),financialInstrumentType:Ce.nullish(),id:f(),investor:ee,leadInvestor:y(),transactionId:f(),updatedAt:m({offset:!0})}),rr=S({entity:He,investorAttribution:h(Ee),round:h(Ke),roundCount:v()}),ir=S({core:D,fundingDetail:Pe.nullish(),similarity:Xn,urlLink:h(be)}),ar=S({compliance:Ie.nullish(),createdAt:m({offset:!0}).nullish(),id:v(),isCurrent:y().nullish(),isPrimary:y().nullish(),language:x().nullish(),owner:ee,text:x(),textName:x().nullish(),textType:x(),updatedAt:m({offset:!0}).nullish()}),or=_([`stored`,`derivedFromPreAndRaised`,`derivedFromPostMinusRaised`,`reportedAssumedPost`]),sr=_([`fundraiseRound`,`researchDetail`]),cr=_([`preMoney`,`postMoney`,`reported`]),lr=S({amountRaised:b().int().nullish(),asOfDate:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/),confidence:Fe,currency:x(),declaredBasis:cr,derivation:or,detailId:v().nullish(),label:x().nullish(),source:sr,sourceRef:x(),valuationPostMoney:b().int().nullish(),valuationPreMoney:b().int().nullish()}),ur=S({createdAt:m({offset:!0}).nullish(),description:x().nullish(),forkCount:v(),githubId:b().int(),homepageUrl:x().nullish(),id:b().int(),isArchived:y(),isFork:y(),language:x().nullish(),license:x().nullish(),name:x(),ownerLogin:x(),repoCreatedAt:m({offset:!0}).nullish(),repoPushedAt:m({offset:!0}).nullish(),stargazerCount:v(),topic:h(x()),updatedAt:m({offset:!0}).nullish(),url:x()}),z=S({empty:y().optional(),sorted:y().optional(),unsorted:y().optional()}),B=S({offset:b().int().optional(),paged:y().optional(),pageNumber:v().optional(),pageSize:v().optional(),sort:z.optional(),unpaged:y().optional()}),dr=S({investorAttribution:h(Ee),person:Be,round:h(Ke),roundCount:v()}),fr=_([`by`,`about`]),pr=_([`newsArticle`,`blogPost`,`externalSocialPost`,`repositoryOwner`,`repository`,`webSite`,`webPage`,`researchPaper`]),mr=S({canonicalUrl:x().nullish(),contentId:x(),contentType:pr,createdAt:m({offset:!0}).nullish(),publishedAt:m({offset:!0}).nullish(),relation:fr.nullish(),sourceDomain:x().nullish(),sourceName:x().nullish(),summary:x().nullish(),title:x(),topic:x().nullish(),updatedAt:m({offset:!0}).nullish(),url:x().nullish(),year:v().nullish()});S({content:h(Oe).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(p([Ne,ve])).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(De).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(D).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(tr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(He).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(nr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(qe).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(rr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(R).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Ue).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(we).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(je).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ze).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Zn).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ir).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ar).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(be).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(lr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ur).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ke).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Te).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Be).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Ve).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(dr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Me).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(mr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()});var hr=S({content:h(R),number:v(),size:v(),totalElements:b().int(),totalPages:v()}),gr=S({content:h(ke),number:v(),size:v(),totalElements:b().int(),totalPages:v()}),_r=S({content:h(Te),number:v(),size:v(),totalElements:b().int(),totalPages:v()});S({content:h(Le).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()});var vr=_([`entityRecord`,`researchSnippet`,`newsArticle`,`personRecord`,`fundraiseTransaction`,`webProfile`]),yr=Object.assign(p([vr,x()]),{enum:vr.enum}),br=S({entityId:f(),source:yr,sourceId:x()}),xr=S({citation:h(br),text:x(),topic:x().nullish()}),Sr=S({citation:h(br),confidence:O,description:x().nullish(),heading:x().nullish(),paragraph:h(xr),relatedQuery:h(x()),shareable:y(),text:x(),title:x().nullish()}),Cr=S({enrichmentRunId:f().nullish(),entityId:f()}),wr=S({sortPriority:_([`NONE`,`ANY_LOGO_FIRST`,`REAL_LOGO_FIRST`]).optional()}),Tr=S({max:m({offset:!0}).nullish(),min:m({offset:!0}).nullish()}),V=S({max:b().nullish(),min:b().nullish()}),H=S({max:v().nullish(),min:v().nullish()}),Er=S({averageAmountInvestedUsdRange:h(V).optional(),largestAmountInvestedUsdRange:h(V).optional(),smallestAmountInvestedUsdRange:h(V).optional(),totalAmountInvestedUsdRange:h(V).optional(),totalInvestmentRange:h(H).optional()}),Dr=S({amountInvestedRange:h(V).optional(),amountRaisedRange:h(V).optional(),dateAnnouncedRange:Tr.nullish(),investedCompanyName:h(x()).optional(),investedCountry:h(x()).optional(),investedIndustry:h(x()).optional(),investedRound:h(x()).optional(),investorActivity:Er.optional(),investorName:h(x()).optional(),lastRoundYearRange:h(H).optional(),rankByInvestmentActivity:y().nullish(),round:h(x()).optional(),totalRaisedRange:h(V).optional(),valuationRange:h(V).optional()}),Or=_([`NONE`,`COMPANY_LISTING_READY`]),kr=_([`Operating`,`Acquired`,`Acquired Subsidiary`,`Closed`,`Closed (Acquihire)`,`Inactive`]),Ar=_([`hostPath`,`domain`]),jr=d({acceleratorBrand:h(x()).optional(),acceleratorCohort:h(x()).optional(),acceleratorName:h(x()).optional(),acceleratorStatus:h(x()).optional(),affinity:h(x()).optional(),closedLast:y().optional(),employeeCountRange:h(H).optional(),entityId:h(f()).optional(),entityName:h(x()).optional(),featured:y().nullish(),fundraiseActivity:Dr.optional(),hasFundraising:y().nullish(),headquartersCity:h(x()).optional(),headquartersCountry:h(x()).optional(),headquartersState:h(x()).optional(),industry:h(x()).optional(),letter:x().nullish(),location:h(x()).optional(),logoOption:wr.optional(),mainProduct:h(x()).optional(),operatingStatus:h(kr).optional(),originCountry:h(x()).optional(),person:h(x()).optional(),portfolioHeadquartersCity:h(x()).optional(),portfolioHeadquartersCountry:h(x()).optional(),portfolioHeadquartersState:h(x()).optional(),qualityGate:Or.optional(),rankByProminence:y().nullish(),semanticQuery:x().nullish(),slug:h(x().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:h(x()).optional(),suppressLateStage:y().nullish(),suppressNonOperating:y().nullish(),suppressZeroTotalRaised:y().nullish(),tag:h(x()).optional(),textSearch:x().nullish(),typeCustomer:h(x()).optional(),typeModel:h(x()).optional(),typeOwnership:h(x()).optional(),typeRecord:h(g).optional(),typeRevenue:h(x()).optional(),typeTechnologyUsed:h(x()).optional(),url:x().nullish(),urlDomain:x().nullish(),urlMatchMode:Ar.nullish(),urlType:Se.nullish(),yearFoundedRange:h(H).optional()}),Mr=_([`discovery`,`profile`,`peer`,`comparison`]),Nr=_([`keyword`,`semantic`]),Pr=_([`ID`,`NAME_BRAND`,`YEAR_FOUNDED`,`STATUS_OPERATING`,`UPDATED_AT`,`CREATED_AT`,`NEXT_DUE_AT`,`DATA_COMPLETION_COVERAGE`,`TOTAL_RAISED`,`AMOUNT_INVESTED`,`RECENT_INVESTMENT_AT`,`STAGE`,`MOST_RECENT_AMOUNT`,`LATEST_VALUATION`,`MOST_RECENT_DATE`,`ACCELERATOR_BRAND`,`ACCELERATOR_COHORT`,`HEADQUARTERS_COUNTRY`,`EMPLOYEE_COUNT`]),Fr=Object.assign(p([Pr,x()]),{enum:Pr.enum}),Ir=S({descending:y(),field:Fr,sortKey:x().nullish()}),Lr=S({order:h(Ir),relevance:Nr.nullish()}),Rr=S({confidence:O,execution:L,fallbackUsed:y(),filter:jr,intent:Mr,interpretation:x(),sort:Lr,subjectEntityName:h(x()),unsupported:x().nullish()}),zr=S({changedAt:m({offset:!0}).nullish(),dataSourceUpdatedAt:m({offset:!0}).nullish(),pendingApproval:v().nullish(),sourceId:x().nullish(),status:x().nullish()}),Br=S({fundManagerRelationshipSource:zr.nullish(),fundraiseTransaction:qe,fundraiseTransactionSource:zr.nullish(),investorJoinSource:zr.nullish()}),Vr=S({evidence:Br,investor:ee,semanticMatch:Re.nullish()}),Hr=S({entityId:f(),matchedOffering:D.nullish(),probability:b(),webUrl:h(x())}),Ur=S({entityId:f(),label:x(),publishedAt:m({offset:!0}).nullish(),score:b(),source:yr,sourceId:x(),text:x(),url:x().nullish()}),Wr=S({answer:Sr.nullish(),filing:h(Cr).nullish(),interpretation:Rr,investment:h(Vr),judgment:h(Hr),passage:h(Ur),peer:h(Zn),pendingWebQuery:h(x()),result:hr,searchRequestId:f().nullish(),subject:h(R)}),Gr=_([`auto-match`,`needs-review`,`approved`,`rejected`]),Kr=S({createdAt:m({offset:!0}),entityId:f(),href:x().nullish(),internal:y(),matchStatus:Gr.nullish(),mention:x().nullish(),slug:x().regex(/^[a-z0-9_-]+$/).max(255).nullish(),typeRecord:g.nullish(),updatedAt:m({offset:!0})}),qr=S({entity:h(Kr),newsId:v()}),Jr=d({acceleratorBrand:h(x()).optional(),acceleratorCohort:h(x()).optional(),acceleratorName:h(x()).optional(),acceleratorStatus:h(x()).optional(),affinity:h(x()).optional(),closedLast:y().optional(),employeeCountRange:h(H).optional(),entityId:h(f()).optional(),entityName:h(x()).optional(),featured:y().nullish(),fundraiseActivity:Dr.optional(),hasFundraising:y().nullish(),headquartersCity:h(x()).optional(),headquartersCountry:h(x()).optional(),headquartersState:h(x()).optional(),industry:h(x()).optional(),letter:x().nullish(),location:h(x()).optional(),logoOption:wr.optional(),mainProduct:h(x()).optional(),operatingStatus:h(kr).optional(),originCountry:h(x()).optional(),person:h(x()).optional(),portfolioHeadquartersCity:h(x()).optional(),portfolioHeadquartersCountry:h(x()).optional(),portfolioHeadquartersState:h(x()).optional(),qualityGate:Or.optional(),rankByProminence:y().nullish(),slug:h(x().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:h(x()).optional(),suppressLateStage:y().nullish(),suppressNonOperating:y().nullish(),suppressZeroTotalRaised:y().nullish(),tag:h(x()).optional(),textSearch:x().nullish(),typeCustomer:h(x()).optional(),typeModel:h(x()).optional(),typeOwnership:h(x()).optional(),typeRecord:h(g).optional(),typeRevenue:h(x()).optional(),typeTechnologyUsed:h(x()).optional(),url:x().nullish(),urlDomain:x().nullish(),urlMatchMode:Ar.nullish(),urlType:Se.nullish(),yearFoundedRange:h(H).optional()}),Yr=S({amountInvestedRange:h(V).nullish(),amountRaisedRange:h(V).nullish(),entityName:h(x()).nullish(),investedCompany:h(x()).nullish(),personTitle:h(x()).nullish(),round:h(x()).nullish(),totalInvestmentCount:h(H).nullish(),typeRecord:h(g).nullish()}),Xr=S({arrayFilter:Yr.optional(),entityFilter:Jr.optional(),entityId:f().nullish(),entitySlug:x().nullish(),firstName:x().nullish(),includeAddress:y().nullish(),includeUrl:y().nullish(),investorActivity:Er.optional(),isCurrent:y().nullish(),lastName:x().nullish(),letter:x().nullish(),personId:h(f()).max(200).optional(),personName:h(x()).optional(),role:x().nullish(),search:x().nullish(),semanticQuery:x().nullish(),status:x().nullish()}),Zr=S({descending:y(),field:_([`ID`,`FIRST_NAME`,`LAST_NAME`,`FULL_NAME`,`SLUG`,`CREATED_AT`,`UPDATED_AT`,`STATUS`,`GENDER`,`AMOUNT_INVESTED`,`TOTAL_INVESTMENTS`]),sortKey:x().nullish()}),Qr=S({order:h(Zr),relevance:Nr.nullish()}),$r=S({confidence:O,execution:L,fallbackUsed:y(),filter:Xr,interpretation:x(),sort:Qr,unsupported:x().nullish()}),ei=S({currentCompany:x().nullish(),headline:x().nullish(),id:f(),location:x().nullish(),name:x(),named:x(),organizationEvidence:_([`headline`,`profile`,`none`]).nullish(),photoUrl:x().nullish(),profileUrl:x(),slug:x().regex(/^[a-z0-9_-]+$/).max(255)}),ti=S({interpretation:$r,investment:h(Vr),profile:h(ei),result:_r,searchRequestId:f().nullish()}),ni=S({label:x(),query:x()}),ri=S({key:x(),option:h(ni),prompt:x()}),ii=S({entity:Wr,entityDetail:h(He),news:gr,newsEntityMention:h(qr),person:ti,personDetail:h(Be),provenance:qn,qualifier:ri.nullish()});function ai(e,r){return e.map(e=>{let a=e.requestBody??[],o=[...e.parameters.map(e=>oi(e)),...a.flatMap(e=>e.parameter.map(t=>oi(t,a.length>1?e.contentType:void 0))),...si(a)],s=[r,...e.cliPath].join(` `),u=e.mutates===!0||t(e.intent),d=n(e),f=a[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:u,destructive:c(e.method,e.intent),auth:e.auth,cli:{command:s,path:e.cliPath},mcpTool:e.binaryResponse||!l(e.path)||d===null?null:i(d),body:{hasBody:f!==void 0,kind:f?.kind??null,...f!==void 0&&a.length>1?{contentType:f.contentType}:{},required:f?.required??!1,description:f?.description??``,requiredPath:f?.requiredPath??[]},flags:o,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function oi(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function si(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request body encoding, never an uploaded file's media type; omit for ${t[0]}.`,choices:t}]}function ci(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var li=[`-id`,`-slug`,`-url`],ui=[`--id`,`--slug`,`--url`],di=`/v1/lookup`,fi=`--from-file "<path>"`;function pi(e,t,n=fe().bin[0]){let r=ai(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:_i(i,r)}function mi(e,t,n=fe().bin[0]){let r=t.find(t=>t.operationId===e),[i]=r===void 0?[]:ai([r],n);return i&&gi(i,bi(i,!1))}function hi(e,t,n,r=fe().bin[0]){let i=e=>{let t=e.findIndex((e,t)=>n[t]!==e);return t===-1?e.length:t},a=`${n[0]} get`,[o,s]=t.filter(({method:t,path:n,parameters:r,cliPath:o})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return t===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===e&&n.endsWith(`/{${c.name}}`)&&(i(o)>1||o.join(` `)===a)}).toSorted((e,t)=>i(t.cliPath)-i(e.cliPath));if(o!==void 0&&(s===void 0||i(s.cliPath)!==i(o.cliPath)))return mi(o.operationId,t,r)}function gi(e,t){return[e.cli.command,...t,`--data`].join(` `)}function _i(e,t){return[`example: ${gi(e,bi(e))}`,...vi(e,t)]}function vi(e,t){return ci(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${U(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===di),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${U(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var yi=/(?:^|\.)text$/u;function bi(e,t=!0){let n=ci(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&yi.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:xi(e)).map(U);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,fi]:o}function xi(e){let t=new Set;N(t,e.resource);for(let n of li)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of ui){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function U(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var Si=`aventure`;function Ci(e,t,n=`cli`){let r=t.find(t=>t.operationId===e);if(n===`mcp`&&r!==void 0){let e=Gt(r);return`${e.tool} ${JSON.stringify(e.arguments)}`}let i=r?.cliPath;return i===void 0?void 0:`${Si} ${i.join(` `)}`}function wi(e,t,n=e,r=`cli`){return r===`mcp`?Ci(e,t,r)??e:mi(e,t,`aventure`)??n}function Ti(e,t,n=`cli`){let r=lt.safeParse(e);if(!r.success)return null;let{answer:i,citation:a,confidence:o,resolution:s}=r.data;if(s!=null)return Ei(i,s,t,n);let c=i.trimEnd().split(`
3
- `),l=new Set(a.flatMap(({sourceType:e,sourceId:r})=>{if(e!==$e.options[0].enum.OPERATION)return[];let i=Ci(r,t,n);return i===void 0?[]:[i]}));return l.size>0&&c.push(``,n===`mcp`?`MCP calls:`:`Commands:`,...[...l].map(e=>` ${e}`)),c.push(``,`Confidence: ${o}`),a.length===0?c:(c.push(`Sources (${a.length}):`),c.push(...a.map(({excerpt:e,sourceId:t})=>{let n=e.trim();return n.length>0?` - ${t}: ${n}`:` - ${t}`})),c)}function Ei(e,t,n,r){let{outcome:i,operationId:a,probability:o,candidate:s,taskKey:c,taskPlan:l}=t,u=[l==null?e.trimEnd():Oi(l)],d=[``,`Outcome: ${i}${o==null?``:` (probability ${o.toFixed(2)})`}`];switch(i){case k.enum.TASK_PLAN:return[...u,...l==null?[]:ki(l,n,r),...d];case k.enum.OPERATION_ADVICE:{let e=s.filter(({sourceId:e})=>e!==a);return[...u,...a==null?[]:[``,r===`mcp`?`MCP call:`:`Command:`,` ${wi(a,n,a,r)}`],...d,...e.length===0?[]:[`Alternatives: ${e.map(({sourceId:e})=>e).join(`, `)}`]]}case k.enum.CLARIFY:return[...u,...c==null?[]:[``,`Leading catalog task: ${c}`],...ji(`Candidates:`,s,n,r),...d];case k.enum.ABSTAIN:return[...u,...ji(`Nearest operations:`,s,n,r),...d];default:throw Error(`Unhandled help resolution outcome ${String(i)}`)}}function Di(e,t,n=`cli`){let r=st.safeParse(e);return r.success?[Oi(r.data),...ki(r.data,t,n)]:null}var Oi=({taskKey:e,catalogRevision:t})=>e===void 0?`Run these steps in order.`:`Run catalog task ${e}${t===void 0?``:` (catalog revision ${t})`}.`;function ki(e,t,n){return e.step.length===0?[``,`This catalog task has no planned steps yet.`]:[...e.input.length===0?[]:[``,`Inputs:`,...e.input.map(({key:e,type:t,description:n,required:r})=>` ${e} (${t}, ${r===!1?`optional`:`required`}): ${n}`)],``,`Steps:`,...e.step.flatMap(({step:r,cliCommand:i,writeGuidance:a},o)=>[` ${o+1}. ${r.stepKey===void 0?``:`${r.stepKey}: `}${wi(r.operationId,t,i,n)}`,` ${r.instruction}`,...Ai(e,o,a)]),...e.gateId?.length?[``,`Completion gates: ${e.gateId.join(`, `)}`]:[]]}function Ai(e,t,n){if(n==null)return[];let r=JSON.stringify(n),i=e.step.findIndex(({writeGuidance:e})=>JSON.stringify(e)===r);return i===t?[` Write guidance:`,` - Expectation: ${n.expectation}`,` - Body: ${n.body}`,` - Read first: ${n.typeCatalog}`,` - Rejected when:`,...n.reject.map(e=>` - ${e}`),` - Override: ${n.override}`,` - Method: ${n.method.join(`; `)}`]:[` Write guidance: as step ${i+1}.`]}function ji(e,t,n,r){if(t.length===0)return[];let i=t.map(({sourceId:e,excerpt:t})=>({command:Ci(e,n,r)??e,excerpt:t})),a=Math.max(...i.map(({command:e})=>e.length));return[``,e,...i.map(({command:e,excerpt:t})=>` ${e.padEnd(a)} # ${t}`)]}var W=30,Mi=8,G=10,Ni=2,Pi=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Fi=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]);function Ii(e,t,n,{transport:r=`cli`,trailer:i=[]}={}){if(typeof t==`string`)return oe(t,r,i);let a=zt(t,i);if(a!==null)return ae(a,i,r);let o=qi(t);if(o===null)return null;let s=e.find(({operationId:e})=>e===o.operationId),c=he(s?.detailField,o.response),l=[...c.hiddenNote,...i],u=(e,t)=>te([e.trimEnd(),...t].join(`
4
- `),{appendNewline:!0,preservedTrailerLines:t.length>0?t.length:void 0,transport:r}),d=s?.parameters??[],f={...o,response:c.response,parameters:d,transport:r},p=Ti(f.response,e,r)??Di(f.response,e,r);if(p!==null)return u(p.join(`
5
- `),i);let m=Li(f);if(m!==null)return u(m.join(`
6
- `),l);let h=[f.summary??n??f.operationId??`OpenAPI call succeeded`,`${f.method} ${f.endpoint}`],g=ie(Vi(f),117-l.length,ce-Xe.byteLength(`${[...h,...l].join(`
1
+ import{n as e}from"./commander-BB7CDPLs.js";import{c as t,f as n,i as r,l as i,m as a,n as o,o as s,s as c,u as l,w as u}from"./tool-policy-BUHiyuYu.js";import{C as d,O as f,T as p,i as m,l as h,n as g,o as _,p as v,t as ee,u as y,v as b,w as x,y as S}from"./person-owner-BJgNYLKX.js";import{Br as te,Gr as ne,Hr as re,Ur as ie,Vr as ae,Wr as oe,Yr as se,zr as ce}from"./dist-Cf8kXL-8.js";import{c as le,f as ue,i as de,r as C}from"./result-envelope-Bl_1n5Tb.js";import{a as fe}from"./package-DPDX5zmx.js";import{a as w,c as pe,i as me,l as he,n as T,r as ge,s as E,t as _e}from"./text-field-jFKOGMzr.js";import{A as ve,C as ye,D as be,E as xe,O as Se,S as Ce,T as D,_ as we,a as Te,b as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,j as Ne,k as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue,v as We,w as Ge,x as Ke,y as qe}from"./detail-BsTee2g2.js";import{a as Je,o as Ye}from"./cli-help-policy-BIiQwYpQ.js";import{Buffer as Xe}from"node:buffer";var O=_([`HIGH`,`MEDIUM`,`LOW`]),Ze=_([`PAID_PLAN`,`DAILY_ALLOWANCE`]),Qe=_([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),$e=Object.assign(p([Qe,x()]),{enum:Qe.enum}),et=S({billingAccess:Ze.nullish(),excerpt:x(),sourceId:x(),sourceType:$e,sourceVersion:x().nullish()}),tt=S({instruction:x(),operationId:x(),planTaskKey:h(x()).optional(),stepKey:x().optional()}),nt=S({body:x(),expectation:x(),method:h(x()),override:x(),reject:h(x()),typeCatalog:x()}),rt=S({cliCommand:x(),mcpTool:x().nullish(),step:tt,writeGuidance:nt.nullish()}),it=_([`ENTITY`,`TEXT`,`WRITER_BRIEF`]),at=Object.assign(p([it,x()]),{enum:it.enum}),ot=S({allowedValue:x().nullish(),description:x(),key:x(),required:y().default(!0).optional(),type:at}),st=S({catalogRevision:v().optional(),gateId:h(x()).optional(),input:h(ot),step:h(rt),taskKey:x().optional()}),k=_([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),ct=S({candidate:h(et),operationId:x().nullish(),outcome:k,probability:b().nullish(),taskKey:x().nullish(),taskPlan:st.nullish()}),lt=S({answer:x(),citation:h(et),confidence:O,resolution:ct.nullish()});function A(e,t,n=t.inputName){if(t.in===`body`)return n;let r=xt.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?bt(_t(n!==`id`&&n!==`slug`?n:`${pt(e.path)}${gt(n)}`),t):r.inputName}function ut(e,t,n=ht(e)){return dt(mt(e,t),new Set(n))}function dt(e,t){if(!t.has(e))return e;let n=`body${gt(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function ft(e,t,n){return`${e}[${t}].${n}`}function pt(e){return St.find(([,t])=>t.test(e))?.[0]??`record`}function mt(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=vt(t);return bt(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?_t(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ht(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>A(e,t)))}function gt(e){return e.replace(/^./u,e=>e.toUpperCase())}function _t(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function vt(e){let t=_t(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?yt(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function yt(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function bt(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var xt=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],St=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];function Ct(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>wt(t,A(e,t))),r=(t?.parameter??[]).map(t=>wt(t,ut(e,t)));return{selector:n.filter(e=>e.location===`path`||Tt(e)),pagination:n.filter(Et),filter:[...n.filter(Dt),...r.filter(Dt)],body:r.filter(e=>!Dt(e))}}function wt(e,t){let{in:n,inputName:r,...i}=e;return{...i,flag:s(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function Tt(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function Et(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function Dt(e){return e.location!==`path`&&!Tt(e)&&!Et(e)}function Ot(e){return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,scope:e.projection.scope,requiredInput:Mt(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]}}function kt(e,t){let n=e.requestBody?.[0],r=Ot(e),i=Pt(e);return t?{...r,...i===void 0?{}:{paidPlan:i},resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:Ct(e)}:{...r,optionalInput:Nt(e),arrayInput:Ft(e),...i===void 0?{}:{paidPlan:i}}}function At(e){let t=Ct(e),n=e=>e.filter(e=>e.required);return{...kt(e,!1),optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function jt(e){let{cli:t,scope:n,...r}=Ot(e),i=Pt(e);return{...r,...i===void 0?{}:{paidPlan:i},optionalDetailOmitted:!0}}function Mt(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Nt(e){let t=e.requestBody?.[0],n=new Set(t?.requiredPath??[]);return{query:e.parameter.filter(e=>e.in===`query`&&!e.required).map(({name:e})=>e),body:(t?.parameter??[]).filter(({name:e})=>!n.has(e)).map(({name:e})=>e)}}function Pt(e){return e.response.find(({status:e})=>e===`402`)?.description}function Ft(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var It=160,j=`Operation catalog matches`,Lt=[`whole`,`described`,`requiredDescribed`,`optionalNamed`],Rt=e=>`${[j,...e].join(`
2
+ `)}\n`;function zt(e,t=[]){if(!Array.isArray(e)||e.length===0||!e.every(Wt))return null;let n=e,r=e=>re([j,...e,...t]);for(let e of Lt){let t=[...n.flatMap(t=>Ht(t,e)),...Vt(n,e)];if(r(t))return Rt(t)}let i=e=>[...n.slice(0,e).flatMap(e=>Ht(e,`optionalNamed`)),...Vt(n.slice(0,e),`optionalNamed`),`... ${n.length-e} more operations omitted to fit ${ce} UTF-8 bytes: ${n.slice(e).map(({operationId:e})=>e).join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`];return Rt(i([...n.keys()].findLast(e=>e>0&&r(i(e)))??1))}var Bt=`call aventure_help with q=<operationId> and limit=1; inspect structuredContent.data argument and optionalInput for the retained inputs`;function Vt(e,t){let n=e.flatMap(e=>`argument`in e?Object.values(e.argument).flat():[]),r=t===`whole`?0:n.filter(e=>e.description.length>It&&(t===`described`||e.required)).length,i=r===0?[]:[`... ${r} argument descriptions shortened; inspect structuredContent.data[].argument for full descriptions.`];if(e.some(e=>`optionalDetailOmitted`in e))return[...i,e.some(e=>`argument`in e)?`... optional argument details omitted: the full list exceeds the result cap; ${Bt}.`:`... optional inputs omitted: the full list exceeds the result cap; call aventure_help with q=<operationId> and limit=1 to read one operation's inputs.`];if(t===`whole`||!e.some(e=>`argument`in e))return[];if(t===`described`)return i;let a=t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`,o=n.filter(({required:e})=>!e).length;return[...i,`... ${o} ${a} omitted to fit ${ce} UTF-8 bytes; structuredContent carries them, and ${Bt}.`]}function Ht(e,t){let n=`argument`in e?Object.values(e.argument).flat():[],r=n.filter(({required:e})=>!e).map(({name:e})=>e);return[`${e.operationId} ${e.method} ${e.path} (aventure_${e.intent})`,` ${e.summary}`,` required: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}`,` responseContentType: ${e.responseContentType.length===0?`none`:e.responseContentType.join(`, `)}`,...`optionalInput`in e?Object.entries(e.optionalInput).filter(([,e])=>e.length>0).map(([e,t])=>` optional ${e}: ${t.join(`, `)}`):[],...`arrayInput`in e&&e.arrayInput.length>0?[` JSON array inputs: ${e.arrayInput.join(`, `)}`]:[],...`paidPlan`in e&&e.paidPlan!==void 0?[` paid plan: ${e.paidPlan}`]:[],...n.filter(({required:e})=>e||t!==`optionalNamed`).map(e=>Ut(e,e.required||t!==`requiredDescribed`,t)),...t===`optionalNamed`&&r.length>0?[` optional inputs: ${r.join(`, `)}`]:[]]}function Ut(e,t,n){let r=[e.location,e.required?`required`:void 0,e.schemaType,e.schemaFormat,e.schemaEnum===void 0?void 0:`choices: ${e.schemaEnum.join(`, `)}`,e.itemSchemaEnum===void 0?void 0:`item choices: ${e.itemSchemaEnum.join(`, `)}`,e.schemaDefault===void 0?void 0:`default: ${JSON.stringify(e.schemaDefault)}`,e.itemSchemaType===void 0?void 0:`items: ${e.itemSchemaType}${e.itemSchemaFormat===void 0?``:` (${e.itemSchemaFormat})`}`].filter(e=>e!==void 0).join(`, `),i=` ${e.name} (${r})`;return t?`${i}: ${n===`whole`||e.description.length<=It?e.description:`${e.description.slice(0,157)}...`}`:i}function Wt(e){return typeof e==`object`&&!!e&&`operationId`in e&&typeof e.operationId==`string`&&`requiredInput`in e&&Array.isArray(e.requiredInput)&&`intent`in e&&`summary`in e}function Gt(e){let t=t=>{let n=(`parameter`in e?e.parameter:e.parameters.map(e=>({...e,in:e.location,schemaDefault:e.defaultValue}))).filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map(({name:e})=>[e,`<${e}>`]);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`);return{tool:i(e.intent),arguments:{operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Kt(e.requestBody[0]?.requiredPath??[])}}}}function Kt(e){let t={},n=e.filter(t=>!e.some(e=>e.startsWith(`${t}.`)||e.startsWith(`${t}[]`)));for(let e of n){let n=e.split(`.`),r=n.slice(0,-1).reduce(qt,t);r[n.at(-1)??e]=`<${e}>`}return t}function qt(e,t){let n=t.replace(/\[\]$/u,``),r=e[n],i=Array.isArray(r)?r[0]:r;if(typeof i==`object`&&i&&!Array.isArray(i))return i;let a={};return e[n]=t.endsWith(`[]`)?[a]:a,a}function Jt(e){let t=Pt(e);return{mcpCall:Gt(e),...t===void 0?{}:{paidPlan:t}}}function Yt(e){let t=Xt(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function Xt(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}var M=2,Zt=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`));function N(e,t){let n=I(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&N(e,`person`),en(e,Qt(n),n),en(e,$t(n),n))}function Qt(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=M&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;let n=e.endsWith(`es`)?e.slice(0,-2):``;if(n.length>=M&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n))return n;if(e.length>M&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function $t(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=M&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=M&&e.endsWith(`es`)))return e.length>=M&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function en(e,t,n){t!==void 0&&t!==n&&t.length>=M&&/^[a-z]+$/u.test(t)&&e.add(t)}function P(e){let t=new Set(F(e)),n=Array.from(t);for(let e of n)N(t,e);return t}function tn(e){return F(e).map(P)}function nn(e,t){if(e.length===0)return!1;let n=P(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function F(e){return I(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!Zt.has(e))}function I(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}var rn=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,an=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,on=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,sn=250,cn=40,ln=100;function un(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(an,()=>(n.add(`uuid`),` `)).replace(rn,e=>{n.add(`url`);let t=e.replace(/^(?:https?:\/\/)?[^/]+/iu,``).replace(/[?#].*$/su,``).split(`/`).filter(e=>e.length>0).map(e=>e.toLowerCase()),i=t.at(-1);return i!==void 0&&on.test(i)&&(n.add(`slug`),t.pop()),r.push(...t.flatMap(e=>e.split(/[^a-z0-9]+/u))),` `}).split(/\s+/u).filter(e=>{let r=e.replace(/^[^a-z0-9]+|[^a-z0-9]+$/giu,``).toLowerCase(),a=on.test(r)&&!t.has(r)&&(i||/\d/u.test(r));return a&&n.add(`slug`),!a}).join(` `).trim(),kind:n,urlPathWord:r.filter(e=>e.length>0)}}function dn(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function fn(e,t){let n=new Set;for(let r of e){let e=new Set;N(e,r);let i=t.filter(({cliPath:t})=>e.has(t[0]??``)),a=i.length>0?i:t.filter(({cliPath:t})=>t.some(t=>e.has(t)));for(let{resource:e}of a)n.add(e)}return n}function pn(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(F(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>dn(t,e,n.path))&&(i+=sn,r.has(t)&&(i+=cn));if(i===0)return 0;let a=new Set(F(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return N(t,e),[...t].some(e=>a.has(e))}))&&(i+=ln),i}var mn=40,hn=4,gn=3,_n=1,vn=new Map;function yn(e){let t=vn.get(e);if(t!==void 0)return t;let n=se(),r=u(n.paths,e),i=r===null?new Map:a(n,r.operation.responses,gn);return vn.set(e,i),i}function bn(e,t,n){let r=0,i=new Map;for(let[e,a]of n){if(t.has(e.toLowerCase())&&(r+=mn*(4-a)/4),a>_n)continue;let n=new Set;for(let t of F(e))N(n,t);for(let e of n)i.set(e,Math.min(i.get(e)??a,a))}for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=_n&&(r+=hn*(2-e))}return r}var xn=5,Sn=.5,Cn=15,wn=30,Tn=2,En=100,Dn=.5;function On(e,t,n){let r=t.map(e=>({item:e,fields:n(e)})),i=un(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=fn(i.urlPathWord,r.map(({fields:e})=>e)),o=I(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=P(o),c=tn(o),l=new Set(i.text.toLowerCase().split(/[^a-z0-9]+/u));return r.map(({item:e,fields:t})=>({item:e,fields:t,score:(o.length===0?0:Mn({normalizedQuery:o,tokens:s,termForm:c,queryWord:l},t))+pn(i,a,t)})).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function kn(e){let t=e.requestBody??[],n=[...e.parameter,...t.flatMap(e=>e.parameter)];return{...e,cliPath:e.projection.cliPath,enumParameter:n.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:n.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...n,...t].map(({description:e})=>e),responseFieldLevel:yn(e.operationId)}}function An(e,t){let n=e.q?.trim()??``,r=On(n,t.filter(t=>jn(e,t)&&(n.length>0||t.deprecated!==!0)),kn),i=(r[0]?.score??0)*Sn,a=r.filter(({score:e})=>e>=i),o=e.limit===void 0||!Number.isFinite(e.limit)?xn:e.limit,s=Math.min(a.length,Math.max(0,Math.trunc(o))),c=a.slice(0,s).map(({item:e})=>e),l={totalOperations:t.length,matched:a.length,returned:c.length},u=c.length===1,d=c.map(e=>kt(e,u)),f=le(j,d,{counts:l}),p=de(f),m=u?c.map(At):c.map(jt);return{summary:j,data:p?d:m,counts:l}}function jn(e,t){let{root:n}=e;return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Mn({normalizedQuery:e,tokens:n,termForm:r,queryWord:i},a){let o=Rn(a),s=In(a),c=0;o.some(t=>t===e)&&(c+=100),o.some(t=>t.includes(e))&&(c+=40),c+=Ln(e,o);let l=new Set(o.flatMap(F)),u=new Set(s.flatMap(F));for(let e of n)o.some(t=>t===e)?c+=20:u.has(e)?c+=8:l.has(e)&&(c+=Tn);for(let e of a.cliPath){let t=new Set;N(t,e),[...t].some(e=>n.has(e))&&(c+=Cn)}nn(r,s)&&(c+=200),r.length>1&&s.some(t=>t.includes(e))&&(c+=En),a.parameterName.some(t=>I(t)===e)&&(c+=wn);let d=new Set(a.parameterDescription.flatMap(F));for(let e of n)d.has(e)&&(c+=Tn);return c+=Bn(n,a.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>n.has(e))&&/^(?:list|search)[A-Z]/u.test(a.operationId)&&(c+=30),c+=bn(r,i,a.responseFieldLevel),c-=zn(e,n,a.description),t(a.intent)&&!Fn(i)?c*Dn:c}var Nn=`edit change set fix rename link unlink mark publish correct`.split(` `),Pn=new Set([...Object.entries(o).filter(([,e])=>t(e)).map(([e])=>e),...Nn]);function Fn(e){return[...e].some(e=>Pn.has(e))}function In(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(I).filter(e=>e.length>0)}function Ln(e,t){let n=F(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Rn(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,(Xt(e.description).useFor||e.description).slice(0,240)].map(I).filter(e=>e.length>0))]}function zn(e,t,n){let r=I(Xt(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(F(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Bn(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>Vn(e,t))&&(n+=i?40:10);return n}function Vn(e,t){let n=F(t);return n.length>0&&n.every(t=>e.has(t))}function Hn(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function Un(e,t,n,r){let i=e.q?.trim()??``;if(i.length===0)return C(`Provide q to resolve a request to one operation.`);let a=n.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(a===void 0)return C(`This build ships no help resolve operation.`);let o=await r(a,{body:{question:i,resolve:!0,...e.scope===void 0?{}:{scope:e.scope===`read`?`READ`:`WRITE`}}});if(!o.ok)return{...o,data:null};let s=lt.safeParse(Hn(o));if(!s.success||s.data.resolution==null)return C(`The help resolve operation returned no resolution.`);let{answer:c,resolution:l}=s.data,u=e=>t.find(t=>t.operationId===e),d=u(l.operationId),f=l.taskPlan??void 0,p=(f?.step??[]).map(({step:e})=>({step:e,contract:u(e.operationId)})),m=[...new Set([...l.operationId!=null&&d===void 0?[l.operationId]:[],...p.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return m.some(e=>!n.some(t=>t.operationId===e))?C(`No operation on this connection answers that request.`):le(m.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${m.join(`, `)}.`,{outcome:l.outcome,probability:l.probability,answer:c,candidate:l.candidate.filter(({sourceId:e})=>n.some(({operationId:t})=>t===e)).map(({sourceId:e})=>{let t=u(e);return t===void 0?{sourceId:e}:Object.assign({sourceId:e},Jt(t))}),...d===void 0?{}:{operation:{operationId:d.operationId,apiRoute:`${d.method} ${d.path}`,...Yt(d),...Jt(d)}},...(l.taskKey,{}),...f===void 0?{}:{taskPlan:{input:f.input,step:p.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:Gt(e)})}}},{warnings:m.map(e=>n.some(t=>t.operationId===e)?`Operation ${e} is in this server's catalog, but your grant does not allow it.`:`Operation ${e} is outside this server's catalog, so no credential runs it here.`)})}var Wn=S({detail:x(),field:x().nullish(),scope:_([`entity`,`person`,`news`])}),Gn=_([`auto`,`exact`,`keyword`,`semantic`,`natural`,`hybrid`]),Kn=Object.assign(p([Gn,x()]),{enum:Gn.enum}),L=S({modeRequested:Kn,modeUsed:Kn}),qn=S({answerUnavailable:y(),entity:L,news:L,person:L,rejection:h(Wn),unavailable:h(_([`entity`,`person`,`news`]))}),Jn=S({acceleratorParticipation:h(Ae),detail:h(je)}),R=S({core:D,enrichment:xe,fundraiseRound:h(qe),provider:We.nullish(),research:Jn,semanticMatch:Re.nullish()}),Yn=_([`curated`,`semantic`,`precomputed`,`derived`,`computed`]),Xn=S({compositeScore:b().nullish(),cosineScore:b().nullish(),curatedAsOf:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),curatedRelationshipType:x().nullish(),curatedSource:x().nullish(),derivedFromEntityId:f().nullish(),matchedSectionWeight:b().nullish(),origin:Yn,rank:v(),sharedSectionCount:v().nullish()}),Zn=S({entity:R,similarity:Xn}),Qn=S({fundraiseInvestorJoin:y(),fundraiseTransaction:y(),operatingStatus:y(),relationship:y()}),$n=_([`Acquisition`,`Acquired`,`Acquired Subsidiary`]),er=_([`Announced`,`Announced; subject to approvals and closing conditions`,`Active`,`Closed`,`Completed`,`In Progress`,`Open`]),tr=S({acquiredEntity:D,acquirerEntity:D,amount:b().int().nullish(),announcedAt:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),asOf:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),completedAt:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),createdAt:m({offset:!0}).nullish(),currency:x().nullish(),dataConfidence:Ce.nullish(),evidence:Qn,fundraiseTransactionId:f().nullish(),investorJoinId:f().nullish(),isCurrent:y().nullish(),publicSource:ye.nullish(),relationshipId:v(),status:$n,transactionStatus:er.nullish(),updatedAt:m({offset:!0}).nullish()}),nr=S({entity:He,investorAttribution:h(Ee),round:h(Ke),roundCount:v()}),rr=S({core:D,fundingDetail:Pe.nullish(),similarity:Xn,urlLink:h(be)}),ir=S({compliance:Ie.nullish(),createdAt:m({offset:!0}).nullish(),id:v(),isCurrent:y().nullish(),isPrimary:y().nullish(),language:x().nullish(),owner:ee,text:x(),textName:x().nullish(),textType:x(),updatedAt:m({offset:!0}).nullish()}),ar=_([`stored`,`derivedFromPreAndRaised`,`derivedFromPostMinusRaised`,`reportedAssumedPost`]),or=_([`fundraiseRound`,`researchDetail`]),sr=_([`preMoney`,`postMoney`,`reported`]),cr=S({amountRaised:b().int().nullish(),asOfDate:x().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/),confidence:Fe,currency:x(),declaredBasis:sr,derivation:ar,detailId:v().nullish(),label:x().nullish(),source:or,sourceRef:x(),valuationPostMoney:b().int().nullish(),valuationPreMoney:b().int().nullish()}),lr=S({createdAt:m({offset:!0}).nullish(),description:x().nullish(),forkCount:v(),githubId:b().int(),homepageUrl:x().nullish(),id:b().int(),isArchived:y(),isFork:y(),language:x().nullish(),license:x().nullish(),name:x(),ownerLogin:x(),repoCreatedAt:m({offset:!0}).nullish(),repoPushedAt:m({offset:!0}).nullish(),stargazerCount:v(),topic:h(x()),updatedAt:m({offset:!0}).nullish(),url:x()}),z=S({empty:y().optional(),sorted:y().optional(),unsorted:y().optional()}),B=S({offset:b().int().optional(),paged:y().optional(),pageNumber:v().optional(),pageSize:v().optional(),sort:z.optional(),unpaged:y().optional()}),ur=S({investorAttribution:h(Ee),person:Be,round:h(Ke),roundCount:v()}),dr=_([`by`,`about`]),fr=_([`newsArticle`,`blogPost`,`externalSocialPost`,`repositoryOwner`,`repository`,`webSite`,`webPage`,`researchPaper`]),pr=S({canonicalUrl:x().nullish(),contentId:x(),contentType:fr,createdAt:m({offset:!0}).nullish(),publishedAt:m({offset:!0}).nullish(),relation:dr.nullish(),sourceDomain:x().nullish(),sourceName:x().nullish(),summary:x().nullish(),title:x(),topic:x().nullish(),updatedAt:m({offset:!0}).nullish(),url:x().nullish(),year:v().nullish()});S({content:h(Oe).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(p([Ne,ve])).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(De).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(D).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(tr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(He).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Ge).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(qe).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(nr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(R).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Ue).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(we).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(je).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ze).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Zn).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(rr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ir).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(be).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(cr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(lr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ke).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Te).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Be).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Ve).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(ur).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(Me).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()}),S({content:h(pr).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()});var mr=S({content:h(R),number:v(),size:v(),totalElements:b().int(),totalPages:v()}),hr=S({content:h(ke),number:v(),size:v(),totalElements:b().int(),totalPages:v()}),gr=S({content:h(Te),number:v(),size:v(),totalElements:b().int(),totalPages:v()});S({content:h(Le).optional(),empty:y().optional(),first:y().optional(),last:y().optional(),number:v().optional(),numberOfElements:v().optional(),pageable:B.optional(),size:v().optional(),sort:z.optional(),totalElements:b().int().optional(),totalPages:v().optional()});var _r=_([`entityRecord`,`researchSnippet`,`newsArticle`,`personRecord`,`fundraiseTransaction`,`webProfile`]),vr=Object.assign(p([_r,x()]),{enum:_r.enum}),yr=S({entityId:f(),source:vr,sourceId:x()}),br=S({citation:h(yr),text:x(),topic:x().nullish()}),xr=S({citation:h(yr),confidence:O,description:x().nullish(),heading:x().nullish(),paragraph:h(br),relatedQuery:h(x()),shareable:y(),text:x(),title:x().nullish()}),Sr=S({enrichmentRunId:f().nullish(),entityId:f()}),Cr=S({sortPriority:_([`NONE`,`ANY_LOGO_FIRST`,`REAL_LOGO_FIRST`]).optional()}),wr=S({max:m({offset:!0}).nullish(),min:m({offset:!0}).nullish()}),V=S({max:b().nullish(),min:b().nullish()}),H=S({max:v().nullish(),min:v().nullish()}),Tr=S({averageAmountInvestedUsdRange:h(V).optional(),largestAmountInvestedUsdRange:h(V).optional(),smallestAmountInvestedUsdRange:h(V).optional(),totalAmountInvestedUsdRange:h(V).optional(),totalInvestmentRange:h(H).optional()}),Er=S({amountInvestedRange:h(V).optional(),amountRaisedRange:h(V).optional(),dateAnnouncedRange:wr.nullish(),investedCompanyName:h(x()).optional(),investedCountry:h(x()).optional(),investedIndustry:h(x()).optional(),investedRound:h(x()).optional(),investorActivity:Tr.optional(),investorName:h(x()).optional(),lastRoundYearRange:h(H).optional(),rankByInvestmentActivity:y().nullish(),round:h(x()).optional(),totalRaisedRange:h(V).optional(),valuationRange:h(V).optional()}),Dr=_([`NONE`,`COMPANY_LISTING_READY`]),Or=_([`Operating`,`Acquired`,`Acquired Subsidiary`,`Closed`,`Closed (Acquihire)`,`Inactive`]),kr=_([`hostPath`,`domain`]),Ar=d({acceleratorBrand:h(x()).optional(),acceleratorCohort:h(x()).optional(),acceleratorName:h(x()).optional(),acceleratorStatus:h(x()).optional(),affinity:h(x()).optional(),closedLast:y().optional(),employeeCountRange:h(H).optional(),entityId:h(f()).optional(),entityName:h(x()).optional(),featured:y().nullish(),fundraiseActivity:Er.optional(),hasFundraising:y().nullish(),headquartersCity:h(x()).optional(),headquartersCountry:h(x()).optional(),headquartersState:h(x()).optional(),industry:h(x()).optional(),letter:x().nullish(),location:h(x()).optional(),logoOption:Cr.optional(),mainProduct:h(x()).optional(),operatingStatus:h(Or).optional(),originCountry:h(x()).optional(),person:h(x()).optional(),portfolioHeadquartersCity:h(x()).optional(),portfolioHeadquartersCountry:h(x()).optional(),portfolioHeadquartersState:h(x()).optional(),qualityGate:Dr.optional(),rankByProminence:y().nullish(),semanticQuery:x().nullish(),slug:h(x().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:h(x()).optional(),suppressLateStage:y().nullish(),suppressNonOperating:y().nullish(),suppressZeroTotalRaised:y().nullish(),tag:h(x()).optional(),textSearch:x().nullish(),typeCustomer:h(x()).optional(),typeModel:h(x()).optional(),typeOwnership:h(x()).optional(),typeRecord:h(g).optional(),typeRevenue:h(x()).optional(),typeTechnologyUsed:h(x()).optional(),url:x().nullish(),urlDomain:x().nullish(),urlMatchMode:kr.nullish(),urlType:Se.nullish(),yearFoundedRange:h(H).optional()}),jr=_([`discovery`,`profile`,`peer`,`comparison`]),Mr=_([`keyword`,`semantic`]),Nr=_([`ID`,`NAME_BRAND`,`YEAR_FOUNDED`,`STATUS_OPERATING`,`UPDATED_AT`,`CREATED_AT`,`NEXT_DUE_AT`,`DATA_COMPLETION_COVERAGE`,`TOTAL_RAISED`,`AMOUNT_INVESTED`,`RECENT_INVESTMENT_AT`,`STAGE`,`MOST_RECENT_AMOUNT`,`LATEST_VALUATION`,`MOST_RECENT_DATE`,`ACCELERATOR_BRAND`,`ACCELERATOR_COHORT`,`HEADQUARTERS_COUNTRY`,`EMPLOYEE_COUNT`]),Pr=Object.assign(p([Nr,x()]),{enum:Nr.enum}),Fr=S({descending:y(),field:Pr,sortKey:x().nullish()}),Ir=S({order:h(Fr),relevance:Mr.nullish()}),Lr=S({confidence:O,execution:L,fallbackUsed:y(),filter:Ar,intent:jr,interpretation:x(),sort:Ir,subjectEntityName:h(x()),unsupported:x().nullish()}),Rr=S({changedAt:m({offset:!0}).nullish(),dataSourceUpdatedAt:m({offset:!0}).nullish(),pendingApproval:v().nullish(),sourceId:x().nullish(),status:x().nullish()}),zr=S({fundManagerRelationshipSource:Rr.nullish(),fundraiseTransaction:qe,fundraiseTransactionSource:Rr.nullish(),investorJoinSource:Rr.nullish()}),Br=S({evidence:zr,investor:ee,semanticMatch:Re.nullish()}),Vr=S({entityId:f(),matchedOffering:D.nullish(),probability:b(),webUrl:h(x())}),Hr=S({entityId:f(),label:x(),publishedAt:m({offset:!0}).nullish(),score:b(),source:vr,sourceId:x(),text:x(),url:x().nullish()}),Ur=S({answer:xr.nullish(),filing:h(Sr).nullish(),interpretation:Lr,investment:h(Br),judgment:h(Vr),passage:h(Hr),peer:h(Zn),pendingWebQuery:h(x()),result:mr,searchRequestId:f().nullish(),subject:h(R)}),Wr=_([`auto-match`,`needs-review`,`approved`,`rejected`]),Gr=S({createdAt:m({offset:!0}),entityId:f(),href:x().nullish(),internal:y(),matchStatus:Wr.nullish(),mention:x().nullish(),slug:x().regex(/^[a-z0-9_-]+$/).max(255).nullish(),typeRecord:g.nullish(),updatedAt:m({offset:!0})}),Kr=S({entity:h(Gr),newsId:v()}),qr=d({acceleratorBrand:h(x()).optional(),acceleratorCohort:h(x()).optional(),acceleratorName:h(x()).optional(),acceleratorStatus:h(x()).optional(),affinity:h(x()).optional(),closedLast:y().optional(),employeeCountRange:h(H).optional(),entityId:h(f()).optional(),entityName:h(x()).optional(),featured:y().nullish(),fundraiseActivity:Er.optional(),hasFundraising:y().nullish(),headquartersCity:h(x()).optional(),headquartersCountry:h(x()).optional(),headquartersState:h(x()).optional(),industry:h(x()).optional(),letter:x().nullish(),location:h(x()).optional(),logoOption:Cr.optional(),mainProduct:h(x()).optional(),operatingStatus:h(Or).optional(),originCountry:h(x()).optional(),person:h(x()).optional(),portfolioHeadquartersCity:h(x()).optional(),portfolioHeadquartersCountry:h(x()).optional(),portfolioHeadquartersState:h(x()).optional(),qualityGate:Dr.optional(),rankByProminence:y().nullish(),slug:h(x().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:h(x()).optional(),suppressLateStage:y().nullish(),suppressNonOperating:y().nullish(),suppressZeroTotalRaised:y().nullish(),tag:h(x()).optional(),textSearch:x().nullish(),typeCustomer:h(x()).optional(),typeModel:h(x()).optional(),typeOwnership:h(x()).optional(),typeRecord:h(g).optional(),typeRevenue:h(x()).optional(),typeTechnologyUsed:h(x()).optional(),url:x().nullish(),urlDomain:x().nullish(),urlMatchMode:kr.nullish(),urlType:Se.nullish(),yearFoundedRange:h(H).optional()}),Jr=S({amountInvestedRange:h(V).nullish(),amountRaisedRange:h(V).nullish(),entityName:h(x()).nullish(),investedCompany:h(x()).nullish(),personTitle:h(x()).nullish(),round:h(x()).nullish(),totalInvestmentCount:h(H).nullish(),typeRecord:h(g).nullish()}),Yr=S({arrayFilter:Jr.optional(),entityFilter:qr.optional(),entityId:f().nullish(),entitySlug:x().nullish(),firstName:x().nullish(),includeAddress:y().nullish(),includeUrl:y().nullish(),investorActivity:Tr.optional(),isCurrent:y().nullish(),lastName:x().nullish(),letter:x().nullish(),personId:h(f()).max(200).optional(),personName:h(x()).optional(),role:x().nullish(),search:x().nullish(),semanticQuery:x().nullish(),status:x().nullish()}),Xr=S({descending:y(),field:_([`ID`,`FIRST_NAME`,`LAST_NAME`,`FULL_NAME`,`SLUG`,`CREATED_AT`,`UPDATED_AT`,`STATUS`,`GENDER`,`AMOUNT_INVESTED`,`TOTAL_INVESTMENTS`]),sortKey:x().nullish()}),Zr=S({order:h(Xr),relevance:Mr.nullish()}),Qr=S({confidence:O,execution:L,fallbackUsed:y(),filter:Yr,interpretation:x(),sort:Zr,unsupported:x().nullish()}),$r=S({currentCompany:x().nullish(),headline:x().nullish(),id:f(),location:x().nullish(),name:x(),named:x(),organizationEvidence:_([`headline`,`profile`,`none`]).nullish(),photoUrl:x().nullish(),profileUrl:x(),slug:x().regex(/^[a-z0-9_-]+$/).max(255)}),ei=S({interpretation:Qr,investment:h(Br),profile:h($r),result:gr,searchRequestId:f().nullish()}),ti=S({label:x(),query:x()}),ni=S({key:x(),option:h(ti),prompt:x()}),ri=S({entity:Ur,entityDetail:h(He),news:hr,newsEntityMention:h(Kr),person:ei,personDetail:h(Be),provenance:qn,qualifier:ni.nullish()});function ii(e,r){return e.map(e=>{let a=e.requestBody??[],o=[...e.parameters.map(e=>ai(e)),...a.flatMap(e=>e.parameter.map(t=>ai(t,a.length>1?e.contentType:void 0))),...oi(a)],s=[r,...e.cliPath].join(` `),u=e.mutates===!0||t(e.intent),d=n(e),f=a[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:u,destructive:c(e.method,e.intent),auth:e.auth,cli:{command:s,path:e.cliPath},mcpTool:e.binaryResponse||!l(e.path)||d===null?null:i(d),body:{hasBody:f!==void 0,kind:f?.kind??null,...f!==void 0&&a.length>1?{contentType:f.contentType}:{},required:f?.required??!1,description:f?.description??``,requiredPath:f?.requiredPath??[]},flags:o,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function ai(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function oi(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request body encoding, never an uploaded file's media type; omit for ${t[0]}.`,choices:t}]}function si(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var ci=[`-id`,`-slug`,`-url`],li=[`--id`,`--slug`,`--url`],ui=`/v1/lookup`,di=`--from-file "<path>"`;function fi(e,t,n=fe().bin[0]){let r=ii(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:gi(i,r)}function pi(e,t,n=fe().bin[0]){let r=t.find(t=>t.operationId===e),[i]=r===void 0?[]:ii([r],n);return i&&hi(i,yi(i,!1))}function mi(e,t,n,r=fe().bin[0]){let i=e=>{let t=e.findIndex((e,t)=>n[t]!==e);return t===-1?e.length:t},a=`${n[0]} get`,[o,s]=t.filter(({method:t,path:n,parameters:r,cliPath:o})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return t===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===e&&n.endsWith(`/{${c.name}}`)&&(i(o)>1||o.join(` `)===a)}).toSorted((e,t)=>i(t.cliPath)-i(e.cliPath));if(o!==void 0&&(s===void 0||i(s.cliPath)!==i(o.cliPath)))return pi(o.operationId,t,r)}function hi(e,t){return[e.cli.command,...t,`--data`].join(` `)}function gi(e,t){return[`example: ${hi(e,yi(e))}`,..._i(e,t)]}function _i(e,t){return si(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${xi(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===ui),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${xi(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var vi=/(?:^|\.)text$/u;function yi(e,t=!0){let n=si(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&vi.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:bi(e)).map(xi);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,di]:o}function bi(e){let t=new Set;N(t,e.resource);for(let n of ci)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of li){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function xi(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var Si=`aventure`;function U(e,t,n=`cli`){let r=t.find(t=>t.operationId===e);if(n===`mcp`&&r!==void 0){let e=Gt(r);return`${e.tool} ${JSON.stringify(e.arguments)}`}let i=r?.cliPath;return i===void 0?void 0:`${Si} ${i.join(` `)}`}function Ci(e,t,n=e,r=`cli`){return r===`mcp`?U(e,t,r)??e:pi(e,t,`aventure`)??n}function wi(e,t,n=`cli`){let r=lt.safeParse(e);if(!r.success)return null;let{answer:i,citation:a,confidence:o,resolution:s}=r.data;if(s!=null)return Ti(i,s,t,n);let c=i.trimEnd().split(`
3
+ `),l=new Set(a.flatMap(({sourceType:e,sourceId:r})=>{if(e!==$e.options[0].enum.OPERATION)return[];let i=U(r,t,n);return i===void 0?[]:[i]}));return l.size>0&&c.push(``,n===`mcp`?`MCP calls:`:`Commands:`,...[...l].map(e=>` ${e}`)),c.push(``,`Confidence: ${o}`),a.length===0?c:(c.push(`Sources (${a.length}):`),c.push(...a.map(({excerpt:e,sourceId:t})=>{let n=e.trim();return n.length>0?` - ${t}: ${n}`:` - ${t}`})),c)}function Ti(e,t,n,r){let{outcome:i,operationId:a,probability:o,candidate:s,taskKey:c,taskPlan:l}=t,u=[l==null?e.trimEnd():Di(l)],d=[``,`Outcome: ${i}${o==null?``:` (probability ${o.toFixed(2)})`}`];switch(i){case k.enum.TASK_PLAN:return[...u,...l==null?[]:Oi(l,n,r),...d];case k.enum.OPERATION_ADVICE:{let e=s.filter(({sourceId:e})=>e!==a);return[...u,...a==null?[]:[``,r===`mcp`?`MCP call:`:`Command:`,` ${Ci(a,n,a,r)}`],...d,...e.length===0?[]:[`Alternatives: ${e.map(({sourceId:e})=>e).join(`, `)}`]]}case k.enum.CLARIFY:return[...u,...c==null?[]:[``,`Leading catalog task: ${c}`],...Ai(`Candidates:`,s,n,r),...d];case k.enum.ABSTAIN:return[...u,...Ai(`Nearest operations:`,s,n,r),...d];default:throw Error(`Unhandled help resolution outcome ${String(i)}`)}}function Ei(e,t,n=`cli`){let r=st.safeParse(e);return r.success?[Di(r.data),...Oi(r.data,t,n)]:null}var Di=({taskKey:e,catalogRevision:t})=>e===void 0?`Run these steps in order.`:`Run catalog task ${e}${t===void 0?``:` (catalog revision ${t})`}.`;function Oi(e,t,n){return e.step.length===0?[``,`This catalog task has no planned steps yet.`]:[...e.input.length===0?[]:[``,`Inputs:`,...e.input.map(({key:e,type:t,description:n,required:r})=>` ${e} (${t}, ${r===!1?`optional`:`required`}): ${n}`)],``,`Steps:`,...e.step.flatMap(({step:r,cliCommand:i,writeGuidance:a},o)=>[` ${o+1}. ${r.stepKey===void 0?``:`${r.stepKey}: `}${Ci(r.operationId,t,i,n)}`,` ${r.instruction}`,...ki(e,o,a)]),...e.gateId?.length?[``,`Completion gates: ${e.gateId.join(`, `)}`]:[]]}function ki(e,t,n){if(n==null)return[];let r=JSON.stringify(n),i=e.step.findIndex(({writeGuidance:e})=>JSON.stringify(e)===r);return i===t?[` Write guidance:`,` - Expectation: ${n.expectation}`,` - Body: ${n.body}`,` - Read first: ${n.typeCatalog}`,` - Rejected when:`,...n.reject.map(e=>` - ${e}`),` - Override: ${n.override}`,` - Method: ${n.method.join(`; `)}`]:[` Write guidance: as step ${i+1}.`]}function Ai(e,t,n,r){if(t.length===0)return[];let i=t.map(({sourceId:e,excerpt:t})=>({command:U(e,n,r)??e,excerpt:t})),a=Math.max(...i.map(({command:e})=>e.length));return[``,e,...i.map(({command:e,excerpt:t})=>` ${e.padEnd(a)} # ${t}`)]}var W=30,ji=8,G=10,Mi=2,Ni=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Pi=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]);function Fi(e,t,n,{transport:r=`cli`,trailer:i=[]}={}){if(typeof t==`string`)return oe(t,r,i);let a=zt(t,i);if(a!==null)return ae(a,i,r);let o=Ki(t);if(o===null)return null;let s=e.find(({operationId:e})=>e===o.operationId),c=he(s?.detailField,o.response),l=[...c.hiddenNote,...i],u=(e,t)=>te([e.trimEnd(),...t].join(`
4
+ `),{appendNewline:!0,preservedTrailerLines:t.length>0?t.length:void 0,transport:r}),d=s?.parameters??[],f={...o,response:c.response,parameters:d,transport:r},p=wi(f.response,e,r)??Ei(f.response,e,r);if(p!==null)return u(p.join(`
5
+ `),i);let m=Ii(f);if(m!==null)return u(m.join(`
6
+ `),l);let h=[f.summary??n??f.operationId??`OpenAPI call succeeded`,`${f.method} ${f.endpoint}`],g=ie(Bi(f),117-l.length,ce-Xe.byteLength(`${[...h,...l].join(`
7
7
  `)}\n`,`utf8`),r);return u([...h,...g].filter(Boolean).join(`
8
- `),l)}function Li({response:e,...t}){if(e===void 0||!X(e)||!(`entity`in e&&`person`in e&&`news`in e))return null;let n=ii.safeParse(e);if(!n.success)return null;let{entity:r,person:i,news:a,provenance:o}=n.data;return[...r.answer?Ri(r.answer):[],...o.unavailable.map(e=>`${e} unavailable: retry this scope later`),...o.answerUnavailable?[`answer unavailable: retry this search later`]:[],...o.rejection.map(({scope:e,detail:t})=>w(`${e} rejected: ${t}`)),[`entities:`,...K(r.result,t)].join(`
8
+ `),l)}function Ii({response:e,...t}){if(e===void 0||!X(e)||!(`entity`in e&&`person`in e&&`news`in e))return null;let n=ri.safeParse(e);if(!n.success)return null;let{entity:r,person:i,news:a,provenance:o}=n.data;return[...r.answer?Li(r.answer):[],...o.unavailable.map(e=>`${e} unavailable: retry this scope later`),...o.answerUnavailable?[`answer unavailable: retry this search later`]:[],...o.rejection.map(({scope:e,detail:t})=>w(`${e} rejected: ${t}`)),[`entities:`,...K(r.result,t)].join(`
9
9
  `),[`people:`,...K(i.result,t)].join(`
10
10
  `),[`news:`,...K(a,t)].join(`
11
- `)]}function Ri(e){let t=`relatedQuery:\n${e.relatedQuery.map(e=>` - ${w(e)}`).join(`
11
+ `)]}function Li(e){let t=`relatedQuery:\n${e.relatedQuery.map(e=>` - ${w(e)}`).join(`
12
12
  `)}`,n=`citations:\n${e.citation.map(({source:e,sourceId:t,entityId:n})=>w(` - ${e}:${t} entity=${n}`)).join(`
13
13
  `)}`;return[`answer:\n ${me(e.text).replaceAll(`
14
14
  `,`
15
- `)}`,...e.relatedQuery.length===0?[]:[t],...e.citation.length===0?[]:[n]]}function zi(e){let t=qi(e)?.response,n=X(t)?t.interpretation:void 0;if(!X(n))return null;let r=L.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=_e(n.filter),{unsupported:s,fallbackUsed:c}=n,l=[`strategy: requested=${i} used=${a}`,...X(o)?[`constraints:`,...Object.entries(o).flatMap(([e,t])=>t===void 0?[]:[` ${e}: ${Bi(t)}`])]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``];return te(l.filter(Boolean).join(`
16
- `),{appendNewline:!0})}var Bi=e=>Z(e)?w(e):Array.isArray(e)&&e.every(Z)?e.map(e=>w(e)).join(`, `):JSON.stringify(e);function Vi(e){let{response:t,method:n,nextCursor:r,httpStatus:i,location:a,transport:o}=e;if(t===void 0)return a!==void 0&&i!==void 0?[`status=${i} redirect=${a}`]:i===void 0?[]:[`status=${i} no response body`];let s=i===void 0||n===`GET`?``:`status=${i}`,c=X(t)&&!Yi(t)?Xi(t):null,l=c===null?void 0:X(c.context.interpretation)?_e(c.context):c.context,u=l!==void 0&&X(l)?Object.entries(l):[],d=u.filter(e=>Array.isArray(e[1])&&e[1].length>0&&e[1].every(X)),f=new Set(d.map(([e])=>e)),p=Object.fromEntries(u.filter(([e])=>!f.has(e)));return[s,...Yi(t)?K(t,e,r):c===null?Qi(t)?Wi(t,[`filter`],t.meta,o):$i(t)?Wi(t,[`arrayFilterEntry`,`rangeFilterEntry`],t.filtersMeta,o):ta(t)?Gi(t,o):q(t,``):[...K(c.page,e,r),...Object.keys(p).length===0?[]:q(p,``),...d.flatMap(([e,t])=>[`${e}:`].concat(Hi(t,o)))]].filter(Boolean)}function K(e,t,n){let r=Ki(t),i=e.numberOfElements??e.content.length,a=Math.min(e.content.length,W),o=Math.max(1,a),s=(e.number??0)*(e.size??i),c=(e.totalElements??0)-s-i,l=e.number===void 0?``:` page=${e.number}`,u=e.size===void 0?``:` size=${e.size}`,d=e.totalElements===void 0?``:` total=${e.totalElements}`,f=e.totalPages===void 0?``:` totalPages=${e.totalPages}`,p=(e.number??0)+1,m=e.totalPages===void 0||p<e.totalPages,h=T(`page`,t.parameters);return[`rows=${i}${l}${u}${d}${f}`,a<i?`page rows omitted: ${i-a} (${a}/${i} shown); reread with ${T(`size`,t.parameters)} ${o} and ${h} ${Math.floor((s+a)/o)} through ${Math.floor((s+i-1)/o)} (MCP: size, page)`:``,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${E(n)}`,c<=0||n!==void 0?``:m&&i===e.size?`more: ${c} rows not shown; use ${h} or ${T(`size`,t.parameters)} to see them`:`more: ${c} more matched but this response returns only these ${i}; narrow the query to reach them${m?` (${h} ${p} starts after this page)`:``}`,...Hi(e.content.slice(0,a),t.transport)].filter(Boolean)}function Hi(e,t){if(!e.every(X))return J(e,``);let n=e.filter(X);if(n.length===0)return e.length===0?[`(empty)`]:J(e,``);let r=Ui(n);if(r.length===0)return J(e,``);let i=n.slice(0,W).map(e=>{let t=Y(e);return r.map(e=>t[e]??``)}),a=r.map(e=>e.split(`.`).at(-1)??e),o=a.map((e,t)=>{let n=i.map(e=>e[t]??``),r=Math.max(e.length,...n.map(e=>e.length));return e===`id`||e.endsWith(`Id`)?r:Math.min(32,r)}),s=e=>e.map((e,t)=>pe(e,o[t]??12).padEnd(o[t]??12)).join(` `),c=[s(a),s(o.map(e=>`-`.repeat(e)))];return i.forEach(e=>c.push(s(e))),n.length>W&&c.push(`... ${n.length-W} more rows omitted; ${ne(t)}`),c}function Ui(e){let t=e.map(e=>Y(e)),n=new Set(t.flatMap(e=>Object.keys(e))),r=Pi.filter(e=>n.has(e)),i=new Set(r.map(Ji)),a=[...n].filter(e=>{let n=t.every(t=>/^-?\d+(?:\.\d+)?$/u.test(t[e]??`0`));return!e.includes(`.`)||/id$/iu.test(e)||i.has(Ji(e))?!1:(n&&i.add(Ji(e)),n)}),o=[...n].filter(e=>/(?:^|\.)id$/u.test(e)).slice(0,1),s=[...new Set([...r,...o,...a])],c=[...n].filter(e=>!s.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,Mi-s.length);return[...s,...c].slice(0,Mi)}function Wi(e,t,n,r){let i=t.flatMap(t=>e[t].map((e,n)=>({...e,path:`.${t}[${n}].choiceOption`}))),a=n!==void 0&&X(n)?n:{},o=[`total`,`limit`].flatMap(e=>typeof a[e]==`number`?[` ${e}=${a[e]}`]:[]).join(``),s=[`filters=${i.length}${o}`];for(let e of i){let t=e.choiceOption.length,n=e.choiceOptionTotal===null?`unknown (degraded)`:e.choiceOptionTotal??t,i=e.choiceOptionTruncated===!0?` truncated`:``;s.push(`- ${e.filterKey} (${e.label}): choices ${t}/${n}${i}`),e.choiceOption.slice(0,G).forEach(t=>{s.push(` ${T(e.filterKey)} ${E(t.value)}`)}),t>G&&s.push(` ... ${t-G} choices omitted for ${e.filterKey}; ${ne(r,e.path)}`)}return s}function Gi(e,t){let n=T(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,G).map(e=>`${n} ${E(e)}`),e.result.length>G?`... ${e.result.length-G} matches omitted; ${ne(t,`.result`)}`:``].filter(Boolean)}function Ki({endpoint:e,parameters:t}){let n=e.indexOf(`?`);return n<0?[]:[...new URLSearchParams(e.slice(n+1)).entries()].filter(([e,t])=>!Fi.has(e)&&t.length>0).map(([e,n])=>`${T(e,t)} ${E(n)}`)}function qi(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=t=>{let n=Reflect.get(e,t);return typeof n==`string`?n:void 0},[n,r,i]=[t(`method`),t(`endpoint`),t(`nextCursor`)];if(n===void 0||r===void 0)return null;let a=Reflect.get(e,`httpStatus`),o=Reflect.get(e,`response`),s=o===void 0?void 0:ue.safeParse(o);return s!==void 0&&!s.success?null:{method:n,endpoint:r,httpStatus:typeof a==`number`?a:void 0,location:t(`location`),operationId:t(`operationId`),summary:t(`summary`),nextCursor:i===``?void 0:i,response:s?.data}}function q(e,t,n){if(e===void 0)return[];if(Z(e))return[`${t}${ge(e,n)}`];if(Array.isArray(e))return J(e,t,n);let r=[];for(let[n,i]of Object.entries(e))if(i!==void 0){if(Z(i)){r.push(`${t}${n}: ${ge(i,n)}`);continue}r.push(`${t}${n}:`);for(let e of q(i,`${t} `,n))r.push(e)}return r.length===0?[`${t}(empty)`]:r}function J(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(Z(i)){r.push(`${t}- ${ge(i,n)}`);continue}r.push(`${t}-`);for(let e of q(i,`${t} `))r.push(e)}return r}function Y(e,t=``,n=0){return Z(e)?t.length===0?{}:{[t]:w(e,t)}:n>Ni?{}:Array.isArray(e)?e[0]===void 0?{}:Y(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{if(r===void 0)return[];let i=t.length===0?e:`${t}.${e}`;return Z(r)?[[i,w(r,i)]]:Object.entries(Y(r,i,n+1))}))}var Ji=e=>e.split(`.`,1)[0],Yi=e=>X(e)&&Array.isArray(e.content);function Xi(e){let[t,...n]=Object.entries(e).filter(e=>Yi(e[1])&&typeof e[1].totalElements==`number`);if(t===void 0||n.length>0)return null;let[r,i]=t;return{page:i,context:Object.fromEntries(Object.entries(e).filter(([e])=>e!==r))}}function Zi(e){return X(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var Qi=e=>X(e)&&ea(e.filter),$i=e=>X(e)&&ea(e.arrayFilterEntry)&&ea(e.rangeFilterEntry),ea=e=>Array.isArray(e)&&e.every(Zi),ta=e=>X(e)&&typeof e.filterKey==`string`&&Array.isArray(e.result)&&e.result.every(e=>typeof e==`string`),X=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z=e=>typeof e!=`object`||!e,Q=/\{([^}]+)\}/gu;function na(e,t,n=`cli`){let i=t.filter(e=>e.method===`GET`&&(n===`cli`||e.binaryResponse!==!0)),a=t=>e.endpoint!==void 0&&t.endsWith(e.endpoint),o=t.find(t=>t.operationId===e.operationId),s=e.ok&&o!==void 0&&r(o.intent),c=[...s&&e.endpoint!==void 0?oa(e.endpoint.split(`?`)[0]??``,i,!1,n).map(e=>n===`mcp`?e:`${e} --data --to-file <path>`):[],...e.references.filter(e=>!a(e)).flatMap(aa).flatMap(e=>oa(e.pathname,i,!0,n)),...e.references.filter(a).flatMap(aa).flatMap(e=>sa(e,i,n))],l=n===`mcp`?ra:void 0;return c.length===0?{write:s,narrowerRead:l}:{exactRecovery:`Read the full result ${c.join(`; `)}.`,write:s,narrowerRead:l}}var ra=`Refetch a narrower result: call aventure_help with q set to the read intent, then call aventure_read with its operationId and declared query or pathParams, using ids/references, filters, or smaller query.page/query.size windows.`;function ia(e,t){let n=t.find(t=>t.operationId===e.operationId);if(!e.ok||n?.method!==`GET`||n.mutates===!0||r(n.intent)||e.endpoint===void 0)return;let i=new URL(e.endpoint,`https://localhost`),a=[...n.path.matchAll(Q)].map(([,e])=>e),o=RegExp(`^${n.path.replace(Q,`([^/]+)`)}$`,`u`).exec(i.pathname);if(o===null)return;let s=n.parameters.find(e=>e.location===`query`&&e.name===`compact`&&e.schemaType===`boolean`);s!==void 0&&i.searchParams.set(s.name,`true`);let c=[];for(let e of n.parameters){let t=e.location===`path`?[decodeURIComponent(o[a.indexOf(e.name)+1]??``)]:e.location===`query`?i.searchParams.getAll(e.name):[];if(e.required&&t.length===0)return;t.length>0&&c.push($(e),...t.map(da))}return`Run: \`${ua(n,[...c,`--data`,`--to-file`,`./aventure-output.json`])}\`. On success, the spill file contains the bare payload (top-level keys as returned), not the result envelope or a data.response wrapper.`}function aa(e){return URL.canParse(e)?[new URL(e)]:[]}function oa(e,t,n,r){return t.flatMap(t=>{let i=[...t.path.matchAll(Q)].map(([,e])=>e),a=RegExp(`^${t.path.replace(Q,`([^/]+)`)}$`,`u`),o=n&&i.length===0?null:a.exec(e);if(o===null)return[];if(r===`mcp`)return[ca(t,{pathParams:Object.fromEntries(i.map((e,t)=>[e??``,decodeURIComponent(o[t+1]??``)]))})];let s=i.flatMap((e,n)=>{let r=t.parameters.find(t=>t.name===e);return r===void 0?[]:[$(r),o[n+1]??``]});return[`${la(t)}, ${ua(t,s)}`]})}function sa(e,t,n){let r=t.find(t=>t.path===e.pathname);return r===void 0?[]:t.flatMap(t=>{if(!t.path.startsWith(`${r.path}/`))return[];let i=t.parameters.find(({name:e})=>e.endsWith(`Offset`)),a=t.parameters.find(({name:e})=>e.endsWith(`Limit`));if(i===void 0||a===void 0)return[];if(n===`mcp`)return[`in windows: ${ca(t,{query:{...Object.fromEntries([...e.searchParams].filter(([e])=>t.parameters.some(t=>t.location===`query`&&t.name===e))),[i.name]:`<offset>`,[a.name]:`<limit>`}})}, advancing query.${i.name} until a window returns fewer than query.${a.name} units`];let o=t.parameters.flatMap(t=>{let n=e.searchParams.get(t.name);return t.location!==`query`||n===null?[]:[$(t),da(n)]}),s=[$(i),`<n>`,$(a),`<n>`];return[`${la(t)}, in windows: ${ua(t,[...o,...s])}, advancing ${$(i)} until a window returns fewer than ${$(a)} units`]})}function ca(e,t){return`${i(e.intent)} ${JSON.stringify({operationId:e.operationId,...t})}`}function la(e){return e.auth===`write`?`with admin sign-in`:`with any sign-in`}function ua(e,t){return[Si,...e.cliPath,...t].join(` `)}function $(e){return e.flag.split(/\s+/u)[0]??e.flag}function da(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function fa(e){return e.toSorted((e,t)=>e.projection.cliPath.length-t.projection.cliPath.length||e.projection.cliPath.join(` `).localeCompare(t.projection.cliPath.join(` `))||e.operationId.localeCompare(t.operationId)).map(e=>{let t=e.parameter.flatMap(t=>{if(t.in!==`path`&&t.in!==`query`&&t.in!==`header`)return[];let n=t.in;return(t.in===`query`&&t.itemProperty!==void 0?t.itemProperty:[t]).map(t=>{let r=_a(t,A(e,t),n);if(t.legacyName===void 0)return r;let i=_a(t,A(e,t,t.legacyName),n).flag;return i===r.flag?r:Object.assign(r,{legacyFlag:i})})}),n=e.requestBody?.map(n=>{let r=ha(e,t,n),i=ma(n.cliConflicts,r),a=i.length===0?{}:{cliConflicts:i};return Object.assign({},n,{parameter:r},a)}),r=e.response.find(({status:e})=>e.startsWith(`2`)),i=r?.schemaName?.replace(/Schema$/,``);return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliPath:e.projection.cliPath,summary:e.summary,description:e.description,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:n,mutationReadback:e.mutationReadback,scope:e.projection.scope,auth:e.projection.auth,visibility:e.projection.visibility,mutates:e.projection.mutates,errorResponse:e.errorResponse,successResponse:i,detailField:r?.detailField,parameters:t}})}function pa(e,t){let[n,r]=e.filter(e=>e.role===t);if(n===void 0||r!==void 0)throw Error(`Generated composite CLI role '${t}' is incomplete`);return n}function ma(e,t){let n=new Map(t.map(({name:e,optionKey:t})=>[e,t]));return(e??[]).map(e=>e.map(e=>{let t=n.get(e);if(t===void 0)throw Error(`x-aventure-cli-conflicts field '${e}' was removed from the generated CLI projection`);return t}))}function ha(e,t,n){let r=new Set(t.map(e=>e.optionKey));(e.requestBody?.length??0)>1&&r.add(`contentType`);let i=new Set(t.filter(e=>e.location===`path`).map(e=>e.name));return n.parameter.toSorted((e,t)=>ga(e.name)-ga(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=ut(e,t,r);return r.add(n),[_a(t,n,`body`)]})}function ga(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function _a(t,n,r){let i=t.itemSchemaEnum??t.schemaEnum,a=Ye(t.schemaType,t.itemSchemaType,t.schemaFormat,n),o=`${s(n)} ${t.schemaType===`boolean`?`[${a}]`:`<${a}>`}`;return{name:t.name,optionKey:new e(o).attributeName(),flag:o,required:t.required&&t.schemaDefault===void 0,description:Je(t.description,i),schemaType:t.schemaType,schemaFormat:t.schemaFormat,itemSchemaType:t.itemSchemaType,defaultValue:va(t.schemaDefault),choices:i,...t.envName===void 0?{}:{envName:t.envName},...t.visibility&&{visibility:t.visibility},location:r}}var va=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{ft as S,yn as _,Ii as a,I as b,ci as c,_i as d,ai as f,Un as g,An as h,na as i,pi as l,On as m,pa as n,zi as o,kn as p,ia as r,yi as s,fa as t,hi as u,P as v,kt as x,F as y};
15
+ `)}`,...e.relatedQuery.length===0?[]:[t],...e.citation.length===0?[]:[n]]}function Ri(e){let t=Ki(e)?.response,n=X(t)?t.interpretation:void 0;if(!X(n))return null;let r=L.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=_e(n.filter),{unsupported:s,fallbackUsed:c}=n,l=[`strategy: requested=${i} used=${a}`,...X(o)?[`constraints:`,...Object.entries(o).flatMap(([e,t])=>t===void 0?[]:[` ${e}: ${zi(t)}`])]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``];return te(l.filter(Boolean).join(`
16
+ `),{appendNewline:!0})}var zi=e=>Z(e)?w(e):Array.isArray(e)&&e.every(Z)?e.map(e=>w(e)).join(`, `):JSON.stringify(e);function Bi(e){let{response:t,method:n,nextCursor:r,httpStatus:i,location:a,transport:o}=e;if(t===void 0)return a!==void 0&&i!==void 0?[`status=${i} redirect=${a}`]:i===void 0?[]:[`status=${i} no response body`];let s=i===void 0||n===`GET`?``:`status=${i}`,c=X(t)&&!Ji(t)?Yi(t):null,l=c===null?void 0:X(c.context.interpretation)?_e(c.context):c.context,u=l!==void 0&&X(l)?Object.entries(l):[],d=u.filter(e=>Array.isArray(e[1])&&e[1].length>0&&e[1].every(X)),f=new Set(d.map(([e])=>e)),p=Object.fromEntries(u.filter(([e])=>!f.has(e)));return[s,...Ji(t)?K(t,e,r):c===null?Zi(t)?Ui(t,[`filter`],t.meta,o):Qi(t)?Ui(t,[`arrayFilterEntry`,`rangeFilterEntry`],t.filtersMeta,o):ea(t)?Wi(t,o):q(t,``):[...K(c.page,e,r),...Object.keys(p).length===0?[]:q(p,``),...d.flatMap(([e,t])=>[`${e}:`].concat(Vi(t,o)))]].filter(Boolean)}function K(e,t,n){let r=Gi(t),i=e.numberOfElements??e.content.length,a=Math.min(e.content.length,W),o=Math.max(1,a),s=(e.number??0)*(e.size??i),c=(e.totalElements??0)-s-i,l=e.number===void 0?``:` page=${e.number}`,u=e.size===void 0?``:` size=${e.size}`,d=e.totalElements===void 0?``:` total=${e.totalElements}`,f=e.totalPages===void 0?``:` totalPages=${e.totalPages}`,p=(e.number??0)+1,m=e.totalPages===void 0||p<e.totalPages,h=T(`page`,t.parameters);return[`rows=${i}${l}${u}${d}${f}`,a<i?`page rows omitted: ${i-a} (${a}/${i} shown); reread with ${T(`size`,t.parameters)} ${o} and ${h} ${Math.floor((s+a)/o)} through ${Math.floor((s+i-1)/o)} (MCP: size, page)`:``,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${E(n)}`,c<=0||n!==void 0?``:m&&i===e.size?`more: ${c} rows not shown; use ${h} or ${T(`size`,t.parameters)} to see them`:`more: ${c} more matched but this response returns only these ${i}; narrow the query to reach them${m?` (${h} ${p} starts after this page)`:``}`,...Vi(e.content.slice(0,a),t.transport)].filter(Boolean)}function Vi(e,t){if(!e.every(X))return J(e,``);let n=e.filter(X);if(n.length===0)return e.length===0?[`(empty)`]:J(e,``);let r=Hi(n);if(r.length===0)return J(e,``);let i=n.slice(0,W).map(e=>{let t=Y(e);return r.map(e=>t[e]??``)}),a=r.map(e=>e.split(`.`).at(-1)??e),o=a.map((e,t)=>{let n=i.map(e=>e[t]??``),r=Math.max(e.length,...n.map(e=>e.length));return e===`id`||e.endsWith(`Id`)?r:Math.min(32,r)}),s=e=>e.map((e,t)=>pe(e,o[t]??12).padEnd(o[t]??12)).join(` `),c=[s(a),s(o.map(e=>`-`.repeat(e)))];return i.forEach(e=>c.push(s(e))),n.length>W&&c.push(`... ${n.length-W} more rows omitted; ${ne(t)}`),c}function Hi(e){let t=e.map(e=>Y(e)),n=new Set(t.flatMap(e=>Object.keys(e))),r=Ni.filter(e=>n.has(e)),i=new Set(r.map(qi)),a=[...n].filter(e=>{let n=t.every(t=>/^-?\d+(?:\.\d+)?$/u.test(t[e]??`0`));return!e.includes(`.`)||/id$/iu.test(e)||i.has(qi(e))?!1:(n&&i.add(qi(e)),n)}),o=[...n].filter(e=>/(?:^|\.)id$/u.test(e)).slice(0,1),s=[...new Set([...r,...o,...a])],c=[...n].filter(e=>!s.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,ji-s.length);return[...s,...c].slice(0,ji)}function Ui(e,t,n,r){let i=t.flatMap(t=>e[t].map((e,n)=>({...e,path:`.${t}[${n}].choiceOption`}))),a=n!==void 0&&X(n)?n:{},o=[`total`,`limit`].flatMap(e=>typeof a[e]==`number`?[` ${e}=${a[e]}`]:[]).join(``),s=[`filters=${i.length}${o}`];for(let e of i){let t=e.choiceOption.length,n=e.choiceOptionTotal===null?`unknown (degraded)`:e.choiceOptionTotal??t,i=e.choiceOptionTruncated===!0?` truncated`:``;s.push(`- ${e.filterKey} (${e.label}): choices ${t}/${n}${i}`),e.choiceOption.slice(0,G).forEach(t=>{s.push(` ${T(e.filterKey)} ${E(t.value)}`)}),t>G&&s.push(` ... ${t-G} choices omitted for ${e.filterKey}; ${ne(r,e.path)}`)}return s}function Wi(e,t){let n=T(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,G).map(e=>`${n} ${E(e)}`),e.result.length>G?`... ${e.result.length-G} matches omitted; ${ne(t,`.result`)}`:``].filter(Boolean)}function Gi({endpoint:e,parameters:t}){let n=e.indexOf(`?`);return n<0?[]:[...new URLSearchParams(e.slice(n+1)).entries()].filter(([e,t])=>!Pi.has(e)&&t.length>0).map(([e,n])=>`${T(e,t)} ${E(n)}`)}function Ki(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=t=>{let n=Reflect.get(e,t);return typeof n==`string`?n:void 0},[n,r,i]=[t(`method`),t(`endpoint`),t(`nextCursor`)];if(n===void 0||r===void 0)return null;let a=Reflect.get(e,`httpStatus`),o=Reflect.get(e,`response`),s=o===void 0?void 0:ue.safeParse(o);return s!==void 0&&!s.success?null:{method:n,endpoint:r,httpStatus:typeof a==`number`?a:void 0,location:t(`location`),operationId:t(`operationId`),summary:t(`summary`),nextCursor:i===``?void 0:i,response:s?.data}}function q(e,t,n){if(e===void 0)return[];if(Z(e))return[`${t}${ge(e,n)}`];if(Array.isArray(e))return J(e,t,n);let r=[];for(let[n,i]of Object.entries(e))if(i!==void 0){if(Z(i)){r.push(`${t}${n}: ${ge(i,n)}`);continue}r.push(`${t}${n}:`);for(let e of q(i,`${t} `,n))r.push(e)}return r.length===0?[`${t}(empty)`]:r}function J(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(Z(i)){r.push(`${t}- ${ge(i,n)}`);continue}r.push(`${t}-`);for(let e of q(i,`${t} `))r.push(e)}return r}function Y(e,t=``,n=0){return Z(e)?t.length===0?{}:{[t]:w(e,t)}:n>Mi?{}:Array.isArray(e)?e[0]===void 0?{}:Y(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{if(r===void 0)return[];let i=t.length===0?e:`${t}.${e}`;return Z(r)?[[i,w(r,i)]]:Object.entries(Y(r,i,n+1))}))}var qi=e=>e.split(`.`,1)[0],Ji=e=>X(e)&&Array.isArray(e.content);function Yi(e){let[t,...n]=Object.entries(e).filter(e=>Ji(e[1])&&typeof e[1].totalElements==`number`);if(t===void 0||n.length>0)return null;let[r,i]=t;return{page:i,context:Object.fromEntries(Object.entries(e).filter(([e])=>e!==r))}}function Xi(e){return X(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var Zi=e=>X(e)&&$i(e.filter),Qi=e=>X(e)&&$i(e.arrayFilterEntry)&&$i(e.rangeFilterEntry),$i=e=>Array.isArray(e)&&e.every(Xi),ea=e=>X(e)&&typeof e.filterKey==`string`&&Array.isArray(e.result)&&e.result.every(e=>typeof e==`string`),X=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Z=e=>typeof e!=`object`||!e,Q=/\{([^}]+)\}/gu;function ta(e,t,n=`cli`){let i=t.filter(e=>e.method===`GET`&&(n===`cli`||e.binaryResponse!==!0)),a=t=>e.endpoint!==void 0&&t.endsWith(e.endpoint),o=t.find(t=>t.operationId===e.operationId),s=e.ok&&o!==void 0&&r(o.intent),c=[...s&&e.endpoint!==void 0?aa(e.endpoint.split(`?`)[0]??``,i,!1,n).map(e=>n===`mcp`?e:`${e} --data --to-file <path>`):[],...e.references.filter(e=>!a(e)).flatMap(ia).flatMap(e=>aa(e.pathname,i,!0,n)),...e.references.filter(a).flatMap(ia).flatMap(e=>oa(e,i,n))],l=n===`mcp`?na:void 0;return c.length===0?{write:s,narrowerRead:l}:{exactRecovery:`Read the full result ${c.join(`; `)}.`,write:s,narrowerRead:l}}var na=`Refetch a narrower result: call aventure_help with q set to the read intent, then call aventure_read with its operationId and declared query or pathParams, using ids/references, filters, or smaller query.page/query.size windows.`;function ra(e,t){let n=t.find(t=>t.operationId===e.operationId);if(!e.ok||n?.method!==`GET`||n.mutates===!0||r(n.intent)||e.endpoint===void 0)return;let i=new URL(e.endpoint,`https://localhost`),a=[...n.path.matchAll(Q)].map(([,e])=>e),o=RegExp(`^${n.path.replace(Q,`([^/]+)`)}$`,`u`).exec(i.pathname);if(o===null)return;let s=n.parameters.find(e=>e.location===`query`&&e.name===`compact`&&e.schemaType===`boolean`);s!==void 0&&i.searchParams.set(s.name,`true`);let c=[];for(let e of n.parameters){let t=e.location===`path`?[decodeURIComponent(o[a.indexOf(e.name)+1]??``)]:e.location===`query`?i.searchParams.getAll(e.name):[];if(e.required&&t.length===0)return;t.length>0&&c.push($(e),...t.map(ua))}return`Run: \`${la(n,[...c,`--data`,`--to-file`,`./aventure-output.json`])}\`. On success, the spill file contains the bare payload (top-level keys as returned), not the result envelope or a data.response wrapper.`}function ia(e){return URL.canParse(e)?[new URL(e)]:[]}function aa(e,t,n,r){return t.flatMap(t=>{let i=[...t.path.matchAll(Q)].map(([,e])=>e),a=RegExp(`^${t.path.replace(Q,`([^/]+)`)}$`,`u`),o=n&&i.length===0?null:a.exec(e);if(o===null)return[];if(r===`mcp`)return[sa(t,{pathParams:Object.fromEntries(i.map((e,t)=>[e??``,decodeURIComponent(o[t+1]??``)]))})];let s=i.flatMap((e,n)=>{let r=t.parameters.find(t=>t.name===e);return r===void 0?[]:[$(r),o[n+1]??``]});return[`${ca(t)}, ${la(t,s)}`]})}function oa(e,t,n){let r=t.find(t=>t.path===e.pathname);return r===void 0?[]:t.flatMap(t=>{if(!t.path.startsWith(`${r.path}/`))return[];let i=t.parameters.find(({name:e})=>e.endsWith(`Offset`)),a=t.parameters.find(({name:e})=>e.endsWith(`Limit`));if(i===void 0||a===void 0)return[];if(n===`mcp`)return[`in windows: ${sa(t,{query:{...Object.fromEntries([...e.searchParams].filter(([e])=>t.parameters.some(t=>t.location===`query`&&t.name===e))),[i.name]:`<offset>`,[a.name]:`<limit>`}})}, advancing query.${i.name} until a window returns fewer than query.${a.name} units`];let o=t.parameters.flatMap(t=>{let n=e.searchParams.get(t.name);return t.location!==`query`||n===null?[]:[$(t),ua(n)]}),s=[$(i),`<n>`,$(a),`<n>`];return[`${ca(t)}, in windows: ${la(t,[...o,...s])}, advancing ${$(i)} until a window returns fewer than ${$(a)} units`]})}function sa(e,t){return`${i(e.intent)} ${JSON.stringify({operationId:e.operationId,...t})}`}function ca(e){return e.auth===`write`?`with admin sign-in`:`with any sign-in`}function la(e,t){return[Si,...e.cliPath,...t].join(` `)}function $(e){return e.flag.split(/\s+/u)[0]??e.flag}function ua(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function da(e){return e.toSorted((e,t)=>e.projection.cliPath.length-t.projection.cliPath.length||e.projection.cliPath.join(` `).localeCompare(t.projection.cliPath.join(` `))||e.operationId.localeCompare(t.operationId)).map(e=>{let t=e.parameter.flatMap(t=>{if(t.in!==`path`&&t.in!==`query`&&t.in!==`header`)return[];let n=t.in;return(t.in===`query`&&t.itemProperty!==void 0?t.itemProperty:[t]).map(t=>{let r=ga(t,A(e,t),n);if(t.legacyName===void 0)return r;let i=ga(t,A(e,t,t.legacyName),n).flag;return i===r.flag?r:Object.assign(r,{legacyFlag:i})})}),n=e.requestBody?.map(n=>{let r=ma(e,t,n),i=pa(n.cliConflicts,r),a=i.length===0?{}:{cliConflicts:i};return Object.assign({},n,{parameter:r},a)}),r=e.response.find(({status:e})=>e.startsWith(`2`)),i=r?.schemaName?.replace(/Schema$/,``);return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliPath:e.projection.cliPath,summary:e.summary,description:e.description,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:n,mutationReadback:e.mutationReadback,scope:e.projection.scope,auth:e.projection.auth,visibility:e.projection.visibility,mutates:e.projection.mutates,errorResponse:e.errorResponse,successResponse:i,detailField:r?.detailField,parameters:t}})}function fa(e,t){let[n,r]=e.filter(e=>e.role===t);if(n===void 0||r!==void 0)throw Error(`Generated composite CLI role '${t}' is incomplete`);return n}function pa(e,t){let n=new Map(t.map(({name:e,optionKey:t})=>[e,t]));return(e??[]).map(e=>e.map(e=>{let t=n.get(e);if(t===void 0)throw Error(`x-aventure-cli-conflicts field '${e}' was removed from the generated CLI projection`);return t}))}function ma(e,t,n){let r=new Set(t.map(e=>e.optionKey));(e.requestBody?.length??0)>1&&r.add(`contentType`);let i=new Set(t.filter(e=>e.location===`path`).map(e=>e.name));return n.parameter.toSorted((e,t)=>ha(e.name)-ha(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=ut(e,t,r);return r.add(n),[ga(t,n,`body`)]})}function ha(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function ga(t,n,r){let i=t.itemSchemaEnum??t.schemaEnum,a=Ye(t.schemaType,t.itemSchemaType,t.schemaFormat,n),o=`${s(n)} ${t.schemaType===`boolean`?`[${a}]`:`<${a}>`}`;return{name:t.name,optionKey:new e(o).attributeName(),flag:o,required:t.required&&t.schemaDefault===void 0,description:Je(t.description,i),schemaType:t.schemaType,schemaFormat:t.schemaFormat,itemSchemaType:t.itemSchemaType,defaultValue:_a(t.schemaDefault),choices:i,...t.envName===void 0?{}:{envName:t.envName},...t.visibility&&{visibility:t.visibility},location:r}}var _a=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{ft as S,yn as _,Fi as a,I as b,si as c,gi as d,ii as f,Un as g,An as h,ta as i,fi as l,On as m,fa as n,Ri as o,kn as p,ra as r,vi as s,da as t,mi as u,P as v,kt as x,F as y};