@aventurevc/aventure-cli 0.8.117 → 0.8.135

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 (53) hide show
  1. package/dist/aventure-cli/index.js +1 -1
  2. package/dist/aventure-cli/unified-operations.json +1 -1
  3. package/dist/chunks/{api-key-bearer-credential-Dp8wdZaA.js → api-key-bearer-credential-CMEYkaoR.js} +1 -1
  4. package/dist/chunks/api-key-bearer-credential-DAgm6bTo.js +1 -0
  5. package/dist/chunks/aventure-cli-YN3NirzF.js +68 -0
  6. package/dist/chunks/{cli-help-policy-DePYCoA9.js → cli-help-policy-DXZ7Rp0Z.js} +1 -1
  7. package/dist/chunks/contract-FQ8_V_na.js +22 -0
  8. package/dist/chunks/detail-CFSXWI3r.js +1 -0
  9. package/dist/chunks/detail-D07FzRkx.js +1 -0
  10. package/dist/chunks/dist-BctE42Qr.js +96 -0
  11. package/dist/chunks/{env-CthjM3DX.js → env-CeJYsGWg.js} +1 -1
  12. package/dist/chunks/logging-vmjaOcxn.js +1 -0
  13. package/dist/chunks/{logging-CTXmbYhC.js → logging-wfRjU4GX.js} +1 -1
  14. package/dist/chunks/mcp-generation-contract-DlZAcvAv.js +1 -0
  15. package/dist/chunks/mcp-generation-contract-yv0qwarU.js +1 -0
  16. package/dist/chunks/{oauth-bearer-credential-Cj6Jn41y.js → oauth-bearer-credential-BD87CkCq.js} +4 -4
  17. package/dist/chunks/oauth-bearer-credential-C5xHnmRJ.js +1 -0
  18. package/dist/chunks/{oauth-login-CUdjCgI3.js → oauth-login-Dzb4sr6O.js} +4 -4
  19. package/dist/chunks/oauth-login-tngdoQwK.js +1 -0
  20. package/dist/chunks/openapi-commands-BFYa0HJp.js +1 -0
  21. package/dist/chunks/openapi-commands-JLtgVrtj.js +1 -0
  22. package/dist/chunks/output-mode-BG_5P6MR.js +1 -0
  23. package/dist/chunks/output-mode-D1d-NDhY.js +1 -0
  24. package/dist/chunks/output-spill-dDabuyH-.js +1 -0
  25. package/dist/chunks/provider-catalog-DvK2d-Kc.js +1 -0
  26. package/dist/chunks/{response-problem-BTtXAL-c.js → response-problem-BGqj-WZj.js} +1 -1
  27. package/dist/chunks/result-envelope-BE0edu_S.js +1 -0
  28. package/dist/chunks/{startup-auth-B1sYk8OX.js → startup-auth-BT4OVJi7.js} +1 -1
  29. package/dist/chunks/startup-auth-JOsquggV.js +1 -0
  30. package/dist/chunks/text-field-CJvckkTy.js +1 -0
  31. package/dist/chunks/text-field-r9akQrZl.js +3 -0
  32. package/dist/chunks/tool-policy-CHLep0O4.js +1 -0
  33. package/package.json +3 -3
  34. package/dist/chunks/api-key-bearer-credential-CVSHy-nX.js +0 -1
  35. package/dist/chunks/aventure-cli-D7UWA9Am.js +0 -67
  36. package/dist/chunks/detail-D2GAzBWm.js +0 -1
  37. package/dist/chunks/detail-DsOtCS-O.js +0 -1
  38. package/dist/chunks/dist-CgcPVnQy.js +0 -96
  39. package/dist/chunks/logging-Br2p0CnQ.js +0 -1
  40. package/dist/chunks/oauth-bearer-credential-BGEJiBN2.js +0 -1
  41. package/dist/chunks/oauth-login-BkSurkGT.js +0 -1
  42. package/dist/chunks/openapi-commands-BSgKC4nb.js +0 -1
  43. package/dist/chunks/openapi-commands-DJu7LwQ2.js +0 -1
  44. package/dist/chunks/output-mode-BiLod3Y2.js +0 -1
  45. package/dist/chunks/output-mode-DAKmH2Wg.js +0 -1
  46. package/dist/chunks/output-spill-BCONSiFs.js +0 -1
  47. package/dist/chunks/provider-catalog-CUCJ2B5F.js +0 -1
  48. package/dist/chunks/result-envelope-ByNODIA7.js +0 -1
  49. package/dist/chunks/startup-auth-C9YCj50a.js +0 -1
  50. package/dist/chunks/text-field-DgHI4P6_.js +0 -1
  51. package/dist/chunks/text-field-ETjSEm6z.js +0 -3
  52. package/dist/chunks/text-response-N9iCLLLf.js +0 -22
  53. package/dist/chunks/tool-policy-GWWChw5-.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-Br2p0CnQ.js`),{readRuntimePackage:i}=await import(`../chunks/package-DjDmfBch.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o}=await import(`../chunks/oauth-bearer-credential-BGEJiBN2.js`),{materializeCliApiKeyBearerCredential:s}=await import(`../chunks/api-key-bearer-credential-CVSHy-nX.js`),{commandAuthMaterializationMode:c}=await import(`../chunks/startup-auth-C9YCj50a.js`),{setTextAllFields:l}=await import(`../chunks/text-field-DgHI4P6_.js`),{cliMachineOutputSelected:u}=await import(`../chunks/output-mode-BiLod3Y2.js`),{GENERATED_OPENAPI_COMMAND_SPECS:d}=await import(`../chunks/openapi-commands-BSgKC4nb.js`),f=process.argv.slice(2);u(f)&&r(!1),f.includes(`--all-fields`)&&l(!0);try{if(a(),c(f,d)===`optional`)try{await o(),await s()}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-D7UWA9Am.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-vmjaOcxn.js`),{readRuntimePackage:i}=await import(`../chunks/package-DjDmfBch.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-C5xHnmRJ.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-DAgm6bTo.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-JOsquggV.js`),{setTextAllFields:u}=await import(`../chunks/text-field-CJvckkTy.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-D1d-NDhY.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-BFYa0HJp.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-YN3NirzF.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-09T02:43:24.607Z",
4
+ "generatedAt": "2026-10-10T06:38:28.178Z",
5
5
  "totalOperations": 140,
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{o as e,r as t}from"./logging-CTXmbYhC.js";import{i as n,l as r,o as i,w as a,y as o}from"./person-owner-BJgNYLKX.js";import{a as s,l as c,t as l}from"./env-CthjM3DX.js";import{i as u}from"./package-DfJq3Rui.js";import{r as d}from"./response-problem-BTtXAL-c.js";import{execFile as f}from"node:child_process";import{dirname as p,join as m}from"node:path";import{homedir as h,platform as g}from"node:os";import{setTimeout as ee}from"node:timers/promises";import{randomUUID as _}from"node:crypto";import{AsyncLocalStorage as te}from"node:async_hooks";import{chmod as ne,mkdir as v,readFile as y,rename as b,rm as x,stat as re,writeFile as S}from"node:fs/promises";function C(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(E(t)?t:`${ae(t)}://${t}`),r=D(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function w(e){let t=C(e);return t.isLoopback?C(s()).host:t.host}function T(e){return{...e,host:C(e.host).origin}}function ie(e){let t=C(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function E(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function ae(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return D(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function D(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var O=o({createdAt:n({offset:!0}),description:a().nullish(),expiresAt:n({offset:!0}).nullish(),id:a().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:n({offset:!0}).nullish(),name:a(),revocationReason:a().nullish(),scopes:r(a()),status:i([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:a(),updatedAt:n({offset:!0})});function k(e,t=[]){let n=e instanceof Error?e.message:String(e);return d(n,t)}function oe(e,t=[]){let n=d(e.title,t),r=d(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function se(){if(g()===`win32`){let e=process.env.APPDATA??m(h(),`AppData`,`Roaming`);return m(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??m(h(),`.config`);return m(e,`aventure`,`config.json`)}function ce(){let e=process.env[l.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function A(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var le=2;function ue(e,t){return M(e,t).redactedUrl}async function de(e,t,n){let r=M(e,t);return await j(new URL(r.openerUrl),n)}async function j(e,t){let n=t.environment??process.env,r=t.operatingSystem??g(),i=N(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=fe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await pe(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function M(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=D(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==le||u.length!==1||u[0]!==n||d.length!==1||f.length===0||i.length===0||f===i)throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let p;try{p=decodeURIComponent(r)}catch{throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`)}if(r.includes(i)||p.includes(i))throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let m=new URL(a);return m.hash=new URLSearchParams({cliAuthorizationId:n,browserSecret:`<redacted>`}).toString(),{openerUrl:r,redactedUrl:m.toString()}}function N(e,t,n){return e?`--no-browser was set`:n===`darwin`&&t.CODEX_SESSION_ID?`macOS Codex browser process boundary`:t.SSH_CONNECTION||t.SSH_CLIENT||t.SSH_TTY?`SSH/headless session detected`:(n===`linux`||n===`freebsd`)&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?`no graphical display detected`:null}function fe(e,t){return e===`darwin`?{command:`open`,arguments:[t]}:e===`win32`?{command:`rundll32.exe`,arguments:[`url.dll,FileProtocolHandler`,t]}:e===`linux`||e===`freebsd`?{command:`xdg-open`,arguments:[t]}:null}function pe(e,t){return new Promise((n,r)=>{f(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var me=100,he=3e4,ge=6e4,P=new te;function F(){return m(p(se()),`credentials.json`)}function I(e){return`OS keyring is unusable (${e}); the credential will be stored in ${F()} (mode 0600).\n`}async function L(e,t){let n=(await W())[e]?.[t];if(n!==void 0)return{record:{provider:`file`,value:n}};try{let n=await(await U(e,t)).getPassword()??void 0;return n===void 0?{}:{record:{provider:`keyring`,value:n}}}catch(e){return{keyringFailure:H(e)}}}async function R(e,t,n){if((await W())[e]?.[t]!==void 0)return await z(e,t,n,`file store holds this account`);let r;try{let i=await U(e,t);if(await i.setPassword(n),await i.getPassword()===n)return await q(e,t,void 0),`keyring`;r=`Error: keyring readback did not match`}catch(e){r=H(e,[n])}return await z(e,t,n,r)}async function z(e,t,n,r){if(await q(e,t,n),(await W())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function B(e,t){try{let n=await U(e,t),r;try{await n.deleteCredential()}catch(e){r=e}let i;try{i=await n.getPassword()??void 0}catch(e){throw Error(`OS keyring removal outcome is unknown (${H(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${H(r)})`,r===void 0?void 0:{cause:r})}finally{await q(e,t,void 0)}}async function V(e,t){let n=`${t}:probe:${_()}`,r=`aventure-cli-credential-probe:${_()}`,i;try{let t=await U(e,n);await t.setPassword(r);let a=await(await U(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await U(e,n)).getPassword()??void 0;if(a!==r)i=`Error: probe readback did not match`;else if(!o||s!==void 0)i=`Error: probe cleanup was not confirmed`;else return{provider:`keyring`}}catch(e){i=H(e,[r])}try{await K(async()=>{await q(e,n,r);let t=(await W())[e]?.[n];if(await q(e,n,void 0),t!==r)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${i}; file ${F()}: ${H(e,[r])})`,{cause:e})}return{provider:`file`,keyringFailure:i}}function H(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=k(e,t).trim().split(`
1
+ import{o as e,r as t}from"./logging-wfRjU4GX.js";import{i as n,l as r,o as i,w as a,y as o}from"./person-owner-BJgNYLKX.js";import{a as s,l as c,t as l}from"./env-CeJYsGWg.js";import{i as u}from"./package-DfJq3Rui.js";import{r as d}from"./response-problem-BGqj-WZj.js";import{execFile as f}from"node:child_process";import{dirname as p,join as m}from"node:path";import{homedir as h,platform as g}from"node:os";import{setTimeout as ee}from"node:timers/promises";import{randomUUID as _}from"node:crypto";import{AsyncLocalStorage as te}from"node:async_hooks";import{chmod as ne,mkdir as v,readFile as y,rename as b,rm as x,stat as re,writeFile as S}from"node:fs/promises";function C(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(E(t)?t:`${ae(t)}://${t}`),r=D(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function w(e){let t=C(e);return t.isLoopback?C(s()).host:t.host}function T(e){return{...e,host:C(e.host).origin}}function ie(e){let t=C(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function E(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function ae(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return D(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function D(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var O=o({createdAt:n({offset:!0}),description:a().nullish(),expiresAt:n({offset:!0}).nullish(),id:a().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:n({offset:!0}).nullish(),name:a(),revocationReason:a().nullish(),scopes:r(a()),status:i([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:a(),updatedAt:n({offset:!0})});function k(e,t=[]){let n=e instanceof Error?e.message:String(e);return d(n,t)}function oe(e,t=[]){let n=d(e.title,t),r=d(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function se(){if(g()===`win32`){let e=process.env.APPDATA??m(h(),`AppData`,`Roaming`);return m(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??m(h(),`.config`);return m(e,`aventure`,`config.json`)}function ce(){let e=process.env[l.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function A(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var le=2;function ue(e,t){return M(e,t).redactedUrl}async function de(e,t,n){let r=M(e,t);return await j(new URL(r.openerUrl),n)}async function j(e,t){let n=t.environment??process.env,r=t.operatingSystem??g(),i=N(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=fe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await pe(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function M(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=D(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==le||u.length!==1||u[0]!==n||d.length!==1||f.length===0||i.length===0||f===i)throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let p;try{p=decodeURIComponent(r)}catch{throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`)}if(r.includes(i)||p.includes(i))throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let m=new URL(a);return m.hash=new URLSearchParams({cliAuthorizationId:n,browserSecret:`<redacted>`}).toString(),{openerUrl:r,redactedUrl:m.toString()}}function N(e,t,n){return e?`--no-browser was set`:n===`darwin`&&t.CODEX_SESSION_ID?`macOS Codex browser process boundary`:t.SSH_CONNECTION||t.SSH_CLIENT||t.SSH_TTY?`SSH/headless session detected`:(n===`linux`||n===`freebsd`)&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?`no graphical display detected`:null}function fe(e,t){return e===`darwin`?{command:`open`,arguments:[t]}:e===`win32`?{command:`rundll32.exe`,arguments:[`url.dll,FileProtocolHandler`,t]}:e===`linux`||e===`freebsd`?{command:`xdg-open`,arguments:[t]}:null}function pe(e,t){return new Promise((n,r)=>{f(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var me=100,he=3e4,ge=6e4,P=new te;function F(){return m(p(se()),`credentials.json`)}function I(e){return`OS keyring is unusable (${e}); the credential will be stored in ${F()} (mode 0600).\n`}async function L(e,t){let n=(await W())[e]?.[t];if(n!==void 0)return{record:{provider:`file`,value:n}};try{let n=await(await U(e,t)).getPassword()??void 0;return n===void 0?{}:{record:{provider:`keyring`,value:n}}}catch(e){return{keyringFailure:H(e)}}}async function R(e,t,n){if((await W())[e]?.[t]!==void 0)return await z(e,t,n,`file store holds this account`);let r;try{let i=await U(e,t);if(await i.setPassword(n),await i.getPassword()===n)return await q(e,t,void 0),`keyring`;r=`Error: keyring readback did not match`}catch(e){r=H(e,[n])}return await z(e,t,n,r)}async function z(e,t,n,r){if(await q(e,t,n),(await W())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function B(e,t){try{let n=await U(e,t),r;try{await n.deleteCredential()}catch(e){r=e}let i;try{i=await n.getPassword()??void 0}catch(e){throw Error(`OS keyring removal outcome is unknown (${H(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${H(r)})`,r===void 0?void 0:{cause:r})}finally{await q(e,t,void 0)}}async function V(e,t){let n=`${t}:probe:${_()}`,r=`aventure-cli-credential-probe:${_()}`,i;try{let t=await U(e,n);await t.setPassword(r);let a=await(await U(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await U(e,n)).getPassword()??void 0;if(a!==r)i=`Error: probe readback did not match`;else if(!o||s!==void 0)i=`Error: probe cleanup was not confirmed`;else return{provider:`keyring`}}catch(e){i=H(e,[r])}try{await K(async()=>{await q(e,n,r);let t=(await W())[e]?.[n];if(await q(e,n,void 0),t!==r)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${i}; file ${F()}: ${H(e,[r])})`,{cause:e})}return{provider:`file`,keyringFailure:i}}function H(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=k(e,t).trim().split(`
2
2
  `,1);return r&&r!==n?`${n}: ${r}`:n}async function U(e,t){let n=g(),r=n===`linux`||n===`freebsd`?N(!1,process.env,n):null;if(r!==null)throw Error(`OS keyring unlock prompt is unreachable (${r})`);let{AsyncEntry:i}=await import(`@napi-rs/keyring`);return new i(e,t)}async function W(){let e=F(),t;try{t=await y(e,`utf8`)}catch(e){if(A(e,`ENOENT`))return{};throw e}let n;try{n=JSON.parse(t)}catch(t){return await G(e,t)}return ve(n)?n:await G(e,void 0)}async function G(t,n){let r=`${t}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await b(t,r)}catch(e){if(A(e,`ENOENT`))return{};throw Error(`${t} is not a valid credential file and could not be moved aside`,{cause:e})}return e({component:u().bin[0],event:`credential_file_quarantined`,message:`${t} is not a valid credential file; moved it to ${r} and continuing with an empty file store`,...n===void 0?{}:{error:n}}),{}}async function K(e){if(P.getStore()===!0)return await e();let t=`${F()}.lock`;await v(p(t),{recursive:!0,mode:448});let n=Date.now()+he,r=_();for(;;){try{await S(t,r,{flag:`wx`,mode:384});break}catch(e){if(!A(e,`EEXIST`))throw e}if(await re(t).then(e=>Date.now()-e.mtimeMs,()=>0)>ge)await x(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await ee(me)}try{return await P.run(!0,e)}finally{await y(t,`utf8`).catch(()=>``)===r&&await x(t,{force:!0})}}async function q(e,t,n){await K(async()=>await _e(e,t,n))}async function _e(e,t,n){let r=F(),i=await W(),a={...i[e]};if(n===void 0?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,Object.keys(i).length===0){await x(r,{force:!0});return}await v(p(r),{recursive:!0,mode:448});let o=`${r}.${_()}.tmp`;await S(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await ne(o,384),await b(o,r)}function ve(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`))}var J=`vc.aventure.aventure-cli`,Y=`aventure-cli-personal-v1`;async function ye(e,t,n){let r=w(e),i=Se(t,n),a;try{a=await R(J,r,i)}catch(e){throw Error(`${k(e,[i,t.secret])}; broker acknowledgment was withheld. Re-run auth status before retrying.`,{cause:e})}return{host:r,provider:a,activation:n,credential:t}}async function X(e){let t=w(e),n;try{n=await L(J,t)}catch(e){return Z(k(e))}let{record:r,keyringFailure:i}=n;return r===void 0?i===void 0?{state:`missing`}:{state:`missing`,keyringFailure:i}:{state:`found`,stored:{host:t,provider:r.provider,...Ce(r.value)}}}async function be(e){let t=await X(e);if(t.state!==`missing`)return t;try{let{keyringFailure:t}=await V(J,w(e));return t===void 0?{state:`missing`}:{state:`missing`,keyringFailure:t}}catch(e){return Z(k(e))}}async function xe(e){await B(J,w(e))}function Z(e){return{state:`unavailable`,summary:e,cause:`storage`}}function Se(e,t){return`${Y}:${t}\n${JSON.stringify(e.apiKey)}\n${e.secret}`}function Ce(e){let t=e.indexOf(`
3
3
  `),n=t<0?-1:e.indexOf(`
4
4
  `,t+1),r=t<0?e:e.slice(0,t),i=r===`${Y}:active`?`active`:`pending`;if(t<0||n<0||r!==`${Y}:pending`&&r!==`${Y}:active`)throw Error(`OS credential entry has an unsupported format`);let a=e.slice(n+1);if(a.length===0)throw Error(`OS credential entry has an empty secret`);let o;try{o=JSON.parse(e.slice(t+1,n))}catch(e){throw Error(`OS credential entry failed canonical schema validation`,{cause:e})}let s=O.safeParse(o);if(!s.success)throw Error(`OS credential entry failed canonical schema validation`,{cause:s.error});return{activation:i,credential:{apiKey:s.data,secret:a}}}async function we(n){if(Q())return;let r=w(c().host);try{let e=await X(r);if(e.state===`unavailable`){t($(`keyring`,Error(e.summary)));return}e.state===`found`&&e.stored.activation===`active`&&!Q()&&(process.env[l.authToken]=e.stored.credential.secret,n?.(`api-key`))}catch(t){e($(`parse`,t))}}function Q(){return(process.env[l.authToken]?.trim().length??0)>0}function $(e,t){return{component:u().bin[0],event:`api_key_materialization_unavailable`,message:`saved API key could not be loaded; continuing with environment auth`,fields:{source:e},error:t}}export{T as S,oe as _,ye as a,C as b,V as c,R as d,j as f,k as g,ce as h,X as i,L as l,ue as m,xe as n,B as o,de as p,be as r,I as s,we as t,K as u,O as v,w as x,ie as y};
@@ -0,0 +1 @@
1
+ import{t as e}from"./api-key-bearer-credential-CMEYkaoR.js";export{e as materializeCliApiKeyBearerCredential};
@@ -0,0 +1,68 @@
1
+ import{n as e,o as t,r as n,t as r}from"./commander-BB7CDPLs.js";import{i,o as a}from"./logging-wfRjU4GX.js";import{M as o,O as s,i as c,o as l,v as u,w as d,y as f}from"./person-owner-BJgNYLKX.js";import{Ar as p,Dr as m,Er as h,Ir as g,Lr as _,Mr as ee,Or as te,kr as ne}from"./dist-BctE42Qr.js";import{n as re,r as v,s as y,u as ie}from"./result-envelope-BE0edu_S.js";import{i as ae,l as b,o as oe,r as se,s as ce,t as x}from"./env-CeJYsGWg.js";import{i as S,t as le}from"./package-DfJq3Rui.js";import{S as ue,d as de,f as fe,o as pe,p as me,r as he,s as ge,t as _e}from"./tool-policy-CHLep0O4.js";import{i as ve,r as ye}from"./response-problem-BGqj-WZj.js";import{n as be}from"./output-spill-dDabuyH-.js";import{_ as xe,a as Se,c as Ce,d as we,f as Te,i as Ee,l as De,m as Oe,n as C,o as ke,r as Ae,s as je,u as Me}from"./contract-FQ8_V_na.js";import{a as Ne,c as Pe,i as Fe,l as Ie,n as Le,s as Re,t as ze}from"./cli-help-policy-DXZ7Rp0Z.js";import{S as Be,_ as Ve,a as He,g as w,h as Ue,i as We,m as Ge,n as Ke,p as qe,r as Je,s as Ye,t as Xe,v as Ze,x as T,y as Qe}from"./api-key-bearer-credential-CMEYkaoR.js";import{a as $e,c as et,d as tt,g as nt,l as rt,m as it,o as at,s as ot,t as st,u as ct}from"./oauth-bearer-credential-BD87CkCq.js";import{n as lt,r as ut,t as dt}from"./oauth-login-Dzb4sr6O.js";import{a as ft,c as pt,d as mt,i as ht,l as gt,n as _t,o as vt,s as yt,t as bt,u as xt}from"./startup-auth-BT4OVJi7.js";import{n as St,t as E}from"./openapi-commands-JLtgVrtj.js";import{i as D,r as Ct,t as O}from"./output-mode-BG_5P6MR.js";import{spawnSync as wt}from"node:child_process";import{basename as Tt,dirname as k,relative as Et,resolve as A,sep as j}from"node:path";import{copyFileSync as Dt,existsSync as M,lstatSync as Ot,mkdirSync as kt,readFileSync as At,readdirSync as jt,realpathSync as Mt,renameSync as Nt,rmSync as Pt,symlinkSync as Ft,writeFileSync as It}from"node:fs";import N,{stderr as P,stdin as Lt}from"node:process";import{TextDecoder as Rt,inspect as zt}from"node:util";import{homedir as Bt,hostname as Vt,platform as Ht}from"node:os";import{fileURLToPath as Ut}from"node:url";import{setTimeout as Wt}from"node:timers/promises";import{webcrypto as Gt}from"node:crypto";import{readFile as Kt}from"node:fs/promises";import{createInterface as qt}from"node:readline/promises";function Jt(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{...v(`${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 y(`Environment-bound options applied`,r)}function Yt(e,t,n){if(!F(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||!un(n,r.name))continue;let a=ln(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 Xt(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 Zt(e,t,n,r=!1){if(r||!pn(t)||!Array.isArray(n))return hn(e,t,n);for(let[r,i]of n.entries()){let n=hn(e,t,i,r);if(!n.ok)return n}return y(`Body value assigned`,null)}function Qt(e,t,n,r){return hn(e,t,r,n)}function $t(e){let t=[];for(let n of e.split(`.`)){let e=_n(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function en(e,t){let n=$t(t);if(n===null)return null;let r=cn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:sn(r)}:null}function tn(e,t){if(pn(e.name)||e.schemaType===`array`)return y(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return y(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?y(`Scalar body option selected`,t[0]):v(`${n} was already given; pass it once.`)}var nn=/^(?<row>\d+):(?<item>.*)$/su;function rn(e,t){let n=$t(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=nn.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 an(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&$t(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function on(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=en(r,i.name);if(a===null)continue;if(a.firstHole!==null)return v(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||rn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return v(`${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 sn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function cn(e,t){let n=e;for(let e of t){if(!F(n))return;n=n[e]??null}return n}function ln(e,t){if(!pn(t))return cn(e,t.split(`.`))}function un(e,t){return fn(e,t.split(`.`))}function dn(e,t,n){if(!F(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)&&un(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function fn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=_n(n);if(!F(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>fn(e,r)):fn(a,r)}function pn(e){return e.split(`.`).some(e=>_n(e).isArray)}function mn(e,t){return e.parameter.length===0||!F(t)?null:yn(t,[],vn(e.parameter))}function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function hn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=_n(o),c=e===i.length-1,l=gn(a,s,t,c,n,r);if(!l.ok||l.data===null)return v(l.summary,l.warnings);if(c)return y(`Body value assigned`,null);a=l.data}return v(`${t} is not a valid body option path.`)}function gn(e,t,n,r,i,a){let o=()=>v(`${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,y(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,y(`Body path created`,e)}return F(c)?y(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,y(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,y(`Body path created`,n)}return F(s)?y(`Body path stepped`,s):o()}function _n(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function vn(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 yn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=yn(r,t,n);if(e!==null)return e}return null}if(!F(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!bn(a,n)){if(!xn(e))continue;return{path:a,suggestion:Sn(e,n)}}let o=yn(i,e,n);if(o!==null)return o}return null}function bn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function xn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function Sn(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:Cn(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 Cn(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}function wn(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(Pe(e)),t.description=ee(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}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?Mn(r,i):r===void 0?i===void 0?0:1:-1})}function Tn(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 En(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Dn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:An(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 On(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function kn(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?Ie(n):`${Ie(n)} Required JSON paths: ${r.join(`, `)}.`}function An(e,t){let n=Ne(t.description,void 0),r=e.kind!==`multipart`&&pn(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}.`:``}${jn(e,t)}`}function jn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=$t(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 Mn(e,t){return Re(e)-Re(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Nn(e){let t;try{t=e===`-`?await Pn():await Kt(e,`utf8`)}catch(t){return v(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return y(`No input provided`,null);let e=JSON.parse(t);return y(`Input parsed`,e)}catch(e){return v(`Input is not valid JSON: ${e.message}`)}}async function Pn(){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 Fn=`--content-type`;function In(t,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Fn)){let n=a.map(({contentType:e})=>e);t.addOption(new e(`${Fn} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Rn(a)))}if(nr(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);t.addOption(new e(`--from-file <path>`,kn(r,r.requiredPath)).argParser(Bn(`--from-file`)))}let o=Tn(a).filter(e=>i(I(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Mn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new e(En(n),a.length>1?Dn(n):An(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?On(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Ln):pn(i.name)||i.schemaType===`array`?o.argParser(zn):o.argParser(Bn(i.flag)),t.addOption(o),o.envVar!==void 0&&t.on(`optionEnv:${o.name()}`,()=>{let e=t.opts()[i.optionKey];typeof e==`string`&&e.trim()&&t.setOptionValueWithSource(i.optionKey,e.trim(),`env`)})}tr(t,n,o)}function Ln(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Rn(e){return(n,r)=>{if(r!==void 0)throw new t(`${Fn} was already given; pass it once.`);let i=ue(e,n);if(!i.ok)throw new t(i.summary);return n}}function zn(e,t){return[...t??[],e]}function Bn(e){let n=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new t(`${n} was already given; pass it once.`);return e}}async function Vn(e,t){let n=vt(e,t),r=ue(e.requestBody??[],n);if(!r.ok||r.data===null)return v(r.summary,r.warnings);let i=r.data;if(i===void 0)return y(`No body`,void 0);let a=Hn(e,i,t);if(a!==null)return v(a);let o=Jt(e.operationId,i,t);if(!o.ok)return v(o.summary,o.warnings);t=o.data;let s=Un(i,t);if(s!==null)return v(s);let c=await qn(t);if(!c.ok)return v(c.summary,c.warnings);let l=dn(e.requestBody??[],i,c.data);if(l!==null)return v(l);let u=Kn(e.operationId,i,c.data);if(!u.ok)return u;let d=Yt(e.operationId,i,c.data);if(d!==null)return v(d);let f=Jn(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?v(er(e.operationId,i)):y(`No body`,void 0);let p=Xn(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 v(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!F(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return v(`${e.operationId} requires a JSON object${t}.`)}let m=Gn(i,p.data);if(m.length>0)return v(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=F(h)?Xt(i).filter(e=>!un(h,e)):[];return g.length>0?v(Wn(e.operationId,i,g)):p}function Hn(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`${I(t)} requires ${Fn} ${i.join(` or `)}.`}return null}function Un(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 Wn(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 Gn(e,t){return F(t)?e.parameter.filter(e=>e.required&&!un(t,e.name)).map(I):[]}function Kn(e,t,n){let r=mn(t,n);if(r===null)return y(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return v(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function qn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return y(`No body file`,void 0);let n=await Nn(t);if(!n.ok)return v(n.summary,n.warnings);let r=ie.safeParse(n.data);return r.success?y(`Input parsed`,r.data):v(`Input is not valid JSON value: ${r.error.message}`)}function Jn(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=tn(e,n[e.optionKey]);if(!a.ok||a.data===null)return v(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Yn(t,n,r,e,o);if(!s.ok)return v(s.summary,s.warnings);i=!0}if(!i)return y(`No direct body options`,void 0);let a=on(e,t,n,r);return a===null?y(`Direct body options parsed`,r):a}function Yn(e,t,n,r,i){let a=rn(r,i);if(a===null){let e=Qn(r,i);return e.ok?Zt(n,r.name,e.data,r.schemaType===`array`):v(e.summary,e.warnings)}if(a.plain.length>0)return v(`${I(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=an(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return v(`${I(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=$n(r.name,r.itemSchemaType,e);if(!t.ok)return v(t.summary,t.warnings);i.push(t.data)}let a=Qt(n,r.name,e,i);if(!a.ok)return a}return y(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function Xn(e,t,n,r){if(n===void 0)return y(`Direct body parsed`,r);if(r===void 0)return y(`Input parsed`,n);if(F(n)&&F(r))try{return y(`Input parsed`,Zn(t,n,r))}catch(t){return v(`${e} ${t.message}`)}return v(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Zn(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(F(n)&&F(a))i[t]=Zn(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:je.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function Qn(e,t){if(typeof t==`boolean`)return y(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return $n(e.name,e.schemaType,t??``);let n=[],r=pn(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=$n(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return y(`Body value parsed`,n)}function $n(e,t,n){if(t===`boolean`)return n===`true`?y(`Body value parsed`,!0):n===`false`?y(`Body value parsed`,!1):v(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?v(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?v(`${e} must be an integer.`):y(`Body value parsed`,i)}return y(`Body value parsed`,n)}function er(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(I).join(`, `)}`;let r=Xt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(I).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function tr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Fn,location:`body`}),nr(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),wn(e.options,r)}function nr(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function rr(e){let t=re(e,Ae(e,E));return fr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function ir(e){let t=re(e,Ae(e,E));fr(t);let n=Ee(E,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=ar(t);r.push(n.endsWith(`
2
+ `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(Se(r.join(`
3
+ `),!0,!0,e.length));return}let i=t.ok?`OK`:`FAIL`;r.push(`[${i}] ${t.summary}`),!t.ok&&t.problem!==void 0&&r.push(...cr(t.problem)),r.push(...ar(t)),process.stdout.write(Se(r.join(`
4
+ `),!0))}function ar(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 L(e,t){let n=be(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?re(n,Ae(n,E)):n;fr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?or(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?rr(n):n;e.mode===`text`&&ir(r),r.ok||(process.exitCode=1)}function or(e){return typeof e!=`object`||!e||Array.isArray(e)||!Reflect.has(e,`method`)||!Reflect.has(e,`endpoint`)||!(`response`in e)||e.response===void 0?e:e.response}function sr(e,t){let n=ke(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
5
+ `),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function cr(e){let t=[];typeof e.code==`string`&&t.push(` code: ${e.code}`),typeof e.detail==`string`&&t.push(` detail: ${e.detail}`),typeof e.hint==`string`&&t.push(` hint: ${e.hint}`),typeof e.suggestion==`string`&&t.push(` suggestion: ${e.suggestion}`);let n=Object.entries(e.suggestions??{});if(n.length>0){let e=n.map(([e,t])=>`${e}=${t}`).join(`; `);t.push(` suggestions: ${e}`)}return typeof e.requiredRole==`string`&&t.push(` requiredRole: ${e.requiredRole}`),t.push(...lr(e),...ur(`unknownParameters`,e.unknownParameters),...ur(`validParameters`,e.validParameters),...dr(e.resolution)),t}function lr(e){let t=[];return typeof e.limitType==`string`&&t.push(`limitType=${e.limitType}`),typeof e.used==`number`&&t.push(`used=${e.used}`),typeof e.limit==`number`&&t.push(`limit=${e.limit}`),typeof e.remaining==`number`&&t.push(`remaining=${e.remaining}`),typeof e.resetAt==`string`&&t.push(`resetAt=${e.resetAt}`),typeof e.windowSeconds==`number`&&t.push(`windowSeconds=${e.windowSeconds}`),typeof e.retryAfterSeconds==`number`&&t.push(`retryAfterSeconds=${e.retryAfterSeconds}`),t.length>0?[` meter: ${t.join(` `)}`]:[]}function ur(e,t){return t!=null&&t.length>0?[` ${e}: ${t.join(`, `)}`]:[]}function dr(e){if(e==null)return[];let t=[`action=${e.action}`];return typeof e.parameter==`string`&&t.push(`parameter=${e.parameter}`),typeof e.fieldPath==`string`&&t.push(`fieldPath=${e.fieldPath}`),typeof e.endpoint==`string`&&t.push(`endpoint=${e.endpoint}`),e.acceptedValue!==null&&e.acceptedValue!==void 0&&e.acceptedValue.length>0&&t.push(`acceptedValue=${e.acceptedValue.join(`, `)}`),typeof e.retryable==`boolean`&&t.push(`retryable=${e.retryable}`),[` resolution: ${t.join(` `)}`]}function fr(e){e.ok&&e.warnings.length===0||a({component:S().bin[0],event:e.ok?`command_warning`:`command_failed`,message:e.warnings.length>0?e.warnings.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function pr(e,t,n=S().bin[0]){let r=e.limit===void 0?void 0:Number(e.limit);if(r!==void 0&&(e.limit?.trim()===``||!Number.isInteger(r)||r<0))return v(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=Te(t,n),a=xe(e.root??``),o=[...new Set(i.map(({cli:e})=>xe(e.path.at(0)??``)))].toSorted();if(a.length>0&&!o.includes(a))return v(`Unknown --root value: ${JSON.stringify(e.root)}`,[`Pass one of: ${o.join(`, `)}.`]);let s=Oe(e.q??``,i.filter(t=>_r(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)]})).map(({item:e})=>e),c=s.slice(0,r);return y(`Operation catalog matches`,{operation:c,count:{totalOperations:t.length,matched:s.length,returned:c.length}})}function mr(e,t,n=S().bin[0]){let r=Te(t,n),i=e.operationId===void 0?hr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=Sr(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return v(`${i} is a command group; show one of its subcommands.`,[`Run \`${n} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let o=i.split(` `),s=new Set([...[...o.keys()].map(e=>o.slice(e+1).join(` `)),...o.slice(1).map((e,t)=>o.toSpliced(t,2,`${o[t]}-${e}`).join(` `))]),c=pr({q:e.command??e.operationId},t,n),l=[...r.filter(({cli:e})=>e.path.length>1&&s.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...c.data?.operation??[]];return v(`Generated operation not found`,[...[...new Set(l.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${n} command-catalog search "<text>"\`.`])}return y(`Generated operation detail`,{operation:i,usage:yr(i,r)})}function hr(e,t){if(t===void 0)return;let{bin:n}=S(),r=Sr(t,n);return e.find(e=>Sr(e.cli.command,n)===r)}var gr=(e,t)=>e===void 0||e===`all`||e===`any`||e===String(t);function _r(e,t){return(t.root===void 0||vr(e,t.root))&&gr(t.scope,e.scope)&&gr(t.mutates,e.mutates)&&gr(t.destructive,e.destructive)&&gr(t.intent,e.intent)&&gr(t.method,e.method)}function vr(e,t){let n=xe(t);return n.length===0||xe(e.cli.path.at(0)??``)===n}function yr(e,t){let n=Ce(e);return[`cli: ${e.cli.command}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (CLI-only operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,...e.successResponse===void 0?[]:[`success: ${e.successResponse}`],...[!0,!1].flatMap(t=>[`path`,`query`,`header`,`body`].map(r=>{let i=n.filter(e=>e.required===t&&e.location===r),a=xr(`${t?`required`:`optional`} ${r} flags`,i);return t&&r===`body`&&e.body.kind===`json`&&i.length>0?`${a} (required unless --from-file sets JSON key(s) ${i.map(({wireName:e})=>e).join(`, `)})`:a})),...we(e,t),...br(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
6
+ `)}function br(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}function xr(e,t){return`${e}: ${t.length===0?`none`:t.map(e=>e.name).join(` `)}`}function Sr(e,t=S().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var Cr=`dist/aventure-cli/command-catalog.compact.txt`,wr=` · `,Tr=`-`;function Er(e=S().bin[0]){return A(Dr(k(Ut(import.meta.url)),e),Cr)}function Dr(e,t){let n=e;for(;;){if(M(A(n,`package.json`)))return n;let r=k(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Or(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function kr(e,t,n,r=S().bin[0]){let i=pr(e,t,r);if(!i.ok||i.data===null){L({mode:n},i);return}jr({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Pr(i.data,Nr(e.format,`lines`)),summary:`Generated operation matches`})}function Ar(e,t,n,r=S().bin[0]){let i=mr(e,t,r);if(!i.ok||i.data===null){L({mode:n},i);return}jr({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Fr(i.data,Nr(e.format,`usage`)),summary:`Generated operation detail`})}function jr(e){let t=e.mode,n=Nr(e.opts.format,e.defaultFormat),r=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&r&&(n===`json`||n===`ndjson`)){L({mode:t},v(`--text or --all-fields cannot be combined with --format json or ndjson`,[`Omit the text flag for machine output, or use --format lines, compact, or text.`]));return}let i=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.matched===0&&(r||e.opts.format===void 0||n===`text`)?`No generated operations matched.`:e.rendered,a=i.endsWith(`
7
+ `)?i:`${i}\n`;if(e.opts.output!==void 0){It(e.opts.output,a),L({mode:t},y(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(a,`utf8`),format:n},{counts:Br(e.data)}));return}if(t===`text`){Mr(e.summary,a);return}L({mode:t},y(e.summary,e.data,{counts:Br(e.data)}))}function Mr(e,t){let n=be(y(e,t));if(!n.ok||n.data===null){L({mode:`text`},n);return}process.stdout.write(n.data.endsWith(`
8
+ `)?n.data:`${n.data}\n`)}function Nr(e,t){return e??t}function Pr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
9
+ `):t===`text`?Rr(e.operation):t===`compact`?e.operation.map(Ir).join(`
10
+ `):e.operation.map(zr).join(`
11
+ `)}function Fr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?zr(e.operation):t===`compact`?Ir(e.operation):e.usage}function Ir(e){let t=Lr(e);return[e.cli.command,e.summary,t.length===0?Tr:t.join(` `)].join(wr)}function Lr(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function Rr(e){return e.map(e=>`${e.cli.command}\n ${zr(e)}`).join(`
12
+ `)}function zr(e){let t=Lr(e);return[R(`operationId`,e.operationId),R(`scope`,e.scope),R(`mutates`,String(e.mutates)),R(`destructive`,String(e.destructive)),R(`intent`,e.intent),R(`resource`,e.resource),R(`cli`,e.cli.command),e.mcpTool===null?``:R(`mcpTool`,e.mcpTool),R(`method`,e.method),R(`path`,e.path),R(`auth`,e.auth),R(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),R(`requiredFlags`,t.join(` `)),R(`bodyKind`,e.body.kind??``),R(`bodyRequired`,String(e.body.required)),R(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function R(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function Br(e){return`count`in e?e.count:{returned:1}}function Vr(e,t,n=S().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show full documentation for a command, or ask a question`).description([`Show a command's full documentation offline. Select it by command path,`,"operationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.","`help ask <question>` or `help --ask <question>` answers a platform question."].join(`
13
+ `)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new Hr(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=Jr(t);i!==void 0&&r.option(`--ask <question>`,i.summary),O(r),r.action(async function(r){let a=this.optsWithGlobals();if(a.help&&r.length===0){this.outputHelp();return}if(!a.help&&i!==void 0&&a.ask!==void 0){let e=D(a);if(r.length>0){L({mode:e},v(`Use either a command path or --ask, not both.`));return}L({mode:e},await Qr(i,a.ask,a.environment,e));return}let o=Zr(e,r),s=t.find(t=>o!==void 0&&Zr(e,t.cliPath)===o);if(a.help||o!==void 0&&s===void 0){o===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),o.outputHelp();return}let c=s===void 0?Xr(r,t):y(`Resolved by command path`,{operationId:s.operationId});if(c.ok&&c.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!c.ok||c.data===null){L({mode:D(a)},c);return}Ar({...a,...c.data},t,D(a,`text`),n)}),qr(e,t,n)}var Hr=class extends e{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},Ur=2,Wr=6,Gr={formatHelp(e,t){let r=r=>n.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),r));if(t.visibleCommands(e).length===0)return r({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=r({...a,visibleCommands:()=>[]}),s=r({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return r(a)+s},visibleCommands(e){let t=n.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!Le.has(e.name())):t},subcommandTerm(e){let t=n.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,r,i){let a=i.helpWidth??80,o=a-t-4;return r===``||o>=i.minWidthToWrap?n.prototype.formatItem.call(i,e,t,r,i):`${` `.repeat(Ur)}${e}\n${Kr(r,a,i)}`}};function Kr(e,t,n){return n.boxWrap(e,t-Wr).replace(/^/gmu,` `.repeat(Wr))}function qr(e,t,n){for(let r of t){let i=Zr(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp();e.prepareContext({helpWidth:i.configureOutput().getOutHelpWidth?.()});let a=e.helpWidth??80,o=De(r.operationId,t,n),[s,...c]=br(r.errorResponse),l=c.map(t=>Kr(t.trimStart(),a,e).replace(/^ +/u,` `.repeat(Ur))),u=s===void 0?[]:[``,s,...l];return`\n${[...o,...u].join(`
14
+ `)}\n`})}}function Jr(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&$r(e)!==void 0});return n.length===0?t:void 0}var Yr='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function Xr(e,t){let[n,...r]=e,i=de.find(e=>e===n?.toLowerCase());if(i===void 0||r.length===0){let n=e.join(` `).trim();return y(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let a=fe(i),o=r.join(``),s=t.find(e=>e.method===a&&e.path===o);if(s!==void 0)return y(`Resolved by route template`,{operationId:s.operationId});let c=ne({method:a,path:o});return!c.ok||c.data===null?v(c.summary,[...c.warnings,Yr]):y(`Resolved by method and path`,{operationId:c.data.operation.operationId})}function Zr(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}async function Qr(e,t,n,r){let i=$r(e);if(i===void 0)return v(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let a=await Vn(e,{[i.optionKey]:t});return a.ok?await p({method:e.method,path:m(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:Ct(r)?`json`:`auto`}):a}function $r(e){if(e.requestBody?.length!==1||e.parameters.some(e=>e.required))return;let t=(e.requestBody[0]?.parameter??[]).filter(e=>e.required);return t.length===1&&t[0]?.schemaType===`string`?t[0]:void 0}function ei(e,t,n){if(e.cliPath[0]!==`lookup`||!ti(n))return null;let r=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`),i=`no record for ${r.length===0?`the given input`:r.join(`, `)}`;return n.ok?v(i):v(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ti(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function ni(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}var ri=f({artifact:d().nullish(),group:d().nullish(),name:d().nullish(),revision:d().nullish(),time:c({offset:!0}).nullish(),version:d().nullish()}),ii=f({build:ri}),ai=l([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),oi=l([`RSA_OAEP_256_A256_GCM_V1`]),si=f({clientLabel:d().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:ai.nullish(),encryptionAlgorithm:oi.nullish(),encryptionPublicKey:d().min(344).max(12e3).nullish()}),ci=32;async function li(){let e=await Gt.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await Gt.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function ui(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=di(n,`wrapped key`,128,1024),s=di(r,`nonce`,12,12),c=di(i,`ciphertext`,1,65536),l=di(a,`authentication tag`,16,16),u;try{u=await Gt.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==ci)throw Error(`broker credential used an invalid AES-256 key`);let e=await Gt.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await Gt.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Rt(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function di(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var fi=l([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),pi=l([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),mi=f({approvedAt:c({offset:!0}).nullish(),clientLabel:d(),clientPlatform:ai,comparisonCode:d(),consumedAt:c({offset:!0}).nullish(),createdAt:c({offset:!0}),expiresAt:c({offset:!0}),id:s(),intervalSeconds:u().int().min(1),keyReadyAt:c({offset:!0}).nullish(),status:fi,terminalAt:c({offset:!0}).nullish(),terminalReason:pi.nullish(),updatedAt:c({offset:!0})}),hi=f({algorithm:oi,authenticationTag:d(),ciphertext:d(),nonce:d(),wrappedKey:d()}),gi=f({delivery:hi.nullish(),expiresAt:c({offset:!0}),status:fi,terminalReason:pi.nullish()}),_i=f({comparisonCode:d(),expiresAt:c({offset:!0}),id:s(),intervalSeconds:u().int().min(1),pollSecret:d(),verificationUrl:d()}),z=[{command:`auth login`,role:`oauth`,summary:`Sign In Through Your Browser`,description:`Sign in through your browser and save verified CLI access in the credential store.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`},{optionKey:`providers`,flag:`--providers`,description:`Print the sign-in providers and CLI OAuth client, then exit without signing in.`}]},{command:`auth login`,role:`start`,summary:`Sign In With a Browser-Approved aVenture API Key`,description:`Creates a short-lived browser approval request and returns its poll credential once.`,operationId:`createCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations`,bodyOption:[{name:`clientLabel`,optionKey:`clientLabel`,flag:`--client-label <client-label>`,required:!1,description:`Label for this CLI installation.`}],localOption:[{optionKey:`key`,flag:`--key`,description:`Sign in with a browser-approved aVenture API key instead of OAuth; the approval URL opens on any device.`},{optionKey:`browser`,flag:`--no-browser`,description:`Print the sign-in URL without opening a browser.`}]},{command:`auth login`,role:`poll`,summary:`Poll CLI Authorization`,description:`Returns pending state, a terminal state, or an encrypted one-time credential delivery.`,operationId:`pollCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/poll`,bodyOption:[],localOption:[]},{command:`auth login`,role:`acknowledge`,summary:`Acknowledge CLI Credential Delivery`,description:`Confirms the CLI stored the delivered API key in its credential store and clears transient delivery material.`,operationId:`acknowledgeCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/acknowledge`,bodyOption:[],localOption:[]},{command:`auth logout`,role:`revoke`,summary:`Sign Out: Revoke the API Key and Forget Stored OAuth`,description:`Revokes the aVenture API key authenticating this request and returns its metadata so the CLI can confirm revocation before deleting its saved copy.`,operationId:`revokeCurrentApiKey`,method:`DELETE`,path:`/v1/auth/api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Delete the saved key even when revocation cannot be confirmed.`}]}],vi=C(z,`start`),yi=C(z,`poll`),bi=C(z,`acknowledge`),B=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${Ve(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Ei(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},xi=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${w(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function Si(e){let t=await _(Be(b()),{method:vi.method,path:me(vi.path,{},vi.operationId),headers:{},contentType:`application/json`,body:e},_i);if(t.ok&&t.redirect)throw new B(`start`,Di(t.status));if(!t.ok)throw new B(`start`,t.problem);return Oi(t.data)}async function Ci(e,t){let n=te(yi.operationId),r=await _(Be(b()),{method:yi.method,path:me(yi.path,{cliAuthorizationId:e},yi.operationId),headers:{[n]:t}},gi);if(r.ok&&r.redirect)throw new B(`poll`,Di(r.status),[t]);if(!r.ok)throw new B(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Ti(r.headers[`retry-after`])}}async function wi(e,t){let n=te(bi.operationId),r;try{r=await _(Be(b()),{method:bi.method,path:me(bi.path,{cliAuthorizationId:e},bi.operationId),headers:{[n]:t}},mi)}catch(e){throw new xi(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new B(`acknowledge`,Di(r.status),[t]);if(!r.ok)throw new B(`acknowledge`,r.problem,[t]);return r.data}function Ti(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Ei(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Di(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Oi(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[zt.custom]:{enumerable:!1,value:a}})}async function ki(e){let t=await Ai(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await He(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`),verification:t}}catch(n){return{stored:e,verification:{state:`unavailable`,summary:`${t.summary}, but the cached metadata could not be updated — ${w(n,[e.credential.secret])}`}}}}async function Ai(e){let t=Be(b()),n;try{n=await _(t,{method:`GET`,path:m(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},Ze)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${w(t,[e])}`}}return n.ok&&n.redirect?{state:`unavailable`,summary:`identity verification returned unexpected redirect ${n.status}`}:n.ok?n.data.status===`ACTIVE`?{state:`verified`,summary:`API key verified by aVenture sign-in`,apiKey:n.data}:{state:`invalid`,summary:`API key is not active`}:{state:n.problem.status===401||n.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${Ve(n.problem,[e])}`}}var ji=C(z,`revoke`);async function Mi(e){let t;try{t=T(b().host)}catch(e){return v(`auth logout: invalid API host — ${w(e)}`)}let n=await Ni(t),r=await Ii(t,e),i=n.state===`failed`?[`OAuth credential could not be removed — ${n.summary}`]:n.state===`forgotten`&&!n.revoked?[`OAuth refresh token was not revoked remotely — ${n.summary??`no revocation endpoint`}`]:[],a={host:t,revoked:!1,forgotten:!1,oauth:n};return r===null?n.state===`missing`?y(`No CLI credential is stored for this API host.`,a):n.state===`failed`?{...v(`auth logout: ${i[0]}`),data:a}:y(n.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,a,{warnings:i}):{...r,data:{...r.data??a,oauth:n},warnings:[...r.warnings,...i]}}async function Ni(e){let t=await at(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Fi(t.stored):{revoked:!1};try{await $e(e)}catch(e){return{state:`failed`,summary:w(e)}}return{state:`forgotten`,...n}}async function Pi(e){let t=Reflect.get(await dt(e),`revocation_endpoint`);return typeof t==`string`?nt(t,`revocation endpoint`,!0):void 0}async function Fi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Pi(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:ct(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:w(e,it(n))}}}async function Ii(e,t){let n;try{n=await We(e)}catch(e){return v(`auth logout: stored credential could not be read — ${w(e)}`)}if(n.state===`unavailable`)return{...v(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await Li(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...v(`auth logout: remote revocation was not confirmed; local credential preserved — ${i.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:Ri(r,!1,!1)};try{await Ke(r.host)}catch(e){return{...v(`auth logout: local credential removal failed — ${w(e,[r.credential.secret])}`,[a?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:Ri(r,a,!1)}}return y(a?`API key revoked remotely and removed locally.`:o?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,Ri(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Li(e){let t=Be(b());try{let n=await _(t,{method:ji.method,path:me(ji.path,{},ji.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},Ze);return n.ok&&n.redirect?{outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${n.status}`}:n.ok?n.data.id!==e.credential.apiKey.id||n.data.subject!==e.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored API key identity`}:n.data.status===`REVOKED`?{outcome:`revoked`,summary:`remote key revocation confirmed`}:{outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}:{outcome:n.problem.status===401&&n.problem.type!==`about:blank`?`rejected`:`unconfirmed`,summary:Ve(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:w(t,[e.credential.secret])}}}function Ri(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var zi=`RSA_OAEP_256_A256_GCM_V1`,Bi=1,Vi=30,V=S().bin[0],Hi=`The local record remains pending and unavailable to ordinary commands. Re-run \`${V} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Ui(e){if(!Lt.isTTY)return v(`${V} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=b().host;t=T(e),n=Qe(e)}catch(e){return v(`auth login --key: invalid environment configuration — ${w(e)}`)}for(;;){let e;try{e=await Je(t)}catch(e){return v(`auth login --key: credential storage could not be inspected — ${w(e)}`)}if(e.state===`unavailable`)return v(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&P.write(Ye(e.keyringFailure));break}let n=await Wi(e.stored);if(n!==null)return n}let r;try{r=await li()}catch(e){return v(`auth login --key: ephemeral encryption key could not be created — ${w(e)}`)}let i=si.safeParse({clientLabel:e.clientLabel?.trim()||(Vt().trim()||V).slice(0,120),clientPlatform:Ji(),encryptionAlgorithm:zi,encryptionPublicKey:r.publicKey});if(!i.success)return v(`auth login --key: ${o(i.error)}`);let a;try{a=await Si(i.data)}catch(e){return v(`auth login --key: could not start browser authorization — ${w(e)}`)}let s;try{s=Ge(a,n)}catch(e){return v(`auth login --key: unsafe browser authorization URL rejected — ${w(e)}`)}if(!qi(await qe(a,n,{noBrowser:e.noBrowser}),a,s))return v(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[s]});let c;try{c=await Ki(a)}catch(e){return v(`auth login --key: authorization did not complete — ${w(e)}`,[],{references:[s]})}if(c.algorithm!==zi)return v(`auth login --key: broker selected an unsupported encryption algorithm`);let l;try{l=await ui(r.privateKey,c)}catch(e){return v(`auth login --key: encrypted credential could not be opened — ${w(e)}`)}let u=await Ai(l);if(u.state!==`verified`)return v(`auth login --key: decrypted credential was neither stored nor acknowledged — ${u.summary}`);let d;try{d=await He(t,{apiKey:u.apiKey,secret:l},`pending`)}catch(e){return v(`auth login --key: credential could not be durably stored — ${w(e)}`)}let f;try{f=await Gi(a)}catch(e){return H(d,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${w(e,[a.pollSecret])}`,Hi)}if(f.status!==`CONSUMED`)return H(d,!0,`auth login --key: broker returned ${f.status} after acknowledgment`,Hi);let p=await Ai(l);if(p.state!==`verified`||!Qi(p.apiKey,d.credential.apiKey))return H(d,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${p.summary}`,Hi);try{let e=await He(t,{apiKey:p.apiKey,secret:l},`active`);return y(`API key stored; authenticated identity and broker acknowledgment verified.`,Zi(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return H(d,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${w(e)}`,Hi)}}async function Wi(e){let t=await Ai(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?y(`API key is already stored and its authenticated identity was verified.`,Zi(e,!0),{ids:[e.credential.apiKey.id]}):H(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${V} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&Qi(t.apiKey,e.credential.apiKey))try{let n=await He(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return y(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,Zi(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return H(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${w(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${V} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return H(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${V} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Li(e);if(n.outcome===`unconfirmed`)return H(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await Ke(e.host)}catch(t){return H(e,!1,`auth login --key: stale pending credential could not be removed — ${w(t,[e.credential.secret])}`)}return P.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
15
+ `:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
16
+ `),null}async function Gi(e){let t=new Date(e.expiresAt).getTime(),n=Yi(e.intervalSeconds);for(;;)try{return await wi(e.id,e.pollSecret)}catch(e){if(e instanceof B){if(!e.retryable)throw e;n=Yi(e.retryAfterSeconds??n)}else if(!(e instanceof xi))throw e;if(Date.now()>=t)throw e;P.write(`Broker acknowledgment was interrupted; retrying.
17
+ `),await Xi(n,t)}}async function Ki(e){let t=new Date(e.expiresAt).getTime(),n=Yi(e.intervalSeconds),r;for(P.write(`Waiting for browser approval...
18
+ `);Date.now()<t;){let i;try{i=await Ci(e.id,e.pollSecret)}catch(e){if(e instanceof B){if(!e.retryable)throw e;n=Yi(e.retryAfterSeconds??n)}r=e,P.write(`Authorization poll was interrupted; retrying.
19
+ `),await Xi(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=Yi(i.retryAfterSeconds??n),await Xi(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:throw Error(ye(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${w(r,[e.pollSecret])}`)}function qi(e,t,n){let r=e.state===`opened`;return!r&&!P.isTTY?!1:(P.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...P.isTTY?[`Open this one-time approval URL in your browser:`,t.verificationUrl]:[`Approval reference: ${n}`],`Comparison code: ${t.comparisonCode}`,`Confirm that the browser shows the same code before approving.`,``].join(`
20
+ `)),!0)}function Ji(){switch(Ht()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function Yi(e){return Math.min(Vi,Math.max(Bi,e))}async function Xi(e,t){let n=t-Date.now();n>0&&await Wt(Math.min(e*1e3,n))}function Zi(e,t){return{host:e.host,provider:e.provider,apiKeyId:e.credential.apiKey.id,name:ye(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function H(e,t,n,r){return{...v(n,r===void 0?[]:[r]),data:Zi(e,t)}}function Qi(e,t){return e.expiresAt===null||e.expiresAt===void 0||t.expiresAt===null||t.expiresAt===void 0?!1:new Date(e.expiresAt)>new Date(t.expiresAt)}async function $i(){return null}async function ea(e){let t=null,n=e=>{t=e};try{await st(e,n),await Xe(n)}catch(e){return{materialized:t,failure:w(e)}}return{materialized:t,failure:null}}async function ta(e,t,n,r){if(r.failure!==null)return{scope:e,selected:null,identity:null,authorization:null,error:r.failure};let i=null,a=null,o,s=e=>{o=e,a=na(e.credential,r.materialized)};try{let t=await p({method:`POST`,path:`/v1/auth/me/permissions`,body:{operation:[]},auth:e,requesterScope:e,responseFormat:`json`,onAuthPrepared:s});if(!t.ok)throw Error(ra(t));if(a===null)throw Error(`Live permission probe did not prepare a credential`);if(i=sa(t.data),e===`read`)return{scope:e,selected:a,identity:null,authorization:i,error:null};if(o===void 0)throw Error(`Live permission probe did not retain its prepared credential`);let n=await $i(e,o);return{scope:e,selected:a,identity:n,authorization:i,error:null}}catch(r){return{scope:e,selected:a,identity:null,authorization:i,error:w(r,ia(t,n,o))}}}function na(e,t){if(e===null)return null;let n=t??Ue().source;if(n===null)throw Error(`Prepared credential has no local provenance`);return{credential:e,source:n}}function ra(e){return[e.summary,...e.warnings].join(` — `)}function ia(e,t,n){return[b().userBearerToken,...ve(n?.headers??{}),...e.state===`found`?it(e.stored.credential.tokens):[],t.state===`found`?t.stored.credential.secret:void 0]}function aa(e,t,n=null){let r=t.state===`found`?t.stored:void 0,i=r?.credential.apiKey.expiresAt??null;return{host:e,present:r!==void 0,provider:r?.provider??null,activation:r?.activation??null,apiKeyId:r?.credential.apiKey.id??null,subject:r?.credential.apiKey.subject??null,scope:r?.credential.apiKey.scopes??[],name:r===void 0?null:ye(r.credential.apiKey.name,[r.credential.secret]),status:r?.credential.apiKey.status??null,expiresAt:i,metadataSource:r===void 0?null:n?.state===`verified`?`clerk`:`store-cache`,live:n===null?null:{state:n.state,summary:n.summary},expiresInDay:ua(i),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function oa(e,t){let n=t.state===`found`?t.stored:void 0;return{host:e,present:n!==void 0,provider:n?.provider??null,expiresAt:n?.credential.expiresAt??null,expired:n===void 0?null:et(n.credential),renewable:n===void 0?null:n.credential.tokens.refresh_token!==void 0,identity:n===void 0?null:tt(n.credential),client:n?.credential.client??null,storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function sa(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)throw Error(`permission probe returned no JSON response`);let t=g.safeParse(e.response);if(!t.success)throw t.error;return t.data}function ca(e,t){let{expiresAt:n,expiresInDay:r}=aa(e,t);return n!==null&&r!==null&&new Date(n).getTime()<=Date.now()?` (cached expiry passed ${Math.abs(r)}d ago; \`auth status\` re-checks it with aVenture sign-in)`:``}var la=864e5;function ua(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/la)}var da=7;function fa(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,da)}\u2026${e.slice(-4)}`}var pa=13,ma=14;function ha(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.apiKey.host}`+(e.apiVersion===null?` (api build unavailable)`:` (api ${e.apiVersion})`),``,..._a(e.oauth,e.cliName,e.refresh),...ya(e.apiKey,e.oauth,e.cliName),``,U(`Providers`,Sa(e.providers)),U(`Environment`,Ca(e.resolved)),U(`Selected`,wa(e.resolved,e.refresh,e.cliName)),...ga(e.live),...e.systemOk?[]:[U(`System`,`uptime read failed`)]].join(`
21
+ `)}function ga(e){if(e===null)return[];let t=W(`local credential provenance was captured before verification`);if(e.error!==null)return[``,U(`Live probe`,`${e.scope} permission probe failed`),t,W(e.error)];if(e.authorization===null)return[];let n=e.authorization.permissionGrant,r=e.identity;return[``,U(`Live probe`,`${e.scope} permission probe succeeded`),t,W(`operation access ${e.authorization.operationAccess}; ${n.role.length} role; ${n.permission.length} permission`),...r===null?[W(e.scope===`read`?`identity not requested for a read-scope credential`:`identity unavailable in this build`)]:[U(`Live account`,r.nameFull??r.email??r.clerkUserId??r.id)],W(`no API operation was executed or individually authorized`)]}function U(e,t){return` ${e.padEnd(pa)}${t}`}function W(e){return` ${``.padEnd(pa)}${e}`}function _a(e,t,n){switch(e.state){case`found`:{let{credential:r,provider:i}=e.stored,a=tt(r);return[U(`OAuth`,`${a.email??a.subject??`unknown identity`} via ${i}`),W(va(r,t,n))]}case`missing`:return[U(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[W(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[U(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[U(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function va(e,t,n){return et(e)?e.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:n.failure===null?n.materialized===`api-key`?`access token expired and renewal failed; the API key is in use — \`${t} auth login\` renews OAuth`:`access token expired — not renewed while AUTH_TOKEN is set in the environment`:`access token expired — ${n.failure}`:`access token valid until ${e.expiresAt}`}function ya(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[U(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[W(`stored credential invalid: ${e.error}`)]]:[U(`Signed in`,`credential storage unavailable`),W(r)]}return[U(t.state===`found`?`API key`:`Signed in`,e.subject??`unknown subject`),W(`via ${e.provider??`unknown store`}`),U(`Key`,`${e.name??`unnamed`} ${fa(e.apiKeyId)}`),...ba(e,n),U(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function ba(e,t){let n=e.live,r=e.expiresInDay,i=e.expiresAt;if(n?.state===`invalid`)return[U(`Key state`,`rejected by aVenture sign-in \u2014 ${n.summary}`),W(`run \`${t} auth logout\`, then \`${t} auth login --key\``)];let a=n?.state===`verified`;return[U(`Key state`,a?`${e.status??`unknown`}, verified by aVenture sign-in now`:`${e.status??`unknown`} when stored`),...i===null||r===null?[W(`no expiry recorded`)]:[W(xa(i,r,a?`expires`:`cached expiry`))],...a?[]:[W(n===null?"aVenture sign-in owns the live verdict — `auth status` re-checks it":`aVenture sign-in could not be reached \u2014 ${n.summary}`)]]}function xa(e,t,n){let r=e.slice(0,10);return new Date(e).getTime()<=Date.now()?`${n} ${r} passed ${Math.abs(t)}d ago`:t<=ma?`${n} ${r}, ${t}d away`:`${n} ${r}`}function Sa(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`browser sign-in`:`no browser sign-in`,t?`oauth ${rt(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function Ca(e){return`${x.authToken}=${e.present?e.source??`resolved`:`unset`}`}function wa(e,t,n){return e.present||t.materialized===`env`?`${x.authToken} from the environment`:t.materialized===`oauth`?`saved OAuth access token`:t.materialized===`api-key`?`saved API key`:`none \u2014 sign in with \`${n} auth login\``}var Ta=`# >>> aventure-cli completion setup (managed by aventure-cli) >>>`,Ea=`# <<< aventure-cli completion setup (managed by aventure-cli) <<<`,Da=`.aventure-cli-completion.bak`;function Oa(e,t){e.command(`install`).summary(`install shell completion loaders`).description(`Install managed shell completion loaders for supported shells.`).action(()=>Fa([])),e.command(`uninstall`).summary(`remove shell completion loaders`).description(`Remove managed shell completion loaders installed by ${t}.`).action(()=>Fa([`--uninstall`]))}function ka(e,t){e.command(`setup`).summary(`configure zsh completion startup`).description(`Configure ~/.zshrc so zsh loads ${t} completion loaders.`).option(`--dry-run`,`print the managed zshrc block without writing`).option(`--yes`,`apply without prompting`).option(`--uninstall`,`remove the managed zshrc block`).action(async e=>{let t=Na(),n=await Ma({rcFile:A(Bt(),`.zshrc`),installerPath:t,mode:e.uninstall?`uninstall`:`install`,dryRun:e.dryRun,prompter:e.yes||e.dryRun?void 0:Ka});N.stdout.write(`${n.message}\n`),!n.cancelled&&!e.dryRun&&Fa(e.uninstall?[`--uninstall`]:[])})}function Aa(e,t=`fpath-only`){return[Ta,`# installer: ${e}`,'fpath=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" $fpath)',...t===`fpath-and-compinit`?[`autoload -Uz compinit`,`compinit`]:[],Ea].join(`
22
+ `)}function ja(){let e=Fa([`--status`],`pipe`);if(e.status!==0)return{refreshed:!1,message:`completion status exited ${e.status??1}`};if(!Ia(e.stdout??``))return{refreshed:!1,message:`no managed shell completions found`};let t=Fa([],`pipe`);return t.status===0?{refreshed:!0,message:(t.stdout??``).trim()||`shell completions refreshed`}:{refreshed:!1,message:`completion refresh exited ${t.status??1}`}}async function Ma({rcFile:e,installerPath:t,mode:n,dryRun:r=!1,prompter:i}){let a=La(e),o=a.length===0?[]:a.split(`
23
+ `),s=Ra(o,e);if(n===`uninstall`&&s===null)return{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:a};let c=n===`install`?za(o,s,t,e):Ba(o,s);return c===a?{changed:!1,cancelled:!1,message:`${e}: already up-to-date`,content:c}:r?{changed:!0,cancelled:!1,message:c,content:c}:i!==void 0&&!await i(`Update ${e}?`)?{changed:!0,cancelled:!0,message:`${e}: unchanged; pass --yes to apply without a prompt`,content:a}:(Ua(e,c),{changed:!0,cancelled:!1,message:`${e}: updated`,content:c})}function Na(e=N.argv[1]){let t=e===void 0?``:Pa(e),n=A(k(t),`..`,`..`,`scripts`,`install-zsh-completion-loader.mjs`);return M(n)?n:A(k(t),`..`,`scripts`,`install-zsh-completion-loader.mjs`)}function Pa(e){try{return Mt(e)}catch{return A(e)}}function Fa(e,t=`inherit`){let n=wt(N.execPath,[Na(),...e],{encoding:t===`pipe`?`utf8`:void 0,stdio:t});if(n.error!==void 0)throw n.error;if(t===`inherit`){n.status!==0&&(N.exitCode=n.status??1);return}return{stdout:n.stdout?.toString(),stderr:n.stderr?.toString(),status:n.status}}function Ia(e){return e.split(/\r?\n/u).some(e=>e.trim().endsWith(`: managed`))}function La(e){return M(e)?(Wa(e),At(e,`utf8`)):``}function Ra(e,t){let n=Va(e,Ta),r=Va(e,Ea);if(n.length===0&&r.length===0)return null;if(n.length!==1||r.length!==1||n[0]>=r[0])throw Error(`${t} has malformed managed completion setup markers; fix manually before retrying.`);return[n[0],r[0]]}function za(e,t,n,r){let i=t===null?[...e]:[...e.slice(0,t[0]),...e.slice(t[1]+1)],a=Ha(i),o=Aa(n,a===-1?`fpath-and-compinit`:`fpath-only`).split(`
24
+ `),s=t===null?a:t[0],c=s===-1?i.length:s;if(t!==null&&a!==-1&&a<c)throw Error(`${r} runs compinit before the managed block; move the block above compinit manually.`);return Ga([...i.slice(0,c),...o,...i.slice(c)])}function Ba(e,t){return Ga(t===null?e:[...e.slice(0,t[0]),...e.slice(t[1]+1)])}function Va(e,t){return e.flatMap((e,n)=>e===t?[n]:[])}function Ha(e){return e.findIndex(e=>/^\s*(autoload\s+.*\bcompinit\b|compinit(?:\s|$))/.test(e))}function Ua(e,t){kt(k(e),{recursive:!0}),M(e)&&(Wa(e),Wa(`${e}${Da}`),Dt(e,`${e}${Da}`));let n=A(k(e),`.${Tt(e)}.${N.pid}.tmp`);Wa(n),It(n,t,{mode:420}),Nt(n,e)}function Wa(e){if(M(e)&&Ot(e).isSymbolicLink())throw Error(`refusing to write symlink: ${e}`)}function Ga(e){let t=e.join(`
25
+ `);return t.length===0||t.endsWith(`
26
+ `)?t:`${t}\n`}async function Ka(e){if(!N.stdin.isTTY)return!1;let t=qt({input:N.stdin,output:N.stdout});try{let n=await t.question(`${e} [y/N] `);return/^(y|yes)$/i.test(n.trim())}finally{t.close()}}var qa=new Intl.Collator(void 0,{numeric:!0}),Ja=2e4,Ya=[`lib`,`aventurevc-releases`],Xa=2;function Za(e,t=S()){let n=t.registry===``?`Requires npm authentication for @aventurevc packages.`:`Installs from npm.`;O(e.command(`update`).summary(`Check for or install the latest release`).description([`Compare the running CLI version against the latest published`,`release and install it into the active published bin prefix.`,``,`Refuses to install when the running binary is the working-tree build`,`(rebuild that checkout instead). ${n}`,`--execute is deprecated, accepted, and ignored; update executes by its verb.`].join(`
27
+ `)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>L({mode:D(e)},Qa(void 0,`apply`,e.release)))}function Qa(e,t=`apply`,n){let r=e;try{r??=S(process.argv[1])}catch(e){return v(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,o=r.registry===``?``:le,s=r.registry===``&&i===`@aventurevc/aventure-cli`,c=n;if(c===void 0){let e=$a([`view`,o,`version`,`--silent`,`--global`],r,{timeout:Ja});if(!e.ok)return{...e,data:null};if(c=(e.data??``).trim(),c===``)return v(`npm view ${o} returned empty version`,[`empty_stdout`])}let l=n!==void 0||s||qa.compare(a,c)<0,u={targetPackage:o,runningPackage:i,currentVersion:a,latestVersion:c,upgradeAvailable:l,upgradeInstalled:!1};if(t===`check`)return y(`${i}@${a} → ${o}@${c} (${l?`available`:`up to date`})`,u);let d=no(r),f=d===null?null:A(d.installPrefix,...Ya,c);if(!l)return y(`${i}@${a} already matches ${o}@${c}`,u);if(r.workingTreeRoot!==null)return v(`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"]);if(d===null&&r.name===`@aventurevc/mcp-server`)return v(`the running MCP package is not in a verifiable global npm prefix`,[`npm install was not run`]);let p=d===null?[]:[`--prefix`,d.installPrefix],m=s?eo(d,o,c):[];if(s){let e=$a([`uninstall`,`-g`,...p,le],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return v(`Cannot remove the retired ${le}: ${e.summary}`,[...e.warnings,...m])}let h=o===``?[o,``]:[o];if(!(f!==null&&h.every(e=>M(A(f,`lib`,`node_modules`,...e.split(`/`),`package.json`))))){let e=$a([`install`,`-g`,...f===null?[]:[`--prefix`,f],...h.map(e=>`${e}@${c}`)],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,warnings:[...e.warnings,...m],data:null}}let g=f===null?void 0:to(f,o,c);if(g?.ok===!1)return{...g,warnings:[...g.warnings,...m],data:null};if(d!==null&&f!==null)try{ao(f,d.installPrefix),oo(d.installPrefix)}catch(e){return v(`${o}@${c} activation failed: ${so(e)}`,[`release prefix: ${f}`])}let _=co();return y(`${o} upgraded to ${c}`,{...u,upgradeInstalled:!0,installPrefix:d?.installPrefix,verifiedVersion:g?.data??void 0,completionRefreshed:_.refreshed,completionRefreshMessage:_.message})}function $a(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=wt(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?v(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):v(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
28
+ `).slice(-3).join(` | `);return v(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return y(`npm ok`,a.stdout??``)}function eo(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${le}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function to(e,t,n){let r;try{let n=S(A(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));r=A(e,`bin`,n.bin[0])}catch(e){return v(`updated ${t} verification failed: ${so(e)}`,[`invalid_package_metadata`])}let i=wt(process.execPath,[r,`--version`],{encoding:`utf8`});if(i.error)return v(`updated ${t} verification failed: ${i.error.message}`,[`spawn_error`]);let a=(i.stdout??``).trim();if(i.status!==0||a!==n){let e=(i.stderr??``).trim().split(`
29
+ `).slice(-3).join(` | `);return v(`updated ${t} verification expected ${n} but active bin reported ${a||`empty output`}`,[e||`active bin: ${r}`])}return y(`active CLI version verified`,a)}function no(e){let t=`${j}lib${j}node_modules${j}${e.name.replace(`/`,j)}`,n=e.packageRoot.lastIndexOf(t);if(n<0)return null;let r=e.packageRoot.slice(0,n);return{installPrefix:ro(e)??r}}function ro(e){let t=`${j}${Ya.join(j)}${j}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:e.packageRoot.slice(0,n)}function io(e){return M(e)?Mt(e):null}function ao(e,t){let n=A(t,`bin`);kt(n,{recursive:!0});for(let t of jt(A(e,`bin`))){let r=Mt(A(e,`bin`,t)),i=A(n,`.${t}-${process.pid}`);Ft(Et(n,r),i),Nt(i,A(n,t))}}function oo(e){let t=A(e,`bin`),n=jt(t).flatMap(e=>io(A(t,e))??[]),r=A(e,...Ya),i=jt(r).toSorted((e,t)=>qa.compare(t,e)).slice(Xa).map(e=>A(r,e)).filter(e=>!n.some(t=>t.startsWith(`${e}${j}`)));for(let e of i)Pt(e,{recursive:!0,force:!0})}function so(e){return e instanceof Error?e.message:String(e)}function co(){try{return ja()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var lo=[{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 its generated status operation`},{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`}],uo=`operationFingerprint`;function fo(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: [...] }`:",...lo.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(`
30
+ `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),L({mode:D(e)},await po(t))})}async function po(e){let t=ho(),n=go(e),[r,i]=await Promise.all([_o(e),vo(t,e)]),a=[n.check,r,i.check,await bo(e),Do(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:mo(a,`pass`),warn:mo(a,`warn`),fail:mo(a,`fail`),skip:mo(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(`
31
+ `);return c.ok?y(l,c,{counts:o}):{...v(l,s,{counts:o}),data:c}}function mo(e,t){return e.filter(e=>e.status===t).length}function G(e,t,n){return{name:e,status:t,message:n}}function ho(){return E.find(e=>e.intent===`status`&&e.resource===`status`)}function go(e){let t=S(),n=Qa(t,`check`);if(!n.ok||n.data===null)return{check:G(`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?G(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):G(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function _o(e){try{let{EntityDetailSchema:e}=await import(`./detail-CFSXWI3r.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return G(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return G(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${w(t)}.`)}}async function vo(e,t){if(e===void 0)return{check:G(`api-host`,`skip`,`No status operation resolved from the generated catalog; fix the catalog check first.`),servedFingerprint:null};let n;try{n=b().host}catch(e){return{check:G(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${w(e)}.`),servedFingerprint:null}}let r=await p({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>v(w(e)));return r.ok?{check:G(`api-host`,`pass`,`${e.method} ${e.path} answered at ${n}.`),servedFingerprint:yo(r.data)}:{check:G(`api-host`,`fail`,r.httpStatus===401?`Replace or unset the credential ${n} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} returned ${r.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} at ${n} returned ${r.summary}.`),servedFingerprint:null}}function yo(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[uo];return typeof n==`string`&&n.length>0?n:null}async function bo(e){let t=Ue(),[n,r]=await Promise.all([So(),Co()]);if(r.state===`unavailable`&&r.cause===`environment`)return G(`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 G(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&et(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return G(`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 G(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${x.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await xo(e,t);return G(`auth`,i.status,`Credential source available: ${wo(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?G(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${x.authToken} through the environment — ${r.summary}.`):G(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${x.authToken} in the environment.`)}async function xo(e,t){let n=T(b().host),r=await ea(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await $i(`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,[b().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function So(){let e;try{e=T(b().host)}catch(e){return{state:`unavailable`,summary:w(e)}}return await ot(e)}async function Co(){let e;try{e=T(b().host)}catch(e){return{state:`unavailable`,summary:w(e),cause:`environment`}}try{return await Je(e)}catch(e){return{state:`unavailable`,summary:w(e),cause:`storage`}}}function wo(e,t,n){return[Ca(e),`oauth=${Eo(t)}`,`api-key=${To(n)}`].join(` `)}function To(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=T(b().host);return`${e.stored.activation}${ca(t,e)}`}function Eo(e){switch(e.state){case`found`:return et(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 Do(e,t,n,r){let i=E.length;if(e===void 0)return G(`catalog`,`fail`,`Regenerate the command catalog with \`make mcp-generate-contracts\` and reinstall: none of its ${i} operations is the status operation.`);if(t===null)return G(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${St}.`);if(t===`bdc072b1fbd068e6`)return G(`catalog`,`pass`,`${i} generated operations match the set the API serves (${St}).`);let a=`This catalog describes a different operation set than the API serves (${St} vs ${t})`;return n===!0?G(`catalog`,`fail`,`${a}: run \`${r} update\`.`):G(`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 Oo=C(z,`oauth`),ko=[C(z,`start`),C(z,`poll`),C(z,`acknowledge`)],Ao=C(z,`revoke`);function jo(t,n=S().bin[0]){let r=Fo(t);fo(r,n);let i=[`${Oo.description} Default method: OAuth in your browser.`,`With --key: ${ko.map(({description:e})=>e).join(` `)}`].join(`
32
+ `);O(Po(r,[Oo,...ko],i)).action(Mo),O(Po(r,[Ao],Ao.description)).action(No),O(r.command(`status`).summary(`Keep saved credentials current and report them with API build and uptime`).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`,` - system: GET /v1/status response (uptime SLA)`,``,`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(`
33
+ `)).addOption(new e(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){Io(this),L({mode:D(e)},await Lo(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: ${x.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(`
34
+ `)).action(async function(){Io(this);let e=await ea(n),t=process.env[x.authToken]?.trim();if(e.failure===null&&t!==void 0&&t.length>0){process.stdout.write(`${t}\n`);return}L({mode:`text`},e.failure===null?Go(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):v(`auth token: ${e.failure}`))})}async function Mo(e){Io(this);let t=D(e);if(e.providers===!0){L({mode:t},await zo());return}L({mode:t},e.key===!0?await Ui({noBrowser:!e.browser,clientLabel:e.clientLabel}):await ut({noBrowser:!e.browser}))}async function No(e){Io(this),L({mode:D(e)},await Mi({forgetLocal:e.forgetLocal===!0}))}function Po(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 Fo(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${Oo.command}\`: ${Oo.summary}; \`--key\` ${ko[0].summary.toLowerCase()}.`,`\`${Ao.command}\`: ${Ao.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build and uptime.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
35
+ `))}function Io(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function Lo(e,t){let n;try{n=T(b().host)}catch(e){return v(`auth status: invalid API host — ${w(e)}`)}let r=Ue(),i=ea(e),[a,o,s]=await Promise.all([Wo(`/v1/status`,`GET /v1/status`),Wo(`/info`,`GET /info`),Bo()]),c=await i,[l,u]=await Promise.all([ot(n),Ro(n)]),d=t===void 0?null:await ta(t,l,u.inspection,c),f=S().version,p=aa(n,u.inspection,u.verification),m=ha({cliName:e,cliVersion:f,apiVersion:o.ok?Ho(o.data):null,oauth:l,apiKey:p,providers:s,resolved:r,refresh:c,systemOk:a.ok,live:d}),h={cli:{version:f},api:o.ok?o.data??null:null,auth:{[x.authToken]:r},selected:c.materialized,oauth:oa(n,l),apiKey:p,providers:s,live:d,system:a.ok?a.data??null:null,...o.ok?{}:{apiError:o.summary},...a.ok?{}:{systemError:a.summary}};return c.failure===null?!o.ok&&o.httpStatus===401?{...v(`auth status: the API rejected the selected credential (401) | ${m}`,[`Replace or unset ${x.authToken}, or run \`${e} auth login\`.`]),data:h}:d!==null&&d.error!==null?{...v(`auth status: ${d.scope} permission probe failed — ${d.error}`,[d.error]),data:h}:d!==null||r.present||l.state===`found`||u.inspection.state===`found`?y(m,h):Go(`auth status: no credentials resolved | ${m}`,h,e,{oauth:l.state===`missing`,apiKey:u.inspection.state===`missing`}):{...v(`auth status: ${c.failure} | ${m}`,[c.failure]),data:h}}async function Ro(e){let t=await Vo(e);if(t.state!==`found`)return{inspection:t,verification:null};let{stored:n,verification:r}=await ki(t.stored);return{inspection:{state:`found`,stored:n},verification:r}}async function zo(){let e=await Bo();return e.state===`found`?y(`Sign-in providers for the selected API host`,e.catalog):v(`auth login --providers: ${e.summary}`)}async function Bo(){try{return{state:`found`,catalog:await lt()}}catch(e){return{state:`unavailable`,summary:w(e)}}}async function Vo(e){try{return await Je(e)}catch(e){return{state:`invalid`,summary:w(e)}}}function Ho(e){if(!Uo(e))return null;let t=ii.safeParse(Reflect.get(e,`response`));if(!t.success)return null;let n=t.data.build.version?.trim();return n&&n.length>0?n:null}function Uo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Wo(e,t){return await p({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>v(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}function Go(e,t,n,r){return{...v(e,[...r.apiKey?[`For an API key (works over SSH), run \`${n} auth login --key\`.`]:[],...r.oauth?[`For OAuth, run \`${n} auth login\`; without a browser it prints a device code.`]:[],`For non-interactive use, set ${x.authToken} to an aVenture API key (create one at ${ae}/settings/api-keys).`]),data:t}}function Ko(e,t=E,n=S().bin[0]){let r=e.command(`completion`).summary(`Generate shell completion scripts`).description(`Generate shell completion scripts for the aVenture CLI.`);for(let i of[`bash`,`fish`,`zsh`])r.command(i).summary(`Print ${i} shell completions`).description(`Print ${i} completion definitions for ${n}.`).action(()=>{N.stdout.write(Jo(e,i,t))});Oa(r,n),ka(r,n)}function qo(){return S().bin}function Jo(e,t,n=E,r=qo()){let i=rs(n);return t===`fish`?[`# fish completions for ${r.join(`, `)}`,...Xo(e),...r.map(e=>`complete -c ${K(e)} -e`),`${gs(r)} -f`,...Zo(e,r),...Qo(e,i,r),``].join(`
36
+ `):Yo(e,t,i,r)}function Yo(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=os(e,n);return[...t===`zsh`?[`#compdef ${r.join(` `)}`]:[],`# ${t} completions for ${r.join(`, `)}`,`${i}_aventure_cli_commands=(`,...o.map(e=>` ${e}`),`)`,`${i}_aventure_cli_options=(`,...s.map(e=>` ${e}`),`)`,`${i}_aventure_cli_values=(`,...c.map(e=>` ${e}`),`)`,``,...ls(t),...t===`bash`?[a,``]:[``]].join(`
37
+ `)}function Xo(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${$o(e).filter(e=>e.required||e.optional).flatMap(e=>fs(e)??[]).map(K).join(` `)}\n set -l tokens (commandline -xpc)\n if test (count $tokens) -gt 0\n set -e tokens[1]\n end\n set -l path\n set -l skip_next 0\n for token in $tokens\n if test $skip_next -eq 1\n set skip_next 0\n continue\n end\n if string match -q -- '--*=*' $token\n set -l name (string replace -r '^--([^=]+)=.*$' '$1' -- $token)\n contains -- $name $global_value_options; and continue\n end\n if string match -q -- '--*' $token\n set -l name (string replace -r '^--' '' -- $token)\n if contains -- $name $global_value_options\n set skip_next 1\n continue\n end\n break\n end\n if string match -q -- '-*' $token\n break\n end\n set -a path $token\n end\n printf '%s\\n' $path\nend\n`,`function __aventure_cli_path_is
38
+ set -l expected $argv
39
+ set -l actual (__aventure_cli_command_path)
40
+ if test (count $actual) -ne (count $expected)
41
+ return 1
42
+ end
43
+ if test (count $expected) -eq 0
44
+ return 0
45
+ end
46
+ for index in (seq (count $expected))
47
+ if test $actual[$index] != $expected[$index]
48
+ return 1
49
+ end
50
+ end
51
+ return 0
52
+ end
53
+ `].flatMap(e=>e.split(`
54
+ `))}function Zo(e,t){return as(e).map(e=>`${gs(t)} -f -n ${K(_s(e.parentPath))} -a ${K(e.name)} -d ${K(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function Qo(e,t,n){return ps(e).flatMap(e=>{let r=hs(e),i=r.length===0?void 0:_s(r);return $o(e).flatMap(e=>{let a=t.get(is(r,e));return cs(a)?es(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function $o(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function es(e,t,n,r){let i=fs(e);if(i===void 0)return[];let a=e.argChoices??ss(n),o=[`-l ${K(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${K(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${K(t)}`,c=e.required||e.optional?ts(a,ns(i,n)):`-f`,l=`${gs(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${K(vs(e.description))}`]:a.map(t=>`${l} -a ${K(t)} -d ${K(vs(e.description))}`)}function ts(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function ns(e,t){return e===`from-file`?!0:t===void 0||t.some(({location:e})=>e!==`body`)?!1:t.every(({schemaFormat:e})=>e===`binary`)?!0:t.length===1&&[`file`,`path`].includes(e.split(`-`).at(-1)??``)}function rs(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...Tn(e.requestBody??[]).map(({variant:e})=>e.map(({parameter:e})=>e))].flatMap(t=>{let n=t[0];if(n===void 0)throw Error(`Generated CLI option has no parameter`);return[[is(e.cliPath,n),t]]})))}function is(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):fs(t);if(`flag`in t&&(n===void 0||n.length===0||n===t.flag))throw Error(`Cannot render completion for option flag: ${t.flag}`);return`${e.join(`\0`)}\u0000${n??``}`}function as(e){return ps(e).flatMap(e=>e.commands.map(t=>({parentPath:hs(e),name:t.name(),description:vs(t.summary()||t.description()||t.name())})))}function os(e,t){let n=[],r=[];for(let i of ps(e)){let e=hs(i);for(let a of $o(i)){let i=fs(a);if(i===void 0)continue;let o=t.get(is(e,a));if(!cs(o))continue;let s=a.argChoices??ss(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&ns(i,o)&&(c=`file`)),n.push(us([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(us([e.join(` `),`--${i}`,t,a.description]))}}return[as(e).map(e=>us([e.parentPath.join(` `),e.name,e.description])).toSorted((e,t)=>e.localeCompare(t)),n.toSorted((e,t)=>e.localeCompare(t)),r.toSorted((e,t)=>e.localeCompare(t))]}function ss(e){let t=e?.[0]?.choices;if(e!==void 0&&t!==void 0)return e.every(e=>e.choices?.length===t.length&&e.choices.every((e,n)=>e===t[n]))?t:void 0}function cs(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function ls(e){let t=e===`bash`,n=t?`COMP_WORDS`:`words`,r=t?`COMP_CWORD`:`CURRENT`,i=t?"${path[*]}":"${(j: :)path}",a=t?'"${_aventure_cli_options[@]}"':`$_aventure_cli_options`,o=t?'"${_aventure_cli_values[@]}"':`$_aventure_cli_values`,s=t?'"${_aventure_cli_commands[@]}"':`$_aventure_cli_commands`;return[`function _aventure_cli {`,` local current="\${${n}[${r}]}" previous="\${${n}[${r}-1]}" row row_path long short description mode name value option token key prefix candidate file_current`,...t?[` COMPREPLY=()`]:[],` local index=${t?1:2} skip_next=0; local -a path names descriptions`,` while (( index < ${r} )); do`,` token="\${${n}[index]}"; (( skip_next )) && { skip_next=0; (( index++ )); continue; }`,` if [[ "$token" == -* && "$token" != "-" && "$token" != "--" ]]; then`,` option="\${token%%=*}"; key="${i}"; mode=''`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && break; mode=''; done`,` [[ -n "$mode" && "$mode" != none && "$token" != *=* ]] && skip_next=1`,` elif [[ "$token" != -* ]]; then path+=("$token"); fi`,` (( index++ ))`,` done`,` key="${i}"`,` if [[ "$current" == --*=* || ( "$previous" == -* && "$current" != -* ) ]]; then`,` option="$previous"; prefix=''; file_current="$current"; [[ "$current" == --*=* ]] && { option="\${current%%=*}"; prefix="$option="; file_current="\${current#*=}"; }`,` for row in ${a}; do IFS='|' read -r row_path long short description mode <<< "$row"; [[ "$row_path" == "$key" && ( "$long" == "$option" || "$short" == "$option" ) ]] && { option="$long"; break; }; mode=''; done`,t?` [[ "$mode" == file ]] && { while IFS= read -r candidate; do COMPREPLY+=("$prefix$candidate"); done < <(compgen -f -- "$file_current"); return 0; }`:` [[ "$mode" == file ]] && { _files; return 0; }`,t?` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { candidate="$prefix$value"; [[ "$candidate" == "$current"* ]] && COMPREPLY+=("$candidate"); }; done`:` [[ "$mode" == choice ]] && for row in ${o}; do IFS='|' read -r row_path long value description <<< "$row"; [[ "$row_path" == "$key" && "$long" == "$option" ]] && { names+=("$prefix$value"); descriptions+=("$description"); }; done`,` elif [[ "$current" == -* ]]; then`,` for row in ${a}; do`,` IFS='|' read -r row_path long short description mode <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$long" == "$current"* ]] && COMPREPLY+=("$long"); [[ -n "$short" && "$short" == "$current"* ]] && COMPREPLY+=("$short"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$long"); descriptions+=("$description"); [[ -n "$short" ]] && { names+=("$short"); descriptions+=("$description"); }; }`,` done`,` elif [[ "$previous" != -* ]]; then`,` for row in ${s}; do`,` IFS='|' read -r row_path name description <<< "$row"`,t?` [[ "$row_path" == "$key" ]] && { [[ "$name" == "$current"* ]] && COMPREPLY+=("$name"); }`:` [[ "$row_path" == "$key" ]] && { names+=("$name"); descriptions+=("$description"); }`,` done`,` fi`,...t?[]:[" (( ${#names} )) && compadd -d descriptions -a names"],` return 0`,`}`,...t?[]:[`_aventure_cli "$@"`]]}function us(e){return`$'${e.map(ds).join(`|`)}'`}function ds(e){return vs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function fs(e){return e.long?.replace(/^--/,``)}function ps(e){return[e,...e.commands.filter(ms).flatMap(e=>ps(e))]}var ms=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function hs(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function gs(e){return`complete ${e.map(e=>`-c ${K(e)}`).join(` `)}`}function _s(e){return[`__aventure_cli_path_is`,...e.map(K)].join(` `)}function vs(e){return e.replace(/\s+/g,` `).trim()}function K(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function ys(e,t){if(e!==t)return;let n=bs(t);n!==void 0&&t.error(`error: ${Ss(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function bs(e){if(!process.argv.includes(`--`)&&e.args.some(xs))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function xs(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function Ss(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Cs(e,t){return e.message.match(RegExp(`${t} '([^']+)'`,`iu`))?.[1]?.split(/\s+/u)[0]}function q(e){return e.flags.split(` `)[0]??e.flags}function ws(e,t){let n=Cs(t,`required option`),r=e.options.findIndex(e=>q(e)===n);if(r<0)return;let i=new Set((Hs(J(e))?.parameters??[]).flatMap(e=>e.location===`path`?[e.optionKey]:[])),a=e.options.slice(r+1).find(t=>{let n=e.getOptionValue(t.attributeName());return i.has(t.attributeName())&&typeof n==`string`&&n!==``});if(a!==void 0)return`hint: ${n} is still required for this nested command; supplied child selector ${q(a)} does not replace the parent selector.`}var Ts=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`],[`--transaction-id`,`--fundraise-round-id`]];function Es(e){let t=new Set(e.options.map(q)),n=process.argv.indexOf(`--`),r=new Set(n<0?process.argv:process.argv.slice(0,n));return e.args.filter(e=>r.has(e)&&/^--[^-=]/u.test(e)).map(e=>e.split(`=`)[0]??e).filter(e=>!t.has(e))}function Ds(e){let t=Hs(J(e))?.parameters??[],n=Es(e).flatMap(n=>{let r=Ts.find(e=>e.includes(n))?.find(t=>e.options.some(e=>q(e)===t))??t.filter(({name:e})=>`--${e.replace(/[A-Z]/gu,`-$&`).toLowerCase()}`===n).map(e=>e.flag.split(` `)[0])[0];return r===void 0?[]:[`use ${r}, not ${n}`]});return n.length===0?void 0:`hint: ${n.join(`; `)}`}function J(e){return e.parent===null?[]:[...J(e.parent),e.name()]}function Os(e){return e.commands.length===0?[e]:e.commands.flatMap(Os)}function ks(e,t){return J(t).slice(J(e).length)}function Y(e){return e.parent===null?e:Y(e.parent)}function As(e,t){let n=t=>{let n=ks(e,t);return n.length*2+ +![`get`,`list`].includes(n.at(-1)??``)};return t.toSorted((e,t)=>n(e)-n(t))[0]}function X(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function js(e,t){let n=J(e),r=process.argv.slice(2+n.length);return[Y(e).name(),...n,...ks(e,t),...r].map(X).join(` `)}function Ms(e,t){let n=Cs(t,`unknown option`);if(n===void 0||e.commands.length===0)return;let r=As(e,Os(e).filter(e=>e.options.some(e=>q(e)===n)));return r===void 0?void 0:`hint: run: ${js(e,r)}`}function Z(e){return e!==void 0&&Object.hasOwn(ft,e)}function Ns(e,t){return t.reduce((e,t)=>e?.commands.find(e=>e.name()===t),e)}function Ps(e,t){let n=J(e),r=[...n.slice(1),t];if(!Z(n.at(0))||!Z(r.at(0)))return;let i=Ns(Y(e),r);if(i===void 0)return;let a=i;for(let e of process.argv.slice(2+n.length+1)){if(e.startsWith(`-`))break;let t=a.commands.find(t=>t.name()===e);if(t===void 0)break;r.push(e),a=t}return r}function Fs(e,t){let[n]=J(e);if(!Z(n))return;let r=[n,t];return Ns(Y(e),r)?.commands.length===0?r:void 0}function Is(e){let[t,...n]=e.args;if(t===void 0)return[];let r=Os(Y(e)).map(J),i=n.findIndex((e,t)=>{let i=[...n.slice(0,t),e];return!r.some(e=>e.some((t,n)=>t===i[0]&&i.every((t,r)=>e[n+r]===t)))});return[t,...i<0?n:n.slice(0,i)]}function Ls(e,t){let n=process.argv.slice(2+J(e).length);if(!(t.length===0||t.some((e,t)=>n[t]!==e)))return Rs(e,t)}function Rs(e,t,n=[]){let r=J(e),i=ht(E).map(e=>e.cliPath).filter(e=>e[0]!==r[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a!==void 0)return`hint: run: ${[Y(e).name(),...a,...n].map(X).join(` `)}`}function zs(e,t,n){if(!Vs(t))return;let r=e.args.slice(n.length),i=r.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${[Y(e).name(),...t,...i<0?[]:r.slice(i)].map(X).join(` `)}`}function Bs(e){let t=J(e);if(t.at(1)!==void 0&&Z(t.at(0)))return`hint: inspect generated command group: ${[Y(e).name(),...t,`--help`].map(X).join(` `)}`}function Vs(e,t){let n=Hs(e);return n!==void 0&&(t===void 0||pe(n.intent)===t)}function Hs(e){return E.find(t=>t.cliPath.join(` `)===e.join(` `))}function Us(e){let t=J(e).join(` `),n=ht(E),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:De(r.operationId,n,Y(e).name()).map(e=>`hint: ${e}`)}function Ws(e){let t=J(e);if(Z(t.at(0))&&Vs(t))return`hint: inspect generated command: ${[Y(e).name(),...t,`--help`].map(X).join(` `)}`}function Gs(e){let t=new Set,n=[];for(let r of E){let i=Ns(e,r.cliPath);if(i===void 0)continue;let a=i.options.map(q);if(pe(r.intent))n.push(a);else for(let e of a)t.add(e)}let[r=[],...i]=n;return new Set(r.filter(e=>!t.has(e)&&i.every(t=>t.includes(e))))}function Ks(e,t){let n=J(e);if(Vs(n,!1)&&Gs(Y(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function qs(e,t,n=!0){let r=Y(e),i=r.commands.find(e=>e.name()===`command-catalog`),a=i?.commands.find(e=>e.name()===`search`);if(i===void 0||a===void 0)return;let o=[r.name(),i.name(),a.name(),t],s=J(e).at(0),c=a.options.find(e=>q(e)===`--root`),l=n&&c!==void 0&&Z(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(q(c),l);let u=ht(E),d=pr({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?Pr(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(X).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
55
+ `).filter(Boolean).map(e=>` ${e}`)].join(`
56
+ `)}function Js(e,t=``){if(e.commands.length>0&&!Vs(J(e)))return;let n=e.options.flatMap(e=>e.hidden?[]:[q(e)]),r=ht(E),i=Me(t,r,J(e),Y(e).name());return`${i===void 0?``:`hint: an id you already hold is read with: ${i}\n`}hint: ${J(e).join(` `)} accepts: ${n.join(` `)}`}function Ys(e,t){let n=Cs(t,`unknown command`);if(n===void 0||t.message.includes(`
57
+ (Did you mean `))return;let r=Is(e),i=Ls(e,r);if(i!==void 0)return i;let a=J(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Vs(o)?o:void 0)??Ps(e,n)??Fs(e,n);if(s!==void 0)return zs(e,s,r)??qs(e,s.join(` `),!1);let c=r.join(` `)||n,l=Bs(e)??qs(e,c),u=[...a,...r.slice(1)];return[l,r.length===a.length+a.length&&a.at(-1)===a.at(0)?zs(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?zs(e,u,r):void 0].filter(e=>e!==void 0).join(`
58
+ `)||void 0}function Xs(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=Es(e);for(let e of r)process.stderr.write(`error: unknown option '${e}'\n`);for(let n of[Ds(e)??(r.length>0?Js(e):void 0),bs(e),ws(e,t),...Us(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=bs(e)??Ws(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=Cs(t,`unknown option`),r=Ds(e)??Ms(e,t)??(n!==void 0&&!t.message.includes(`
59
+ (Did you mean `)?Ks(e,n)??Rs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??Js(e,n)??qs(e,J(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=Ys(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}process.exit(t.exitCode)}}var Zs=class extends e{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 Qs(e){e.showHelpAfterError(!1).exitOverride(Xs(e)),e.commands.length===0?e.hook(`preAction`,ys):e.registeredArguments.length===0&&e.addHelpOption(new Zs(e));for(let t of e.commands)Qs(t)}function $s(e,t=new Date){let n=nc(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 ec(e){return`${JSON.stringify(e,null,2)}\n`}function tc(e,t){let n=A(e),r=ec(t);return kt(k(n),{recursive:!0}),It(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function nc(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:ge(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 rc=`Match only the first canonical or CLI-alias command segment`,ic=[`text`,`lines`,`compact`,`json`,`ndjson`];function ac(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(`
60
+ `));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 ${Er(n)}\n`),oc(r,t,n),sc(r,t,n),cc(r,t,n),lc(r)}function oc(t,n,r){let i=t.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>`,rc).addOption(new e(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new e(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new e(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new e(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new e(`--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 e(`--format <format>`,`Text/file render format`).choices(ic)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(e){let t=this.optsWithGlobals(),i=D(t,`text`);kr(Or(t,e),n,i,r)})}function sc(t,n,r){let i=t.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 e(`--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();Ar(e,n,D(e,`text`),r)})}function cc(t,n,r){let i=t.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,rc).addOption(new e(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new e(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new e(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new e(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new e(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new e(`--format <format>`,`Text/file render format`).choices(ic)).option(`--output <path>`,`Write rendered output to a file`);O(i),i.action(function(){let e=this.optsWithGlobals();kr(e,n,D(e,`text`),r)})}function lc(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-yv0qwarU.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){L({mode:t},y(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=$s(n);if(e.output!==void 0){let n=tc(e.output,r);L({mode:t},y(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){Mr(`Unified operations JSON`,ec(r));return}L({mode:t},y(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var uc=S(Ut(import.meta.url)),Q=uc.bin[0];function dc(e,t){i({component:Q,event:`fatal`,message:e.message,error:e}),process.stderr.write(`${Q} fatal (${t}): ${e.stack??e.message}\n`);let n=e instanceof h?{httpStatus:e.problem.status,problem:e.problem}:{};rr({...v(`${Q} ${t}: ${e.message}`,[e.name||`Error`],n),counts:{exitCode:1}}),process.exit(1)}function fc(e){return ze[Fe(e,ft)??`cli`]}function pc(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:fc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>bt(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)mc(e,t,r,a,i.has(t.cliPath.join(` `)))}function mc(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=hc(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=>he(e.schemaType,e.itemSchemaType))?_e:``].filter(Boolean).join(`
61
+ `));let f=xt(t);for(let e of t.parameters)gc(u,e,i||e===f);if(In(u,t),pe(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),O(u),u.hook(`preAction`,e=>gt(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 ${yt(f.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),r=D(n),i=mt(f,e,n);if(!i.ok||i.data===null)return L({mode:r},i);let a=pt(t,i.data);if(a.length>0)return L({mode:r},v(`missing required options: ${a.join(`, `)}`));let o=await _c(t,i.data,r),s=ei(t,i.data,o);if(s!==null)return L({mode:r},s);n.explain===!0&&o.ok&&sr(r,o.data),o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):L({mode:r},o)});return}u.action(async function(){let e=this.optsWithGlobals(),n=D(e),r=pt(t,e);if(r.length>0)return L({mode:n},v(`missing required options: ${r.join(`, `)}`));let i=await _c(t,e,n),a=ei(t,e,i);if(a!==null)return L({mode:n},a);e.explain===!0&&i.ok&&sr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):L({mode:n},i)})}function hc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=ft[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function gc(t,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 e(n.flag,i);a!==void 0&&o.default(a);let s=new e(n.legacyFlag,i).conflicts(n.optionKey);t.addOption(o).addOption(s),t.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){t.option(n.flag,i,a);return}if(n.required&&!r){t.requiredOption(n.flag,i);return}t.option(n.flag,i)}async function _c(e,t,n){if(t.environment!==void 0){let e=ce(t.environment);if(e===null)return v(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${oe().join(`, `)}`]);process.env.API_ENV=e}let r=await Vn(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)]})),a=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]]})),o=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 ni(e,await p({method:e.method,path:m(e.operationId,i),searchParams:a,headers:o,body:r.data,contentType:vt(e,t),auth:e.auth,responseFormat:Ct(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0}))}process.on(`uncaughtException`,e=>dc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>dc(e instanceof Error?e:Error(String(e)),`unhandledRejection`));var vc=_t(process.argv.slice(2),E),yc=vc===`required`?E:ht(E),$=new r;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(Gr).version(uc.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.
62
+ `,`Mutations execute directly; --execute is a deprecated no-op.
63
+ The aVenture MCP server tools execute through this same CLI.`].join(`
64
+ `)).addOption(new e(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${se})`).choices([...oe()])).showHelpAfterError(`(run \`${Q} --help\` for usage)`),pc($,yc),jo($,Q),Za($,uc),Ko($,yc,Q),ac($,yc,Q),Vr($,yc,Q);for(let e of $.commands)e.helpGroup()||e.helpGroup(fc(e.name()).heading);if(Qs($),vc===`required`){let e=[$];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&(await st(),await Xe())}))}}var bc=new Set($.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));$.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find one news article; companies and people use the root lookup`],[`get`,` get Read one record`],[`list`,` list Read many records`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>bc.has(e)?[t]:[]),``,`Account (free or paid; every command that calls aVenture needs one):`,` Create one at ${ae}/sign-up, then run: ${Q} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Profile views, searches, and web searches count toward your monthly allowance.`,` Usage and upgrades: ${ae}/settings/subscription`,` Plans and prices: ${Q} billing plans list`,` Check what this shell holds with: ${Q} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
65
+ `,`Exit codes:`,` 0 envelope.ok === true
66
+ 1 envelope.ok === false
67
+ `,`Examples:`,` $ ${Q} auth login`,` $ ${Q} lookup --name Stripe --url https://stripe.com`,` $ ${Q} search "fintech companies in Austin"\n`,`Run \`${Q} <command> --help\` for its subcommands and options,`,`or \`${Q} help <command>\` for its full documentation.`].join(`
68
+ `));try{await $.parseAsync()}catch(e){dc(e instanceof Error?e:Error(String(e)),`parseAsync`)}export{};
@@ -1 +1 @@
1
- import{c as e}from"./tool-policy-GWWChw5-.js";function t(t,n,r,i){let a=t===`array`?n:t,o=t===`array`?`...`:``;return r===`uuid`||r===`date-time`||r===`date`?`${r}${o}`:a===`boolean`?`true|false${o}`:a===`integer`||a===`number`?`${a}${o}`:`${e(i)}${o}`}function n(e,t){let n=s(e);if(t===void 0||t.length===0)return n;let r=`Allowed values: ${t.join(`, `)}`;return n===``?`${r}.`:`${n} ${r}.`}var r={path:{heading:`Path parameters:`,rank:0},header:{heading:`Request headers:`,rank:1},input:{heading:`Input:`,rank:2},body:{heading:`Body fields:`,rank:3},option:{heading:`Options:`,rank:1/0}};function i(e){return o(e).rank}function a(e){return o(e).heading}function o(e){return e.location===`path`?r.path:e.location===`header`?r.header:e.inputType===`file`||e.schemaFormat===`binary`?r.input:e.location===`body`?r.body:r.option}var s=e=>e===``||/[.!?]$/u.test(e)?e:`${e}.`,c={researchData:{heading:`Research data commands:`,rank:0},account:{heading:`Account commands:`,rank:1},administration:{heading:`Administration commands:`,rank:2},cli:{heading:`CLI commands:`,rank:3}};function l(e,t){return e!==void 0&&u(e,t)===`administration`}function u(e,t){return d[e]??t?.[e]?.section}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,provenance:`administration`,billing:`account`,harness:`administration`,jobs:`administration`,operations:`administration`,metrics:`cli`,inference:`administration`,web:`researchData`,contacts:`administration`,"url-types":`researchData`,"unique-ids":`researchData`,research:`administration`,status:`cli`,agents:`cli`,help:`cli`},f=new Set([`metrics`]);export{n as a,a as c,u as i,s as l,f as n,t as o,l as r,i as s,c as t};
1
+ import{l as e}from"./tool-policy-CHLep0O4.js";function t(t,n,r,i){let a=t===`array`?n:t,o=t===`array`?`...`:``;return r===`uuid`||r===`date-time`||r===`date`?`${r}${o}`:a===`boolean`?`true|false${o}`:a===`integer`||a===`number`?`${a}${o}`:`${e(i)}${o}`}function n(e,t){let n=s(e);if(t===void 0||t.length===0)return n;let r=`Allowed values: ${t.join(`, `)}`;return n===``?`${r}.`:`${n} ${r}.`}var r={path:{heading:`Path parameters:`,rank:0},header:{heading:`Request headers:`,rank:1},input:{heading:`Input:`,rank:2},body:{heading:`Body fields:`,rank:3},option:{heading:`Options:`,rank:1/0}};function i(e){return o(e).rank}function a(e){return o(e).heading}function o(e){return e.location===`path`?r.path:e.location===`header`?r.header:e.inputType===`file`||e.schemaFormat===`binary`?r.input:e.location===`body`?r.body:r.option}var s=e=>e===``||/[.!?]$/u.test(e)?e:`${e}.`,c={researchData:{heading:`Research data commands:`,rank:0},account:{heading:`Account commands:`,rank:1},administration:{heading:`Administration commands:`,rank:2},cli:{heading:`CLI commands:`,rank:3}};function l(e,t){return e!==void 0&&u(e,t)===`administration`}function u(e,t){return d[e]??t?.[e]?.section}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,provenance:`administration`,billing:`account`,harness:`administration`,jobs:`administration`,operations:`administration`,metrics:`cli`,inference:`administration`,web:`researchData`,contacts:`administration`,"url-types":`researchData`,"unique-ids":`researchData`,research:`administration`,status:`cli`,agents:`cli`,help:`cli`},f=new Set([`metrics`]);export{n as a,a as c,u as i,s as l,f as n,t as o,l as r,i as s,c as t};
@@ -0,0 +1,22 @@
1
+ import{C as e,O as t,T as n,i as r,l as i,n as a,o,p as s,r as c,t as l,u,v as d,w as f,y as p}from"./person-owner-BJgNYLKX.js";import{r as m,s as ee,t as h,u as g}from"./result-envelope-BE0edu_S.js";import{i as _}from"./package-DfJq3Rui.js";import{a as te,c as ne,i as re,o as ie,s as ae}from"./tool-policy-CHLep0O4.js";import{C as oe,S as se,T as ce,_ as le,a as ue,b as v,c as de,d as fe,f as pe,g as y,h as me,i as b,l as he,m as ge,n as _e,o as ve,p as ye,r as x,s as be,t as S,u as xe,v as Se,w as Ce,x as we,y as Te}from"./detail-D07FzRkx.js";import{a as Ee,n as De,r as C,t as Oe}from"./text-field-r9akQrZl.js";import{a as ke,o as Ae}from"./cli-help-policy-DXZ7Rp0Z.js";import{Buffer as je}from"node:buffer";var w=o([`HIGH`,`MEDIUM`,`LOW`]),Me=n([o([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),f()]),Ne=p({excerpt:f(),sourceId:f(),sourceType:Me,sourceVersion:f().nullish()}),Pe=p({instruction:f(),operationId:f(),stepKey:f()}),Fe=p({body:f(),expectation:f(),method:i(f()),override:f(),reject:i(f()),typeCatalog:f()}),Ie=p({cliCommand:f(),mcpTool:f().nullish(),step:Pe,writeGuidance:Fe.nullish()}),Le=n([o([`ENTITY`,`TEXT`]),f()]),Re=p({description:f(),key:f(),type:Le}),ze=p({catalogRevision:s(),gateId:i(f()),input:i(Re),step:i(Ie),taskKey:f()}),T=o([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),Be=p({candidate:i(Ne),operationId:f().nullish(),outcome:T,probability:d().nullish(),taskKey:f().nullish(),taskPlan:ze.nullish()}),Ve=p({answer:f(),citation:i(Ne),confidence:w,resolution:Be.nullish()});function E(e,t,n=t.inputName){if(t.in===`body`)return n;let r=Ze.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?Xe(D(n!==`id`&&n!==`slug`?n:`${We(e.path)}${qe(n)}`),t):r.inputName}function He(e,t,n=Ke(e)){return Ue(Ge(e,t),new Set(n))}function Ue(e,t){if(!t.has(e))return e;let n=`body${qe(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function We(e){return Qe.find(([,t])=>t.test(e))?.[0]??`record`}function Ge(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=Je(t);return Xe(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?D(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function Ke(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>E(e,t)))}function qe(e){return e.replace(/^./u,e=>e.toUpperCase())}function D(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 Je(e){let t=D(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?Ye(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function Ye(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function Xe(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var Ze=[{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`}],Qe=[[`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 $e(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>et(t,E(e,t))),r=(t?.parameter??[]).map(t=>et(t,He(e,t)));return{selector:n.filter(e=>e.location===`path`||tt(e)),pagination:n.filter(nt),filter:[...n.filter(rt),...r.filter(rt)],body:r.filter(e=>!rt(e))}}function et(e,t){return{name:e.in===`body`?t:e.name,flag:re(t),required:e.required,location:e.in,description:e.description||`${e.name} ${e.in} parameter`}}function tt(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function nt(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function rt(e){return e.location!==`path`&&!tt(e)&&!nt(e)}function it(e,t){let n=e.requestBody?.[0],r={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:at(e)};return t?{...r,resource:e.resource,bodySchemaName:n?.schemaName??null,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:$e(e)}:{...r,optionalInput:ot(e)}}function at(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function ot(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)}}var st=160;function ct(e){return!Array.isArray(e)||e.length===0||!e.every(lt)?null:`Operation catalog matches\n${e.flatMap(e=>[`${e.operationId} ${e.method} ${e.path} (aventure_${e.intent})`,` ${e.summary}`,` required: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}`,...`optionalInput`in e?Object.entries(e.optionalInput).filter(([,e])=>e.length>0).map(([e,t])=>` optional ${e}: ${t.join(`, `)}`):[],...`argument`in e?Object.values(e.argument).flat().map(e=>` ${e.name} (${e.location}${e.required?`, required`:``}): ${e.description.length<=st?e.description:`${e.description.slice(0,157)}...`}`):[]]).join(`
2
+ `)}\n`}function lt(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 ut(e){let t=t=>{let n=e.parameter.filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map(dt);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`),i=[...new Set((e.requestBody?.[0]?.requiredPath??[]).map(e=>e.split(/[.[]/u)[0]))];return{tool:ae(e.intent),operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Object.fromEntries(i.map(e=>[e,`<${e}>`]))}}}function dt(e){return[e.name,`<${e.name}>`]}function ft(e){let t=pt(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function pt(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 O=2,mt=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 k(e,t){let n=j(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&k(e,`person`),_t(e,ht(n),n),_t(e,gt(n),n))}function ht(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=O&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;if(e.length>O&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function gt(e){return e===`person`?`people`:e.length>=O&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e)?`${e.slice(0,-1)}ies`:e.endsWith(`s`)?void 0:`${e}s`}function _t(e,t,n){t!==void 0&&t!==n&&t.length>=O&&/^[a-z]+$/u.test(t)&&e.add(t)}function vt(e){let t=new Set(A(e)),n=Array.from(t);for(let e of n)k(t,e);return t}function yt(e){return A(e).map(vt)}function bt(e,t){if(e.length===0)return!1;let n=vt(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function A(e){return j(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!mt.has(e))}function j(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 xt=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,St=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,Ct=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,wt=250,Tt=40,Et=100;function Dt(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(St,()=>(n.add(`uuid`),` `)).replace(xt,e=>{n.add(`url`);let t=e.replace(/^(?:https?:\/\/)?[^/]+/iu,``).split(/[?#]/u)[0].split(`/`).filter(e=>e.length>0).map(e=>e.toLowerCase()),i=t.at(-1);return i!==void 0&&Ct.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=Ct.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 Ot(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function kt(e,t){let n=new Set;for(let r of e){let e=new Set;k(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 At(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(A(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>Ot(t,e,n.path))&&(i+=wt,r.has(t)&&(i+=Tt));if(i===0)return 0;let a=new Set(A(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return k(t,e),[...t].some(e=>a.has(e))}))&&(i+=Et),i}var jt=5,Mt=.5,Nt=15,Pt=30,Ft=2;function It(e,t,n){let r=t.map(e=>({item:e,fields:n(e)})),i=Dt(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=kt(i.urlPathWord,r.map(({fields:e})=>e)),o=j(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=vt(o),c=yt(o);return r.map(({item:e,fields:t})=>({item:e,fields:t,score:(o.length===0?0:Bt(o,s,c,t))+At(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 Lt(e){let t=[...e.parameter,...(e.requestBody??[]).flatMap(e=>e.parameter)];return{...e,cliPath:e.projection.cliPath,enumParameter:t.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:t.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...e.parameter,...e.requestBody??[],...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({description:e})=>e)}}function Rt(e,t){let n=It(e.q?.trim()??``,t.filter(t=>zt(e,t)),Lt),r=(n[0]?.score??0)*Mt,i=n.filter(({score:e})=>e>=r),a=e.limit===void 0||!Number.isFinite(e.limit)?jt:e.limit,o=Math.min(i.length,Math.max(0,Math.trunc(a))),s=i.slice(0,o).map(({item:e})=>e),c=s.map(e=>it(e,s.length===1));return{summary:`Operation catalog matches`,data:c,counts:{totalOperations:t.length,matched:i.length,returned:c.length}}}function zt(e,t){let n=e.root?.trim().toLowerCase();return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Bt(e,t,n,r){let i=Ut(r),a=Vt(r),o=0;i.some(t=>t===e)&&(o+=100),i.some(t=>t.includes(e))&&(o+=40),o+=Ht(e,i);let s=new Set(i.flatMap(A));for(let e of t)i.some(t=>t===e)?o+=20:s.has(e)&&(o+=8);for(let e of r.cliPath){let n=new Set;k(n,e),[...n].some(e=>t.has(e))&&(o+=Nt)}bt(n,a)&&(o+=200),r.parameterName.some(t=>j(t)===e)&&(o+=Pt);let c=new Set(r.parameterDescription.flatMap(A));for(let e of t)c.has(e)&&(o+=Ft);return o+=Gt(t,r.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(r.operationId)&&(o+=30),o-=Wt(e,t,r.description),o}function Vt(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(j).filter(e=>e.length>0)}function Ht(e,t){let n=A(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 Ut(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,pt(e.description).useFor||e.description].map(j).filter(e=>e.length>0))]}function Wt(e,t,n){let r=j(pt(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(A(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Gt(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>Kt(e,t))&&(n+=i?40:10);return n}function Kt(e,t){let n=A(t);return n.length>0&&n.every(t=>e.has(t))}var qt=3,Jt=200;function Yt(e,t){let{operationId:n}=e;if(n===void 0||t.some(e=>e.operationId===n))return null;let r=Rt({q:[n,...Xt(e)].join(` `),limit:qt},t),i=r.summary===`Operation catalog matches`?r.data:[],a=i.map(e=>`${e.operationId} (${e.method} ${e.path})`);return m(`Operation ${n} is not in the MCP catalog.${a.length===0?``:` Closest operations: ${a.join(`, `)}.`}`,i.map(e=>`Use operationId ${e.operationId} with aventure_${e.intent}: ${e.method} ${e.path}; required inputs: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}.`))}function Xt(e){let t=e.body,n=typeof t==`object`&&t&&!Array.isArray(t)?Object.entries(t):[];return[...Object.entries(e.pathParams??{}),...Object.entries(e.query??{}),...n].flatMap(([e,t])=>typeof t==`string`&&t.length<=Jt?[e,t]:[e])}function Zt(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function Qt(e,t,n,r){let i=e.q?.trim()??``;if(i.length===0)return m(`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 m(`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`},includePrivate:!1}});if(!o.ok)return{...o,data:null};let s=Ve.safeParse(Zt(o));if(!s.success||s.data.resolution==null)return m(`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)})),h=[...new Set([...l.operationId!=null&&d===void 0?[l.operationId]:[],...p.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return ee(h.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${h.join(`, `)}.`,{outcome:l.outcome,probability:l.probability,answer:c,candidate:l.candidate.map(({sourceId:e})=>e),...d===void 0?{}:{operation:{operationId:d.operationId,apiRoute:`${d.method} ${d.path}`,...ft(d),bodySchemaName:d.requestBody?.[0]?.schemaName??null,mcpCall:ut(d)}},...l.taskKey==null?{}:{taskKey:l.taskKey},...f===void 0?{}:{taskPlan:{catalogRevision:f.catalogRevision,input:f.input,...f.gateId.length===0?{}:{gateId:f.gateId},step:p.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{stepKey:t,instruction:n,operationId:r}:{stepKey:t,instruction:n,mcpCall:ut(e)})}}},{warnings:h.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 $t=p({detail:f(),field:f().nullish(),scope:o([`entity`,`person`,`news`])}),en=n([o([`auto`,`exact`,`keyword`,`semantic`,`natural`,`hybrid`]),f()]),M=p({modeRequested:en,modeUsed:en}),tn=p({answerUnavailable:u(),entity:M,news:M,person:M,rejection:i($t),unavailable:i(o([`entity`,`person`,`news`]))}),nn=p({acceleratorParticipation:i(ye),detail:i(fe)}),N=p({core:v,enrichment:we,fundraiseRound:i(y),research:nn,semanticMatch:ue.nullish()}),rn=o([`curated`,`semantic`,`precomputed`,`derived`,`computed`]),an=p({compositeScore:d().nullish(),cosineScore:d().nullish(),curatedAsOf:c().nullish(),curatedRelationshipType:f().nullish(),curatedSource:f().nullish(),derivedFromEntityId:t().nullish(),matchedSectionWeight:d().nullish(),origin:rn,rank:s(),sharedSectionCount:s().nullish()}),on=p({entity:N,similarity:an}),sn=o([`aventureBlog`,`personalBlog`,`employerBlog`,`linkedin`,`xTwitter`,`medium`,`substack`,`other`]),cn=p({author:f().nullish(),createdAt:r({offset:!0}),externalId:f().nullish(),id:t(),isCurrent:u(),lastFetchedAt:r({offset:!0}).nullish(),mentionedEntityId:i(t()),mentionedPersonId:i(t()),owner:l,publishedAt:r({offset:!0}).nullish(),summary:f().nullish(),summaryGeneratedAt:r({offset:!0}).nullish(),title:f().nullish(),topic:f().nullish(),type:sn,updatedAt:r({offset:!0}),url:f()}),ln=o([`low`,`medium`,`high`]),un=p({asOfDate:r({offset:!0}).nullish(),dataConfidence:ln.nullish(),dateValue:r({offset:!0}).nullish(),numericValue:d().nullish(),referenceValue:f().nullish(),source:f().nullish(),textValue:f().nullish(),updatedAt:r({offset:!0}).nullish(),valueType:pe}),dn=p({asOfDate:r({offset:!0}),fact:un,id:f()}),fn=p({fundraiseInvestorJoin:u(),fundraiseTransaction:u(),operatingStatus:u(),relationship:u()}),pn=o([`Acquisition`,`Acquired`,`Acquired Subsidiary`]),mn=o([`Announced`,`Announced; subject to approvals and closing conditions`,`Active`,`Closed`,`Completed`,`In Progress`,`Open`]),hn=p({acquiredEntity:v,acquirerEntity:v,amount:d().int().nullish(),announcedAt:r({offset:!0}).nullish(),asOf:c().nullish(),completedAt:r({offset:!0}).nullish(),createdAt:r({offset:!0}).nullish(),currency:f().nullish(),dataConfidence:Te.nullish(),evidence:fn,fundraiseTransactionId:t().nullish(),investorJoinId:t().nullish(),publicSource:me.nullish(),relationshipId:s(),status:pn,transactionStatus:mn.nullish(),updatedAt:r({offset:!0}).nullish()}),gn=o([`SAFE`,`Convertible Note`,`Preferred Stock`,`Common Stock`,`Other Equity`,`Bond`,`Loan`,`Other Debt`,`Grant`,`Token`]),_n=p({amountInvested:d().nullish(),createdAt:r({offset:!0}),financialInstrumentType:gn.nullish(),id:t(),investor:l,leadInvestor:u(),transactionId:t(),updatedAt:r({offset:!0})}),vn=p({entity:S,investorAttribution:i(le),round:i(Se),roundCount:s()}),yn=p({core:v,similarity:an,urlLink:i(se)}),bn=p({compliance:xe.nullish(),createdAt:r({offset:!0}).nullish(),id:s(),isCurrent:u().nullish(),isPrimary:u().nullish(),language:f().nullish(),owner:l,text:f(),textName:f().nullish(),textType:f(),updatedAt:r({offset:!0}).nullish()}),xn=o([`stored`,`derivedFromPreAndRaised`,`derivedFromPostMinusRaised`,`reportedAssumedPost`]),Sn=o([`fundraiseRound`,`researchDetail`]),Cn=o([`preMoney`,`postMoney`,`reported`]),wn=p({amountRaised:d().int().nullish(),asOfDate:r({offset:!0}),confidence:ln,currency:f(),declaredBasis:Cn,derivation:xn,detailId:s().nullish(),label:f().nullish(),source:Sn,sourceRef:f(),valuationPostMoney:d().int().nullish(),valuationPreMoney:d().int().nullish()}),Tn=p({createdAt:r({offset:!0}).nullish(),description:f().nullish(),forkCount:s(),githubId:d().int(),homepageUrl:f().nullish(),id:d().int(),isArchived:u(),isFork:u(),language:f().nullish(),license:f().nullish(),name:f(),ownerLogin:f(),repoCreatedAt:r({offset:!0}).nullish(),repoPushedAt:r({offset:!0}).nullish(),stargazerCount:s(),topic:i(f()),updatedAt:r({offset:!0}).nullish(),url:f()}),P=p({empty:u().optional(),sorted:u().optional(),unsorted:u().optional()}),F=p({offset:d().int().optional(),paged:u().optional(),pageNumber:s().optional(),pageSize:s().optional(),sort:P.optional(),unpaged:u().optional()}),En=p({investorAttribution:i(le),person:x,round:i(Se),roundCount:s()}),Dn=o([`precomputed`,`live`]),On=p({compositeScore:d().nullish(),cosineScore:d().nullish(),matchedSectionWeight:d().nullish(),origin:Dn,rank:s(),sharedSectionCount:s().nullish()}),kn=p({currentRole:be.nullish(),person:b,similarity:On}),An=o([`by`,`about`]),jn=o([`newsArticle`,`blogPost`,`externalSocialPost`,`repositoryOwner`,`repository`,`webSite`,`webPage`,`researchPaper`]),Mn=p({canonicalUrl:f().nullish(),contentId:f(),contentType:jn,createdAt:r({offset:!0}).nullish(),publishedAt:r({offset:!0}).nullish(),relation:An.nullish(),sourceDomain:f().nullish(),sourceName:f().nullish(),summary:f().nullish(),title:f(),topic:f().nullish(),updatedAt:r({offset:!0}).nullish(),url:f().nullish(),year:s().nullish()});p({content:i(cn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(n([ce,Ce])).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(dn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(v).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(hn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(S).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(_n).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(y).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(vn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(N).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(be).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(ge).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(fe).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(he).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(on).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(yn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(bn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(se).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(wn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(Tn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(de).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(b).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(x).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(ve).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(En).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(kn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()}),p({content:i(Mn).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()});var Nn=p({content:i(N),number:s(),size:s(),totalElements:d().int(),totalPages:s()}),Pn=p({content:i(de),number:s(),size:s(),totalElements:d().int(),totalPages:s()}),Fn=p({content:i(b),number:s(),size:s(),totalElements:d().int(),totalPages:s()});p({content:i(_e).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:s().optional(),numberOfElements:s().optional(),pageable:F.optional(),size:s().optional(),sort:P.optional(),totalElements:d().int().optional(),totalPages:s().optional()});var In=n([o([`entityRecord`,`researchSnippet`,`newsArticle`,`personRecord`,`fundraiseTransaction`]),f()]),Ln=p({entityId:t(),source:In,sourceId:f()}),Rn=p({citation:i(Ln),text:f(),topic:f().nullish()}),zn=p({citation:i(Ln),confidence:w,description:f().nullish(),heading:f().nullish(),paragraph:i(Rn),relatedQuery:i(f()),shareable:u(),text:f(),title:f().nullish()}),Bn=p({sortPriority:o([`NONE`,`ANY_LOGO_FIRST`,`REAL_LOGO_FIRST`]).optional()}),Vn=p({max:r({offset:!0}).nullish(),min:r({offset:!0}).nullish()}),I=p({max:d().nullish(),min:d().nullish()}),L=p({max:s().nullish(),min:s().nullish()}),Hn=p({averageAmountInvestedUsdRange:i(I).optional(),largestAmountInvestedUsdRange:i(I).optional(),smallestAmountInvestedUsdRange:i(I).optional(),totalAmountInvestedUsdRange:i(I).optional(),totalInvestmentRange:i(L).optional()}),Un=p({amountInvestedRange:i(I).optional(),amountRaisedRange:i(I).optional(),dateAnnouncedRange:Vn.nullish(),investedCompanyName:i(f()).optional(),investedCountry:i(f()).optional(),investedIndustry:i(f()).optional(),investedRound:i(f()).optional(),investorActivity:Hn.optional(),investorName:i(f()).optional(),lastRoundYearRange:i(L).optional(),rankByInvestmentActivity:u().nullish(),round:i(f()).optional(),totalRaisedRange:i(I).optional(),valuationRange:i(I).optional()}),Wn=o([`NONE`,`COMPANY_LISTING_READY`]),Gn=o([`Operating`,`Acquired`,`Acquired Subsidiary`,`Closed`,`Closed (Acquihire)`,`Inactive`]),Kn=o([`hostPath`,`domain`]),qn=e({acceleratorBrand:i(f()).optional(),acceleratorCohort:i(f()).optional(),acceleratorName:i(f()).optional(),acceleratorStatus:i(f()).optional(),affinity:i(f()).optional(),closedLast:u().optional(),employeeCountRange:i(L).optional(),entityId:i(t()).optional(),entityName:i(f()).optional(),featured:u().nullish(),fundraiseActivity:Un.optional(),hasFundraising:u().nullish(),headquartersCity:i(f()).optional(),headquartersCountry:i(f()).optional(),headquartersState:i(f()).optional(),industry:i(f()).optional(),letter:f().nullish(),location:i(f()).optional(),logoOption:Bn.optional(),mainProduct:i(f()).optional(),operatingStatus:i(Gn).optional(),originCountry:i(f()).optional(),person:i(f()).optional(),portfolioHeadquartersCity:i(f()).optional(),portfolioHeadquartersCountry:i(f()).optional(),portfolioHeadquartersState:i(f()).optional(),qualityGate:Wn.optional(),rankByProminence:u().nullish(),semanticQuery:f().nullish(),slug:i(f().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:i(f()).optional(),suppressLateStage:u().nullish(),suppressNonOperating:u().nullish(),suppressZeroTotalRaised:u().nullish(),tag:i(f()).optional(),textSearch:f().nullish(),typeCustomer:i(f()).optional(),typeModel:i(f()).optional(),typeOwnership:i(f()).optional(),typeRecord:i(a).optional(),typeRevenue:i(f()).optional(),typeTechnologyUsed:i(f()).optional(),url:f().nullish(),urlDomain:f().nullish(),urlMatchMode:Kn.nullish(),urlType:oe.nullish(),yearFoundedRange:i(L).optional()}),Jn=o([`discovery`,`profile`,`peer`,`comparison`]),Yn=o([`keyword`,`semantic`]),Xn=n([o([`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`]),f()]),Zn=p({descending:u(),field:Xn,sortKey:f().nullish()}),Qn=p({order:i(Zn),relevance:Yn.nullish()}),$n=p({confidence:w,execution:M,fallbackUsed:u(),filter:qn,intent:Jn,interpretation:f(),sort:Qn,subjectEntityName:i(f()),unsupported:f().nullish()}),R=p({changedAt:r({offset:!0}).nullish(),dataSourceUpdatedAt:r({offset:!0}).nullish(),pendingApproval:s().nullish(),sourceId:f().nullish(),status:f().nullish()}),er=p({fundManagerRelationshipSource:R.nullish(),fundraiseTransaction:y,fundraiseTransactionSource:R.nullish(),investorJoinSource:R.nullish()}),tr=p({evidence:er,investor:l,semanticMatch:ue.nullish()}),nr=p({entityId:t(),matchedOffering:v.nullish(),probability:d(),webUrl:i(f())}),rr=p({entityId:t(),label:f(),publishedAt:r({offset:!0}).nullish(),score:d(),source:In,sourceId:f(),text:f(),url:f().nullish()}),ir=p({answer:zn.nullish(),interpretation:$n,investment:i(tr),judgment:i(nr),passage:i(rr),peer:i(on),pendingWebQuery:i(f()),result:Nn,searchRequestId:t().nullish(),subject:i(N)}),ar=o([`auto-match`,`needs-review`,`approved`,`rejected`]),or=p({createdAt:r({offset:!0}),entityId:t(),href:f().nullish(),internal:u(),matchStatus:ar.nullish(),mention:f().nullish(),slug:f().regex(/^[a-z0-9_-]+$/).max(255).nullish(),typeRecord:a.nullish(),updatedAt:r({offset:!0})}),sr=p({entity:i(or),newsId:s()}),cr=e({acceleratorBrand:i(f()).optional(),acceleratorCohort:i(f()).optional(),acceleratorName:i(f()).optional(),acceleratorStatus:i(f()).optional(),affinity:i(f()).optional(),closedLast:u().optional(),employeeCountRange:i(L).optional(),entityId:i(t()).optional(),entityName:i(f()).optional(),featured:u().nullish(),fundraiseActivity:Un.optional(),hasFundraising:u().nullish(),headquartersCity:i(f()).optional(),headquartersCountry:i(f()).optional(),headquartersState:i(f()).optional(),industry:i(f()).optional(),letter:f().nullish(),location:i(f()).optional(),logoOption:Bn.optional(),mainProduct:i(f()).optional(),operatingStatus:i(Gn).optional(),originCountry:i(f()).optional(),person:i(f()).optional(),portfolioHeadquartersCity:i(f()).optional(),portfolioHeadquartersCountry:i(f()).optional(),portfolioHeadquartersState:i(f()).optional(),qualityGate:Wn.optional(),rankByProminence:u().nullish(),slug:i(f().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:i(f()).optional(),suppressLateStage:u().nullish(),suppressNonOperating:u().nullish(),suppressZeroTotalRaised:u().nullish(),tag:i(f()).optional(),textSearch:f().nullish(),typeCustomer:i(f()).optional(),typeModel:i(f()).optional(),typeOwnership:i(f()).optional(),typeRecord:i(a).optional(),typeRevenue:i(f()).optional(),typeTechnologyUsed:i(f()).optional(),url:f().nullish(),urlDomain:f().nullish(),urlMatchMode:Kn.nullish(),urlType:oe.nullish(),yearFoundedRange:i(L).optional()}),lr=p({amountInvestedRange:i(I).nullish(),amountRaisedRange:i(I).nullish(),entityName:i(f()).nullish(),investedCompany:i(f()).nullish(),personTitle:i(f()).nullish(),round:i(f()).nullish(),totalInvestmentCount:i(L).nullish(),typeRecord:i(a).nullish()}),ur=p({arrayFilter:lr.optional(),entityFilter:cr.optional(),entityId:t().nullish(),entitySlug:f().nullish(),firstName:f().nullish(),includeAddress:u().nullish(),includeUrl:u().nullish(),investorActivity:Hn.optional(),isCurrent:u().nullish(),lastName:f().nullish(),letter:f().nullish(),personId:i(t()).max(200).optional(),personName:i(f()).optional(),role:f().nullish(),search:f().nullish(),semanticQuery:f().nullish(),status:f().nullish()}),dr=p({descending:u(),field:o([`ID`,`FIRST_NAME`,`LAST_NAME`,`FULL_NAME`,`SLUG`,`CREATED_AT`,`UPDATED_AT`,`STATUS`,`GENDER`,`AMOUNT_INVESTED`,`TOTAL_INVESTMENTS`]),sortKey:f().nullish()}),fr=p({order:i(dr),relevance:Yn.nullish()}),pr=p({confidence:w,execution:M,fallbackUsed:u(),filter:ur,interpretation:f(),sort:fr,unsupported:f().nullish()}),mr=p({interpretation:pr,investment:i(tr),result:Fn,searchRequestId:t().nullish()}),hr=p({entity:ir,entityDetail:i(S),news:Pn,newsEntityMention:i(sr),person:mr,personDetail:i(x),provenance:tn});function z(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>gr(e)),...n.flatMap(e=>e.parameter.map(t=>gr(t,n.length>1?e.contentType:void 0))),..._r(n)],i=[t,...e.cliPath].join(` `),a=ie(e.intent),o=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:te(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse||!ne(e.path)?null:ae(e.intent),body:{hasBody:o!==void 0,kind:o?.kind??null,...o!==void 0&&n.length>1?{contentType:o.contentType}:{},required:o?.required??!1,description:o?.description??``,requiredPath:o?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,successResponse:e.successResponse,summary:e.summary,description:e.description,deprecated:e.deprecated}})}function gr(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 _r(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 B(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var vr=[`-id`,`-slug`,`-url`],yr=[`--id`,`--slug`,`--url`],br=`/v1/lookup`,xr=`--from-file "<path>"`;function Sr(e,t,n=_().bin[0]){let r=z(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:Er(i,r)}function Cr(e,t,n=_().bin[0]){let r=t.find(t=>t.operationId===e),[i]=r===void 0?[]:z([r],n);return i&&Tr(i,kr(i,!1))}function wr(e,t,n,r=_().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 Cr(o.operationId,t,r)}function Tr(e,t){return[e.cli.command,...t,`--data`].join(` `)}function Er(e,t){return[`example: ${Tr(e,kr(e))}`,...Dr(e,t)]}function Dr(e,t){return B(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} ${V(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===br),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} ${V(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var Or=/(?:^|\.)text$/u;function kr(e,t=!0){let n=B(e).filter(e=>e.required),r=e.body.kind===`json`&&n.some(e=>e.location===`body`&&Or.test(e.wireName))?n.filter(e=>e.location!==`body`):n,i=(n.length>0||!t?r:Ar(e)).map(V);return(e.body.required||e.body.requiredPath.length>0)&&!r.some(e=>e.location===`body`)?[...i,xr]:i}function Ar(e){let t=new Set;k(t,e.resource);for(let n of vr)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 yr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function V(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var jr=`aventure`;function Mr(e,t){let n=t.find(t=>t.operationId===e)?.cliPath;return n===void 0?void 0:`${jr} ${n.join(` `)}`}function Nr(e,t,n=e){return Cr(e,t,`aventure`)??n}function Pr(e,t){let n=Ve.safeParse(e);if(!n.success)return null;let{answer:r,citation:i,confidence:a,resolution:o}=n.data;if(o!=null)return Fr(r,o,t);let s=r.trimEnd().split(`
3
+ `),c=new Set(i.flatMap(({sourceType:e,sourceId:n})=>{if(e!==Me.options[0].enum.OPERATION)return[];let r=Mr(n,t);return r===void 0?[]:[r]}));return c.size>0&&s.push(``,`Commands:`,...[...c].map(e=>` ${e}`)),s.push(``,`Confidence: ${a}`),i.length===0?s:(s.push(`Sources (${i.length}):`),s.push(...i.map(({excerpt:e,sourceId:t})=>{let n=e.trim();return n.length>0?` - ${t}: ${n}`:` - ${t}`})),s)}function Fr(e,t,n){let{outcome:r,operationId:i,probability:a,candidate:o,taskKey:s,taskPlan:c}=t,l=[c==null?e.trimEnd():Lr(c)],u=[``,`Outcome: ${r}${a==null?``:` (probability ${a.toFixed(2)})`}`];switch(r){case T.enum.TASK_PLAN:return[...l,...c==null?[]:Rr(c,n),...u];case T.enum.OPERATION_ADVICE:{let e=o.filter(({sourceId:e})=>e!==i);return[...l,...i==null?[]:[``,`Command:`,` ${Nr(i,n)}`],...u,...e.length===0?[]:[`Alternatives: ${e.map(({sourceId:e})=>e).join(`, `)}`]]}case T.enum.CLARIFY:return[...l,...s==null?[]:[``,`Leading catalog task: ${s}`],...Br(`Candidates:`,o,n),...u];case T.enum.ABSTAIN:return[...l,...Br(`Nearest operations:`,o,n),...u];default:throw Error(`Unhandled help resolution outcome ${String(r)}`)}}function Ir(e,t){let n=ze.safeParse(e);return n.success?[Lr(n.data),...Rr(n.data,t)]:null}var Lr=({taskKey:e,catalogRevision:t})=>`Run catalog task ${e} (catalog revision ${t}).`;function Rr(e,t){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})=>` ${e} (${t}): ${n}`)],``,`Steps:`,...e.step.flatMap(({step:n,cliCommand:r,writeGuidance:i},a)=>[` ${a+1}. ${n.stepKey}: ${Nr(n.operationId,t,r)}`,` ${n.instruction}`,...zr(e,a,i)]),...e.gateId.length===0?[]:[``,`Completion gates: ${e.gateId.join(`, `)}`]]}function zr(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 Br(e,t,n){if(t.length===0)return[];let r=t.map(({sourceId:e,excerpt:t})=>({command:Mr(e,n)??e,excerpt:t})),i=Math.max(...r.map(({command:e})=>e.length));return[``,e,...r.map(({command:e,excerpt:t})=>` ${e.padEnd(i)} # ${t}`)]}var H=120,U=30,Vr=8,W=10,Hr=2,Ur=[`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`],Wr=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]),Gr=[`interpretation`,`confidence`,`unsupported`,`execution`,`fallbackUsed`];function Kr(e,t,n){if(typeof t==`string`)return Q(t);let r=ct(t);if(r!==null)return Q(r);let i=ri(t);if(i===null)return null;let a=e.find(({operationId:e})=>e===i.operationId),{response:o,hiddenNote:s}=Ee(a?.detailField,i.response),c={...i,response:o},l=Pr(c.response,e)??Ir(c.response,e);if(l!==null)return Q(l.join(`
4
+ `),!0);let u=qr(c.endpoint,c.response);if(u!==null)return Q([...u,...s].join(`
5
+ `),!0,s.length>0);let d=c.summary??n??c.operationId??`OpenAPI call succeeded`,f=Zr(c);return Q([...[d,`${c.method} ${c.endpoint}`,...f].filter(e=>e.length>0),...s].join(`
6
+ `),!0,s.length>0)}function qr(e,t){if(t===void 0||!Y(t)||!(`entity`in t&&`person`in t&&`news`in t))return null;let n=hr.safeParse(t);if(!n.success)return null;let{entity:r,person:i,news:a,provenance:o}=n.data;return[...r.answer?Jr(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})=>C(`${e} rejected: ${t}`)),[`entities:`,...G(r.result,e)].join(`
7
+ `),[`people:`,...G(i.result,e)].join(`
8
+ `),[`news:`,...G(a,e)].join(`
9
+ `)]}function Jr(e){let t=`relatedQuery:\n${e.relatedQuery.map(e=>` - ${C(e)}`).join(`
10
+ `)}`,n=`citations:\n${e.citation.map(({source:e,sourceId:t,entityId:n})=>C(` - ${e}:${t} entity=${n}`)).join(`
11
+ `)}`;return[`answer:\n ${De(e.text).replaceAll(`
12
+ `,`
13
+ `)}`,...e.relatedQuery.length===0?[]:[t],...e.citation.length===0?[]:[n]]}function Yr(e){let t=ri(e)?.response,n=t!==void 0&&Y(t)?t.interpretation:void 0;if(n===void 0||!Y(n))return null;let r=M.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=q(n.filter??null),{unsupported:s,fallbackUsed:c}=n;return Q([`strategy: requested=${i} used=${a}`,...o!==void 0&&Y(o)?[`constraints:`,...Object.entries(o).map(([e,t])=>` ${e}: ${Xr(t)}`)]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``].filter(Boolean).join(`
14
+ `),!0)}var Xr=e=>X(e)?C(e):Array.isArray(e)&&e.every(X)?e.map(e=>C(e)).join(`, `):JSON.stringify(e);function Zr(e){let{response:t,method:n,endpoint:r,nextCursor:i,httpStatus:a,location:o}=e;if(t===void 0)return o!==void 0&&a!==void 0?[`status=${a} redirect=${o}`]:a===void 0?[]:[`status=${a} no response body`];let s=a===void 0||n===`GET`?``:`status=${a}`,c=Y(t)&&!ai(t)?oi(t):null,l=c===null?void 0:Y(c.context.interpretation)?q(c.context):c.context,u=l!==void 0&&Y(l)?Object.entries(l):[],d=u.filter(e=>Array.isArray(e[1])&&e[1].length>0&&e[1].every(Y)),f=new Set(d.map(([e])=>e)),p=Object.fromEntries(u.filter(([e])=>!f.has(e)));return[s,...ai(t)?G(t,r,i):c===null?ci(t)?ei(t.filter,t.meta):li(t)?ei([...t.arrayFilterEntry,...t.rangeFilterEntry],t.filtersMeta):di(t)?ti(t):K(t,``):[...G(c.page,r,i),...Object.keys(p).length===0?[]:K(p,``),...d.flatMap(([e,t])=>[`${e}:`].concat(Qr(t)))]].filter(Boolean)}function G(e,t,n){let r=ni(t);return[`rows=${e.numberOfElements??e.content.length}${e.number===void 0?``:` page=${e.number}`}${e.size===void 0?``:` size=${e.size}`}${e.totalElements===void 0?``:` total=${e.totalElements}`}${e.totalPages===void 0?``:` totalPages=${e.totalPages}`}`,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${Z(n)}`,...Qr(e.content)].filter(Boolean)}function Qr(e){let t=e.filter(Y);if(t.length===0)return e.length===0?[`(empty)`]:ii(e,``);let n=$r(t);if(n.length===0)return ii(e.slice(0,U),``);let r=t.slice(0,U).map(e=>{let t=J(e);return n.map(e=>t[e]??``)}),i=n.map(e=>e.split(`.`).at(-1)??e),a=i.map((e,t)=>{let n=r.map(e=>e[t]??``),i=Math.max(e.length,...n.map(e=>e.length));return e===`id`||e.endsWith(`Id`)?i:Math.min(32,i)}),o=e=>e.map((e,t)=>pi(e,a[t]??12).padEnd(a[t]??12)).join(` `),s=[o(i),o(a.map(e=>`-`.repeat(e)))];return r.forEach(e=>s.push(o(e))),t.length>U&&s.push(`... ${t.length-U} more rows`),s}function $r(e){let t=new Set(e.flatMap(e=>Object.keys(J(e)))),n=Ur.filter(e=>t.has(e)),r=[...t].filter(e=>!n.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,Vr-n.length);return[...n,...r].slice(0,Vr)}function ei(e,t){let n=t!==void 0&&Y(t)?t:{},r=[`total`,`limit`].flatMap(e=>typeof n[e]==`number`?[` ${e}=${n[e]}`]:[]).join(``),i=[`filters=${e.length}${r}`];for(let t of e){let e=t.choiceOption.length,n=t.choiceOptionTotal===null?`unknown (degraded)`:t.choiceOptionTotal??e,r=t.choiceOptionTruncated===!0?` truncated`:``;i.push(`- ${t.filterKey} (${t.label}): choices ${e}/${n}${r}`),t.choiceOption.slice(0,W).forEach(e=>{i.push(` ${fi(t.filterKey)} ${Z(e.value)}`)}),e>W&&i.push(` ... ${e-W} more shown`)}return i}function ti(e){let t=fi(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,W).map(e=>`${t} ${Z(e)}`),e.result.length>W?`... ${e.result.length-W} more matches`:``].filter(Boolean)}function ni(e){let t=e.indexOf(`?`);return t<0?[]:[...new URLSearchParams(e.slice(t+1)).entries()].filter(([e,t])=>!Wr.has(e)&&t.length>0).map(([e,t])=>`${fi(e)} ${Z(t)}`)}function ri(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=Reflect.get(e,`method`),n=Reflect.get(e,`endpoint`);if(typeof t!=`string`||typeof n!=`string`)return null;let r=Reflect.get(e,`operationId`),i=Reflect.get(e,`summary`),a=Reflect.get(e,`httpStatus`),o=Reflect.get(e,`location`),s=Reflect.get(e,`nextCursor`),c=Reflect.get(e,`response`),l=c===void 0?void 0:g.safeParse(c);return l!==void 0&&!l.success?null:{method:t,endpoint:n,httpStatus:typeof a==`number`?a:void 0,location:typeof o==`string`?o:void 0,operationId:typeof r==`string`?r:void 0,summary:typeof i==`string`?i:void 0,nextCursor:typeof s==`string`&&s.length>0?s:void 0,response:l?.data}}function K(e,t,n){if(e===void 0)return[];if(X(e))return[`${t}${Oe(e,n)}`];if(Array.isArray(e))return ii(e,t,n);let r=[];for(let[n,i]of Object.entries(e)){if(X(i)){r.push(`${t}${n}: ${Oe(i,n)}`);continue}r.push(`${t}${n}:`);for(let e of K(i,`${t} `,n))r.push(e)}return r.length===0?[`${t}(empty)`]:r}function ii(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(X(i)){r.push(`${t}- ${Oe(i,n)}`);continue}r.push(`${t}-`);for(let e of K(i,`${t} `))r.push(e)}return r}function q(e){if(X(e))return e===null||typeof e==`string`&&e.trim().length===0?void 0:e;if(Array.isArray(e)){let t=e.flatMap(e=>{let t=q(e);return t===void 0?[]:[t]});return t.length===0?void 0:t}let t=Object.entries(e).flatMap(([e,t])=>{let n=q(t);return n===void 0?[]:[[e,n]]});if(t.length!==0)return Object.fromEntries([...Gr.flatMap(e=>t.filter(([t])=>t===e)),...t.filter(([e])=>!Gr.includes(e))])}function J(e,t=``,n=0){return X(e)?t.length===0?{}:{[t]:C(e,t)}:n>Hr?{}:Array.isArray(e)?e.length===0?{}:J(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{let i=t.length===0?e:`${t}.${e}`;return X(r)?[[i,C(r,i)]]:Object.entries(J(r,i,n+1))}))}var ai=e=>Y(e)&&Array.isArray(e.content);function oi(e){let[t,...n]=Object.entries(e).filter(e=>ai(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 si(e){return Y(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var ci=e=>Y(e)&&ui(e.filter),li=e=>Y(e)&&ui(e.arrayFilterEntry)&&ui(e.rangeFilterEntry),ui=e=>Array.isArray(e)&&e.every(si),di=e=>Y(e)&&typeof e.filterKey==`string`&&Array.isArray(e.result)&&e.result.every(e=>typeof e==`string`),Y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),X=e=>typeof e!=`object`||!e,fi=e=>`--${e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`,Z=e=>/^[A-Za-z0-9._:/@-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,pi=(e,t)=>e.length<=t?e:`${e.slice(0,Math.max(0,t-3))}...`,Q=(e,t=!1,n=!1,r=1)=>{let i=De(e),a=t||i.endsWith(`
15
+ `),o=i.endsWith(`
16
+ `)?i.slice(0,-1):i,s=o.length===0?[]:o.split(`
17
+ `),c=je.byteLength(`${s.join(`
18
+ `)}\n`,`utf8`);if(s.length<=H&&c<=5e4)return`${s.join(`
19
+ `)}${a?`
20
+ `:``}`;let l=n?Math.min(Math.max(1,r),118):0,u=l>0?s.slice(-l):[],d=u.length===0?s:s.slice(0,-u.length),f=[s.length>H?`${H} physical lines`:``,c>5e4?`${h} UTF-8 bytes`:``].filter(Boolean).join(` and `),p=e=>De(`... output truncated: ${e} more lines omitted to stay within ${f}; recover omitted response content with narrower server-side filters, the relevant sub-resource operation (aventure_help names it), or responseFormat json.`),m=(e,t)=>[...e,...u,t].join(`
21
+ `),ee=H-u.length-1,g=d.slice(0,ee),_=p(s.length-g.length-u.length);for(;je.byteLength(`${m(g,_)}\n`,`utf8`)>h;){if(g.length>0)g=g.slice(0,-1);else if(u.length>0)u=u.slice(1);else break;_=p(s.length-g.length-u.length)}return`${m(g,_)}${a?`
22
+ `:``}`},mi=/\{([^}]+)\}/gu;function hi(e,t){let n=t.filter(e=>e.method===`GET`),r=t=>e.endpoint!==void 0&&t.endsWith(e.endpoint),i=t.find(t=>t.operationId===e.operationId),a=e.ok&&i!==void 0&&ie(i.intent),o=[...a&&e.endpoint!==void 0?_i(e.endpoint.split(`?`)[0]??``,n,!1).map(e=>`${e} --data --to-file <path>`):[],...e.references.filter(e=>!r(e)).flatMap(gi).flatMap(e=>_i(e.pathname,n,!0)),...e.references.filter(r).flatMap(gi).flatMap(e=>vi(e,n))];return o.length===0?{write:a}:{exactRecovery:`Read the full result ${o.join(`; `)}.`,write:a}}function gi(e){return URL.canParse(e)?[new URL(e)]:[]}function _i(e,t,n){return t.flatMap(t=>{let r=[...t.path.matchAll(mi)].map(([,e])=>e),i=RegExp(`^${t.path.replace(mi,`([^/]+)`)}$`,`u`),a=n&&r.length===0?null:i.exec(e);if(a===null)return[];let o=r.flatMap((e,n)=>{let r=t.parameters.find(t=>t.name===e);return r===void 0?[]:[$(r),a[n+1]??``]});return[`${yi(t)}, ${bi(t,o)}`]})}function vi(e,t){let n=t.find(t=>t.path===e.pathname);return n===void 0?[]:t.flatMap(t=>{if(!t.path.startsWith(`${n.path}/`))return[];let r=t.parameters.find(({name:e})=>e.endsWith(`Offset`)),i=t.parameters.find(({name:e})=>e.endsWith(`Limit`));if(r===void 0||i===void 0)return[];let a=t.parameters.flatMap(t=>{let n=e.searchParams.get(t.name);return t.location!==`query`||n===null?[]:[$(t),xi(n)]}),o=[$(r),`<n>`,$(i),`<n>`];return[`${yi(t)}, in windows: ${bi(t,[...a,...o])}, advancing ${$(r)} until a window returns fewer than ${$(i)} units`]})}function yi(e){return e.auth===`write`?`with admin sign-in`:`with any sign-in`}function bi(e,t){return[jr,...e.cliPath,...t].join(` `)}function $(e){return e.flag.split(/\s+/u)[0]??e.flag}function xi(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function Si(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=Di(t,E(e,t),n);if(t.legacyName===void 0)return r;let i=Di(t,E(e,t,t.legacyName),n).flag;return i===r.flag?r:Object.assign(r,{legacyFlag:i})})}),n=e.requestBody?.map(n=>{let r=Ti(e,t,n),i=wi(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`))?.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,errorResponse:e.errorResponse,successResponse:r,detailField:e.response.find(e=>e.detailField!==void 0)?.detailField,parameters:t}})}function Ci(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 wi(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 Ti(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)=>Ei(e.name)-Ei(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=He(e,t,r);return r.add(n),[Di(t,n,`body`)]})}function Ei(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function Di(e,t,n){let r=e.itemSchemaEnum??e.schemaEnum,i=Ae(e.schemaType,e.itemSchemaType,e.schemaFormat,t);return{name:e.name,optionKey:t,flag:`${re(t)} ${e.schemaType===`boolean`?`[${i}]`:`<${i}>`}`,required:e.required&&e.schemaDefault===void 0,description:ke(e.description,r),schemaType:e.schemaType,schemaFormat:e.schemaFormat,itemSchemaType:e.itemSchemaType,defaultValue:Oi(e.schemaDefault),choices:r,...e.envName===void 0?{}:{envName:e.envName},...e.visibility&&{visibility:e.visibility},location:n}}var Oi=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{j as _,Q as a,B as c,Er as d,z as f,Qt as g,Rt as h,Kr as i,Sr as l,It as m,Ci as n,Yr as o,Yt as p,hi as r,Or as s,Si as t,wr as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./detail-D07FzRkx.js";export{e as EntityDetailSchema};