@aventurevc/aventure-cli 0.8.185 → 0.8.187

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 (34) 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-DIELOZAr.js +1 -0
  4. package/dist/chunks/{api-key-bearer-credential-BYpoThef.js → api-key-bearer-credential-auXuInf6.js} +1 -1
  5. package/dist/chunks/{aventure-cli-g54kxG8S.js → aventure-cli-Bcodt15N.js} +8 -8
  6. package/dist/chunks/{cli-help-policy-RGOSoZ1Z.js → cli-help-policy-CuiFrmX2.js} +1 -1
  7. package/dist/chunks/{contract-CQeFe7mk.js → contract-CJePAAbr.js} +2 -2
  8. package/dist/chunks/{dist-Ce24grer.js → dist-B7MAXU9_.js} +1 -1
  9. package/dist/chunks/{env-YDNggcP1.js → env-DPGP9jZR.js} +1 -1
  10. package/dist/chunks/{logging-CDCaRpiW.js → logging-CkWwAnww.js} +1 -1
  11. package/dist/chunks/logging-lT5vID0k.js +1 -0
  12. package/dist/chunks/{oauth-bearer-credential-4hGvDZoQ.js → oauth-bearer-credential-37I1eza2.js} +2 -2
  13. package/dist/chunks/oauth-bearer-credential-CwzuhMIM.js +1 -0
  14. package/dist/chunks/{oauth-login-BiXKKdqF.js → oauth-login-D2eOQm9g.js} +1 -1
  15. package/dist/chunks/oauth-login-OtUPqSJI.js +1 -0
  16. package/dist/chunks/{output-mode-BW9Jfk5x.js → output-mode-DWDcjV6L.js} +1 -1
  17. package/dist/chunks/output-mode-afpMhky2.js +1 -0
  18. package/dist/chunks/output-spill-BHtm9w1h.js +1 -0
  19. package/dist/chunks/provider-catalog-xEveZBI7.js +1 -0
  20. package/dist/chunks/{response-problem-DEZ2kyCp.js → response-problem-BWkiz0cI.js} +1 -1
  21. package/dist/chunks/result-envelope-CMkMWwDI.js +1 -0
  22. package/dist/chunks/startup-auth-BA1MsnfA.js +1 -0
  23. package/dist/chunks/{startup-auth-BJ3mNNZp.js → startup-auth-e7EaXrQp.js} +1 -1
  24. package/dist/chunks/{tool-policy-D7R8FUUe.js → tool-policy-Cu9R-Sz2.js} +1 -1
  25. package/package.json +3 -3
  26. package/dist/chunks/api-key-bearer-credential-B-1UINE8.js +0 -1
  27. package/dist/chunks/logging-C5C6Bsga.js +0 -1
  28. package/dist/chunks/oauth-bearer-credential-DJ2PA6d4.js +0 -1
  29. package/dist/chunks/oauth-login-BLRUSc5A.js +0 -1
  30. package/dist/chunks/output-mode-QxmCrOJw.js +0 -1
  31. package/dist/chunks/output-spill-CvlQjh5i.js +0 -1
  32. package/dist/chunks/provider-catalog-BxkTk-Lo.js +0 -1
  33. package/dist/chunks/result-envelope-D5wNfKzB.js +0 -1
  34. package/dist/chunks/startup-auth-BCJtMtHx.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-C5C6Bsga.js`),{readRuntimePackage:i}=await import(`../chunks/package-N5oYCiVc.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-DJ2PA6d4.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-B-1UINE8.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-BCJtMtHx.js`),{setTextAllFields:u}=await import(`../chunks/text-field-CxrRvM47.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-QxmCrOJw.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-C0WAjaN3.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-g54kxG8S.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-lT5vID0k.js`),{readRuntimePackage:i}=await import(`../chunks/package-N5oYCiVc.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-Bva_KyCh.js`),{materializeCliOAuthBearerCredential:o,materializeSavedCliOAuthBearerCredential:s}=await import(`../chunks/oauth-bearer-credential-CwzuhMIM.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-DIELOZAr.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-BA1MsnfA.js`),{setTextAllFields:u}=await import(`../chunks/text-field-CxrRvM47.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-afpMhky2.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-C0WAjaN3.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-Bcodt15N.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-15T16:48:35.678Z",
4
+ "generatedAt": "2026-10-15T19:21:31.345Z",
5
5
  "totalOperations": 136,
6
6
  "note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
