@aventurevc/aventure-cli 0.8.183 → 0.8.185

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 (46) hide show
  1. package/dist/aventure-cli/command-catalog.compact.txt +5 -1
  2. package/dist/aventure-cli/index.js +1 -1
  3. package/dist/aventure-cli/unified-operations.json +62 -4
  4. package/dist/chunks/api-key-bearer-credential-B-1UINE8.js +1 -0
  5. package/dist/chunks/{api-key-bearer-credential-Cxons3cm.js → api-key-bearer-credential-BYpoThef.js} +1 -1
  6. package/dist/chunks/{aventure-cli-ZrfLeo3x.js → aventure-cli-g54kxG8S.js} +3 -3
  7. package/dist/chunks/{cli-help-policy-CEZmY2LL.js → cli-help-policy-RGOSoZ1Z.js} +1 -1
  8. package/dist/chunks/contract-CQeFe7mk.js +27 -0
  9. package/dist/chunks/{dist-9kkSpcmP.js → dist-Ce24grer.js} +2 -2
  10. package/dist/chunks/{env-gpTPURvt.js → env-YDNggcP1.js} +1 -1
  11. package/dist/chunks/logging-C5C6Bsga.js +1 -0
  12. package/dist/chunks/{logging-D_7xwm_N.js → logging-CDCaRpiW.js} +1 -1
  13. package/dist/chunks/mcp-generation-contract-B6pMxUtz.js +1 -0
  14. package/dist/chunks/mcp-generation-contract-Ch56aEHy.js +1 -0
  15. package/dist/chunks/{oauth-bearer-credential-BbDjUDbF.js → oauth-bearer-credential-4hGvDZoQ.js} +2 -2
  16. package/dist/chunks/oauth-bearer-credential-DJ2PA6d4.js +1 -0
  17. package/dist/chunks/oauth-login-BLRUSc5A.js +1 -0
  18. package/dist/chunks/{oauth-login-aa5m1Kuc.js → oauth-login-BiXKKdqF.js} +1 -1
  19. package/dist/chunks/openapi-commands-C0WAjaN3.js +1 -0
  20. package/dist/chunks/openapi-commands-K3hFzG4D.js +1 -0
  21. package/dist/chunks/output-mode-BW9Jfk5x.js +1 -0
  22. package/dist/chunks/output-mode-QxmCrOJw.js +1 -0
  23. package/dist/chunks/{output-spill-BRyuNqcH.js → output-spill-CvlQjh5i.js} +1 -1
  24. package/dist/chunks/provider-catalog-BxkTk-Lo.js +1 -0
  25. package/dist/chunks/{response-problem-D6NByFDg.js → response-problem-DEZ2kyCp.js} +1 -1
  26. package/dist/chunks/result-envelope-D5wNfKzB.js +1 -0
  27. package/dist/chunks/startup-auth-BCJtMtHx.js +1 -0
  28. package/dist/chunks/startup-auth-BJ3mNNZp.js +1 -0
  29. package/dist/chunks/tool-policy-D7R8FUUe.js +1 -0
  30. package/package.json +3 -3
  31. package/dist/chunks/api-key-bearer-credential-BQEuNZq_.js +0 -1
  32. package/dist/chunks/contract-BnIEMW_J.js +0 -27
  33. package/dist/chunks/logging-B7HscXAR.js +0 -1
  34. package/dist/chunks/mcp-generation-contract-BP4h0kA3.js +0 -1
  35. package/dist/chunks/mcp-generation-contract-wxtUVCwc.js +0 -1
  36. package/dist/chunks/oauth-bearer-credential-CrAMYo89.js +0 -1
  37. package/dist/chunks/oauth-login-E8UJj8UQ.js +0 -1
  38. package/dist/chunks/openapi-commands-Bn5UfQTY.js +0 -1
  39. package/dist/chunks/openapi-commands-XSw0ZcJR.js +0 -1
  40. package/dist/chunks/output-mode-ClwZIjEf.js +0 -1
  41. package/dist/chunks/output-mode-DTYU9WPD.js +0 -1
  42. package/dist/chunks/provider-catalog-B3ghWM0D.js +0 -1
  43. package/dist/chunks/result-envelope-BQn5YxYv.js +0 -1
  44. package/dist/chunks/startup-auth-BgliDNpy.js +0 -1
  45. package/dist/chunks/startup-auth-V9kB5Weo.js +0 -1
  46. package/dist/chunks/tool-policy-CrjzsCMg.js +0 -1
@@ -1,4 +1,4 @@
1
- aventure lookup · Read a Company, Product, Service, or Person Identity Without Enrichment · -
1
+ aventure lookup · Read a Company, Product, Service, or Person Identity · -
2
2
  aventure lookup-from-file · Identify a Company, Product, Service, or Person by Name, URL, or ID · -
3
3
  aventure lookup-mentions · Identify Every Company and Person a Page or Screenshot Names · -
4
4
  aventure metrics · Get Platform Totals for Companies, Funding, and People · -
@@ -29,6 +29,7 @@ aventure search link · Search From a Page URL · --url
29
29
  aventure unique-ids lookup · Look Up an Identifier Owner · --id-type --identifier
30
30
  aventure url-types list · List URL Types · -
31
31
  aventure web search · Search the Live Web · --search
32
+ aventure addresses links list · List Address Links · --address-id
32
33
  aventure agents help answer · Deprecated: Answer a Natural-Language Platform Help Question · --question
33
34
  aventure auth api-key get · Get Current API Key · -
34
35
  aventure auth api-key revoke · Revoke Current API Key · -
@@ -44,6 +45,8 @@ aventure billing plans list · List Subscription Tiers and Plans · -
44
45
  aventure billing portal-sessions create · Create a Hosted Billing Portal Session · -
45
46
  aventure billing subscription get · Read the Current Billing Subscription · -
46
47
  aventure billing subscription update · Cancel or Resume the Subscription · -
48
+ aventure directory shared create · Share a Directory View · -
49
+ aventure directory shared list · List Shared Directory Views · -
47
50
  aventure entities acquisitions get · Get One Company Acquisition · --entity-id --relationship-id
48
51
  aventure entities acquisitions list · List a Company's Acquisitions · --entity-id
49
52
  aventure entities addresses get · Get One Company Address · --entity-id --address-join-id
@@ -132,6 +135,7 @@ aventure auth me permissions authorize · Authorize API Operations · -
132
135
  aventure auth me permissions get · Current User Permissions · -
133
136
  aventure billing subscription next-charge get · Preview the Next Subscription Charge · -
134
137
  aventure billing subscription payment-profile get · Read Your Card on File and Introductory Offer · -
138
+ aventure directory shared slug get · Read a Shared Directory View by Slug · --record-slug
135
139
  aventure entities classifications catalog get · Get the Company Classification Taxonomy · -
136
140
  aventure entities classifications suggestions list · Suggest Classifications for a Company · --entity-id
137
141
  aventure entities classifications tags list · List Classification Tags · -
@@ -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-B7HscXAR.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-CrAMYo89.js`),{materializeCliApiKeyBearerCredential:c}=await import(`../chunks/api-key-bearer-credential-BQEuNZq_.js`),{commandAuthMaterializationMode:l}=await import(`../chunks/startup-auth-BgliDNpy.js`),{setTextAllFields:u}=await import(`../chunks/text-field-CxrRvM47.js`),{cliMachineOutputSelected:d}=await import(`../chunks/output-mode-ClwZIjEf.js`),{GENERATED_OPENAPI_COMMAND_SPECS:f}=await import(`../chunks/openapi-commands-Bn5UfQTY.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-ZrfLeo3x.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-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{};
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "MCP_GENERATION_CONTRACT",
4
- "generatedAt": "2026-10-15T00:30:56.296Z",
5
- "totalOperations": 133,
4
+ "generatedAt": "2026-10-15T16:48:35.678Z",
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": [
8
+ {
9
+ "operationId": "listAddressLinks",
10
+ "method": "GET",
11
+ "path": "/v1/addresses/{addressId}/links",
12
+ "resource": "addresses",
13
+ "intent": "read",
14
+ "cliCommand": "addresses links list",
15
+ "cliPath": [
16
+ "addresses",
17
+ "links",
18
+ "list"
19
+ ],
20
+ "mcpTool": "aventure_read",
21
+ "bodySchemaName": null,
22
+ "bodySchemaImport": null,
23
+ "auth": "bearer",
24
+ "scope": "read",
25
+ "destructive": false
26
+ },
8
27
  {
9
28
  "operationId": "answerAgentHelpQuestion",
10
29
  "method": "POST",
@@ -179,6 +198,45 @@
179
198
  "scope": "read",
180
199
  "destructive": false
181
200
  },
201
+ {
202
+ "operationId": "listSharedDirectory",
203
+ "method": "GET",
204
+ "path": "/v1/directory/shared",
205
+ "resource": "directory",
206
+ "intent": "read",
207
+ "cliCommand": "directory shared list",
208
+ "cliPath": [
209
+ "directory",
210
+ "shared",
211
+ "list"
212
+ ],
213
+ "mcpTool": "aventure_read",
214
+ "bodySchemaName": null,
215
+ "bodySchemaImport": null,
216
+ "auth": "none",
217
+ "scope": "read",
218
+ "destructive": false
219
+ },
220
+ {
221
+ "operationId": "getSharedDirectoryBySlug",
222
+ "method": "GET",
223
+ "path": "/v1/directory/shared/slug/{slug}",
224
+ "resource": "directory",
225
+ "intent": "read",
226
+ "cliCommand": "directory shared slug get",
227
+ "cliPath": [
228
+ "directory",
229
+ "shared",
230
+ "slug",
231
+ "get"
232
+ ],
233
+ "mcpTool": "aventure_read",
234
+ "bodySchemaName": null,
235
+ "bodySchemaImport": null,
236
+ "auth": "none",
237
+ "scope": "read",
238
+ "destructive": false
239
+ },
182
240
  {
183
241
  "operationId": "enrichRecords",
184
242
  "method": "POST",
@@ -1794,8 +1852,8 @@
1794
1852
  "enrich"
1795
1853
  ],
1796
1854
  "mcpTool": "aventure_job",
1797
- "bodySchemaName": "EnrichmentPromptSchema",
1798
- "bodySchemaImport": "@aventurevc/api-schemas/enrichment/prompt",
1855
+ "bodySchemaName": "PersonEnrichmentPromptSchema",
1856
+ "bodySchemaImport": "@aventurevc/api-schemas/person/enrichment-prompt",
1799
1857
  "auth": "bearer",
1800
1858
  "scope": "read",
1801
1859
  "destructive": false
@@ -0,0 +1 @@
1
+ import{t as e}from"./api-key-bearer-credential-BYpoThef.js";export{e as materializeCliApiKeyBearerCredential};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t}from"./logging-D_7xwm_N.js";import{a as n,t as r,u as i}from"./env-gpTPURvt.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-D6NByFDg.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-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(`
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,4 +1,4 @@
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-D_7xwm_N.js";import{i as s,o as c,r as l,s as u,t as d,u as f}from"./env-gpTPURvt.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-9kkSpcmP.js";import{c as y,d as le,i as b,r as ue}from"./result-envelope-BQn5YxYv.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-CrjzsCMg.js";import{i as Se,r as Ce}from"./response-problem-D6NByFDg.js";import{n as we,r as Te}from"./output-spill-BRyuNqcH.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-BnIEMW_J.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-CEZmY2LL.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-Cxons3cm.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-BbDjUDbF.js";import{n as ht,r as gt,t as _t}from"./oauth-login-aa5m1Kuc.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-V9kB5Weo.js";import{n as Ot,t as T}from"./openapi-commands-XSw0ZcJR.js";import{i as E,r as kt,t as D}from"./output-mode-DTYU9WPD.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(`
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
2
  `)?n.slice(0,-1):n),r.push(...e),process.stdout.write(Le(r.join(`
3
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
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
@@ -27,7 +27,7 @@ import{a as e,n as t,o as n,r,t as i}from"./commander-BB7CDPLs.js";import{i as a
27
27
  `)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>R({mode:E(e)},io(void 0,`apply`,e.release)))}function io(e,t=`apply`,n){let r=e;try{r??=x(process.argv[1])}catch(e){return b(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let i=r.name,a=r.version,o=r.registry===``?``:de,s=r.registry===``&&i===`@aventurevc/aventure-cli`,c=n;if(c===void 0){let e=ao([`view`,o,`version`,`--silent`,`--global`],r,{timeout:to});if(!e.ok)return{...e,data:null};if(c=(e.data??``).trim(),c===``)return b(`npm view ${o} returned empty version`,[`empty_stdout`])}let l=n!==void 0||s||eo.compare(a,c)<0,u={targetPackage:o,runningPackage:i,currentVersion:a,latestVersion:c,upgradeAvailable:l,upgradeInstalled:!1};if(t===`check`)return y(`${i}@${a} → ${o}@${c} (${l?`available`:`up to date`})`,u);if(r.workingTreeRoot!==null)return b(`Refusing to install over the working-tree build at ${r.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);try{let e=co(r),t=A(e,...no),i=O(o),s=A(t,`${i}-current`),l=o===``?[o,``]:[o,fe],d=lo(e,r),f=n??[c,d?.version??a].reduce((e,t)=>eo.compare(e,t)<0?t:e,a);M(t,{recursive:!0});let p=[so(r),...j(s)?[zt(s)]:[],...Lt(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>A(t,e.name))],m,h=null,g=!1;for(let t of new Set(p.filter(t=>t!==e))){let e=oo(t,l,f,r.registry);if(e.ok&&e.data!==null){m=t,h=e.data;break}}if(m===void 0){m=Ft(A(t,`${i}-${encodeURIComponent(f)}-`));let e=ao([`install`,`-g`,`--prefix`,m,...l.map(e=>`${e}@${f}`)],r,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,data:null};g=!0;let n=oo(m,l,f,r.registry);if(!n.ok)return{...n,data:null};h=n.data}if(h===null)throw Error(`release verification produced no package`);let ee=uo(m,e,s,h,n),_=po();return y(`${o} active at ${ee}`,{...u,upgradeInstalled:g||n!==void 0||d?.version!==ee,installPrefix:e,verifiedVersion:ee,completionRefreshed:_.refreshed,completionRefreshMessage:_.message})}catch(e){return b(`${o} update failed: ${fo(e)}`,[`existing releases were preserved`])}}function ao(e,t,n={}){let r={...process.env};t.registry===``?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let i=[...e,`--@aventurevc:registry=${t.registry}`],a=At(`npm`,i,{env:r,encoding:`utf8`,...n});if(a.error)return a.signal===`SIGTERM`&&n.timeout!==void 0?b(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):b(`npm ${e[0]??``} failed to start: ${a.error.message}`,[`spawn_error`]);if(a.status!==0){let t=(a.stderr??``).trim().split(`
28
28
  `).slice(-3).join(` | `);return b(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return y(`npm ok`,a.stdout??``)}function oo(e,t,n,r){try{let i=t.map(t=>{let i=x(A(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));if(i.name!==t||i.version!==n||i.registry!==r)throw Error(`${t} does not match ${n} from ${r}`);for(let t of i.bin)if(!zt(A(e,`bin`,t)).startsWith(`${i.packageRoot}${Mt}`))throw Error(`${t} escapes ${i.packageRoot}`);return i});for(let t of i){let r=A(e,`bin`,t.bin[0]),i=At(process.execPath,[r,`--version`],{encoding:`utf8`,timeout:to});if(i.error)throw Error(`${t.name} verification failed: ${i.error.message}`);let a=(i.stdout??``).trim();if(i.status!==0||a!==n)throw Error(`${t.name} expected ${n} but reported ${a||`empty output`}`)}return y(`CLI and MCP release verified`,i)}catch(t){return b(`release verification failed: ${fo(t)}`,[`release prefix: ${e}`])}}function so(e){let t=k(e.packageRoot),n=k(t),r=k(n);if(O(t)!==e.name.split(`/`)[0]||O(n)!==`node_modules`||O(r)!==`lib`)throw Error(`the running package is not in a verifiable global npm prefix; npm install was not run`);if(!e.entryPath.startsWith(`${e.packageRoot}${Mt}`))throw Error(`the running entry escapes its package root`);return k(r)}function co(e){let t=so(e),n=`${Mt}${no.join(Mt)}${Mt}`,r=t.lastIndexOf(n);return r<0?t:t.slice(0,r)}function lo(e,t){let n=t.registry===``?O(``):pe,r=A(e,`bin`,n);if(!j(r))return null;let i=x(r);if(i.registry!==t.registry)throw Error(`${r} belongs to another product`);return i}function uo(e,t,n,r,i){let a=r[0];if(a===void 0)throw Error(`release contains no CLI`);let o=A(t,`bin`);M(o,{recursive:!0});let s=r.flatMap(e=>e.bin.filter((e,t)=>{let n=A(o,e);if(!j(n)||x(n).registry===a.registry)return!0;if(a.registry!==``&&t>0)return!1;throw Error(`${n} belongs to another product`)}));if(!j(n)){let t=Ft(A(k(n),`${O(n)}-seed-`));M(A(t,`bin`));for(let n of s){let r=A(o,n);Vt(zt(j(r)?r:A(e,`bin`,n)),A(t,`bin`,n))}try{Vt(jt(k(n),t),n)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`EEXIST`))throw e}}if(!Pt(n).isSymbolicLink())throw Error(`${n} is not a release symlink`);for(let e of s){let t=jt(o,A(n,`bin`,e)),r=A(o,`.${e}-${Zt()}`);Vt(t,r),Bt(r,A(o,e))}for(let e of s){let t=A(o,e);if(!Pt(t).isSymbolicLink()||A(o,Rt(t))!==A(n,`bin`,e))throw Error(`${t} does not follow the product current pointer`)}let c=lo(t,a);if(i===void 0&&c!==null&&eo.compare(c.version,a.version)>0)return c.version;let l=`${n}-${Zt()}`;return Vt(jt(k(n),e),l),Bt(l,n),a.version}function fo(e){return e instanceof Error?e.message:String(e)}function po(){try{return Ra()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var mo=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers`},{name:`auth`,purpose:`which credential signs in, as which account and role, never secrets`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}];function ho(e,t=x().bin[0]){D(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",...mo.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable) or a`,`warned one (the account read failed) does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
29
29
  `))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),R({mode:E(e)},await go(t))})}async function go(e){let t=vo(),n=yo(e),[r,i]=await Promise.all([bo(e),xo(t,e)]),a=[n.check,r,i.check,await Co(e),Ao(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:_o(a,`pass`),warn:_o(a,`warn`),fail:_o(a,`fail`),skip:_o(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.warn} warn, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
30
- `);return c.ok?y(l,c,{counts:o}):{...b(l,s,{counts:o}),data:c}}function _o(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function vo(){return T.find(e=>e.intent===`status`&&e.resource===`status`)}function yo(e){let t=x(),n=io(t,`check`);if(!n.ok||n.data===null)return{check:K(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function bo(e){try{let{EntityDetailSchema:e}=await import(`./detail-D3FyUXbw.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return K(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return K(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${C(t)}.`)}}async function xo(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:K(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${C(e)}.`),servedFingerprint:null}}let i=await re({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>b(C(e)));return i.ok?{check:K(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:So(i.data)}:{check:K(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function So(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function Co(e){let t=Ye(),[n,r]=await Promise.all([To(),Eo()]);if(r.state===`unavailable`&&r.cause===`environment`)return K(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return K(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&ot(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return K(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${d.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await wo(e,t);return K(`auth`,i.status,`Credential source available: ${Do(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${d.authToken} through the environment — ${r.summary}.`):K(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${d.authToken} in the environment.`)}async function wo(e,t){let n=w(f().host),r=await sa(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await oa(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${C(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function To(){let e;try{e=w(f().host)}catch(e){return{state:`unavailable`,summary:C(e)}}return await ft(e)}async function Eo(){let e;try{e=w(f().host)}catch(e){return{state:`unavailable`,summary:C(e),cause:`environment`}}try{return await et(e)}catch(e){return{state:`unavailable`,summary:C(e),cause:`storage`}}}function Do(e,t,n){return[Aa(e),`oauth=${ko(t)}`,`api-key=${Oo(n)}`].join(` `)}function Oo(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=w(f().host);return`${e.stored.activation}${ha(t,e)}`}function ko(e){switch(e.state){case`found`:return ot(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function Ao(e,t,n,r){let i=T.length;if(e===void 0)return K(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return K(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ot}.`);if(t===`3d443fa340b44907`)return K(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ot}).`);let a=`This catalog describes a different operation set than the API serves (${Ot} vs ${t})`;return n===!0?K(`catalog`,`fail`,`${a}: run \`${r} update\`.`):K(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var jo=S(B,`oauth`),Mo=[S(B,`start`),S(B,`poll`),S(B,`acknowledge`)],No=S(B,`revoke`);function Po(e,n=x().bin[0]){let r=Ro(e);ho(r,n);let i=[`${jo.description} Default method: OAuth in your browser.`,`With --key: ${Mo.map(({description:e})=>e).join(` `)}`].join(`
30
+ `);return c.ok?y(l,c,{counts:o}):{...b(l,s,{counts:o}),data:c}}function _o(e,t){return e.filter(e=>e.status===t).length}function K(e,t,n){return{name:e,status:t,message:n}}function vo(){return T.find(e=>e.intent===`status`&&e.resource===`status`)}function yo(e){let t=x(),n=io(t,`check`);if(!n.ok||n.data===null)return{check:K(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?K(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):K(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function bo(e){try{let{EntityDetailSchema:e}=await import(`./detail-D3FyUXbw.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return K(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return K(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${C(t)}.`)}}async function xo(e,t){let n=e??{method:`GET`,path:`/info`,auth:`none`},r;try{r=f().host}catch(e){return{check:K(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${C(e)}.`),servedFingerprint:null}}let i=await re({method:n.method,path:n.path,auth:n.auth,responseFormat:`json`}).catch(e=>b(C(e)));return i.ok?{check:K(`api-host`,`pass`,`${n.method} ${n.path} answered at ${r}.`),servedFingerprint:e===void 0?null:So(i.data)}:{check:K(`api-host`,`fail`,i.httpStatus===401?`Replace or unset the credential ${r} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} returned ${i.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${n.method} ${n.path} at ${r} returned ${i.summary}.`),servedFingerprint:null}}function So(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function Co(e){let t=Ye(),[n,r]=await Promise.all([To(),Eo()]);if(r.state===`unavailable`&&r.cause===`environment`)return K(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present,a=r.state===`found`&&r.stored.activation===`active`;if(!i&&n.state===`invalid`)return K(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`);if(!i&&n.state===`found`&&ot(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0)return K(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!i&&!a&&n.state===`unavailable`)return K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${d.authToken} through the environment — ${n.summary}.`);if(i||n.state===`found`||a){let i=await wo(e,t);return K(`auth`,i.status,`Credential source available: ${Do(t,n,r)}; ${i.text}.`)}return r.state===`unavailable`?K(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${d.authToken} through the environment — ${r.summary}.`):K(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${d.authToken} in the environment.`)}async function wo(e,t){let n=w(f().host),r=await sa(e),i=`credential=${t.present?t.source??`env`:r.materialized??`none`}`;try{if(r.failure!==null)throw Error(r.failure);let e=await oa(`write`);if(e===null)return{status:`pass`,text:`${i} host=${n}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${i} account=${e.email??e.id} role=${t} host=${n}`}}catch(t){return{status:`warn`,text:`${i} account=unread host=${n} — GET /v1/auth/me returned ${C(t,[f().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function To(){let e;try{e=w(f().host)}catch(e){return{state:`unavailable`,summary:C(e)}}return await ft(e)}async function Eo(){let e;try{e=w(f().host)}catch(e){return{state:`unavailable`,summary:C(e),cause:`environment`}}try{return await et(e)}catch(e){return{state:`unavailable`,summary:C(e),cause:`storage`}}}function Do(e,t,n){return[Aa(e),`oauth=${ko(t)}`,`api-key=${Oo(n)}`].join(` `)}function Oo(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=w(f().host);return`${e.stored.activation}${ha(t,e)}`}function ko(e){switch(e.state){case`found`:return ot(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function Ao(e,t,n,r){let i=T.length;if(e===void 0)return K(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return K(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ot}.`);if(t===`9da80c9549e71216`)return K(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ot}).`);let a=`This catalog describes a different operation set than the API serves (${Ot} vs ${t})`;return n===!0?K(`catalog`,`fail`,`${a}: run \`${r} update\`.`):K(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var jo=S(B,`oauth`),Mo=[S(B,`start`),S(B,`poll`),S(B,`acknowledge`)],No=S(B,`revoke`);function Po(e,n=x().bin[0]){let r=Ro(e);ho(r,n);let i=[`${jo.description} Default method: OAuth in your browser.`,`With --key: ${Mo.map(({description:e})=>e).join(` `)}`].join(`
31
31
  `);D(Lo(r,[jo,...Mo],i)).action(Fo),D(Lo(r,[No],No.description)).action(Io),D(r.command(`status`).summary(`Keep saved credentials current and report them`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
32
32
  `)).addOption(new t(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){zo(this),R({mode:E(e)},await Bo(n,e.verify))}),r.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${d.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
33
33
  `)).action(async function(){zo(this);let e=await sa(n),t=process.env[d.authToken]?.trim();if(e.failure===null&&t!==void 0&&t.length>0){process.stdout.write(`${t}\n`);return}R({mode:`text`},e.failure===null?Jo(`auth token: no credentials resolved`,null,n,{oauth:!0,apiKey:!0}):b(`auth token: ${e.failure}`))})}async function Fo(e){zo(this);let t=E(e);if(e.providers===!0){R({mode:t},await Ho());return}R({mode:t},e.key===!0?await Xi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await gt({noBrowser:!e.browser}))}async function Io(e){zo(this),R({mode:E(e)},await zi({forgetLocal:e.forgetLocal===!0}))}function Lo(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Ro(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${jo.command}\`: ${jo.summary}; \`--key\` ${Mo[0].summary.toLowerCase()}.`,`\`${No.command}\`: ${No.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build metadata.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
@@ -56,7 +56,7 @@ end
56
56
  (Did you mean `))return;let r=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(`
59
- `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Nr(n)}\n`),uc(r,t,n),dc(r,t,n),fc(r,t,n),pc(r)}function uc(e,n,r){let i=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,sc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new t(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(e){let t=this.optsWithGlobals(),i=E(t,`text`),a=Fr(t,e);Ir(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function dc(e,n,r){let i=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(){let e=this.optsWithGlobals();Lr(e,n,E(e,`text`),r)})}function fc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,sc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(){let e=this.optsWithGlobals();Ir(e,n,E(e,`text`),r)})}function pc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);D(t),t.action(async function(){let e=this.optsWithGlobals(),t=E(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-wxtUVCwc.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},y(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=rc(n);if(e.output!==void 0){let n=ac(e.output,r);R({mode:t},y(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){zr(`Unified operations JSON`,ic(r));return}R({mode:t},y(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var mc=x(Yt(import.meta.url)),Q=mc.bin[0];function hc(e,t){let n=e instanceof Error?e:Error(String(e));a({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof ie?{httpStatus:n.problem.status,problem:n.problem}:{};ur({...b(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function gc(e){return Ge[Ve(e,vt)??`cli`]}function _c(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:gc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>Et(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)vc(e,t,r,a,i.has(t.cliPath.join(` `)))}function vc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=yc(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>_e(e.schemaType,e.itemSchemaType))?ye:``].filter(Boolean).join(`
59
+ `));r.addHelpText(`after`,()=>`\nShipped compact catalog of operations callable without an admin grant, greppable without\nrunning this CLI (dump --format compact lists every operation your credential reaches):\n ${Nr(n)}\n`),uc(r,t,n),dc(r,t,n),fc(r,t,n),pc(r)}function uc(e,n,r){let i=e.command(`search`).summary(`Search generated operations`).description(`Search generated operation metadata without calling the API.`).argument(`[query...]`,`Search query; same as --q.`).option(`--q <query>`,`Search generated command metadata`).option(`--root <root>`,sc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`,`20`).addOption(new t(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(e){let t=this.optsWithGlobals(),i=E(t,`text`),a=Fr(t,e);Ir(a,(a.q?.trim()??``)===``?n.filter(({deprecated:e})=>e!==!0):n,i,r)})}function dc(e,n,r){let i=e.command(`show`).summary(`Show one generated operation`).description(`Show one generated operation by command path or operationId.`).option(`--command <command>`,`CLI command path, with or without ${r} prefix`).option(`--operation-id <operationId>`,`Generated OpenAPI operationId`).addOption(new t(`--format <format>`,`Text/file render format`).choices([`usage`,`lines`,`compact`,`json`,`ndjson`]).default(`usage`)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(){let e=this.optsWithGlobals();Lr(e,n,E(e,`text`),r)})}function fc(e,n,r){let i=e.command(`dump`).summary(`Dump generated operations`).description(`Dump generated operations for rg/grep/ag/ack or JSON/NDJSON tooling.`).option(`--root <root>`,sc).addOption(new t(`--scope <scope>`,`Filter by required auth scope`).choices([`read`,`write`,`all`]).default(`all`)).addOption(new t(`--mutates <mutates>`,`Filter mutating operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--destructive <destructive>`,`Filter destructive operations`).choices([`true`,`false`,`any`]).default(`any`)).addOption(new t(`--intent <intent>`,`Filter by operation intent`).choices([`read`,`lookup`,`search`,`write`,`delete`,`status`,`all`]).default(`all`)).addOption(new t(`--method <method>`,`Filter by HTTP method`).choices([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`all`]).default(`all`)).option(`--limit <count>`,`Maximum rows to return`).addOption(new t(`--format <format>`,`Text/file render format`).choices(cc)).option(`--output <path>`,`Write rendered output to a file`);D(i),i.action(function(){let e=this.optsWithGlobals();Ir(e,n,E(e,`text`),r)})}function pc(e){let t=e.command(`unified`).summary(`Dump unified CLI/API/MCP operation JSON`).description(`Dump the flat unified operations JSON projected from MCP_GENERATION_CONTRACT.`).option(`--output <path>`,`Write unified operations JSON to a file`);D(t),t.action(async function(){let e=this.optsWithGlobals(),t=E(e,`text`),{MCP_GENERATION_CONTRACT:n}=await import(`./mcp-generation-contract-Ch56aEHy.js`);if(t===`text`&&e.output===void 0&&(e.text===!0||e.allFields===!0)){R({mode:t},y(`Unified operations JSON`,`Use --output <path> to write the unified operations JSON.`,{counts:{totalOperations:n.length}}));return}let r=rc(n);if(e.output!==void 0){let n=ac(e.output,r);R({mode:t},y(`Unified operations JSON written`,{outputPath:n.target,byteLength:n.byteLength,schemaVersion:r.schemaVersion},{counts:{totalOperations:n.totalOperations}}));return}if(t===`text`){zr(`Unified operations JSON`,ic(r));return}R({mode:t},y(`Unified operations JSON`,r,{counts:{totalOperations:r.totalOperations}}))})}var mc=x(Yt(import.meta.url)),Q=mc.bin[0];function hc(e,t){let n=e instanceof Error?e:Error(String(e));a({component:Q,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Q} fatal (${t}): ${n.stack??n.message}\n`);let r=n instanceof ie?{httpStatus:n.problem.status,problem:n.problem}:{};ur({...b(`${Q} ${t}: ${n.message}`,[n.name||`Error`],r),counts:{exitCode:1}}),process.exit(1)}function gc(e){return Ge[Ve(e,vt)??`cli`]}function _c(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:gc(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>Et(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)vc(e,t,r,a,i.has(t.cliPath.join(` `)))}function vc(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=yc(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${Q} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>_e(e.schemaType,e.itemSchemaType))?ye:``].filter(Boolean).join(`
60
60
  `));let f=Dt(t);for(let e of t.parameters)bc(u,e,i||e===f);if(Un(u,t),ve(t.intent)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),D(u),u.hook(`preAction`,e=>St(e,t)),t.explain===!0&&u.option(`--explain`,`Print the search strategy and parsed constraints before the results`),f!==void 0){u.argument(`[text...]`,f.description||`Same as ${Tt(f.flag)}.`),u.action(async function(e){let n=this.optsWithGlobals(),r=E(n),i=bt(f,e,n);if(!i.ok||i.data===null)return R({mode:r},i);let a=yt(t,i.data);if(a.length>0)return R({mode:r},b(`missing required options: ${a.join(`, `)}`));let o=await xc(t,i.data,r),s=si(t,i.data,o);if(s!==null)return R({mode:r},s);n.explain===!0&&o.ok&&mr(r,o.data),o.ok&&o.data instanceof Uint8Array?process.stdout.write(o.data):R({mode:r},o)});return}u.action(async function(){let e=this.optsWithGlobals(),n=E(e),r=yt(t,e);if(r.length>0)return R({mode:n},b(`missing required options: ${r.join(`, `)}`));let i=await xc(t,e,n),a=si(t,e,i);if(a!==null)return R({mode:n},a);e.explain===!0&&i.ok&&mr(n,i.data),i.ok&&i.data instanceof Uint8Array?process.stdout.write(i.data):R({mode:n},i)})}function yc(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=vt[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function bc(e,n,r=!1){let i=n.description||`${n.name} ${n.location} parameter`,a=n.defaultValue===void 0?void 0:typeof n.defaultValue==`string`||typeof n.defaultValue==`boolean`?n.defaultValue:[...n.defaultValue];if(n.legacyFlag!==void 0){let o=new t(n.flag,i);a!==void 0&&o.default(a);let s=new t(n.legacyFlag,i).conflicts(n.optionKey);e.addOption(o).addOption(s),e.hook(`preAction`,e=>{let t=e.opts(),i=t[n.optionKey],a=t[s.attributeName()];if(a!==void 0){(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`);return}!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`})});return}if(a!==void 0){e.option(n.flag,i,a);return}if(n.required&&!r){e.requiredOption(n.flag,i);return}e.option(n.flag,i)}async function xc(e,t,n){if(t.environment!==void 0){let e=u(t.environment);if(e===null)return b(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${c().join(`, `)}`]);process.env.API_ENV=e}let r=await Jn(e,t);if(!r.ok)return r;let i=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let n=t[e.optionKey];if(Array.isArray(n))return[e.name,n.at(0)??``];if(n===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(n)]})),a=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let n=t[e.optionKey];if(n===void 0||Array.isArray(n)&&n.length===0)return[];let r=Array.isArray(n)||typeof n==`boolean`?n:String(n);return[[e.name,r]]})),o=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let n=t[e.optionKey];return n===void 0||Array.isArray(n)&&n.length===0?[]:[[e.name,Array.isArray(n)?n.join(`,`):String(n)]]}));return li(e,await re({method:e.method,path:se(e.operationId,i),searchParams:a,headers:o,body:r.data,contentType:wt(e,t),auth:e.auth,responseFormat:kt(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0}))}process.on(`uncaughtException`,e=>hc(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>hc(e,`unhandledRejection`));var Sc=Ct(process.argv.slice(2),T),Cc=Sc===`required`?T:xt(T),$=new i;$.name(Q).usage(`<command> [subcommand] [options]`).configureHelp(Qr).version(mc.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description([`The aVenture research API from your terminal. Three records — companies,`,`people, and news — carry everything else: funding, publications, and tags.
61
61
  `,`Mutations execute directly; --execute is a deprecated no-op.
62
62
  The aVenture MCP server tools execute through this same CLI.`].join(`
@@ -1 +1 @@
1
- import{u as e}from"./tool-policy-CrjzsCMg.js";function t(t,n,r,i){let a=t===`array`?n:t,o=t===`array`?`...`:``;return r===`uuid`||r===`date-time`||r===`date`?`${r}${o}`:a===`boolean`?`true|false${o}`:a===`integer`||a===`number`?`${a}${o}`:`${e(i)}${o}`}function n(e,t){let n=s(e);if(t===void 0||t.length===0)return n;let r=`Allowed values: ${t.join(`, `)}`;return n===``?`${r}.`:`${n} ${r}.`}var r={path:{heading:`Path parameters:`,rank:0},header:{heading:`Request headers:`,rank:1},input:{heading:`Input:`,rank:2},body:{heading:`Body fields:`,rank:3},option:{heading:`Options:`,rank:1/0}};function i(e){return o(e).rank}function a(e){return o(e).heading}function o(e){return e.location===`path`?r.path:e.location===`header`?r.header:e.inputType===`file`||e.schemaFormat===`binary`?r.input:e.location===`body`?r.body:r.option}var s=e=>e===``||/[.!?]$/u.test(e)?e:`${e}.`,c={researchData:{heading:`Research data commands:`,rank:0},account:{heading:`Account commands:`,rank:1},administration:{heading:`Administration commands:`,rank:2},cli:{heading:`CLI commands:`,rank:3}};function l(e,t){return e!==void 0&&u(e,t)===`administration`}function u(e,t){return d[e]??t?.[e]?.section}var d={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,"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-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};
@@ -0,0 +1,27 @@
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(`
2
+ `)}\n`,`utf8`)<=t,E=(e,t=!1,n=!1,r=1)=>{let i=de(e),a=t||i.endsWith(`
3
+ `),o=i.endsWith(`
4
+ `)?i.slice(0,-1):i,s=o.length===0?[]:o.split(`
5
+ `),c=x.byteLength(`${s.join(`
6
+ `)}\n`,`utf8`);if(s.length<=120&&c<=16e3)return`${s.join(`
7
+ `)}${a?`
8
+ `:``}`;let l=n?Math.min(Math.max(1,r),118):0,u=l>0?s.slice(-l):[],d=u.length===0?s:s.slice(0,-u.length),f=[s.length>120?`120 physical lines`:``,c>16e3?`${T} UTF-8 bytes`:``].filter(Boolean).join(` and `),p=e=>de(`... output truncated: ${e} more lines omitted to stay within ${f}; recover omitted response content with narrower server-side filters, the relevant sub-resource operation (aventure_help names it), or responseFormat json.`),m=(e,t)=>[...e,...u,t].join(`
9
+ `),ee=120-u.length-1,h=d.slice(0,ee),g=p(s.length-h.length-u.length);for(;x.byteLength(`${m(h,g)}\n`,`utf8`)>T;){if(h.length>0)h=h.slice(0,-1);else if(u.length>0)u=u.slice(1);else break;g=p(s.length-h.length-u.length)}return`${m(h,g)}${a?`
10
+ `:``}`},bt=e=>E(Ct(e.trimEnd().split(`
11
+ `),120).join(`
12
+ `),e.endsWith(`
13
+ `)),xt=new Set([`core`,`nameFull`,`nameBrand`,`name`,`title`,`fundingDetail`,`round`,`dateAnnounced`,`amountRaised`,`person`,`fundraiseRound`]),St=5;function Ct(e,t,n=T){let r=e=>e.length<=t&&yt(e,n);if(r(e))return e;let i=wt(e),a=e=>[...Mt(i,e-1),`... output folded to fit 120 lines and ${T} UTF-8 bytes; "(+N lines)" and "N more" mark hidden content; read it whole with responseFormat json, --data --to-file <path>, or the section's sub-resource operation.`],o=2,s=t,c=a(o);for(;o<=s;){let e=Math.floor((o+s)/2),t=a(e);r(t)?(c=t,o=e+1):s=e-1}return c}function wt(e){let t={line:``,child:[]},n=[{node:t,indent:-1}];for(let t of e){let e=Et(t);for(;n.length>1&&(n.at(-1)?.indent??-1)>=e;)n.pop();let r={line:t,child:[]};n.at(-1)?.node.child.push(r),n.push({node:r,indent:e})}return t.child}var Tt=new WeakMap,D=e=>{let t=Tt.get(e);if(t!==void 0)return t;let n=e.child.reduce((e,t)=>e+D(t),1);return Tt.set(e,n),n},Et=e=>e.length-e.trimStart().length,Dt=/^(?:- ?|\d+\.(?: |$))/u,Ot=e=>(e.line.trimStart().replace(Dt,``).split(/[:= ]/u)[0]??``).split(`.`).at(-1)?.replace(/\[\d+\]$/u,``)??``,kt=e=>xt.has(Ot(e)),O=e=>kt(e)||!A(e)&&e.child.some(O),k=e=>kt(e)?D(e):O(e)?e.child.reduce((e,t)=>e+k(t),1):1,A=e=>Dt.test(e.line.trimStart()),At=e=>e.line.trimStart().startsWith(`... `),jt=e=>[e.line,...e.child.flatMap(jt)];function Mt(e,t){if(e.reduce((e,t)=>e+D(t),0)<=t)return e.flatMap(jt);if(!e.some(A)||!e.every(e=>A(e)||At(e)))return Ft(e,t);let n=e.filter(At).map(({line:e})=>e);return[...Pt(e.filter(A),t-n.length),...n]}function Nt(e,t){return t>=D(e)?jt(e):t<=1?[`${e.line} (+${D(e)-1} lines)`]:[e.line,...Mt(e.child,t-1)]}function Pt(e,t){let n=Math.max(1,Math.floor((t-1)/Math.min(e.length,St))),r=[],i=0;for(let a of e){let e=Math.min(n,D(a));if(r.length+e>t-1)break;r.push(...Nt(a,e)),i+=1}let a=` `.repeat(Et(e[0]?.line??``));return i===e.length?r:[...r,`${a}... ${e.length-i} more`]}function Ft(e,t){let n=e=>e.reduce((e,t)=>e+k(t),0);if(e.length>t||n(e)>t&&e.some(e=>k(e)===1)){let r=e.toSorted((e,t)=>Number(O(t))-Number(O(e))||D(e)-D(t)).slice(0,Math.max(0,t-1));for(;r.length>1&&k(r.at(-1)??e[0]??{line:``,child:[]})===1&&n(r)>t-1;)r.pop();let i=` `.repeat(Et(e[0]?.line??``)),a=Ft(e.filter(e=>r.includes(e)),t-1),o=e.filter(e=>!r.includes(e)).map(Ot),s=o.slice(0,10).join(`, `),c=o.length>10?`, ...`:``;return[...a,`${i}... ${o.length} more fields: ${s}${c}`]}let r=e.map(e=>({node:e,allotted:1})),i=t-e.length,a=(e,t)=>e.forEach((n,r)=>{let a=Math.min(t(n.node)-n.allotted,Math.floor(i/(e.length-r)));n.allotted+=a,i-=a});return a(r.filter(({node:e})=>k(e)>1).toSorted((e,t)=>k(e.node)-k(t.node)),k),a(r.toSorted((e,t)=>D(e.node)-e.allotted-(D(t.node)-t.allotted)),D),r.flatMap(({node:e,allotted:t})=>Nt(e,t))}function It(e,t){let n=e.requestBody?.[0],r={operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,scope:e.projection.scope,requiredInput:Rt(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]},i=Bt(e);return t?{...r,...i===void 0?{}:{paidPlan:i},resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:mt(e)}:{...r,optionalInput:zt(e),arrayInput:Vt(e),...i===void 0?{}:{paidPlan:i}}}function Lt(e){let t=mt(e),n=e=>e.filter(e=>e.required);return{...It(e,!1),optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function Rt(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function zt(e){let t=e.requestBody?.[0],n=new Set(t?.requiredPath??[]);return{query:e.parameter.filter(e=>e.in===`query`&&!e.required).map(({name:e})=>e),body:(t?.parameter??[]).filter(({name:e})=>!n.has(e)).map(({name:e})=>e)}}function Bt(e){return e.response.find(({status:e})=>e===`402`)?.description}function Vt(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var Ht=160,j=`Operation catalog matches`,Ut=[`whole`,`described`,`requiredDescribed`,`optionalNamed`],Wt=e=>`${[j,...e].join(`
14
+ `)}\n`,Gt=e=>yt([j,...e]);function Kt(e){if(!Array.isArray(e)||e.length===0||!e.every(Zt))return null;let t=e;for(let e of Ut){let n=[...t.flatMap(t=>Yt(t,e)),...Jt(t,e)];if(Gt(n))return Wt(n)}let n=e=>[...t.slice(0,e).flatMap(e=>Yt(e,`optionalNamed`)),...Jt(t.slice(0,e),`optionalNamed`),`... ${t.length-e} more operations omitted to fit ${T} UTF-8 bytes: ${t.slice(e).map(({operationId:e})=>e).join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`];return Wt(n([...t.keys()].findLast(e=>e>0&&Gt(n(e)))??1))}var qt="the CLI's `aventure help <operationId> --data` prints every input";function Jt(e,t){return e.some(e=>`optionalDetailOmitted`in e)?[`... optional argument details omitted: the full list exceeds the result cap; ${qt}.`]:t===`whole`||t===`described`||!e.some(e=>`argument`in e)?[]:[`... ${t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`} omitted to fit ${T} UTF-8 bytes; structuredContent carries them, and ${qt}.`]}function Yt(e,t){let n=`argument`in e?Object.values(e.argument).flat():[],r=n.filter(({required:e})=>!e).map(({name:e})=>e);return[`${e.operationId} ${e.method} ${e.path} (aventure_${e.intent})`,` ${e.summary}`,` required: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}`,` responseContentType: ${e.responseContentType.length===0?`none`:e.responseContentType.join(`, `)}`,...`optionalInput`in e?Object.entries(e.optionalInput).filter(([,e])=>e.length>0).map(([e,t])=>` optional ${e}: ${t.join(`, `)}`):[],...`arrayInput`in e&&e.arrayInput.length>0?[` JSON array inputs: ${e.arrayInput.join(`, `)}`]:[],...`paidPlan`in e&&e.paidPlan!==void 0?[` paid plan: ${e.paidPlan}`]:[],...n.filter(({required:e})=>e||t!==`optionalNamed`).map(e=>Xt(e,e.required||t!==`requiredDescribed`,t)),...t===`optionalNamed`&&r.length>0?[` optional inputs: ${r.join(`, `)}`]:[]]}function Xt(e,t,n){let r=[e.location,e.required?`required`:void 0,e.schemaType,e.schemaFormat,e.schemaEnum===void 0?void 0:`choices: ${e.schemaEnum.join(`, `)}`,e.itemSchemaEnum===void 0?void 0:`item choices: ${e.itemSchemaEnum.join(`, `)}`,e.schemaDefault===void 0?void 0:`default: ${JSON.stringify(e.schemaDefault)}`,e.itemSchemaType===void 0?void 0:`items: ${e.itemSchemaType}${e.itemSchemaFormat===void 0?``:` (${e.itemSchemaFormat})`}`].filter(e=>e!==void 0).join(`, `),i=` ${e.name} (${r})`;return t?`${i}: ${n===`whole`||e.description.length<=Ht?e.description:`${e.description.slice(0,157)}...`}`:i}function Zt(e){return typeof e==`object`&&!!e&&`operationId`in e&&typeof e.operationId==`string`&&`requiredInput`in e&&Array.isArray(e.requiredInput)&&`intent`in e&&`summary`in e}function Qt(e){let t=t=>{let n=e.parameter.filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map($t);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`),i=[...new Set((e.requestBody?.[0]?.requiredPath??[]).map(e=>e.replace(/[.[].*$/su,``)))];return{tool:ie(e.intent),operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Object.fromEntries(i.map(e=>[e,`<${e}>`]))}}}function $t(e){return[e.name,`<${e.name}>`]}function en(e){let t=tn(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function tn(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}var M=2,nn=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`));function N(e,t){let n=I(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&N(e,`person`),on(e,rn(n),n),on(e,an(n),n))}function rn(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=M&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${e.slice(0,-3)}y`;if(e.length>M&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function an(e){if(e===`person`)return`people`;if(e!==`new`)return e.length>=M&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e)?`${e.slice(0,-1)}ies`:e.endsWith(`s`)?void 0:`${e}s`}function on(e,t,n){t!==void 0&&t!==n&&t.length>=M&&/^[a-z]+$/u.test(t)&&e.add(t)}function P(e){let t=new Set(F(e)),n=Array.from(t);for(let e of n)N(t,e);return t}function sn(e){return F(e).map(P)}function cn(e,t){if(e.length===0)return!1;let n=P(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function F(e){return I(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!nn.has(e))}function I(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}var ln=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,un=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,dn=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,fn=250,pn=40,mn=100;function hn(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(un,()=>(n.add(`uuid`),` `)).replace(ln,e=>{n.add(`url`);let t=e.replace(/^(?:https?:\/\/)?[^/]+/iu,``).replace(/[?#].*$/su,``).split(`/`).filter(e=>e.length>0).map(e=>e.toLowerCase()),i=t.at(-1);return i!==void 0&&dn.test(i)&&(n.add(`slug`),t.pop()),r.push(...t.flatMap(e=>e.split(/[^a-z0-9]+/u))),` `}).split(/\s+/u).filter(e=>{let r=e.replace(/^[^a-z0-9]+|[^a-z0-9]+$/giu,``).toLowerCase(),a=dn.test(r)&&!t.has(r)&&(i||/\d/u.test(r));return a&&n.add(`slug`),!a}).join(` `).trim(),kind:n,urlPathWord:r.filter(e=>e.length>0)}}function gn(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function _n(e,t){let n=new Set;for(let r of e){let e=new Set;N(e,r);let i=t.filter(({cliPath:t})=>e.has(t[0]??``)),a=i.length>0?i:t.filter(({cliPath:t})=>t.some(t=>e.has(t)));for(let{resource:e}of a)n.add(e)}return n}function vn(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(F(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>gn(t,e,n.path))&&(i+=fn,r.has(t)&&(i+=pn));if(i===0)return 0;let a=new Set(F(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return N(t,e),[...t].some(e=>a.has(e))}))&&(i+=mn),i}var yn=40,bn=4,xn=3,Sn=1,Cn=new Map;function wn(e){let t=Cn.get(e);if(t!==void 0)return t;let n=m(),r=ne(n.paths,e),i=r===null?new Map:oe(n,r.operation.responses,xn);return Cn.set(e,i),i}function Tn(e,t,n){let r=0,i=new Map;for(let[e,a]of n){if(t.has(e.toLowerCase())&&(r+=yn*(4-a)/4),a>Sn)continue;let n=new Set;for(let t of F(e))N(n,t);for(let e of n)i.set(e,Math.min(i.get(e)??a,a))}for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=Sn&&(r+=bn*(2-e))}return r}var En=5,Dn=.5,On=15,kn=30,An=2,jn=.5;function Mn(e,t,n){let r=t.map(e=>({item:e,fields:n(e)})),i=hn(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=_n(i.urlPathWord,r.map(({fields:e})=>e)),o=I(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=P(o),c=sn(o),l=new Set(i.text.toLowerCase().split(/[^a-z0-9]+/u));return r.map(({item:e,fields:t})=>({item:e,fields:t,score:(o.length===0?0:In({normalizedQuery:o,tokens:s,termForm:c,queryWord:l},t))+vn(i,a,t)})).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}function Nn(e){let t=[...e.parameter,...(e.requestBody??[]).flatMap(e=>e.parameter)];return{...e,cliPath:e.projection.cliPath,enumParameter:t.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:t.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...e.parameter,...e.requestBody??[],...(e.requestBody??[]).flatMap(e=>e.parameter)].map(({description:e})=>e),responseFieldLevel:wn(e.operationId)}}function Pn(e,t){let n=e.q?.trim()??``,r=Mn(n,t.filter(t=>Fn(e,t)&&(n.length>0||t.deprecated!==!0)),Nn),i=(r[0]?.score??0)*Dn,a=r.filter(({score:e})=>e>=i),o=e.limit===void 0||!Number.isFinite(e.limit)?En:e.limit,s=Math.min(a.length,Math.max(0,Math.trunc(o))),c=a.slice(0,s).map(({item:e})=>e),l={totalOperations:t.length,matched:a.length,returned:c.length},u=c.map(e=>It(e,c.length===1));return{summary:j,data:ee(h(j,u,{counts:l}))?u:c.map(Lt),counts:l}}function Fn(e,t){let{root:n}=e;return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function In({normalizedQuery:e,tokens:t,termForm:n,queryWord:r},i){let a=Hn(i),o=Bn(i),s=0;a.some(t=>t===e)&&(s+=100),a.some(t=>t.includes(e))&&(s+=40),s+=Vn(e,a);let c=new Set(a.flatMap(F));for(let e of t)a.some(t=>t===e)?s+=20:c.has(e)&&(s+=8);for(let e of i.cliPath){let n=new Set;N(n,e),[...n].some(e=>t.has(e))&&(s+=On)}cn(n,o)&&(s+=200),i.parameterName.some(t=>I(t)===e)&&(s+=kn);let l=new Set(i.parameterDescription.flatMap(F));for(let e of t)l.has(e)&&(s+=An);return s+=Wn(t,i.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(i.operationId)&&(s+=30),s+=Tn(n,r,i.responseFieldLevel),s-=Un(e,t,i.description),v(i.intent)&&!zn(r)?s*jn:s}var Ln=`edit change set fix rename link unlink mark publish correct`.split(` `),Rn=new Set([...Object.entries(ce).filter(([,e])=>v(e)).map(([e])=>e),...Ln]);function zn(e){return[...e].some(e=>Rn.has(e))}function Bn(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(I).filter(e=>e.length>0)}function Vn(e,t){let n=F(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function Hn(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,tn(e.description).useFor||e.description].map(I).filter(e=>e.length>0))]}function Un(e,t,n){let r=I(tn(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(F(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function Wn(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>Gn(e,t))&&(n+=i?40:10);return n}function Gn(e,t){let n=F(t);return n.length>0&&n.every(t=>e.has(t))}function Kn(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function qn(e,t,n,r){let i=e.q?.trim()??``;if(i.length===0)return _(`Provide q to resolve a request to one operation.`);let a=n.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(a===void 0)return _(`This build ships no help resolve operation.`);let o=await r(a,{body:{question:i,resolve:!0,...e.scope===void 0?{}:{scope:e.scope===`read`?`READ`:`WRITE`}}});if(!o.ok)return{...o,data:null};let s=et.safeParse(Kn(o));if(!s.success||s.data.resolution==null)return _(`The help resolve operation returned no resolution.`);let{answer:c,resolution:l}=s.data,u=e=>t.find(t=>t.operationId===e),d=u(l.operationId),f=l.taskPlan??void 0,p=(f?.step??[]).map(({step:e})=>({step:e,contract:u(e.operationId)})),m=[...new Set([...l.operationId!=null&&d===void 0?[l.operationId]:[],...p.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return m.some(e=>!n.some(t=>t.operationId===e))?_(`No operation on this connection answers that request.`):h(m.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${m.join(`, `)}.`,{outcome:l.outcome,probability:l.probability,answer:c,candidate:l.candidate.map(({sourceId:e})=>e).filter(e=>n.some(({operationId:t})=>t===e)),...d===void 0?{}:{operation:{operationId:d.operationId,apiRoute:`${d.method} ${d.path}`,...en(d),mcpCall:Qt(d)}},...(l.taskKey,{}),...f===void 0?{}:{taskPlan:{input:f.input,step:p.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:Qt(e)})}}},{warnings:m.map(e=>n.some(t=>t.operationId===e)?`Operation ${e} is in this server's catalog, but your grant does not allow it.`:`Operation ${e} is outside this server's catalog, so no credential runs it here.`)})}var Jn=p({detail:f(),field:f().nullish(),scope:s([`entity`,`person`,`news`])}),Yn=s([`auto`,`exact`,`keyword`,`semantic`,`natural`,`hybrid`]),Xn=Object.assign(r([Yn,f()]),{enum:Yn.enum}),L=p({modeRequested:Xn,modeUsed:Xn}),Zn=p({answerUnavailable:u(),entity:L,news:L,person:L,rejection:a(Jn),unavailable:a(s([`entity`,`person`,`news`]))}),Qn=p({acceleratorParticipation:a(we),detail:a(Te)}),R=p({core:b,enrichment:Re,fundraiseRound:a(Le),research:Qn,semanticMatch:je.nullish()}),$n=s([`curated`,`semantic`,`precomputed`,`derived`,`computed`]),er=p({compositeScore:d().nullish(),cosineScore:d().nullish(),curatedAsOf:f().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),curatedRelationshipType:f().nullish(),curatedSource:f().nullish(),derivedFromEntityId:n().nullish(),matchedSectionWeight:d().nullish(),origin:$n,rank:c(),sharedSectionCount:c().nullish()}),tr=p({entity:R,similarity:er}),nr=p({fundraiseInvestorJoin:u(),fundraiseTransaction:u(),operatingStatus:u(),relationship:u()}),rr=s([`Acquisition`,`Acquired`,`Acquired Subsidiary`]),ir=s([`Announced`,`Announced; subject to approvals and closing conditions`,`Active`,`Closed`,`Completed`,`In Progress`,`Open`]),ar=p({acquiredEntity:b,acquirerEntity:b,amount:d().int().nullish(),announcedAt:f().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),asOf:f().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),completedAt:f().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/).nullish(),createdAt:i({offset:!0}).nullish(),currency:f().nullish(),dataConfidence:ze.nullish(),evidence:nr,fundraiseTransactionId:n().nullish(),investorJoinId:n().nullish(),isCurrent:u().nullish(),publicSource:ge.nullish(),relationshipId:c(),status:rr,transactionStatus:ir.nullish(),updatedAt:i({offset:!0}).nullish()}),or=s([`SAFE`,`Convertible Note`,`Preferred Stock`,`Common Stock`,`Other Equity`,`Bond`,`Loan`,`Other Debt`,`Grant`,`Token`]),sr=p({amountInvested:d().nullish(),createdAt:i({offset:!0}),financialInstrumentType:or.nullish(),id:n(),investor:l,leadInvestor:u(),transactionId:n(),updatedAt:i({offset:!0})}),cr=p({entity:Fe,investorAttribution:a(Be),round:a(be),roundCount:c()}),lr=p({core:b,fundingDetail:pe.nullish(),similarity:er,urlLink:a(_e)}),ur=p({compliance:ke.nullish(),createdAt:i({offset:!0}).nullish(),id:c(),isCurrent:u().nullish(),isPrimary:u().nullish(),language:f().nullish(),owner:l,text:f(),textName:f().nullish(),textType:f(),updatedAt:i({offset:!0}).nullish()}),dr=s([`stored`,`derivedFromPreAndRaised`,`derivedFromPostMinusRaised`,`reportedAssumedPost`]),fr=s([`fundraiseRound`,`researchDetail`]),pr=s([`preMoney`,`postMoney`,`reported`]),mr=p({amountRaised:d().int().nullish(),asOfDate:f().regex(/^(?!0000)[0-9]{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?(?:Z|[+-](?:(?:0[0-9]|1[0-7]):[0-5][0-9]|18:00)))?)?)?$/),confidence:Oe,currency:f(),declaredBasis:pr,derivation:dr,detailId:c().nullish(),label:f().nullish(),source:fr,sourceRef:f(),valuationPostMoney:d().int().nullish(),valuationPreMoney:d().int().nullish()}),hr=p({createdAt:i({offset:!0}).nullish(),description:f().nullish(),forkCount:c(),githubId:d().int(),homepageUrl:f().nullish(),id:d().int(),isArchived:u(),isFork:u(),language:f().nullish(),license:f().nullish(),name:f(),ownerLogin:f(),repoCreatedAt:i({offset:!0}).nullish(),repoPushedAt:i({offset:!0}).nullish(),stargazerCount:c(),topic:a(f()),updatedAt:i({offset:!0}).nullish(),url:f()}),z=p({empty:u().optional(),sorted:u().optional(),unsorted:u().optional()}),B=p({offset:d().int().optional(),paged:u().optional(),pageNumber:c().optional(),pageSize:c().optional(),sort:z.optional(),unpaged:u().optional()}),gr=p({investorAttribution:a(Be),person:Ne,round:a(be),roundCount:c()}),_r=s([`by`,`about`]),vr=s([`newsArticle`,`blogPost`,`externalSocialPost`,`repositoryOwner`,`repository`,`webSite`,`webPage`,`researchPaper`]),yr=p({canonicalUrl:f().nullish(),contentId:f(),contentType:vr,createdAt:i({offset:!0}).nullish(),publishedAt:i({offset:!0}).nullish(),relation:_r.nullish(),sourceDomain:f().nullish(),sourceName:f().nullish(),summary:f().nullish(),title:f(),topic:f().nullish(),updatedAt:i({offset:!0}).nullish(),url:f().nullish(),year:c().nullish()});p({content:a(Se).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(r([De,he])).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(xe).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(b).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(ar).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Fe).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(sr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Le).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(cr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(R).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Ie).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(ve).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Te).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Me).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(tr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(lr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(ur).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(_e).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(mr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(hr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Ce).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(ye).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Ne).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Pe).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(gr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(Ee).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()}),p({content:a(yr).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()});var br=p({content:a(R),number:c(),size:c(),totalElements:d().int(),totalPages:c()}),xr=p({content:a(Ce),number:c(),size:c(),totalElements:d().int(),totalPages:c()}),Sr=p({content:a(ye),number:c(),size:c(),totalElements:d().int(),totalPages:c()});p({content:a(Ae).optional(),empty:u().optional(),first:u().optional(),last:u().optional(),number:c().optional(),numberOfElements:c().optional(),pageable:B.optional(),size:c().optional(),sort:z.optional(),totalElements:d().int().optional(),totalPages:c().optional()});var Cr=s([`entityRecord`,`researchSnippet`,`newsArticle`,`personRecord`,`fundraiseTransaction`]),wr=Object.assign(r([Cr,f()]),{enum:Cr.enum}),Tr=p({entityId:n(),source:wr,sourceId:f()}),Er=p({citation:a(Tr),text:f(),topic:f().nullish()}),Dr=p({citation:a(Tr),confidence:S,description:f().nullish(),heading:f().nullish(),paragraph:a(Er),relatedQuery:a(f()),shareable:u(),text:f(),title:f().nullish()}),Or=p({enrichmentRunId:n().nullish(),entityId:n()}),kr=p({sortPriority:s([`NONE`,`ANY_LOGO_FIRST`,`REAL_LOGO_FIRST`]).optional()}),Ar=p({max:i({offset:!0}).nullish(),min:i({offset:!0}).nullish()}),V=p({max:d().nullish(),min:d().nullish()}),H=p({max:c().nullish(),min:c().nullish()}),jr=p({averageAmountInvestedUsdRange:a(V).optional(),largestAmountInvestedUsdRange:a(V).optional(),smallestAmountInvestedUsdRange:a(V).optional(),totalAmountInvestedUsdRange:a(V).optional(),totalInvestmentRange:a(H).optional()}),Mr=p({amountInvestedRange:a(V).optional(),amountRaisedRange:a(V).optional(),dateAnnouncedRange:Ar.nullish(),investedCompanyName:a(f()).optional(),investedCountry:a(f()).optional(),investedIndustry:a(f()).optional(),investedRound:a(f()).optional(),investorActivity:jr.optional(),investorName:a(f()).optional(),lastRoundYearRange:a(H).optional(),rankByInvestmentActivity:u().nullish(),round:a(f()).optional(),totalRaisedRange:a(V).optional(),valuationRange:a(V).optional()}),Nr=s([`NONE`,`COMPANY_LISTING_READY`]),Pr=s([`Operating`,`Acquired`,`Acquired Subsidiary`,`Closed`,`Closed (Acquihire)`,`Inactive`]),Fr=s([`hostPath`,`domain`]),Ir=t({acceleratorBrand:a(f()).optional(),acceleratorCohort:a(f()).optional(),acceleratorName:a(f()).optional(),acceleratorStatus:a(f()).optional(),affinity:a(f()).optional(),closedLast:u().optional(),employeeCountRange:a(H).optional(),entityId:a(n()).optional(),entityName:a(f()).optional(),featured:u().nullish(),fundraiseActivity:Mr.optional(),hasFundraising:u().nullish(),headquartersCity:a(f()).optional(),headquartersCountry:a(f()).optional(),headquartersState:a(f()).optional(),industry:a(f()).optional(),letter:f().nullish(),location:a(f()).optional(),logoOption:kr.optional(),mainProduct:a(f()).optional(),operatingStatus:a(Pr).optional(),originCountry:a(f()).optional(),person:a(f()).optional(),portfolioHeadquartersCity:a(f()).optional(),portfolioHeadquartersCountry:a(f()).optional(),portfolioHeadquartersState:a(f()).optional(),qualityGate:Nr.optional(),rankByProminence:u().nullish(),semanticQuery:f().nullish(),slug:a(f().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:a(f()).optional(),suppressLateStage:u().nullish(),suppressNonOperating:u().nullish(),suppressZeroTotalRaised:u().nullish(),tag:a(f()).optional(),textSearch:f().nullish(),typeCustomer:a(f()).optional(),typeModel:a(f()).optional(),typeOwnership:a(f()).optional(),typeRecord:a(o).optional(),typeRevenue:a(f()).optional(),typeTechnologyUsed:a(f()).optional(),url:f().nullish(),urlDomain:f().nullish(),urlMatchMode:Fr.nullish(),urlType:me.nullish(),yearFoundedRange:a(H).optional()}),Lr=s([`discovery`,`profile`,`peer`,`comparison`]),Rr=s([`keyword`,`semantic`]),zr=s([`ID`,`NAME_BRAND`,`YEAR_FOUNDED`,`STATUS_OPERATING`,`UPDATED_AT`,`CREATED_AT`,`NEXT_DUE_AT`,`DATA_COMPLETION_COVERAGE`,`TOTAL_RAISED`,`AMOUNT_INVESTED`,`RECENT_INVESTMENT_AT`,`STAGE`,`MOST_RECENT_AMOUNT`,`LATEST_VALUATION`,`MOST_RECENT_DATE`,`ACCELERATOR_BRAND`,`ACCELERATOR_COHORT`,`HEADQUARTERS_COUNTRY`,`EMPLOYEE_COUNT`]),Br=Object.assign(r([zr,f()]),{enum:zr.enum}),Vr=p({descending:u(),field:Br,sortKey:f().nullish()}),Hr=p({order:a(Vr),relevance:Rr.nullish()}),Ur=p({confidence:S,execution:L,fallbackUsed:u(),filter:Ir,intent:Lr,interpretation:f(),sort:Hr,subjectEntityName:a(f()),unsupported:f().nullish()}),Wr=p({changedAt:i({offset:!0}).nullish(),dataSourceUpdatedAt:i({offset:!0}).nullish(),pendingApproval:c().nullish(),sourceId:f().nullish(),status:f().nullish()}),Gr=p({fundManagerRelationshipSource:Wr.nullish(),fundraiseTransaction:Le,fundraiseTransactionSource:Wr.nullish(),investorJoinSource:Wr.nullish()}),Kr=p({evidence:Gr,investor:l,semanticMatch:je.nullish()}),qr=p({entityId:n(),matchedOffering:b.nullish(),probability:d(),webUrl:a(f())}),Jr=p({entityId:n(),label:f(),publishedAt:i({offset:!0}).nullish(),score:d(),source:wr,sourceId:f(),text:f(),url:f().nullish()}),Yr=p({answer:Dr.nullish(),filing:a(Or).nullish(),interpretation:Ur,investment:a(Kr),judgment:a(qr),passage:a(Jr),peer:a(tr),pendingWebQuery:a(f()),result:br,searchRequestId:n().nullish(),subject:a(R)}),Xr=s([`auto-match`,`needs-review`,`approved`,`rejected`]),Zr=p({createdAt:i({offset:!0}),entityId:n(),href:f().nullish(),internal:u(),matchStatus:Xr.nullish(),mention:f().nullish(),slug:f().regex(/^[a-z0-9_-]+$/).max(255).nullish(),typeRecord:o.nullish(),updatedAt:i({offset:!0})}),Qr=p({entity:a(Zr),newsId:c()}),$r=t({acceleratorBrand:a(f()).optional(),acceleratorCohort:a(f()).optional(),acceleratorName:a(f()).optional(),acceleratorStatus:a(f()).optional(),affinity:a(f()).optional(),closedLast:u().optional(),employeeCountRange:a(H).optional(),entityId:a(n()).optional(),entityName:a(f()).optional(),featured:u().nullish(),fundraiseActivity:Mr.optional(),hasFundraising:u().nullish(),headquartersCity:a(f()).optional(),headquartersCountry:a(f()).optional(),headquartersState:a(f()).optional(),industry:a(f()).optional(),letter:f().nullish(),location:a(f()).optional(),logoOption:kr.optional(),mainProduct:a(f()).optional(),operatingStatus:a(Pr).optional(),originCountry:a(f()).optional(),person:a(f()).optional(),portfolioHeadquartersCity:a(f()).optional(),portfolioHeadquartersCountry:a(f()).optional(),portfolioHeadquartersState:a(f()).optional(),qualityGate:Nr.optional(),rankByProminence:u().nullish(),slug:a(f().regex(/^[a-z0-9_-]+$/).max(255)).optional(),stage:a(f()).optional(),suppressLateStage:u().nullish(),suppressNonOperating:u().nullish(),suppressZeroTotalRaised:u().nullish(),tag:a(f()).optional(),textSearch:f().nullish(),typeCustomer:a(f()).optional(),typeModel:a(f()).optional(),typeOwnership:a(f()).optional(),typeRecord:a(o).optional(),typeRevenue:a(f()).optional(),typeTechnologyUsed:a(f()).optional(),url:f().nullish(),urlDomain:f().nullish(),urlMatchMode:Fr.nullish(),urlType:me.nullish(),yearFoundedRange:a(H).optional()}),ei=p({amountInvestedRange:a(V).nullish(),amountRaisedRange:a(V).nullish(),entityName:a(f()).nullish(),investedCompany:a(f()).nullish(),personTitle:a(f()).nullish(),round:a(f()).nullish(),totalInvestmentCount:a(H).nullish(),typeRecord:a(o).nullish()}),ti=p({arrayFilter:ei.optional(),entityFilter:$r.optional(),entityId:n().nullish(),entitySlug:f().nullish(),firstName:f().nullish(),includeAddress:u().nullish(),includeUrl:u().nullish(),investorActivity:jr.optional(),isCurrent:u().nullish(),lastName:f().nullish(),letter:f().nullish(),personId:a(n()).max(200).optional(),personName:a(f()).optional(),role:f().nullish(),search:f().nullish(),semanticQuery:f().nullish(),status:f().nullish()}),ni=p({descending:u(),field:s([`ID`,`FIRST_NAME`,`LAST_NAME`,`FULL_NAME`,`SLUG`,`CREATED_AT`,`UPDATED_AT`,`STATUS`,`GENDER`,`AMOUNT_INVESTED`,`TOTAL_INVESTMENTS`]),sortKey:f().nullish()}),ri=p({order:a(ni),relevance:Rr.nullish()}),ii=p({confidence:S,execution:L,fallbackUsed:u(),filter:ti,interpretation:f(),sort:ri,unsupported:f().nullish()}),ai=p({interpretation:ii,investment:a(Kr),result:Sr,searchRequestId:n().nullish()}),oi=p({label:f(),query:f()}),si=p({key:f(),option:a(oi),prompt:f()}),ci=p({entity:Yr,entityDetail:a(Fe),news:xr,newsEntityMention:a(Qr),person:ai,personDetail:a(Ne),provenance:Zn,qualifier:si.nullish()});function li(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>ui(e)),...n.flatMap(e=>e.parameter.map(t=>ui(t,n.length>1?e.contentType:void 0))),...di(n)],i=[t,...e.cliPath].join(` `),a=v(e.intent),o=ae(e),s=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:le(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse||!se(e.path)||o===null?null:ie(o),body:{hasBody:s!==void 0,kind:s?.kind??null,...s!==void 0&&n.length>1?{contentType:s.contentType}:{},required:s?.required??!1,description:s?.description??``,requiredPath:s?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function ui(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function di(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request body encoding, never an uploaded file's media type; omit for ${t[0]}.`,choices:t}]}function fi(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var pi=[`-id`,`-slug`,`-url`],mi=[`--id`,`--slug`,`--url`],hi=`/v1/lookup`,gi=`--from-file "<path>"`;function _i(e,t,n=te().bin[0]){let r=li(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:xi(i,r)}function vi(e,t,n=te().bin[0]){let r=t.find(t=>t.operationId===e),[i]=r===void 0?[]:li([r],n);return i&&bi(i,wi(i,!1))}function yi(e,t,n,r=te().bin[0]){let i=e=>{let t=e.findIndex((e,t)=>n[t]!==e);return t===-1?e.length:t},a=`${n[0]} get`,[o,s]=t.filter(({method:t,path:n,parameters:r,cliPath:o})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return t===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===e&&n.endsWith(`/{${c.name}}`)&&(i(o)>1||o.join(` `)===a)}).toSorted((e,t)=>i(t.cliPath)-i(e.cliPath));if(o!==void 0&&(s===void 0||i(s.cliPath)!==i(o.cliPath)))return vi(o.operationId,t,r)}function bi(e,t){return[e.cli.command,...t,`--data`].join(` `)}function xi(e,t){return[`example: ${bi(e,wi(e))}`,...Si(e,t)]}function Si(e,t){return fi(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${Ei(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===hi),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${Ei(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var Ci=/(?:^|\.)text$/u;function wi(e,t=!0){let n=fi(e).filter(e=>e.required),r=e.body.kind===`json`&&n.some(e=>e.location===`body`&&Ci.test(e.wireName))?n.filter(e=>e.location!==`body`):n,i=(n.length>0||!t?r:Ti(e)).map(Ei);return(e.body.required||e.body.requiredPath.length>0)&&!r.some(e=>e.location===`body`)?[...i,gi]:i}function Ti(e){let t=new Set;N(t,e.resource);for(let n of pi)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of mi){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function Ei(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var Di=`aventure`;function Oi(e,t){let n=t.find(t=>t.operationId===e)?.cliPath;return n===void 0?void 0:`${Di} ${n.join(` `)}`}function ki(e,t,n=e){return vi(e,t,`aventure`)??n}function Ai(e,t){let n=et.safeParse(e);if(!n.success)return null;let{answer:r,citation:i,confidence:a,resolution:o}=n.data;if(o!=null)return ji(r,o,t);let s=r.trimEnd().split(`
15
+ `),c=new Set(i.flatMap(({sourceType:e,sourceId:n})=>{if(e!==We.options[0].enum.OPERATION)return[];let r=Oi(n,t);return r===void 0?[]:[r]}));return c.size>0&&s.push(``,`Commands:`,...[...c].map(e=>` ${e}`)),s.push(``,`Confidence: ${a}`),i.length===0?s:(s.push(`Sources (${i.length}):`),s.push(...i.map(({excerpt:e,sourceId:t})=>{let n=e.trim();return n.length>0?` - ${t}: ${n}`:` - ${t}`})),s)}function ji(e,t,n){let{outcome:r,operationId:i,probability:a,candidate:o,taskKey:s,taskPlan:c}=t,l=[c==null?e.trimEnd():Ni(c)],u=[``,`Outcome: ${r}${a==null?``:` (probability ${a.toFixed(2)})`}`];switch(r){case C.enum.TASK_PLAN:return[...l,...c==null?[]:Pi(c,n),...u];case C.enum.OPERATION_ADVICE:{let e=o.filter(({sourceId:e})=>e!==i);return[...l,...i==null?[]:[``,`Command:`,` ${ki(i,n)}`],...u,...e.length===0?[]:[`Alternatives: ${e.map(({sourceId:e})=>e).join(`, `)}`]]}case C.enum.CLARIFY:return[...l,...s==null?[]:[``,`Leading catalog task: ${s}`],...Ii(`Candidates:`,o,n),...u];case C.enum.ABSTAIN:return[...l,...Ii(`Nearest operations:`,o,n),...u];default:throw Error(`Unhandled help resolution outcome ${String(r)}`)}}function Mi(e,t){let n=Qe.safeParse(e);return n.success?[Ni(n.data),...Pi(n.data,t)]:null}var Ni=({taskKey:e,catalogRevision:t})=>e===void 0?`Run these steps in order.`:`Run catalog task ${e}${t===void 0?``:` (catalog revision ${t})`}.`;function Pi(e,t){return e.step.length===0?[``,`This catalog task has no planned steps yet.`]:[...e.input.length===0?[]:[``,`Inputs:`,...e.input.map(({key:e,type:t,description:n})=>` ${e} (${t}): ${n}`)],``,`Steps:`,...e.step.flatMap(({step:n,cliCommand:r,writeGuidance:i},a)=>[` ${a+1}. ${n.stepKey===void 0?``:`${n.stepKey}: `}${ki(n.operationId,t,r)}`,` ${n.instruction}`,...Fi(e,a,i)]),...e.gateId?.length?[``,`Completion gates: ${e.gateId.join(`, `)}`]:[]]}function Fi(e,t,n){if(n==null)return[];let r=JSON.stringify(n),i=e.step.findIndex(({writeGuidance:e})=>JSON.stringify(e)===r);return i===t?[` Write guidance:`,` - Expectation: ${n.expectation}`,` - Body: ${n.body}`,` - Read first: ${n.typeCatalog}`,` - Rejected when:`,...n.reject.map(e=>` - ${e}`),` - Override: ${n.override}`,` - Method: ${n.method.join(`; `)}`]:[` Write guidance: as step ${i+1}.`]}function Ii(e,t,n){if(t.length===0)return[];let r=t.map(({sourceId:e,excerpt:t})=>({command:Oi(e,n)??e,excerpt:t})),i=Math.max(...r.map(({command:e})=>e.length));return[``,e,...r.map(({command:e,excerpt:t})=>` ${e.padEnd(i)} # ${t}`)]}var U=30,Li=8,W=10,Ri=2,zi=[`id`,`association.associationId`,`slug`,`name`,`nameBrand`,`nameFull`,`core.nameBrand`,`core.nameFull`,`core.slug`,`core.typeRecord`,`entity.core.nameBrand`,`entity.core.slug`,`title`,`sourceName`,`publishedAt`,`round`,`dateAnnounced`,`amountRaised`,`investorAttribution.amountInvested`,`stage`,`updatedAt`,`createdAt`],Bi=new Set([`page`,`size`,`sort`,`cursor`,`mode`,`projection`]),Vi=[`interpretation`,`confidence`,`unsupported`,`execution`,`fallbackUsed`];function Hi(e,t,n){if(typeof t==`string`)return bt(t);let r=Kt(t);if(r!==null)return E(r);let i=$i(t);if(i===null)return null;let a=e.find(({operationId:e})=>e===i.operationId),{response:o,hiddenNote:s}=ue(a?.detailField,i.response),c={...i,response:o,parameters:a?.parameters??[]},l=Ai(c.response,e)??Mi(c.response,e);if(l!==null)return E(l.join(`
16
+ `),!0);let u=Ui(c);if(u!==null)return E([...u,...s].join(`
17
+ `),!0,s.length>0);let d=[c.summary??n??c.operationId??`OpenAPI call succeeded`,`${c.method} ${c.endpoint}`],f=Ct(qi(c),117-s.length,T-x.byteLength(`${[...d,...s].join(`
18
+ `)}\n`,`utf8`));return E([...[...d,...f].filter(Boolean),...s].join(`
19
+ `),!0,s.length>0)}function Ui({response:e,...t}){if(e===void 0||!Y(e)||!(`entity`in e&&`person`in e&&`news`in e))return null;let n=ci.safeParse(e);if(!n.success)return null;let{entity:r,person:i,news:a,provenance:o}=n.data;return[...r.answer?Wi(r.answer):[],...o.unavailable.map(e=>`${e} unavailable: retry this scope later`),...o.answerUnavailable?[`answer unavailable: retry this search later`]:[],...o.rejection.map(({scope:e,detail:t})=>y(`${e} rejected: ${t}`)),[`entities:`,...G(r.result,t)].join(`
20
+ `),[`people:`,...G(i.result,t)].join(`
21
+ `),[`news:`,...G(a,t)].join(`
22
+ `)]}function Wi(e){let t=`relatedQuery:\n${e.relatedQuery.map(e=>` - ${y(e)}`).join(`
23
+ `)}`,n=`citations:\n${e.citation.map(({source:e,sourceId:t,entityId:n})=>y(` - ${e}:${t} entity=${n}`)).join(`
24
+ `)}`;return[`answer:\n ${de(e.text).replaceAll(`
25
+ `,`
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};