7
7
  "operations": [
@@ -0,0 +1 @@
1
+ import{t as e}from"./api-key-bearer-credential-auXuInf6.js";export{e as materializeCliApiKeyBearerCredential};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t}from"./logging-CDCaRpiW.js";import{a as n,t as r,u as i}from"./env-YDNggcP1.js";import{i as a,l as o,o as s,w as c,y as l}from"./person-owner-BJgNYLKX.js";import{a as u}from"./package-DPDX5zmx.js";import{r as d}from"./response-problem-DEZ2kyCp.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 _}from"node:timers/promises";import{randomUUID as v}from"node:crypto";import{AsyncLocalStorage as ee}from"node:async_hooks";import{chmod as te,mkdir as y,readFile as b,rename as x,rm as S,stat as ne,writeFile as C}from"node:fs/promises";function w(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(ae(t)?t:`${oe(t)}://${t}`),r=E(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function T(e){let t=w(e);return t.isLoopback?w(n()).host:t.host}function re(e){return{...e,host:w(e.host).origin}}function ie(e){let t=w(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function ae(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function oe(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return E(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function E(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var D=l({createdAt:a({offset:!0}),description:c().nullish(),expiresAt:a({offset:!0}).nullish(),id:c().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:a({offset:!0}).nullish(),name:c(),revocationReason:c().nullish(),scopes:o(c()),status:s([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:c(),updatedAt:a({offset:!0})});function O(e,t=[]){let n=e instanceof Error?e.message:String(e);return d(n,t)}function se(e,t=[]){let n=d(e.title,t),r=d(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function ce(){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 le(){let e=process.env[r.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function k(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var ue=2;function de(e,t){return j(e,t).redactedUrl}async function fe(e,t,n){let r=j(e,t);return await A(new URL(r.openerUrl),n)}async function A(e,t){let n=t.environment??process.env,r=t.operatingSystem??g(),i=M(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=pe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await me(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function j(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=E(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==ue||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 M(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 pe(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 me(e,t){return new Promise((n,r)=>{f(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var he=100,N=3e4,ge=6e4,P=new ee;function F(){return m(p(ce()),`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:${v()}`,r=`aventure-cli-credential-probe:${v()}`,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=``]=O(e,t).trim().split(`
1
+ import{o as e,r as t}from"./logging-CkWwAnww.js";import{a as n,t as r,u as i}from"./env-DPGP9jZR.js";import{i as a,l as o,o as s,w as c,y as l}from"./person-owner-BJgNYLKX.js";import{a as u}from"./package-DPDX5zmx.js";import{r as d}from"./response-problem-BWkiz0cI.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 _}from"node:timers/promises";import{randomUUID as v}from"node:crypto";import{AsyncLocalStorage as ee}from"node:async_hooks";import{chmod as te,mkdir as y,readFile as b,rename as x,rm as S,stat as ne,writeFile as C}from"node:fs/promises";function w(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(ae(t)?t:`${oe(t)}://${t}`),r=E(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function T(e){let t=w(e);return t.isLoopback?w(n()).host:t.host}function re(e){return{...e,host:w(e.host).origin}}function ie(e){let t=w(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function ae(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function oe(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return E(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function E(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var D=l({createdAt:a({offset:!0}),description:c().nullish(),expiresAt:a({offset:!0}).nullish(),id:c().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:a({offset:!0}).nullish(),name:c(),revocationReason:c().nullish(),scopes:o(c()),status:s([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:c(),updatedAt:a({offset:!0})});function O(e,t=[]){let n=e instanceof Error?e.message:String(e);return d(n,t)}function se(e,t=[]){let n=d(e.title,t),r=d(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function ce(){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 le(){let e=process.env[r.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function k(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}var ue=2;function de(e,t){return j(e,t).redactedUrl}async function fe(e,t,n){let r=j(e,t);return await A(new URL(r.openerUrl),n)}async function A(e,t){let n=t.environment??process.env,r=t.operatingSystem??g(),i=M(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=pe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await me(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function j(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=E(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==ue||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 M(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 pe(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 me(e,t){return new Promise((n,r)=>{f(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var he=100,N=3e4,ge=6e4,P=new ee;function F(){return m(p(ce()),`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:${v()}`,r=`aventure-cli-credential-probe:${v()}`,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=``]=O(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`?M(!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 b(e,`utf8`)}catch(e){if(k(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 x(t,r)}catch(e){if(k(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 y(p(t),{recursive:!0,mode:448});let n=Date.now()+N,r=v();for(;;){try{await C(t,r,{flag:`wx`,mode:384});break}catch(e){if(!k(e,`EEXIST`))throw e}if(await ne(t).then(e=>Date.now()-e.mtimeMs,()=>0)>ge)await S(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await _(he)}try{return await P.run(!0,e)}finally{await b(t,`utf8`).catch(()=>``)===r&&await S(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 S(r,{force:!0});return}await y(p(r),{recursive:!0,mode:448});let o=`${r}.${v()}.tmp`;await C(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await te(o,384),await x(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=T(e),i=Se(t,n),a;try{a=await R(J,r,i)}catch(e){throw Error(`${O(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=T(e),n;try{n=await L(J,t)}catch(e){return Z(O(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,T(e));return t===void 0?{state:`missing`}:{state:`missing`,keyringFailure:t}}catch(e){return Z(O(e))}}async function xe(e){await B(J,T(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=D.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 a=T(i().host);try{let e=await X(a);if(e.state===`unavailable`){t($(`keyring`,Error(e.summary)));return}e.state===`found`&&e.stored.activation===`active`&&!Q()&&(process.env[r.authToken]=e.stored.credential.secret,n?.(`api-key`))}catch(t){e($(`parse`,t))}}function Q(){return(process.env[r.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{re as S,se as _,ye as a,w as b,V as c,R as d,A as f,O as g,le as h,X as i,L as l,de as m,xe as n,B as o,fe as p,be as r,I as s,we as t,K as u,D as v,T as x,ie as y};
@@ -1,8 +1,8 @@
1
- import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{i as a,o}from"./logging-CDCaRpiW.js";import{i as s,o as c,r as l,s as u,t as d,u as f}from"./env-YDNggcP1.js";import{M as p,O as m,i as h,o as g,v as ee,w as _,y as v}from"./person-owner-BJgNYLKX.js";import{Ar as te,Br as ne,Mr as re,Or as ie,Pr as ae,jr as oe,kr as se,zr as ce}from"./dist-Ce24grer.js";import{c as y,d as le,i as b,r as ue}from"./result-envelope-D5wNfKzB.js";import{a as x,n as de,r as fe,t as pe}from"./package-DPDX5zmx.js";import{_ as me,b as he,c as ge,i as _e,s as ve,t as ye,v as be,y as xe}from"./tool-policy-D7R8FUUe.js";import{i as Se,r as Ce}from"./response-problem-DEZ2kyCp.js";import{n as we,r as Te}from"./output-spill-CvlQjh5i.js";import{a as Ee,c as De,d as Oe,g as ke,i as Ae,l as je,n as S,o as Me,p as Ne,r as Pe,s as Fe,u as Ie,x as Le,y as Re}from"./contract-CQeFe7mk.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-RGOSoZ1Z.js";import{S as Ke,_ as qe,a as Je,g as C,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as w,y as it}from"./api-key-bearer-credential-BYpoThef.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-4hGvDZoQ.js";import{n as ht,r as gt,t as _t}from"./oauth-login-BiXKKdqF.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-BJ3mNNZp.js";import{n as Ot,t as T}from"./openapi-commands-K3hFzG4D.js";import{i as E,r as kt,t as D}from"./output-mode-BW9Jfk5x.js";import{spawnSync as At}from"node:child_process";import{basename as O,dirname as k,relative as jt,resolve as A,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as j,lstatSync as Pt,mkdirSync as M,mkdtempSync as Ft,readFileSync as It,readdirSync as Lt,readlinkSync as Rt,realpathSync as zt,renameSync as Bt,symlinkSync as Vt,writeFileSync as Ht}from"node:fs";import N,{stderr as P,stdin as Ut}from"node:process";import{TextDecoder as Wt,inspect as Gt}from"node:util";import{homedir as Kt,hostname as qt,platform as Jt}from"node:os";import{fileURLToPath as Yt}from"node:url";import{setTimeout as Xt}from"node:timers/promises";import{randomUUID as Zt,webcrypto as Qt}from"node:crypto";import{readFile as $t}from"node:fs/promises";import{createInterface as en}from"node:readline/promises";function tn(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{...b(`${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 nn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!_n(n,r.name))continue;let a=gn(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 rn(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 an(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return xn(e,t,n);for(let[r,i]of n.entries()){let n=xn(e,t,i,r);if(!n.ok)return n}return y(`Body value assigned`,null)}function on(e,t,n,r){return xn(e,t,r,n)}function sn(e){let t=[];for(let n of e.split(`.`)){let e=Cn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function cn(e,t){let n=sn(t);if(n===null)return null;let r=hn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:mn(r)}:null}function ln(e,t){if(F(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]):b(`${n} was already given; pass it once.`)}var un=/^(?<row>\d+):(?<item>.*)$/su;function dn(e,t){let n=sn(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=un.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 fn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&sn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function pn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=cn(r,i.name);if(a===null)continue;if(a.firstHole!==null)return b(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||dn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return b(`${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 mn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function hn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function gn(e,t){if(!F(t))return hn(e,t.split(`.`))}function _n(e,t){return yn(e,t.split(`.`))}function vn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&_n(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function yn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=Cn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>yn(e,r)):yn(a,r)}function F(e){return e.split(`.`).some(e=>Cn(e).isArray)}function bn(e,t){return e.parameter.length===0||!I(t)?null:Tn(t,[],wn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=Cn(o),c=e===i.length-1,l=Sn(a,s,t,c,n,r);if(!l.ok||l.data===null)return b(l.summary,l.warnings);if(c)return y(`Body value assigned`,null);a=l.data}return b(`${t} is not a valid body option path.`)}function Sn(e,t,n,r,i,a){let o=()=>b(`${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 I(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 I(s)?y(`Body path stepped`,s):o()}function Cn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function wn(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 Tn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=Tn(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!En(a,n)){if(!Dn(e))continue;let t=On(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=Tn(i,e,n);if(o!==null)return o}return null}function En(e,t){return t.prefix.has(e)||t.leaf.has(e)}function Dn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function On(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:kn(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 kn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}var An=e=>Array.isArray(e)&&!Object.isFrozen(e);function jn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=ae(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!An(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?zn(r,i):r===void 0?i===void 0?0:1:-1})}function Mn(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 Nn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Pn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Ln(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 Fn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function In(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Ln(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${Rn(e,t)}`}function Rn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=sn(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 zn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Bn(e){let t;try{t=e===`-`?await Vn():await $t(e,`utf8`)}catch(t){return b(`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 b(`Input is not valid JSON: ${e.message}`)}}async function Vn(){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 Hn=`--content-type`;function Un(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Hn)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Hn} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Gn(a)))}if(lr(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,In(r,r.requiredPath)).argParser(qn(`--from-file`)))}let o=Mn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>zn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Nn(n),a.length>1?Pn(n):Ln(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Fn(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Wn):F(i.name)||i.schemaType===`array`?o.argParser(Kn):o.argParser(qn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}cr(e,n,o)}function Wn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Gn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Hn} was already given; pass it once.`);let i=me(e,t);if(!i.ok)throw new n(i.summary);return t}}function Kn(e,t){return[...t??[],e]}function qn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Jn(e,t){let n=wt(e,t),r=me(e.requestBody??[],n);if(!r.ok||r.data===null)return b(r.summary,r.warnings);let i=r.data;if(i===void 0)return y(`No body`,void 0);let a=Yn(e,i,t);if(a!==null)return b(a);let o=tn(e.operationId,i,t);if(!o.ok)return b(o.summary,o.warnings);t=o.data;let s=Xn(i,t);if(s!==null)return b(s);let c=await er(t);if(!c.ok)return b(c.summary,c.warnings);let l=vn(e.requestBody??[],i,c.data);if(l!==null)return b(l);let u=$n(e.operationId,i,c.data);if(!u.ok)return u;let d=nn(e.operationId,i,c.data);if(d!==null)return b(d);let f=tr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?b(sr(e.operationId,i)):y(`No body`,void 0);let p=rr(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 b(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return b(`${e.operationId} requires a JSON object${t}.`)}let m=Qn(i,p.data);if(m.length>0)return b(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?rn(i).filter(e=>!_n(h,e)):[];return g.length>0?b(Zn(e.operationId,i,g)):p}function Yn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Hn} ${i.join(` or `)}.`}return null}function Xn(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 Zn(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 Qn(e,t){return I(t)?e.parameter.filter(e=>e.required&&!_n(t,e.name)).map(L):[]}function $n(e,t,n){let r=bn(t,n);if(r===null)return y(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return b(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function er(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 Bn(t);if(!n.ok)return b(n.summary,n.warnings);let r=le.safeParse(n.data);return r.success?y(`Input parsed`,r.data):b(`Input is not valid JSON value: ${r.error.message}`)}function tr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=ln(e,n[e.optionKey]);if(!a.ok||a.data===null)return b(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=nr(t,n,r,e,o);if(!s.ok)return b(s.summary,s.warnings);i=!0}if(!i)return y(`No direct body options`,void 0);let a=pn(e,t,n,r);return a===null?y(`Direct body options parsed`,r):a}function nr(e,t,n,r,i){let a=dn(r,i);if(a===null){let e=ar(r,i);return e.ok?an(n,r.name,e.data,r.schemaType===`array`):b(e.summary,e.warnings)}if(a.plain.length>0)return b(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=fn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return b(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=or(r.name,r.itemSchemaType,e);if(!t.ok)return b(t.summary,t.warnings);i.push(t.data)}let a=on(n,r.name,e,i);if(!a.ok)return a}return y(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function rr(e,t,n,r){if(n===void 0)return y(`Direct body parsed`,r);if(r===void 0)return y(`Input parsed`,n);if(I(n)&&I(r))try{return y(`Input parsed`,ir(t,n,r))}catch(t){return b(`${e} ${t instanceof Error?t.message:String(t)}`)}return b(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ir(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ir(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`:Me.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function ar(e,t){if(typeof t==`boolean`)return y(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return or(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=or(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return y(`Body value parsed`,n)}function or(e,t,n){if(t===`boolean`)return n===`true`?y(`Body value parsed`,!0):n===`false`?y(`Body value parsed`,!1):b(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?b(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?b(`${e} must be an integer.`):y(`Body value parsed`,i)}return y(`Body value parsed`,n)}function sr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=rn(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function cr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Hn,location:`body`}),lr(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),jn(e.options,r)}function lr(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function ur(e){let t=ue(e,Pe(e,T));return yr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function dr(e){let t=ue(e,Pe(e,T));yr(t);let n=Ae(T,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=fr(t);r.push(n.endsWith(`
2
- `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(Le(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(...hr(t.problem)),r.push(...fr(t)),process.stdout.write(Le(r.join(`
4
- `),!0))}function fr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function R(e,t){let n=Te(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?ue(n,pr(n)):n;yr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?we(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?ur(n):n;e.mode===`text`&&dr(r),r.ok||(process.exitCode=1)}function pr(e){let t=Pe(e,T);if(t.write===!0||!e.ok)return t;let n=t.exactRecovery??`Refetch a narrower result: use ids/references, a more specific list read (e.g. entities relationships list, entities people list, or news list --owner-entity-id), filters, or smaller pages with page and size.`;return{...t,exactRecovery:`--data printed this truncated result envelope (truncated: true), not the bare payload, so payload paths read as null; rerun with --to-file <path> for the whole payload, or --data-full in a bounded program. ${n}`}}function mr(e,t){let n=Ee(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 hr(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(...gr(e),..._r(`unknownParameters`,e.unknownParameters),..._r(`validParameters`,e.validParameters),...vr(e.resolution)),t}function gr(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 _r(e,t){return t!=null&&t.length>0?[` ${e}: ${t.join(`, `)}`]:[]}function vr(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 yr(e){if(e.ok&&e.warnings.length===0)return;let t=e.truncation===void 0?e.warnings:[...e.warnings,`omitted: ${e.truncation.omitted.join(`, `)}`,`recovery: ${e.truncation.recovery}`];o({component:x().bin[0],event:e.ok?`command_warning`:`command_failed`,message:t.length>0?t.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function br(e,t,n=x().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 b(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=Oe(t,n),a=Re(e.root??``),o=[...new Set(i.map(({cli:e})=>Re(e.path.at(0)??``)))].toSorted();if(a.length>0&&!o.includes(a))return b(`Unknown --root value: ${JSON.stringify(e.root)}`,[`Pass one of: ${o.join(`, `)}.`]);let s=Ne(e.q??``,i.filter(t=>wr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)],responseFieldLevel:ke(e.operationId)})).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 xr(e,t,n=x().bin[0]){let r=Oe(t,n),i=e.operationId===void 0?Sr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=kr(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return b(`${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=br({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 b(`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:Er(i,r)})}function Sr(e,t){if(t===void 0)return;let{bin:n}=x(),r=kr(t,n);return e.find(e=>kr(e.cli.command,n)===r)}var Cr=(e,t)=>e===void 0||e===`all`||e===`any`||e===String(t);function wr(e,t){return(t.root===void 0||Tr(e,t.root))&&Cr(t.scope,e.scope)&&Cr(t.mutates,e.mutates)&&Cr(t.destructive,e.destructive)&&Cr(t.intent,e.intent)&&Cr(t.method,e.method)}function Tr(e,t){let n=Re(t);return n.length===0||Re(e.cli.path.at(0)??``)===n}function Er(e,t){let n=Fe(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=Or(`${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})),...Ie(e,t),...Dr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
1
+ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{i as a,o}from"./logging-CkWwAnww.js";import{i as s,o as c,r as l,s as u,t as d,u as f}from"./env-DPGP9jZR.js";import{M as p,O as m,i as h,o as g,v as ee,w as _,y as v}from"./person-owner-BJgNYLKX.js";import{Ar as te,Br as ne,Mr as re,Or as ie,Pr as ae,jr as oe,kr as se,zr as ce}from"./dist-B7MAXU9_.js";import{c as y,d as le,i as b,r as ue}from"./result-envelope-CMkMWwDI.js";import{a as x,n as de,r as fe,t as pe}from"./package-DPDX5zmx.js";import{_ as me,b as he,c as ge,i as _e,s as ve,t as ye,v as be,y as xe}from"./tool-policy-Cu9R-Sz2.js";import{i as Se,r as Ce}from"./response-problem-BWkiz0cI.js";import{n as we,r as Te}from"./output-spill-BHtm9w1h.js";import{S as Ee,a as De,c as Oe,d as ke,g as Ae,i as je,l as Me,n as S,o as Ne,p as Pe,r as Fe,s as Ie,u as Le,y as Re}from"./contract-CJePAAbr.js";import{a as ze,c as Be,i as Ve,l as He,n as Ue,s as We,t as Ge}from"./cli-help-policy-CuiFrmX2.js";import{S as Ke,_ as qe,a as Je,g as C,h as Ye,i as Xe,m as Ze,n as Qe,p as $e,r as et,s as tt,t as nt,v as rt,x as w,y as it}from"./api-key-bearer-credential-auXuInf6.js";import{a as at,c as ot,d as st,g as ct,l as lt,m as ut,o as dt,s as ft,t as pt,u as mt}from"./oauth-bearer-credential-37I1eza2.js";import{n as ht,r as gt,t as _t}from"./oauth-login-D2eOQm9g.js";import{a as vt,c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,s as Tt,t as Et,u as Dt}from"./startup-auth-e7EaXrQp.js";import{n as Ot,t as T}from"./openapi-commands-K3hFzG4D.js";import{i as E,r as kt,t as D}from"./output-mode-DWDcjV6L.js";import{spawnSync as At}from"node:child_process";import{basename as O,dirname as k,relative as jt,resolve as A,sep as Mt}from"node:path";import{copyFileSync as Nt,existsSync as j,lstatSync as Pt,mkdirSync as M,mkdtempSync as Ft,readFileSync as It,readdirSync as Lt,readlinkSync as Rt,realpathSync as zt,renameSync as Bt,symlinkSync as Vt,writeFileSync as Ht}from"node:fs";import N,{stderr as P,stdin as Ut}from"node:process";import{TextDecoder as Wt,inspect as Gt}from"node:util";import{homedir as Kt,hostname as qt,platform as Jt}from"node:os";import{fileURLToPath as Yt}from"node:url";import{setTimeout as Xt}from"node:timers/promises";import{randomUUID as Zt,webcrypto as Qt}from"node:crypto";import{readFile as $t}from"node:fs/promises";import{createInterface as en}from"node:readline/promises";function tn(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{...b(`${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 nn(e,t,n){if(!I(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!_n(n,r.name))continue;let a=gn(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 rn(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 an(e,t,n,r=!1){if(r||!F(t)||!Array.isArray(n))return xn(e,t,n);for(let[r,i]of n.entries()){let n=xn(e,t,i,r);if(!n.ok)return n}return y(`Body value assigned`,null)}function on(e,t,n,r){return xn(e,t,r,n)}function sn(e){let t=[];for(let n of e.split(`.`)){let e=Cn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function cn(e,t){let n=sn(t);if(n===null)return null;let r=hn(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:mn(r)}:null}function ln(e,t){if(F(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]):b(`${n} was already given; pass it once.`)}var un=/^(?<row>\d+):(?<item>.*)$/su;function dn(e,t){let n=sn(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=un.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 fn(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&sn(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function pn(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=cn(r,i.name);if(a===null)continue;if(a.firstHole!==null)return b(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||dn(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return b(`${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 mn(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function hn(e,t){let n=e;for(let e of t){if(!I(n))return;n=n[e]??null}return n}function gn(e,t){if(!F(t))return hn(e,t.split(`.`))}function _n(e,t){return yn(e,t.split(`.`))}function vn(e,t,n){if(!I(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&_n(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function yn(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=Cn(n);if(!I(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>yn(e,r)):yn(a,r)}function F(e){return e.split(`.`).some(e=>Cn(e).isArray)}function bn(e,t){return e.parameter.length===0||!I(t)?null:Tn(t,[],wn(e.parameter))}function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=Cn(o),c=e===i.length-1,l=Sn(a,s,t,c,n,r);if(!l.ok||l.data===null)return b(l.summary,l.warnings);if(c)return y(`Body value assigned`,null);a=l.data}return b(`${t} is not a valid body option path.`)}function Sn(e,t,n,r,i,a){let o=()=>b(`${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 I(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 I(s)?y(`Body path stepped`,s):o()}function Cn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function wn(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 Tn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=Tn(r,t,n);if(e!==null)return e}return null}if(!I(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!En(a,n)){if(!Dn(e))continue;let t=On(e,n);return{path:a,...t===void 0?{}:{suggestion:t}}}let o=Tn(i,e,n);if(o!==null)return o}return null}function En(e,t){return t.prefix.has(e)||t.leaf.has(e)}function Dn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function On(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:kn(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 kn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}var An=e=>Array.isArray(e)&&!Object.isFrozen(e);function jn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&(t.helpGroup(Be(e)),t.description=ae(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!An(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?zn(r,i):r===void 0?i===void 0?0:1:-1})}function Mn(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 Nn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function Pn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:Ln(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 Fn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function In(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function Ln(e,t){let n=ze(t.description,void 0),r=e.kind!==`multipart`&&F(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${Rn(e,t)}`}function Rn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=sn(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 zn(e,t){return We(e)-We(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function Bn(e){let t;try{t=e===`-`?await Vn():await $t(e,`utf8`)}catch(t){return b(`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 b(`Input is not valid JSON: ${e.message}`)}}async function Vn(){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 Hn=`--content-type`;function Un(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(Hn)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${Hn} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Gn(a)))}if(lr(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,In(r,r.requiredPath)).argParser(qn(`--from-file`)))}let o=Mn(a).filter(e=>i(L(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>zn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Nn(n),a.length>1?Pn(n):Ln(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Fn(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Wn):F(i.name)||i.schemaType===`array`?o.argParser(Kn):o.argParser(qn(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}cr(e,n,o)}function Wn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Gn(e){return(t,r)=>{if(r!==void 0)throw new n(`${Hn} was already given; pass it once.`);let i=me(e,t);if(!i.ok)throw new n(i.summary);return t}}function Kn(e,t){return[...t??[],e]}function qn(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Jn(e,t){let n=wt(e,t),r=me(e.requestBody??[],n);if(!r.ok||r.data===null)return b(r.summary,r.warnings);let i=r.data;if(i===void 0)return y(`No body`,void 0);let a=Yn(e,i,t);if(a!==null)return b(a);let o=tn(e.operationId,i,t);if(!o.ok)return b(o.summary,o.warnings);t=o.data;let s=Xn(i,t);if(s!==null)return b(s);let c=await er(t);if(!c.ok)return b(c.summary,c.warnings);let l=vn(e.requestBody??[],i,c.data);if(l!==null)return b(l);let u=$n(e.operationId,i,c.data);if(!u.ok)return u;let d=nn(e.operationId,i,c.data);if(d!==null)return b(d);let f=tr(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?b(sr(e.operationId,i)):y(`No body`,void 0);let p=rr(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 b(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!I(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return b(`${e.operationId} requires a JSON object${t}.`)}let m=Qn(i,p.data);if(m.length>0)return b(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,g=I(h)?rn(i).filter(e=>!_n(h,e)):[];return g.length>0?b(Zn(e.operationId,i,g)):p}function Yn(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${L(t)} requires ${Hn} ${i.join(` or `)}.`}return null}function Xn(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 Zn(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 Qn(e,t){return I(t)?e.parameter.filter(e=>e.required&&!_n(t,e.name)).map(L):[]}function $n(e,t,n){let r=bn(t,n);if(r===null)return y(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return b(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function er(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 Bn(t);if(!n.ok)return b(n.summary,n.warnings);let r=le.safeParse(n.data);return r.success?y(`Input parsed`,r.data):b(`Input is not valid JSON value: ${r.error.message}`)}function tr(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=ln(e,n[e.optionKey]);if(!a.ok||a.data===null)return b(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=nr(t,n,r,e,o);if(!s.ok)return b(s.summary,s.warnings);i=!0}if(!i)return y(`No direct body options`,void 0);let a=pn(e,t,n,r);return a===null?y(`Direct body options parsed`,r):a}function nr(e,t,n,r,i){let a=dn(r,i);if(a===null){let e=ar(r,i);return e.ok?an(n,r.name,e.data,r.schemaType===`array`):b(e.summary,e.warnings)}if(a.plain.length>0)return b(`${L(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=fn(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return b(`${L(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=or(r.name,r.itemSchemaType,e);if(!t.ok)return b(t.summary,t.warnings);i.push(t.data)}let a=on(n,r.name,e,i);if(!a.ok)return a}return y(`Body value assigned`,null)}var L=e=>e.flag.split(` `)[0]??e.name;function rr(e,t,n,r){if(n===void 0)return y(`Direct body parsed`,r);if(r===void 0)return y(`Input parsed`,n);if(I(n)&&I(r))try{return y(`Input parsed`,ir(t,n,r))}catch(t){return b(`${e} ${t instanceof Error?t.message:String(t)}`)}return b(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function ir(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(I(n)&&I(a))i[t]=ir(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`:Ne.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function ar(e,t){if(typeof t==`boolean`)return y(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return or(e.name,e.schemaType,t??``);let n=[],r=F(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=or(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return y(`Body value parsed`,n)}function or(e,t,n){if(t===`boolean`)return n===`true`?y(`Body value parsed`,!0):n===`false`?y(`Body value parsed`,!1):b(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?b(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?b(`${e} must be an integer.`):y(`Body value parsed`,i)}return y(`Body value parsed`,n)}function sr(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(L).join(`, `)}`;let r=rn(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(L).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function cr(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Hn,location:`body`}),lr(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),jn(e.options,r)}function lr(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function ur(e){let t=ue(e,Fe(e,T));return yr(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function dr(e){let t=ue(e,Fe(e,T));yr(t);let n=je(T,t.data,t.summary),r=[];if(t.ok&&n!==null){let e=fr(t);r.push(n.endsWith(`
2
+ `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(Ee(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(...hr(t.problem)),r.push(...fr(t)),process.stdout.write(Ee(r.join(`
4
+ `),!0))}function fr(e){let t=[];e.ids.length>0&&t.push(` ids: ${e.ids.join(`, `)}`);for(let[n,r]of Object.entries(e.counts))t.push(` ${n}: ${r}`);for(let n of e.references)t.push(` ref: ${n}`);if(e.truncation!==void 0){let n=e.truncation.omitted.join(`, `);t.push(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${n}`,` recovery: ${e.truncation.recovery}`)}for(let n of e.warnings)t.push(` warn: ${n}`);return t}function R(e,t){let n=Te(t);if(e.mode===`data`||e.mode===`data-full`){let t=e.mode===`data`?ue(n,pr(n)):n;yr(t),process.stdout.write(`${JSON.stringify(t.ok&&t.truncated!==!0?we(t.data):t)}\n`),t.ok||(process.exitCode=1);return}let r=e.mode===`json`?ur(n):n;e.mode===`text`&&dr(r),r.ok||(process.exitCode=1)}function pr(e){let t=Fe(e,T);if(t.write===!0||!e.ok)return t;let n=t.exactRecovery??`Refetch a narrower result: use ids/references, a more specific list read (e.g. entities relationships list, entities people list, or news list --owner-entity-id), filters, or smaller pages with page and size.`;return{...t,exactRecovery:`--data printed this truncated result envelope (truncated: true), not the bare payload, so payload paths read as null; rerun with --to-file <path> for the whole payload, or --data-full in a bounded program. ${n}`}}function mr(e,t){let n=De(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 hr(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(...gr(e),..._r(`unknownParameters`,e.unknownParameters),..._r(`validParameters`,e.validParameters),...vr(e.resolution)),t}function gr(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 _r(e,t){return t!=null&&t.length>0?[` ${e}: ${t.join(`, `)}`]:[]}function vr(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 yr(e){if(e.ok&&e.warnings.length===0)return;let t=e.truncation===void 0?e.warnings:[...e.warnings,`omitted: ${e.truncation.omitted.join(`, `)}`,`recovery: ${e.truncation.recovery}`];o({component:x().bin[0],event:e.ok?`command_warning`:`command_failed`,message:t.length>0?t.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function br(e,t,n=x().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 b(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=ke(t,n),a=Re(e.root??``),o=[...new Set(i.map(({cli:e})=>Re(e.path.at(0)??``)))].toSorted();if(a.length>0&&!o.includes(a))return b(`Unknown --root value: ${JSON.stringify(e.root)}`,[`Pass one of: ${o.join(`, `)}.`]);let s=Pe(e.q??``,i.filter(t=>wr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),directParameterName:e.flags.filter(({location:e})=>e!==`body`).map(({wireName:e})=>e),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)],responseFieldLevel:Ae(e.operationId)})).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 xr(e,t,n=x().bin[0]){let r=ke(t,n),i=e.operationId===void 0?Sr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=kr(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return b(`${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=br({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 b(`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:Er(i,r)})}function Sr(e,t){if(t===void 0)return;let{bin:n}=x(),r=kr(t,n);return e.find(e=>kr(e.cli.command,n)===r)}var Cr=(e,t)=>e===void 0||e===`all`||e===`any`||e===String(t);function wr(e,t){return(t.root===void 0||Tr(e,t.root))&&Cr(t.scope,e.scope)&&Cr(t.mutates,e.mutates)&&Cr(t.destructive,e.destructive)&&Cr(t.intent,e.intent)&&Cr(t.method,e.method)}function Tr(e,t){let n=Re(t);return n.length===0||Re(e.cli.path.at(0)??``)===n}function Er(e,t){let n=Ie(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=Or(`${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})),...Le(e,t),...Dr(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
6
6
  `)}function Dr(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}function Or(e,t){return`${e}: ${t.length===0?`none`:t.map(e=>e.name).join(` `)}`}function kr(e,t=x().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var Ar=`dist/aventure-cli/command-catalog.compact.txt`,jr=` · `,Mr=`-`;function Nr(e=x().bin[0]){return A(Pr(k(Yt(import.meta.url)),e),Ar)}function Pr(e,t){let n=e;for(;;){if(j(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 Fr(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Ir(e,t,n,r=x().bin[0]){let i=br(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Rr({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:Vr(i.data,Br(e.format,`lines`)),summary:`Generated operation matches`})}function Lr(e,t,n,r=x().bin[0]){let i=xr(e,t,r);if(!i.ok||i.data===null){R({mode:n},i);return}Rr({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Hr(i.data,Br(e.format,`usage`)),summary:`Generated operation detail`})}function Rr(e){let t=e.mode,n=Br(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`)){R({mode:t},b(`--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
7
  `)?i:`${i}\n`;if(e.opts.output!==void 0){Ht(e.opts.output,a),R({mode:t},y(e.summary,{outputPath:e.opts.output,byteLength:Buffer.byteLength(a,`utf8`),format:n},{counts:qr(e.data)}));return}if(t===`text`){zr(e.summary,a);return}R({mode:t},y(e.summary,e.data,{counts:qr(e.data)}))}function zr(e,t){let n=Te(y(e,t));if(!n.ok||n.data===null){R({mode:`text`},n);return}process.stdout.write(n.data.endsWith(`
8
8
  `)?n.data:`${n.data}\n`)}function Br(e,t){return e??t}function Vr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?e.operation.map(e=>JSON.stringify(e)).join(`
@@ -10,7 +10,7 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{i as a
10
10
  `):e.operation.map(Kr).join(`
11
11
  `)}function Hr(e,t){return t===`json`?JSON.stringify(e,null,2):t===`ndjson`?JSON.stringify(e.operation):t===`lines`?Kr(e.operation):t===`compact`?Ur(e.operation):e.usage}function Ur(e){let t=Wr(e);return[e.cli.command,e.summary,t.length===0?Mr:t.join(` `)].join(jr)}function Wr(e){return e.flags.filter(t=>t.required&&(t.contentType===void 0||t.contentType===e.body.contentType)).map(e=>e.name)}function Gr(e){return e.map(e=>`${e.cli.command}\n ${Kr(e)}`).join(`
12
12
  `)}function Kr(e){let t=Wr(e);return[z(`operationId`,e.operationId),z(`scope`,e.scope),z(`mutates`,String(e.mutates)),z(`destructive`,String(e.destructive)),z(`intent`,e.intent),z(`resource`,e.resource),z(`cli`,e.cli.command),e.mcpTool===null?``:z(`mcpTool`,e.mcpTool),z(`method`,e.method),z(`path`,e.path),z(`auth`,e.auth),z(`flags`,[...new Set(e.flags.map(e=>e.name))].join(` `)),z(`requiredFlags`,t.join(` `)),z(`bodyKind`,e.body.kind??``),z(`bodyRequired`,String(e.body.required)),z(`summary`,e.summary)].filter(e=>e.length>0).join(` `)}function z(e,t){return t.length===0?``:`${e}=${JSON.stringify(t)}`}function qr(e){return`count`in e?e.count:{returned:1}}function Jr(e,t,n=x().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 Yr(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=ti(t);i!==void 0&&r.option(`--ask <question>`,i.summary),D(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=E(a);if(r.length>0){R({mode:e},b(`Use either a command path or --ask, not both.`));return}R({mode:e},await ai(i,a.ask,a.environment,e));return}let o=ii(e,r),s=t.find(t=>o!==void 0&&ii(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?ri(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){R({mode:E(a)},c);return}Lr({...a,...c.data},t,E(a,`text`),n)}),ei(e,t,n)}var Yr=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},Xr=2,Zr=6,Qr={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!Ue.has(e.name())):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(Xr)}${e}\n${$r(n,a,i)}`}};function $r(e,t,n){return n.boxWrap(e,t-Zr).replace(/^/gmu,` `.repeat(Zr))}function ei(e,t,n){for(let r of t){let i=ii(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=De(r.operationId,t,n),[c,...l]=Dr(r.errorResponse),u=l.map(t=>$r(t.trimStart(),o,e).replace(/^ +/u,` `.repeat(Xr))),d=c===void 0?[]:[``,c,...u];return`\n${[...s,...d].join(`
13
+ `)).argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new Yr(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=ti(t);i!==void 0&&r.option(`--ask <question>`,i.summary),D(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=E(a);if(r.length>0){R({mode:e},b(`Use either a command path or --ask, not both.`));return}R({mode:e},await ai(i,a.ask,a.environment,e));return}let o=ii(e,r),s=t.find(t=>o!==void 0&&ii(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?ri(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){R({mode:E(a)},c);return}Lr({...a,...c.data},t,E(a,`text`),n)}),ei(e,t,n)}var Yr=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},Xr=2,Zr=6,Qr={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>!Ue.has(e.name())):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(Xr)}${e}\n${$r(n,a,i)}`}};function $r(e,t,n){return n.boxWrap(e,t-Zr).replace(/^/gmu,` `.repeat(Zr))}function ei(e,t,n){for(let r of t){let i=ii(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=Oe(r.operationId,t,n),[c,...l]=Dr(r.errorResponse),u=l.map(t=>$r(t.trimStart(),o,e).replace(/^ +/u,` `.repeat(Xr))),d=c===void 0?[]:[``,c,...u];return`\n${[...s,...d].join(`
14
14
  `)}\n`})}}function ti(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&oi(e)!==void 0});return n.length===0?t:void 0}var ni='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';function ri(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?y(`Resolved by route`,{operationId:i.operationId}):b(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[ni]);let o=be.find(e=>e===n.toLowerCase());if(o===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 s=xe(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return y(`Resolved by route template`,{operationId:l.operationId});let u=oe({method:s,path:c});return!u.ok||u.data===null?b(u.summary,[...u.warnings,ni]):y(`Resolved by method and path`,{operationId:u.data.operation.operationId})}function ii(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 ai(e,t,n,r){let i=oi(e);if(i===void 0)return b(`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 Jn(e,{[i.optionKey]:t});return a.ok?await re({method:e.method,path:se(e.operationId,{}),searchParams:{},body:a.data,auth:e.auth,responseFormat:kt(r)?`json`:`auto`}):a}function oi(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 si(e,t,n){if(e.cliPath[0]!==`lookup`||!ci(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?b(i):b(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ci(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function li(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 ui=v({artifact:_().nullish(),group:_().nullish(),name:_().nullish(),revision:_().nullish(),time:h({offset:!0}).nullish(),version:_().nullish()}),di=v({build:ui}),fi=g([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),pi=g([`RSA_OAEP_256_A256_GCM_V1`]),mi=v({clientLabel:_().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:fi.nullish(),encryptionAlgorithm:pi.nullish(),encryptionPublicKey:_().min(344).max(12e3).nullish()}),hi=32;async function gi(){let e=await Qt.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await Qt.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function _i(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=vi(n,`wrapped key`,128,1024),s=vi(r,`nonce`,12,12),c=vi(i,`ciphertext`,1,65536),l=vi(a,`authentication tag`,16,16),u;try{u=await Qt.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!==hi)throw Error(`broker credential used an invalid AES-256 key`);let e=await Qt.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 Qt.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new Wt(`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 vi(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 yi=g([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),bi=g([`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`]),xi=v({approvedAt:h({offset:!0}).nullish(),clientLabel:_(),clientPlatform:fi,comparisonCode:_(),consumedAt:h({offset:!0}).nullish(),createdAt:h({offset:!0}),expiresAt:h({offset:!0}),id:m(),intervalSeconds:ee().int().min(1),keyReadyAt:h({offset:!0}).nullish(),status:yi,terminalAt:h({offset:!0}).nullish(),terminalReason:bi.nullish(),updatedAt:h({offset:!0})}),Si=v({algorithm:pi,authenticationTag:_(),ciphertext:_(),nonce:_(),wrappedKey:_()}),Ci=v({delivery:Si.nullish(),expiresAt:h({offset:!0}),status:yi,terminalReason:bi.nullish()}),wi=v({comparisonCode:_(),expiresAt:h({offset:!0}),id:m(),intervalSeconds:ee().int().min(1),pollSecret:_(),verificationUrl:_()}),B=[{command:`auth login`,role:`oauth`,summary:`Sign In Through Your Browser`,description:`Sign in through your browser and save verified CLI access in the credential store. Use --no-browser for OAuth device authorization only when the issuer advertises device-grant support; otherwise use --key --no-browser for API-key approval.`,operationId:`getAuthProviderCatalog`,method:`GET`,path:`/v1/auth/providers`,bodyOption:[],localOption:[{optionKey:`browser`,flag:`--no-browser`,description:`Use OAuth device authorization only when the issuer advertises device-grant support: print a sign-in URL and code, then wait for approval. Otherwise use --key --no-browser for API-key approval.`},{optionKey:`providers`,flag:`--providers`,description:`Print the sign-in providers and CLI OAuth client, then exit without signing in.`}]},{command:`auth login`,role:`start`,summary:`Sign In With a Browser-Approved aVenture API Key`,description:`Creates a short-lived browser approval request and returns its poll credential once.`,operationId:`createCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations`,bodyOption:[{name:`clientLabel`,optionKey:`clientLabel`,flag:`--client-label <client-label>`,required:!1,description:`Label for this CLI installation.`}],localOption:[{optionKey:`key`,flag:`--key`,description:`Sign in with a browser-approved aVenture API key instead of OAuth; the approval URL opens on any device.`},{optionKey:`browser`,flag:`--no-browser`,description:`Print the API-key approval URL and wait for approval without opening a browser.`}]},{command:`auth login`,role:`poll`,summary:`Poll CLI Authorization`,description:`Returns pending state, a terminal state, or an encrypted one-time credential delivery.`,operationId:`pollCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/poll`,bodyOption:[],localOption:[]},{command:`auth login`,role:`acknowledge`,summary:`Acknowledge CLI Credential Delivery`,description:`Confirms the CLI stored the delivered API key in its credential store and clears transient delivery material.`,operationId:`acknowledgeCliAuthorization`,method:`POST`,path:`/v1/auth/cli-authorizations/{cliAuthorizationId}/acknowledge`,bodyOption:[],localOption:[]},{command:`auth logout`,role:`revoke`,summary:`Sign Out: Revoke the API Key and Forget Stored OAuth`,description:`Revokes the aVenture API key authenticating this request and returns its metadata so the CLI can confirm revocation before deleting its saved copy.`,operationId:`revokeCurrentApiKey`,method:`DELETE`,path:`/v1/auth/api-key`,bodyOption:[],localOption:[{optionKey:`forgetLocal`,flag:`--forget-local`,description:`Delete the saved key even when revocation cannot be confirmed.`}]}],Ti=S(B,`start`),Ei=S(B,`poll`),Di=S(B,`acknowledge`),V=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${qe(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=Ni(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},Oi=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${C(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function ki(e){let t=await ne(Ke(f()),{method:Ti.method,path:he(Ti.path,{},Ti.operationId),headers:{},contentType:`application/json`,body:e},wi);if(t.ok&&t.redirect)throw new V(`start`,Pi(t.status));if(!t.ok)throw new V(`start`,t.problem);return Fi(t.data)}async function Ai(e,t){let n=te(Ei.operationId),r=await ne(Ke(f()),{method:Ei.method,path:he(Ei.path,{cliAuthorizationId:e},Ei.operationId),headers:{[n]:t}},Ci);if(r.ok&&r.redirect)throw new V(`poll`,Pi(r.status),[t]);if(!r.ok)throw new V(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:Mi(r.headers[`retry-after`])}}async function ji(e,t){let n=te(Di.operationId),r;try{r=await ne(Ke(f()),{method:Di.method,path:he(Di.path,{cliAuthorizationId:e},Di.operationId),headers:{[n]:t}},xi)}catch(e){throw new Oi(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new V(`acknowledge`,Pi(r.status),[t]);if(!r.ok)throw new V(`acknowledge`,r.problem,[t]);return r.data}function Mi(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function Ni(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function Pi(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function Fi(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())})`},[Gt.custom]:{enumerable:!1,value:a}})}async function Ii(e){let t=await Li(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await Je(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 — ${C(n,[e.credential.secret])}`}}}}async function Li(e){let t=Ke(f()),n;try{n=await ne(t,{method:`GET`,path:se(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${e}`}},rt)}catch(t){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${C(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: ${qe(n.problem,[e])}`}}var Ri=S(B,`revoke`);async function zi(e){let t;try{t=w(f().host)}catch(e){return b(`auth logout: invalid API host — ${C(e)}`)}let n=await Bi(t),r=await Ui(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`?{...b(`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 Bi(e){let t=await dt(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await Hi(t.stored):{revoked:!1};try{await at(e)}catch(e){return{state:`failed`,summary:C(e)}}return{state:`forgotten`,...n}}async function Vi(e){let t=Reflect.get(await _t(e),`revocation_endpoint`);return typeof t==`string`?ct(t,`revocation endpoint`,!0):void 0}async function Hi(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await Vi(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:mt(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:C(e,ut(n))}}}async function Ui(e,t){let n;try{n=await Xe(e)}catch(e){return b(`auth logout: stored credential could not be read — ${C(e)}`)}if(n.state===`unavailable`)return{...b(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let r=n.stored,i=await Wi(r),a=i.outcome===`revoked`,o=r.activation===`pending`&&i.outcome===`rejected`;if(!a&&!o&&!t.forgetLocal)return{...b(`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:Gi(r,!1,!1)};try{await Qe(r.host)}catch(e){return{...b(`auth logout: local credential removal failed — ${C(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:Gi(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.`,Gi(r,a,!0),{ids:[r.credential.apiKey.id],warnings:a||o?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function Wi(e){let t=Ke(f());try{let n=await ne(t,{method:Ri.method,path:he(Ri.path,{},Ri.operationId),headers:{Authorization:`Bearer ${e.credential.secret}`}},rt);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:qe(n.problem,[e.credential.secret])}}catch(t){return{outcome:`unconfirmed`,summary:C(t,[e.credential.secret])}}}function Gi(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}var Ki=`RSA_OAEP_256_A256_GCM_V1`,qi=1,Ji=30,H=x().bin[0],Yi=`The local record remains pending and unavailable to ordinary commands. Re-run \`${H} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function Xi(e){if(!Ut.isTTY)return b(`${H} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let t,n;try{let e=f().host;t=w(e),n=it(e)}catch(e){return b(`auth login --key: invalid environment configuration — ${C(e)}`)}for(;;){let e;try{e=await et(t)}catch(e){return b(`auth login --key: credential storage could not be inspected — ${C(e)}`)}if(e.state===`unavailable`)return b(`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(tt(e.keyringFailure));break}let n=await Zi(e.stored);if(n!==null)return n}let r;try{r=await gi()}catch(e){return b(`auth login --key: ephemeral encryption key could not be created — ${C(e)}`)}let i=mi.safeParse({clientLabel:e.clientLabel?.trim()||(qt().trim()||H).slice(0,120),clientPlatform:ta(),encryptionAlgorithm:Ki,encryptionPublicKey:r.publicKey});if(!i.success)return b(`auth login --key: ${p(i.error)}`);let a;try{a=await ki(i.data)}catch(e){return b(`auth login --key: could not start browser authorization — ${C(e)}`)}let o;try{o=Ze(a,n)}catch(e){return b(`auth login --key: unsafe browser authorization URL rejected — ${C(e)}`)}if(!ea(await $e(a,n,{noBrowser:e.noBrowser}),a,o))return b(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[o]});let s;try{s=await $i(a)}catch(e){return b(`auth login --key: authorization did not complete — ${C(e)}`,[],{references:[o]})}if(s.algorithm!==Ki)return b(`auth login --key: broker selected an unsupported encryption algorithm`);let c;try{c=await _i(r.privateKey,s)}catch(e){return b(`auth login --key: encrypted credential could not be opened — ${C(e)}`)}let l=await Li(c);if(l.state!==`verified`)return b(`auth login --key: decrypted credential was neither stored nor acknowledged — ${l.summary}`);let u;try{u=await Je(t,{apiKey:l.apiKey,secret:c},`pending`)}catch(e){return b(`auth login --key: credential could not be durably stored — ${C(e)}`)}let d;try{d=await Qi(a)}catch(e){return U(u,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${C(e,[a.pollSecret])}`,Yi)}if(d.status!==`CONSUMED`)return U(u,!0,`auth login --key: broker returned ${d.status} after acknowledgment`,Yi);let m=await Li(c);if(m.state!==`verified`||!aa(m.apiKey,u.credential.apiKey))return U(u,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${m.summary}`,Yi);try{let e=await Je(t,{apiKey:m.apiKey,secret:c},`active`);return y(`API key stored; authenticated identity and broker acknowledgment verified.`,ia(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return U(u,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${C(e)}`,Yi)}}async function Zi(e){let t=await Li(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?y(`API key is already stored and its authenticated identity was verified.`,ia(e,!0),{ids:[e.credential.apiKey.id]}):U(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${H} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&aa(t.apiKey,e.credential.apiKey))try{let n=await Je(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return y(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,ia(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return U(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${C(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${H} 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 U(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 \`${H} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await Wi(e);if(n.outcome===`unconfirmed`)return U(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 Qe(e.host)}catch(t){return U(e,!1,`auth login --key: stale pending credential could not be removed — ${C(t,[e.credential.secret])}`)}return P.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
15
15
  `:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
16
16
  `),null}async function Qi(e){let t=new Date(e.expiresAt).getTime(),n=na(e.intervalSeconds);for(;;)try{return await ji(e.id,e.pollSecret)}catch(e){if(e instanceof V){if(!e.retryable)throw e;n=na(e.retryAfterSeconds??n)}else if(!(e instanceof Oi))throw e;if(Date.now()>=t)throw e;P.write(`Broker acknowledgment was interrupted; retrying.
@@ -50,9 +50,9 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{i as a
50
50
  return 0
51
51
  end
52
52
  `].flatMap(e=>e.split(`
53
- `))}function es(e,t){return cs(e).map(e=>`${ys(t)} -f -n ${q(bs(e.parentPath))} -a ${q(e.name)} -d ${q(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function ts(e,t,n){return gs(e).flatMap(e=>{let r=vs(e),i=r.length===0?void 0:bs(r);return ns(e).flatMap(e=>{let a=t.get(ss(r,e));return ds(a)?rs(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function ns(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function rs(e,t,n,r){let i=hs(e);if(i===void 0)return[];let a=e.argChoices??us(n),o=[`-l ${q(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${q(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${q(t)}`,c=e.required||e.optional?is(a,as(i,n)):`-f`,l=`${ys(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${q(xs(e.description))}`]:a.map(t=>`${l} -a ${q(t)} -d ${q(xs(e.description))}`)}function is(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function as(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 os(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...Mn(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[[ss(e.cliPath,n),t]]})))}function ss(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):hs(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 cs(e){return gs(e).flatMap(e=>e.commands.map(t=>({parentPath:vs(e),name:t.name(),description:xs(t.summary()||t.description()||t.name())})))}function ls(e,t){let n=[],r=[];for(let i of gs(e)){let e=vs(i);for(let a of ns(i)){let i=hs(a);if(i===void 0)continue;let o=t.get(ss(e,a));if(!ds(o))continue;let s=a.argChoices??us(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&as(i,o)&&(c=`file`)),n.push(ps([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(ps([e.join(` `),`--${i}`,t,a.description]))}}return[cs(e).map(e=>ps([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 us(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 ds(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function fs(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 ps(e){return`$'${e.map(ms).join(`|`)}'`}function ms(e){return xs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function hs(e){return e.long?.replace(/^--/,``)}function gs(e){return[e,...e.commands.filter(_s).flatMap(e=>gs(e))]}var _s=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function vs(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function ys(e){return`complete ${e.map(e=>`-c ${q(e)}`).join(` `)}`}function bs(e){return[`__aventure_cli_path_is`,...e.map(q)].join(` `)}function xs(e){return e.replace(/\s+/g,` `).trim()}function q(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function Ss(e,t){if(e!==t)return;let n=Cs(t);n!==void 0&&t.error(`error: ${Ts(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function Cs(e){if(!process.argv.includes(`--`)&&e.args.some(ws))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function ws(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function Ts(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Es(e,t){return e.message.match(RegExp(`${t} '([^']+)'`,`iu`))?.[1]?.split(/\s+/u)[0]}function J(e){return e.flags.split(` `)[0]??e.flags}function Ds(e,t){let n=Es(t,`required option`),r=e.options.findIndex(e=>J(e)===n);if(r<0)return;let i=new Set((Ks(Y(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 ${J(a)} does not replace the parent selector.`}var Os=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`],[`--transaction-id`,`--fundraise-round-id`]];function ks(e){let t=new Set(e.options.map(J)),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 As(e){let t=Ks(Y(e))?.parameters??[],n=ks(e).flatMap(n=>{let r=Os.find(e=>e.includes(n))?.find(t=>e.options.some(e=>J(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 Y(e){return e.parent===null?[]:[...Y(e.parent),e.name()]}function js(e){return e.commands.length===0?[e]:e.commands.flatMap(js)}function Ms(e,t){return Y(t).slice(Y(e).length)}function X(e){return e.parent===null?e:X(e.parent)}function Ns(e,t){let n=t=>{let n=Ms(e,t);return n.length*2+ +![`get`,`list`].includes(n.at(-1)??``)};return t.toSorted((e,t)=>n(e)-n(t))[0]}function Ps(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function Fs(e,t){let n=[...e.options,...e.createHelp().visibleOptions(e)];for(let t=e.parent;t!==null;t=t.parent)n.push(...t.options);let r=t,i;for(let e=0;e<t.length;e++){let a=t[e];if(a===void 0||a===`--`)break;if(!a.startsWith(`-`)||a===`-`||i?.variadic&&Number.isFinite(Number(a)))continue;let o=a.indexOf(`=`),s=o<0?a:a.slice(0,o);if(i=n.find(e=>e.short===s||e.long===s),i===void 0||o>=0&&!i.required&&!i.optional){r=[`--help`];break}o<0&&(i.required||i.optional&&!t[e+1]?.startsWith(`-`))&&e++}return[X(e).name(),...Y(e),...r].map(Ps).join(` `)}function Is(e,t){let n=Es(t,`unknown option`);if(n===void 0||e.commands.length===0)return;let r=Ns(e,js(e).filter(e=>e.options.some(e=>J(e)===n)));return r===void 0?void 0:`hint: run: ${Fs(r,process.argv.slice(2+Y(e).length))}`}function Z(e){return e!==void 0&&Object.hasOwn(vt,e)}function Ls(e,t){return t.reduce((e,t)=>e?.commands.find(e=>e.name()===t),e)}function Rs(e,t){let n=Y(e),r=[...n.slice(1),t];if(!Z(n.at(0))||!Z(r.at(0)))return;let i=Ls(X(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 zs(e,t){let[n]=Y(e);if(n===void 0||!Z(n))return;let r=[n,t];return Ls(X(e),r)?.commands.length===0?r:void 0}function Bs(e){let[t,...n]=e.args;if(t===void 0)return[];let r=js(X(e)).map(Y),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 Vs(e,t){let n=process.argv.slice(2+Y(e).length);if(!(t.length===0||t.some((e,t)=>n[t]!==e)))return Hs(e,t)}function Hs(e,t,n=[]){let r=Y(e),i=xt(T).map(e=>e.cliPath).filter(e=>e[0]!==r[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a===void 0)return;let o=Ls(X(e),a);return o===void 0?void 0:`hint: run: ${Fs(o,n)}`}function Us(e,t,n){if(!Gs(t))return;let r=Ls(X(e),t);if(r===void 0)return;let i=e.args.slice(n.length),a=i.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${Fs(r,a<0?[]:i.slice(a))}`}function Ws(e){let t=Y(e);if(t.at(1)!==void 0&&Z(t.at(0)))return`hint: inspect generated command group: ${[X(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Gs(e,t){let n=Ks(e);return n!==void 0&&(t===void 0||ve(n.intent)===t)}function Ks(e){return T.find(t=>t.cliPath.join(` `)===e.join(` `))}function qs(e){let t=Y(e).join(` `),n=xt(T),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:De(r.operationId,n,X(e).name()).map(e=>`hint: ${e}`)}function Js(e){let t=Y(e);if(Z(t.at(0))&&Gs(t))return`hint: inspect generated command: ${[X(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Ys(e){let t=new Set,n=[];for(let r of T){let i=Ls(e,r.cliPath);if(i===void 0)continue;let a=i.options.map(J);if(ve(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 Xs(e,t){let n=Y(e);if(Gs(n,!1)&&Ys(X(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function Zs(e,t,n=!0){let r=X(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=Y(e).at(0),c=a.options.find(e=>J(e)===`--root`),l=n&&c!==void 0&&Z(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(J(c),l);let u=xt(T),d=br({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?Vr(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(Ps).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
53
+ `))}function es(e,t){return cs(e).map(e=>`${ys(t)} -f -n ${q(bs(e.parentPath))} -a ${q(e.name)} -d ${q(e.description)}`).toSorted((e,t)=>e.localeCompare(t))}function ts(e,t,n){return gs(e).flatMap(e=>{let r=vs(e),i=r.length===0?void 0:bs(r);return ns(e).flatMap(e=>{let a=t.get(ss(r,e));return ds(a)?rs(e,i,a,n):[]})}).toSorted((e,t)=>e.localeCompare(t))}function ns(e){return e.parent===null?e.createHelp().visibleOptions(e):e.options}function rs(e,t,n,r){let i=hs(e);if(i===void 0)return[];let a=e.argChoices??us(n),o=[`-l ${q(i)}`,e.short===void 0?``:`${e.short.startsWith(`--`)?`-l`:`-s`} ${q(e.short.replace(/^-+/,``))}`].filter(Boolean),s=t===void 0?``:` -n ${q(t)}`,c=e.required||e.optional?is(a,as(i,n)):`-f`,l=`${ys(r)}${s} ${o.join(` `)} ${c}`;return a===void 0||a.length===0?[`${l} -d ${q(xs(e.description))}`]:a.map(t=>`${l} -a ${q(t)} -d ${q(xs(e.description))}`)}function is(e,t){return e!==void 0&&e.length>0?`-x`:t?`-r -F`:`-r -f`}function as(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 os(e){return new Map(e.flatMap(e=>[...e.parameters.map(e=>[e]),...Mn(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[[ss(e.cliPath,n),t]]})))}function ss(e,t){let n=`flag`in t?t.flag.split(/\s+/)[0]?.replace(/^--/,``):hs(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 cs(e){return gs(e).flatMap(e=>e.commands.map(t=>({parentPath:vs(e),name:t.name(),description:xs(t.summary()||t.description()||t.name())})))}function ls(e,t){let n=[],r=[];for(let i of gs(e)){let e=vs(i);for(let a of ns(i)){let i=hs(a);if(i===void 0)continue;let o=t.get(ss(e,a));if(!ds(o))continue;let s=a.argChoices??us(o),c=`none`;(a.required||a.optional)&&(c=s!==void 0&&s.length>0?`choice`:`scalar`,c===`scalar`&&as(i,o)&&(c=`file`)),n.push(ps([e.join(` `),`--${i}`,a.short??``,a.description,c]));for(let t of s??[])r.push(ps([e.join(` `),`--${i}`,t,a.description]))}}return[cs(e).map(e=>ps([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 us(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 ds(e){return e?.some(({visibility:e})=>e!==`private`)??!0}function fs(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 ps(e){return`$'${e.map(ms).join(`|`)}'`}function ms(e){return xs(e).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`).replaceAll(`|`,` `)}function hs(e){return e.long?.replace(/^--/,``)}function gs(e){return[e,...e.commands.filter(_s).flatMap(e=>gs(e))]}var _s=e=>e.parent?.createHelp().visibleCommands(e.parent).includes(e)??!0;function vs(e){let t=[];for(let n=e;n?.parent!==null;n=n.parent)t.unshift(n.name());return t}function ys(e){return`complete ${e.map(e=>`-c ${q(e)}`).join(` `)}`}function bs(e){return[`__aventure_cli_path_is`,...e.map(q)].join(` `)}function xs(e){return e.replace(/\s+/g,` `).trim()}function q(e){return`'${e.replace(/[\r\n\t]/g,` `).replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`}function Ss(e,t){if(e!==t)return;let n=Cs(t);n!==void 0&&t.error(`error: ${Ts(t)} takes text input, not a JSON object.\n${n}`,{code:`aventure.payloadOperand`})}function Cs(e){if(!process.argv.includes(`--`)&&e.args.some(ws))return`hint: use the command's named options instead of a JSON payload; run --help to list them.`}function ws(e){if(!e.startsWith(`{`))return!1;try{return typeof JSON.parse(e)==`object`}catch{return!1}}function Ts(e){let t=[];for(let n=e;n?.parent;n=n.parent)t.unshift(n.name());return t.join(` `)}function Es(e,t){return e.message.match(RegExp(`${t} '([^']+)'`,`iu`))?.[1]?.split(/\s+/u)[0]}function J(e){return e.flags.split(` `)[0]??e.flags}function Ds(e,t){let n=Es(t,`required option`),r=e.options.findIndex(e=>J(e)===n);if(r<0)return;let i=new Set((Ks(Y(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 ${J(a)} does not replace the parent selector.`}var Os=[[`--search`,`--query`,`--q`,`--term`,`--keyword`],[`--size`,`--limit`,`--page-size`,`--per-page`],[`--transaction-id`,`--fundraise-round-id`]];function ks(e){let t=new Set(e.options.map(J)),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 As(e){let t=Ks(Y(e))?.parameters??[],n=ks(e).flatMap(n=>{let r=Os.find(e=>e.includes(n))?.find(t=>e.options.some(e=>J(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 Y(e){return e.parent===null?[]:[...Y(e.parent),e.name()]}function js(e){return e.commands.length===0?[e]:e.commands.flatMap(js)}function Ms(e,t){return Y(t).slice(Y(e).length)}function X(e){return e.parent===null?e:X(e.parent)}function Ns(e,t){let n=t=>{let n=Ms(e,t);return n.length*2+ +![`get`,`list`].includes(n.at(-1)??``)};return t.toSorted((e,t)=>n(e)-n(t))[0]}function Ps(e){return/^[A-Za-z0-9_./:=@+-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function Fs(e,t){let n=[...e.options,...e.createHelp().visibleOptions(e)];for(let t=e.parent;t!==null;t=t.parent)n.push(...t.options);let r=t,i;for(let e=0;e<t.length;e++){let a=t[e];if(a===void 0||a===`--`)break;if(!a.startsWith(`-`)||a===`-`||i?.variadic&&Number.isFinite(Number(a)))continue;let o=a.indexOf(`=`),s=o<0?a:a.slice(0,o);if(i=n.find(e=>e.short===s||e.long===s),i===void 0||o>=0&&!i.required&&!i.optional){r=[`--help`];break}o<0&&(i.required||i.optional&&!t[e+1]?.startsWith(`-`))&&e++}return[X(e).name(),...Y(e),...r].map(Ps).join(` `)}function Is(e,t){let n=Es(t,`unknown option`);if(n===void 0||e.commands.length===0)return;let r=Ns(e,js(e).filter(e=>e.options.some(e=>J(e)===n)));return r===void 0?void 0:`hint: run: ${Fs(r,process.argv.slice(2+Y(e).length))}`}function Z(e){return e!==void 0&&Object.hasOwn(vt,e)}function Ls(e,t){return t.reduce((e,t)=>e?.commands.find(e=>e.name()===t),e)}function Rs(e,t){let n=Y(e),r=[...n.slice(1),t];if(!Z(n.at(0))||!Z(r.at(0)))return;let i=Ls(X(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 zs(e,t){let[n]=Y(e);if(n===void 0||!Z(n))return;let r=[n,t];return Ls(X(e),r)?.commands.length===0?r:void 0}function Bs(e){let[t,...n]=e.args;if(t===void 0)return[];let r=js(X(e)).map(Y),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 Vs(e,t){let n=process.argv.slice(2+Y(e).length);if(!(t.length===0||t.some((e,t)=>n[t]!==e)))return Hs(e,t)}function Hs(e,t,n=[]){let r=Y(e),i=xt(T).map(e=>e.cliPath).filter(e=>e[0]!==r[0]&&e.length>=t.length&&t.every((n,r)=>e[e.length-t.length+r]===n)),a=i.find(e=>e.length===t.length&&e.every((e,n)=>e===t[n]))??(i.length===1?i[0]:void 0);if(a===void 0)return;let o=Ls(X(e),a);return o===void 0?void 0:`hint: run: ${Fs(o,n)}`}function Us(e,t,n){if(!Gs(t))return;let r=Ls(X(e),t);if(r===void 0)return;let i=e.args.slice(n.length),a=i.findIndex(e=>e.startsWith(`-`));return`hint: Did you mean: ${Fs(r,a<0?[]:i.slice(a))}`}function Ws(e){let t=Y(e);if(t.at(1)!==void 0&&Z(t.at(0)))return`hint: inspect generated command group: ${[X(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Gs(e,t){let n=Ks(e);return n!==void 0&&(t===void 0||ve(n.intent)===t)}function Ks(e){return T.find(t=>t.cliPath.join(` `)===e.join(` `))}function qs(e){let t=Y(e).join(` `),n=xt(T),r=n.find(e=>e.cliPath.join(` `)===t);return r===void 0?[]:Oe(r.operationId,n,X(e).name()).map(e=>`hint: ${e}`)}function Js(e){let t=Y(e);if(Z(t.at(0))&&Gs(t))return`hint: inspect generated command: ${[X(e).name(),...t,`--help`].map(Ps).join(` `)}`}function Ys(e){let t=new Set,n=[];for(let r of T){let i=Ls(e,r.cliPath);if(i===void 0)continue;let a=i.options.map(J);if(ve(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 Xs(e,t){let n=Y(e);if(Gs(n,!1)&&Ys(X(e)).has(t))return`hint: ${n.join(` `)} is a read operation; ${t} is a deprecated compatibility option only on mutation commands`}function Zs(e,t,n=!0){let r=X(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=Y(e).at(0),c=a.options.find(e=>J(e)===`--root`),l=n&&c!==void 0&&Z(s)?s:void 0;c!==void 0&&l!==void 0&&o.push(J(c),l);let u=xt(T),d=br({q:t,root:l,limit:`3`},u,r.name()),f=d.ok&&d.data!==null?Vr(d.data,`compact`):``;return[`hint: search generated commands: ${o.map(Ps).join(` `)}`,...f===``?[]:[`hint: closest commands (command · summary · required flags):`],...f.split(`
54
54
  `).filter(Boolean).map(e=>` ${e}`)].join(`
55
- `)}function Qs(e,t=``){if(e.commands.length>0&&!Gs(Y(e)))return;let n=e.options.flatMap(e=>e.hidden?[]:[J(e)]),r=xt(T),i=je(t,r,Y(e),X(e).name());return`${i===void 0?``:`hint: an id you already hold is read with: ${i}\n`}hint: ${Y(e).join(` `)} accepts: ${n.join(` `)}`}function $s(e,t){let n=Es(t,`unknown command`);if(n===void 0||t.message.includes(`
55
+ `)}function Qs(e,t=``){if(e.commands.length>0&&!Gs(Y(e)))return;let n=e.options.flatMap(e=>e.hidden?[]:[J(e)]),r=xt(T),i=Me(t,r,Y(e),X(e).name());return`${i===void 0?``:`hint: an id you already hold is read with: ${i}\n`}hint: ${Y(e).join(` `)} accepts: ${n.join(` `)}`}function $s(e,t){let n=Es(t,`unknown command`);if(n===void 0||t.message.includes(`
56
56
  (Did you mean `))return;let r=Bs(e),i=Vs(e,r);if(i!==void 0)return i;let a=Y(e),o=[...a.slice(0,-1),`${a.at(-1)}-${n}`,...r.slice(1)],s=(Gs(o)?o:void 0)??Rs(e,n)??zs(e,n);if(s!==void 0)return Us(e,s,r)??Zs(e,s.join(` `),!1);let c=r.join(` `)||n,l=Ws(e)??Zs(e,c),u=[...a,...r.slice(1)];return[l,r.length===a.length+a.length&&a.at(-1)===a.at(0)?Us(e,u,r)?.replace(/^hint: Did you mean: /u,` `)+` · `:u.slice(1,-1).length>0?Us(e,u,r):void 0].filter(e=>e!==void 0).join(`
57
57
  `)||void 0}function ec(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=ks(e);for(let e of r)process.stderr.write(`error: unknown option '${e}'\n`);for(let n of[As(e)??(r.length>0?Qs(e):void 0),Cs(e),Ds(e,t),...qs(e)])n!==void 0&&process.stderr.write(`${n}\n`)}else if(t.code===`commander.excessArguments`){let t=Cs(e)??Js(e);t!==void 0&&process.stderr.write(`${t}\n`)}else if(t.code===`commander.unknownOption`){let n=Es(t,`unknown option`),r=As(e)??Is(e,t)??(n!==void 0&&!t.message.includes(`
58
58
  (Did you mean `)?Xs(e,n)??Hs(e,[n.replace(/^--/u,``)],process.argv.slice(process.argv.indexOf(n)+1))??Qs(e,n)??Zs(e,Y(e).slice(1).join(` `)||n.replace(/^--/u,``)):void 0);r!==void 0&&process.stderr.write(`${r}\n`)}else if(t.code===`commander.unknownCommand`){let n=$s(e,t);n!==void 0&&process.stderr.write(`${n}\n`)}throw t}}var tc=class extends t{group;constructor(e){super(`-h, --help`,`display help for command`),this.group=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.group.args.at(0);return t===void 0||t.startsWith(`-`)?!0:this.group.commands.some(e=>e.name()===t||e.aliases().includes(t))}};function nc(e){e.showHelpAfterError(!1).exitOverride(ec(e)),e.commands.length===0?e.hook(`preAction`,Ss):e.registeredArguments.length===0&&e.addHelpOption(new tc(e));for(let t of e.commands)nc(t)}function rc(e,t=new Date){let n=oc(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 ic(e){return`${JSON.stringify(e,null,2)}\n`}function ac(e,t){let n=A(e),r=ic(t);return M(k(n),{recursive:!0}),Ht(n,r),{target:n,byteLength:Buffer.byteLength(r,`utf8`),totalOperations:t.totalOperations}}function oc(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 sc=`Match only the first canonical or CLI-alias command segment`,cc=[`text`,`lines`,`compact`,`json`,`ndjson`];function lc(e,t,n=x().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(`
@@ -1 +1 @@
1
- import{u as e}from"./tool-policy-D7R8FUUe.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 t?.[e]?.section??d[e]}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,directory:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,"research-runs":`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{u as e}from"./tool-policy-Cu9R-Sz2.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 t?.[e]?.section??d[e]}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,directory:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,"research-runs":`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,4 +1,4 @@
1
- import{n as e}from"./commander-BB7CDPLs.js";import{C as t,O as n,T as r,i,l as a,n as o,o as s,p as c,t as l,u,v as d,w as f,y as p}from"./person-owner-BJgNYLKX.js";import{Fr as m}from"./dist-Ce24grer.js";import{a as ee,c as h,d as g,i as _}from"./result-envelope-D5wNfKzB.js";import{a as te}from"./package-DPDX5zmx.js";import{S as ne,a as re,c as ie,d as ae,f as oe,l as se,n as ce,o as le,s as v}from"./tool-policy-D7R8FUUe.js";import{a as ue,n as de,r as y,t as fe}from"./text-field-BoNdbrtA.js";import{C as b,D as pe,E as me,O as he,S as ge,T as _e,_ as ve,a as ye,b as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,k as De,l as Oe,m as ke,n as Ae,o as je,p as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./detail-DIjiKrvq.js";import{a as Ve,o as He}from"./cli-help-policy-RGOSoZ1Z.js";import{Buffer as x}from"node:buffer";var S=s([`HIGH`,`MEDIUM`,`LOW`]),Ue=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),We=Object.assign(r([Ue,f()]),{enum:Ue.enum}),Ge=p({excerpt:f(),sourceId:f(),sourceType:We,sourceVersion:f().nullish()}),Ke=p({instruction:f(),operationId:f(),stepKey:f().optional()}),qe=p({body:f(),expectation:f(),method:a(f()),override:f(),reject:a(f()),typeCatalog:f()}),Je=p({cliCommand:f(),mcpTool:f().nullish(),step:Ke,writeGuidance:qe.nullish()}),Ye=s([`ENTITY`,`TEXT`,`WRITER_BRIEF`]),Xe=Object.assign(r([Ye,f()]),{enum:Ye.enum}),Ze=p({allowedValue:f().nullish(),description:f(),key:f(),type:Xe}),Qe=p({catalogRevision:c().optional(),gateId:a(f()).optional(),input:a(Ze),step:a(Je),taskKey:f().optional()}),C=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),$e=p({candidate:a(Ge),operationId:f().nullish(),outcome:C,probability:d().nullish(),taskKey:f().nullish(),taskPlan:Qe.nullish()}),et=p({answer:f(),citation:a(Ge),confidence:S,resolution:$e.nullish()});function w(e,t,n=t.inputName){if(t.in===`body`)return n;let r=ft.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?dt(ct(n!==`id`&&n!==`slug`?n:`${it(e.path)}${st(n)}`),t):r.inputName}function tt(e,t,n=ot(e)){return nt(at(e,t),new Set(n))}function nt(e,t){if(!t.has(e))return e;let n=`body${st(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function rt(e,t,n){return`${e}[${t}].${n}`}function it(e){return pt.find(([,t])=>t.test(e))?.[0]??`record`}function at(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=lt(t);return dt(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?ct(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ot(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>w(e,t)))}function st(e){return e.replace(/^./u,e=>e.toUpperCase())}function ct(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 lt(e){let t=ct(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?ut(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function ut(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function dt(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var ft=[{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`}],pt=[[`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 mt(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>ht(t,w(e,t))),r=(t?.parameter??[]).map(t=>ht(t,tt(e,t)));return{selector:n.filter(e=>e.location===`path`||gt(e)),pagination:n.filter(_t),filter:[...n.filter(vt),...r.filter(vt)],body:r.filter(e=>!vt(e))}}function ht(e,t){let{in:n,inputName:r,...i}=e;return{...i,name:e.in===`body`?t:e.name,flag:re(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function gt(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function _t(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function vt(e){return e.location!==`path`&&!gt(e)&&!_t(e)}var T=16e3,yt=(e,t=T)=>e.length<=120&&x.byteLength(`${e.join(`
1
+ import{n as e}from"./commander-BB7CDPLs.js";import{C as t,O as n,T as r,i,l as a,n as o,o as s,p as c,t as l,u,v as d,w as f,y as p}from"./person-owner-BJgNYLKX.js";import{Fr as m}from"./dist-B7MAXU9_.js";import{a as ee,c as h,d as g,i as _}from"./result-envelope-CMkMWwDI.js";import{a as te}from"./package-DPDX5zmx.js";import{S as ne,a as re,c as ie,d as ae,f as oe,l as se,n as ce,o as le,s as v}from"./tool-policy-Cu9R-Sz2.js";import{a as ue,n as de,r as y,t as fe}from"./text-field-BoNdbrtA.js";import{C as b,D as pe,E as me,O as he,S as ge,T as _e,_ as ve,a as ye,b as be,c as xe,d as Se,f as Ce,g as we,h as Te,i as Ee,k as De,l as Oe,m as ke,n as Ae,o as je,p as Me,r as Ne,s as Pe,t as Fe,u as Ie,v as Le,w as Re,x as ze,y as Be}from"./detail-DIjiKrvq.js";import{a as Ve,o as He}from"./cli-help-policy-CuiFrmX2.js";import{Buffer as x}from"node:buffer";var S=s([`HIGH`,`MEDIUM`,`LOW`]),Ue=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),We=Object.assign(r([Ue,f()]),{enum:Ue.enum}),Ge=p({excerpt:f(),sourceId:f(),sourceType:We,sourceVersion:f().nullish()}),Ke=p({instruction:f(),operationId:f(),stepKey:f().optional()}),qe=p({body:f(),expectation:f(),method:a(f()),override:f(),reject:a(f()),typeCatalog:f()}),Je=p({cliCommand:f(),mcpTool:f().nullish(),step:Ke,writeGuidance:qe.nullish()}),Ye=s([`ENTITY`,`TEXT`,`WRITER_BRIEF`]),Xe=Object.assign(r([Ye,f()]),{enum:Ye.enum}),Ze=p({allowedValue:f().nullish(),description:f(),key:f(),type:Xe}),Qe=p({catalogRevision:c().optional(),gateId:a(f()).optional(),input:a(Ze),step:a(Je),taskKey:f().optional()}),C=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),$e=p({candidate:a(Ge),operationId:f().nullish(),outcome:C,probability:d().nullish(),taskKey:f().nullish(),taskPlan:Qe.nullish()}),et=p({answer:f(),citation:a(Ge),confidence:S,resolution:$e.nullish()});function w(e,t,n=t.inputName){if(t.in===`body`)return n;let r=ft.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?dt(ct(n!==`id`&&n!==`slug`?n:`${it(e.path)}${st(n)}`),t):r.inputName}function tt(e,t,n=ot(e)){return nt(at(e,t),new Set(n))}function nt(e,t){if(!t.has(e))return e;let n=`body${st(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function rt(e,t,n){return`${e}[${t}].${n}`}function it(e){return pt.find(([,t])=>t.test(e))?.[0]??`record`}function at(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=lt(t);return dt(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?ct(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function ot(e){return new Set(e.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(t=>w(e,t)))}function st(e){return e.replace(/^./u,e=>e.toUpperCase())}function ct(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 lt(e){let t=ct(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?ut(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function ut(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function dt(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var ft=[{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`}],pt=[[`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 mt(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>ht(t,w(e,t))),r=(t?.parameter??[]).map(t=>ht(t,tt(e,t)));return{selector:n.filter(e=>e.location===`path`||gt(e)),pagination:n.filter(_t),filter:[...n.filter(vt),...r.filter(vt)],body:r.filter(e=>!vt(e))}}function ht(e,t){let{in:n,inputName:r,...i}=e;return{...i,name:e.in===`body`?t:e.name,flag:re(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function gt(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function _t(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function vt(e){return e.location!==`path`&&!gt(e)&&!_t(e)}var T=16e3,yt=(e,t=T)=>e.length<=120&&x.byteLength(`${e.join(`
2
2
  `)}\n`,`utf8`)<=t,E=(e,t=!1,n=!1,r=1)=>{let i=de(e),a=t||i.endsWith(`
3
3
  `),o=i.endsWith(`
4
4
  `)?i.slice(0,-1):i,s=o.length===0?[]:o.split(`
@@ -24,4 +24,4 @@ import{n as e}from"./commander-BB7CDPLs.js";import{C as t,O as n,T as r,i,l as a
24
24
  `)}`;return[`answer:\n ${de(e.text).replaceAll(`
25
25
  `,`
26
26
  `)}`,...e.relatedQuery.length===0?[]:[t],...e.citation.length===0?[]:[n]]}function Gi(e){let t=$i(e)?.response,n=Y(t)?t.interpretation:void 0;if(!Y(n))return null;let r=L.safeParse(n.execution);if(!r.success)return null;let{modeRequested:i,modeUsed:a}=r.data,o=q(n.filter),{unsupported:s,fallbackUsed:c}=n;return E([`strategy: requested=${i} used=${a}`,...Y(o)?[`constraints:`,...Object.entries(o).flatMap(([e,t])=>t===void 0?[]:[` ${e}: ${Ki(t)}`])]:[],typeof s==`string`&&s.trim().length>0?`unsupported: ${s}`:``,c===!0?`fallback: semantic search over the original query`:``].filter(Boolean).join(`
27
- `),!0)}var Ki=e=>X(e)?y(e):Array.isArray(e)&&e.every(X)?e.map(e=>y(e)).join(`, `):JSON.stringify(e);function qi(e){let{response:t,method:n,nextCursor:r,httpStatus:i,location:a}=e;if(t===void 0)return a!==void 0&&i!==void 0?[`status=${i} redirect=${a}`]:i===void 0?[]:[`status=${i} no response body`];let o=i===void 0||n===`GET`?``:`status=${i}`,s=Y(t)&&!na(t)?ra(t):null,c=s===null?void 0:Y(s.context.interpretation)?q(s.context):s.context,l=c!==void 0&&Y(c)?Object.entries(c):[],u=l.filter(e=>Array.isArray(e[1])&&e[1].length>0&&e[1].every(Y)),d=new Set(u.map(([e])=>e)),f=Object.fromEntries(l.filter(([e])=>!d.has(e)));return[o,...na(t)?G(t,e,r):s===null?aa(t)?Xi(t.filter,t.meta):oa(t)?Xi([...t.arrayFilterEntry,...t.rangeFilterEntry],t.filtersMeta):ca(t)?Zi(t):K(t,``):[...G(s.page,e,r),...Object.keys(f).length===0?[]:K(f,``),...u.flatMap(([e,t])=>[`${e}:`].concat(Ji(t)))]].filter(Boolean)}function G(e,t,n){let r=Qi(t),i=e.numberOfElements??e.content.length,a=(e.totalElements??0)-(e.number??0)*(e.size??0)-i,o=e.number===void 0?``:` page=${e.number}`,s=e.size===void 0?``:` size=${e.size}`,c=e.totalElements===void 0?``:` total=${e.totalElements}`,l=e.totalPages===void 0?``:` totalPages=${e.totalPages}`,u=(e.number??0)+1,d=e.totalPages===void 0||u<e.totalPages,f=Z(`page`,t.parameters);return[`rows=${i}${o}${s}${c}${l}`,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${Q(n)}`,a<=0||n!==void 0?``:d&&i===e.size?`more: ${a} rows not shown; use ${f} or ${Z(`size`,t.parameters)} to see them`:`more: ${a} more matched but this response returns only these ${i}; narrow the query to reach them${d?` (${f} ${u} starts after this page)`:``}`,...Ji(e.content)].filter(Boolean)}function Ji(e){let t=e.filter(Y);if(t.length===0)return e.length===0?[`(empty)`]:ea(e,``);let n=Yi(t);if(n.length===0)return ea(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)=>la(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 Yi(e){let t=e.map(e=>J(e)),n=new Set(t.flatMap(e=>Object.keys(e))),r=zi.filter(e=>n.has(e)),i=new Set(r.map(ta)),a=[...n].filter(e=>{let n=t.every(t=>/^-?\d+(?:\.\d+)?$/u.test(t[e]??`0`));return!e.includes(`.`)||/id$/iu.test(e)||i.has(ta(e))?!1:(n&&i.add(ta(e)),n)}),o=[...n].filter(e=>/(?:^|\.)id$/u.test(e)).slice(0,1),s=[...new Set([...r,...o,...a])],c=[...n].filter(e=>!s.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,Li-s.length);return[...s,...c].slice(0,Li)}function Xi(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(` ${Z(t.filterKey)} ${Q(e.value)}`)}),e>W&&i.push(` ... ${e-W} more shown`)}return i}function Zi(e){let t=Z(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,W).map(e=>`${t} ${Q(e)}`),e.result.length>W?`... ${e.result.length-W} more matches`:``].filter(Boolean)}function Qi({endpoint:e,parameters:t}){let n=e.indexOf(`?`);return n<0?[]:[...new URLSearchParams(e.slice(n+1)).entries()].filter(([e,t])=>!Bi.has(e)&&t.length>0).map(([e,n])=>`${Z(e,t)} ${Q(n)}`)}function $i(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=t=>{let n=Reflect.get(e,t);return typeof n==`string`?n:void 0},[n,r,i]=[t(`method`),t(`endpoint`),t(`nextCursor`)];if(n===void 0||r===void 0)return null;let a=Reflect.get(e,`httpStatus`),o=Reflect.get(e,`response`),s=o===void 0?void 0:g.safeParse(o);return s!==void 0&&!s.success?null:{method:n,endpoint:r,httpStatus:typeof a==`number`?a:void 0,location:t(`location`),operationId:t(`operationId`),summary:t(`summary`),nextCursor:i===``?void 0:i,response:s?.data}}function K(e,t,n){if(e===void 0)return[];if(X(e))return[`${t}${fe(e,n)}`];if(Array.isArray(e))return ea(e,t,n);let r=[];for(let[n,i]of Object.entries(e))if(i!==void 0){if(X(i)){r.push(`${t}${n}: ${fe(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 ea(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(X(i)){r.push(`${t}- ${fe(i,n)}`);continue}r.push(`${t}-`);for(let e of K(i,`${t} `))r.push(e)}return r}function q(e){if(e===void 0||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([...Vi.flatMap(e=>t.filter(([t])=>t===e)),...t.filter(([e])=>!Vi.includes(e))])}function J(e,t=``,n=0){return X(e)?t.length===0?{}:{[t]:y(e,t)}:n>Ri?{}:Array.isArray(e)?e[0]===void 0?{}:J(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{if(r===void 0)return[];let i=t.length===0?e:`${t}.${e}`;return X(r)?[[i,y(r,i)]]:Object.entries(J(r,i,n+1))}))}var ta=e=>e.split(`.`,1)[0],na=e=>Y(e)&&Array.isArray(e.content);function ra(e){let[t,...n]=Object.entries(e).filter(e=>na(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 ia(e){return Y(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var aa=e=>Y(e)&&sa(e.filter),oa=e=>Y(e)&&sa(e.arrayFilterEntry)&&sa(e.rangeFilterEntry),sa=e=>Array.isArray(e)&&e.every(ia),ca=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,Z=(e,t=[])=>t.find(({name:t})=>t===e)?.flag.split(` `)[0]??`--${e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`,Q=e=>/^[A-Za-z0-9._:/@-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,la=(e,t)=>e.length<=t?e:`${e.slice(0,Math.max(0,t-3))}...`,ua=/\{([^}]+)\}/gu;function da(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&&v(i.intent),o=[...a&&e.endpoint!==void 0?pa(e.endpoint.split(`?`)[0]??``,n,!1).map(e=>`${e} --data --to-file <path>`):[],...e.references.filter(e=>!r(e)).flatMap(fa).flatMap(e=>pa(e.pathname,n,!0)),...e.references.filter(r).flatMap(fa).flatMap(e=>ma(e,n))];return o.length===0?{write:a}:{exactRecovery:`Read the full result ${o.join(`; `)}.`,write:a}}function fa(e){return URL.canParse(e)?[new URL(e)]:[]}function pa(e,t,n){return t.flatMap(t=>{let r=[...t.path.matchAll(ua)].map(([,e])=>e),i=RegExp(`^${t.path.replace(ua,`([^/]+)`)}$`,`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[`${ha(t)}, ${ga(t,o)}`]})}function ma(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),_a(n)]}),o=[$(r),`<n>`,$(i),`<n>`];return[`${ha(t)}, in windows: ${ga(t,[...a,...o])}, advancing ${$(r)} until a window returns fewer than ${$(i)} units`]})}function ha(e){return e.auth===`write`?`with admin sign-in`:`with any sign-in`}function ga(e,t){return[Di,...e.cliPath,...t].join(` `)}function $(e){return e.flag.split(/\s+/u)[0]??e.flag}function _a(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function va(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=Ca(t,w(e,t),n);if(t.legacyName===void 0)return r;let i=Ca(t,w(e,t,t.legacyName),n).flag;return i===r.flag?r:Object.assign(r,{legacyFlag:i})})}),n=e.requestBody?.map(n=>{let r=xa(e,t,n),i=ba(n.cliConflicts,r),a=i.length===0?{}:{cliConflicts:i};return Object.assign({},n,{parameter:r},a)}),r=e.response.find(({status:e})=>e.startsWith(`2`)),i=r?.schemaName?.replace(/Schema$/,``);return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliPath:e.projection.cliPath,summary:e.summary,description:e.description,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:n,mutationReadback:e.mutationReadback,scope:e.projection.scope,auth:e.projection.auth,visibility:e.projection.visibility,errorResponse:e.errorResponse,successResponse:i,detailField:r?.detailField,parameters:t}})}function ya(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 ba(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 xa(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)=>Sa(e.name)-Sa(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=tt(e,t,r);return r.add(n),[Ca(t,n,`body`)]})}function Sa(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function Ca(t,n,r){let i=t.itemSchemaEnum??t.schemaEnum,a=He(t.schemaType,t.itemSchemaType,t.schemaFormat,n),o=`${re(n)} ${t.schemaType===`boolean`?`[${a}]`:`<${a}>`}`;return{name:t.name,optionKey:new e(o).attributeName(),flag:o,required:t.required&&t.schemaDefault===void 0,description:Ve(t.description,i),schemaType:t.schemaType,schemaFormat:t.schemaFormat,itemSchemaType:t.itemSchemaType,defaultValue:wa(t.schemaDefault),choices:i,...t.envName===void 0?{}:{envName:t.envName},...t.visibility&&{visibility:t.visibility},location:r}}var wa=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{rt as S,P as _,Gi as a,It as b,_i as c,li as d,Nn as f,wn as g,qn as h,Hi as i,yi as l,Pn as m,ya as n,Ci as o,Mn as p,da as r,fi as s,va as t,xi as u,F as v,E as x,I as y};
27
+ `),!0)}var Ki=e=>X(e)?y(e):Array.isArray(e)&&e.every(X)?e.map(e=>y(e)).join(`, `):JSON.stringify(e);function qi(e){let{response:t,method:n,nextCursor:r,httpStatus:i,location:a}=e;if(t===void 0)return a!==void 0&&i!==void 0?[`status=${i} redirect=${a}`]:i===void 0?[]:[`status=${i} no response body`];let o=i===void 0||n===`GET`?``:`status=${i}`,s=Y(t)&&!na(t)?ra(t):null,c=s===null?void 0:Y(s.context.interpretation)?q(s.context):s.context,l=c!==void 0&&Y(c)?Object.entries(c):[],u=l.filter(e=>Array.isArray(e[1])&&e[1].length>0&&e[1].every(Y)),d=new Set(u.map(([e])=>e)),f=Object.fromEntries(l.filter(([e])=>!d.has(e)));return[o,...na(t)?G(t,e,r):s===null?aa(t)?Xi(t.filter,t.meta):oa(t)?Xi([...t.arrayFilterEntry,...t.rangeFilterEntry],t.filtersMeta):ca(t)?Zi(t):K(t,``):[...G(s.page,e,r),...Object.keys(f).length===0?[]:K(f,``),...u.flatMap(([e,t])=>[`${e}:`].concat(Ji(t)))]].filter(Boolean)}function G(e,t,n){let r=Qi(t),i=e.numberOfElements??e.content.length,a=(e.totalElements??0)-(e.number??0)*(e.size??0)-i,o=e.number===void 0?``:` page=${e.number}`,s=e.size===void 0?``:` size=${e.size}`,c=e.totalElements===void 0?``:` total=${e.totalElements}`,l=e.totalPages===void 0?``:` totalPages=${e.totalPages}`,u=(e.number??0)+1,d=e.totalPages===void 0||u<e.totalPages,f=Z(`page`,t.parameters);return[`rows=${i}${o}${s}${c}${l}`,r.length>0?`filters: ${r.join(` `)}`:``,n===void 0?``:`next: --cursor ${Q(n)}`,a<=0||n!==void 0?``:d&&i===e.size?`more: ${a} rows not shown; use ${f} or ${Z(`size`,t.parameters)} to see them`:`more: ${a} more matched but this response returns only these ${i}; narrow the query to reach them${d?` (${f} ${u} starts after this page)`:``}`,...Ji(e.content)].filter(Boolean)}function Ji(e){let t=e.filter(Y);if(t.length===0)return e.length===0?[`(empty)`]:ea(e,``);let n=Yi(t);if(n.length===0)return ea(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)=>la(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 Yi(e){let t=e.map(e=>J(e)),n=new Set(t.flatMap(e=>Object.keys(e))),r=zi.filter(e=>n.has(e)),i=new Set(r.map(ta)),a=[...n].filter(e=>{let n=t.every(t=>/^-?\d+(?:\.\d+)?$/u.test(t[e]??`0`));return!e.includes(`.`)||/id$/iu.test(e)||i.has(ta(e))?!1:(n&&i.add(ta(e)),n)}),o=[...n].filter(e=>/(?:^|\.)id$/u.test(e)).slice(0,1),s=[...new Set([...r,...o,...a])],c=[...n].filter(e=>!s.includes(e)).filter(e=>!e.toLowerCase().includes(`logo`)).slice(0,Li-s.length);return[...s,...c].slice(0,Li)}function Xi(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(` ${Z(t.filterKey)} ${Q(e.value)}`)}),e>W&&i.push(` ... ${e-W} more shown`)}return i}function Zi(e){let t=Z(e.filterKey);return[`${e.filterKey}: ${e.result.length} matches`,...e.result.slice(0,W).map(e=>`${t} ${Q(e)}`),e.result.length>W?`... ${e.result.length-W} more matches`:``].filter(Boolean)}function Qi({endpoint:e,parameters:t}){let n=e.indexOf(`?`);return n<0?[]:[...new URLSearchParams(e.slice(n+1)).entries()].filter(([e,t])=>!Bi.has(e)&&t.length>0).map(([e,n])=>`${Z(e,t)} ${Q(n)}`)}function $i(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=t=>{let n=Reflect.get(e,t);return typeof n==`string`?n:void 0},[n,r,i]=[t(`method`),t(`endpoint`),t(`nextCursor`)];if(n===void 0||r===void 0)return null;let a=Reflect.get(e,`httpStatus`),o=Reflect.get(e,`response`),s=o===void 0?void 0:g.safeParse(o);return s!==void 0&&!s.success?null:{method:n,endpoint:r,httpStatus:typeof a==`number`?a:void 0,location:t(`location`),operationId:t(`operationId`),summary:t(`summary`),nextCursor:i===``?void 0:i,response:s?.data}}function K(e,t,n){if(e===void 0)return[];if(X(e))return[`${t}${fe(e,n)}`];if(Array.isArray(e))return ea(e,t,n);let r=[];for(let[n,i]of Object.entries(e))if(i!==void 0){if(X(i)){r.push(`${t}${n}: ${fe(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 ea(e,t,n){if(e.length===0)return[`${t}(empty)`];let r=[];for(let i of e){if(X(i)){r.push(`${t}- ${fe(i,n)}`);continue}r.push(`${t}-`);for(let e of K(i,`${t} `))r.push(e)}return r}function q(e){if(e===void 0||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([...Vi.flatMap(e=>t.filter(([t])=>t===e)),...t.filter(([e])=>!Vi.includes(e))])}function J(e,t=``,n=0){return X(e)?t.length===0?{}:{[t]:y(e,t)}:n>Ri?{}:Array.isArray(e)?e[0]===void 0?{}:J(e[0],t,n+1):Object.fromEntries(Object.entries(e).flatMap(([e,r])=>{if(r===void 0)return[];let i=t.length===0?e:`${t}.${e}`;return X(r)?[[i,y(r,i)]]:Object.entries(J(r,i,n+1))}))}var ta=e=>e.split(`.`,1)[0],na=e=>Y(e)&&Array.isArray(e.content);function ra(e){let[t,...n]=Object.entries(e).filter(e=>na(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 ia(e){return Y(e)&&typeof e.label==`string`&&typeof e.filterKey==`string`&&Array.isArray(e.choiceOption)}var aa=e=>Y(e)&&sa(e.filter),oa=e=>Y(e)&&sa(e.arrayFilterEntry)&&sa(e.rangeFilterEntry),sa=e=>Array.isArray(e)&&e.every(ia),ca=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,Z=(e,t=[])=>t.find(({name:t})=>t===e)?.flag.split(` `)[0]??`--${e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase()}`,Q=e=>/^[A-Za-z0-9._:/@-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,la=(e,t)=>e.length<=t?e:`${e.slice(0,Math.max(0,t-3))}...`,ua=/\{([^}]+)\}/gu;function da(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&&v(i.intent),o=[...a&&e.endpoint!==void 0?pa(e.endpoint.split(`?`)[0]??``,n,!1).map(e=>`${e} --data --to-file <path>`):[],...e.references.filter(e=>!r(e)).flatMap(fa).flatMap(e=>pa(e.pathname,n,!0)),...e.references.filter(r).flatMap(fa).flatMap(e=>ma(e,n))];return o.length===0?{write:a}:{exactRecovery:`Read the full result ${o.join(`; `)}.`,write:a}}function fa(e){return URL.canParse(e)?[new URL(e)]:[]}function pa(e,t,n){return t.flatMap(t=>{let r=[...t.path.matchAll(ua)].map(([,e])=>e),i=RegExp(`^${t.path.replace(ua,`([^/]+)`)}$`,`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[`${ha(t)}, ${ga(t,o)}`]})}function ma(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),_a(n)]}),o=[$(r),`<n>`,$(i),`<n>`];return[`${ha(t)}, in windows: ${ga(t,[...a,...o])}, advancing ${$(r)} until a window returns fewer than ${$(i)} units`]})}function ha(e){return e.auth===`write`?`with admin sign-in`:`with any sign-in`}function ga(e,t){return[Di,...e.cliPath,...t].join(` `)}function $(e){return e.flag.split(/\s+/u)[0]??e.flag}function _a(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function va(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=Ca(t,w(e,t),n);if(t.legacyName===void 0)return r;let i=Ca(t,w(e,t,t.legacyName),n).flag;return i===r.flag?r:Object.assign(r,{legacyFlag:i})})}),n=e.requestBody?.map(n=>{let r=xa(e,t,n),i=ba(n.cliConflicts,r),a=i.length===0?{}:{cliConflicts:i};return Object.assign({},n,{parameter:r},a)}),r=e.response.find(({status:e})=>e.startsWith(`2`)),i=r?.schemaName?.replace(/Schema$/,``);return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliPath:e.projection.cliPath,summary:e.summary,description:e.description,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:n,mutationReadback:e.mutationReadback,scope:e.projection.scope,auth:e.projection.auth,visibility:e.projection.visibility,errorResponse:e.errorResponse,successResponse:i,detailField:r?.detailField,parameters:t}})}function ya(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 ba(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 xa(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)=>Sa(e.name)-Sa(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=tt(e,t,r);return r.add(n),[Ca(t,n,`body`)]})}function Sa(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function Ca(t,n,r){let i=t.itemSchemaEnum??t.schemaEnum,a=He(t.schemaType,t.itemSchemaType,t.schemaFormat,n),o=`${re(n)} ${t.schemaType===`boolean`?`[${a}]`:`<${a}>`}`;return{name:t.name,optionKey:new e(o).attributeName(),flag:o,required:t.required&&t.schemaDefault===void 0,description:Ve(t.description,i),schemaType:t.schemaType,schemaFormat:t.schemaFormat,itemSchemaType:t.itemSchemaType,defaultValue:wa(t.schemaDefault),choices:i,...t.envName===void 0?{}:{envName:t.envName},...t.visibility&&{visibility:t.visibility},location:r}}var wa=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{rt as C,E as S,P as _,Gi as a,It as b,_i as c,li as d,Nn as f,wn as g,qn as h,Hi as i,yi as l,Pn as m,ya as n,Ci as o,Mn as p,da as r,fi as s,va as t,xi as u,F as v,T as x,I as y};