@aventurevc/mcp-server 0.8.425 → 0.8.426

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 (27) hide show
  1. package/dist/chunks/{auth-resolver-BnK4x1vt.js → auth-resolver-BmJIQlrJ.js} +1 -1
  2. package/dist/chunks/{cli-help-policy-BX-whN-w.js → cli-help-policy-13I76Xu_.js} +1 -1
  3. package/dist/chunks/{contract-parameter-BsYdHniz.js → contract-parameter-BEjNGBMH.js} +1 -1
  4. package/dist/chunks/{contract-B2oibXOn.js → contract-zH7bZrs8.js} +1 -1
  5. package/dist/chunks/{env-Buhr_6D_.js → env-D4oMpzxb.js} +1 -1
  6. package/dist/chunks/{env-CC1-vnc-.js → env-D87fitNv.js} +1 -1
  7. package/dist/chunks/{help-catalog-BgXKbrdt.js → help-catalog-C0gb6USI.js} +1 -1
  8. package/dist/chunks/{help-intent-v1ouGBUB.js → help-intent-CK3kuZ3u.js} +1 -1
  9. package/dist/chunks/{logging-D7Z7a3sv.js → logging-B8EQigaJ.js} +1 -1
  10. package/dist/chunks/{logging-DqIIwQLm.js → logging-DqYFeXq0.js} +1 -1
  11. package/dist/chunks/{mcp-generation-contract-nD5keYgZ.js → mcp-generation-contract-DLEcZsPX.js} +1 -1
  12. package/dist/chunks/{oauth-discovery-DoJEKpY6.js → oauth-discovery-D2rLmm2M.js} +1 -1
  13. package/dist/chunks/{openapi-call-BiKamLmB.js → openapi-call-DVQ2Mfsw.js} +1 -1
  14. package/dist/chunks/openapi-snapshot.json +1 -1
  15. package/dist/chunks/{output-spill-DnYgVM4r.js → output-spill-CL4GDXGw.js} +1 -1
  16. package/dist/chunks/{private-readback-O02uf2R4.js → private-readback-BsoFytmm.js} +1 -1
  17. package/dist/chunks/{request-replay-Dq4didr7.js → request-replay-B3_y0f5A.js} +1 -1
  18. package/dist/chunks/{response-problem-BKDrFcVc.js → response-problem-XCQh8X_P.js} +1 -1
  19. package/dist/chunks/result-envelope-B3yDteWk.js +1 -0
  20. package/dist/chunks/{sentry-BGjCz4Gu.js → sentry-CwG-qe2R.js} +1 -1
  21. package/dist/chunks/{sentry-CoShnYF0.js → sentry-DpEg3Xls.js} +1 -1
  22. package/dist/chunks/{streamable-http-DhqAnoH9.js → streamable-http-3X4cqhSN.js} +1 -1
  23. package/dist/chunks/{text-response-DmgwEKZa.js → text-response-C1Yr8KM5.js} +1 -1
  24. package/dist/chunks/{tool-policy-BmDEaARa.js → tool-policy-Cn4OoupR.js} +1 -1
  25. package/dist/mcp-server/index.js +1 -1
  26. package/package.json +3 -3
  27. package/dist/chunks/result-envelope-Cqvvr4zX.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./env-CC1-vnc-.js";import{join as t}from"node:path";import{homedir as n,platform as r}from"node:os";function i(){if(r()===`win32`){let e=process.env.APPDATA??t(n(),`AppData`,`Roaming`);return t(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??t(n(),`.config`);return t(e,`aventure`,`config.json`)}function a(){let t=process.env[e.authToken];return typeof t==`string`&&t.length>0?{present:!0,source:`env`}:{present:!1,source:null}}var o;function s(t,n){process.env[e.authToken]=t,o=n}async function c(){return await o?.()}function l(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}export{a,c as i,l as n,s as r,i as t};
1
+ import{t as e}from"./env-D87fitNv.js";import{join as t}from"node:path";import{homedir as n,platform as r}from"node:os";function i(){if(r()===`win32`){let e=process.env.APPDATA??t(n(),`AppData`,`Roaming`);return t(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??t(n(),`.config`);return t(e,`aventure`,`config.json`)}function a(){let t=process.env[e.authToken];return typeof t==`string`&&t.length>0?{present:!0,source:`env`}:{present:!1,source:null}}var o;function s(t,n){process.env[e.authToken]=t,o=n}async function c(){return await o?.()}function l(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}export{a,c as i,l as n,s as r,i as t};
@@ -1 +1 @@
1
- import{f as e}from"./tool-policy-BmDEaARa.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}export{t as a,s as c,n as i,l as n,i as o,u as r,a as s,c as t};
1
+ import{f as e}from"./tool-policy-Cn4OoupR.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}export{t as a,s as c,n as i,l as n,i as o,u as r,a as s,c as t};
@@ -1 +1 @@
1
- import"./tool-policy-BmDEaARa.js";function e(e,t,n=t.inputName){if(t.in===`body`)return n;let r=f.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?d(c(n!==`id`&&n!==`slug`?n:`${i(e.path)}${s(n)}`),t):r.inputName}function t(e,t,r=o(e)){return n(a(e,t),new Set(r))}function n(e,t){if(!t.has(e))return e;let n=`body${s(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function r(e,t,n){return`${e}[${t}].${n}`}function i(e){return p.find(([,t])=>t.test(e))?.[0]??`record`}function a(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=l(t);return d(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?c(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function o(t){return new Set(t.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(n=>e(t,n)))}function s(e){return e.replace(/^./u,e=>e.toUpperCase())}function c(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 l(e){let t=c(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?u(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function u(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function d(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var f=[{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`}],p=[[`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]];export{e as n,r,t};
1
+ import"./tool-policy-Cn4OoupR.js";function e(e,t,n=t.inputName){if(t.in===`body`)return n;let r=f.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?d(c(n!==`id`&&n!==`slug`?n:`${i(e.path)}${s(n)}`),t):r.inputName}function t(e,t,r=o(e)){return n(a(e,t),new Set(r))}function n(e,t){if(!t.has(e))return e;let n=`body${s(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function r(e,t,n){return`${e}[${t}].${n}`}function i(e){return p.find(([,t])=>t.test(e))?.[0]??`record`}function a(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=l(t);return d(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?c(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function o(t){return new Set(t.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(n=>e(t,n)))}function s(e){return e.replace(/^./u,e=>e.toUpperCase())}function c(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 l(e){let t=c(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?u(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function u(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function d(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var f=[{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`}],p=[[`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]];export{e as n,r,t};
@@ -1 +1 @@
1
- import{n as e}from"./commander-DEj7N1b9.js";import{c as t}from"./tool-policy-BmDEaARa.js";import{a as n,i as r}from"./cli-help-policy-BX-whN-w.js";import{n as i,t as a}from"./contract-parameter-BsYdHniz.js";function o(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{security:t,parameter:n,projection:r,response:a,...o}=e,s=n.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=d(t,i(e,t),n);if(t.legacyName===void 0)return r;let a=d(t,i(e,t,t.legacyName),n).flag;return a===r.flag?r:Object.assign(r,{legacyFlag:a})})}),u=e.requestBody?.map(t=>{let n=l(e,s,t),r=c(t.cliConflicts,n),i=r.length===0?{}:{cliConflicts:r};return Object.assign({},t,{parameter:n},i)}),f=a.find(({status:e})=>e.startsWith(`2`)),p=f?.schemaName?.replace(/Schema$/,``);return Object.assign(o,{cliPath:r.cliPath,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:u,scope:r.scope,auth:r.auth,visibility:r.visibility,mutates:r.mutates,selfCredential:r.selfCredential,successResponse:p,detailField:f?.detailField,header:f?.header,parameters:s})})}function s(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 c(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 l(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)=>u(e.name)-u(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=a(e,t,r);return r.add(n),[d(t,n,`body`)]})}function u(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function d(i,a,o){let s=i.itemSchemaEnum??i.schemaEnum,c=n(i.schemaType,i.itemSchemaType,i.schemaFormat,a),l=`${t(a)} ${i.schemaType===`boolean`?`[${c}]`:`<${c}>`}`;return{name:i.name,optionKey:new e(l).attributeName(),flag:l,required:i.required&&i.schemaDefault===void 0,description:r(i.description,s),schemaType:i.schemaType,schemaFormat:i.schemaFormat,itemSchemaType:i.itemSchemaType,nullable:i.nullable,defaultValue:f(i.schemaDefault),choices:s,...i.envName===void 0?{}:{envName:i.envName},...i.visibility&&{visibility:i.visibility},location:o}}var f=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{s as n,o as t};
1
+ import{n as e}from"./commander-DEj7N1b9.js";import{c as t}from"./tool-policy-Cn4OoupR.js";import{a as n,i as r}from"./cli-help-policy-13I76Xu_.js";import{n as i,t as a}from"./contract-parameter-BEjNGBMH.js";function o(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{security:t,parameter:n,projection:r,response:a,...o}=e,s=n.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=d(t,i(e,t),n);if(t.legacyName===void 0)return r;let a=d(t,i(e,t,t.legacyName),n).flag;return a===r.flag?r:Object.assign(r,{legacyFlag:a})})}),u=e.requestBody?.map(t=>{let n=l(e,s,t),r=c(t.cliConflicts,n),i=r.length===0?{}:{cliConflicts:r};return Object.assign({},t,{parameter:n},i)}),f=a.find(({status:e})=>e.startsWith(`2`)),p=f?.schemaName?.replace(/Schema$/,``);return Object.assign(o,{cliPath:r.cliPath,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:u,scope:r.scope,auth:r.auth,visibility:r.visibility,mutates:r.mutates,selfCredential:r.selfCredential,successResponse:p,detailField:f?.detailField,header:f?.header,parameters:s})})}function s(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 c(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 l(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)=>u(e.name)-u(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=a(e,t,r);return r.add(n),[d(t,n,`body`)]})}function u(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function d(i,a,o){let s=i.itemSchemaEnum??i.schemaEnum,c=n(i.schemaType,i.itemSchemaType,i.schemaFormat,a),l=`${t(a)} ${i.schemaType===`boolean`?`[${c}]`:`<${c}>`}`;return{name:i.name,optionKey:new e(l).attributeName(),flag:l,required:i.required&&i.schemaDefault===void 0,description:r(i.description,s),schemaType:i.schemaType,schemaFormat:i.schemaFormat,itemSchemaType:i.itemSchemaType,nullable:i.nullable,defaultValue:f(i.schemaDefault),choices:s,...i.envName===void 0?{}:{envName:i.envName},...i.visibility&&{visibility:i.visibility},location:o}}var f=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{s as n,o as t};
@@ -1 +1 @@
1
- export{t as AUTH_SECRET_NAME,n as AUTH_SECRET_NAMES,r as DEFAULT_ENVIRONMENT,i as DEFAULT_REQUEST_TIMEOUT_MS,a as PUBLIC_API_ORIGIN,o as PUBLIC_SITE_ORIGIN,s as bearerAuthHeaders,c as defaultEnvironmentHost,l as environmentNames,u as normalizeEnvironmentName,d as prepareCallEnv,f as publicApiHost,p as readEnv,m as requestTimeoutMs}from"./env-CC1-vnc-.js";
1
+ export{t as AUTH_SECRET_NAME,n as AUTH_SECRET_NAMES,r as DEFAULT_ENVIRONMENT,i as DEFAULT_REQUEST_TIMEOUT_MS,a as PUBLIC_API_ORIGIN,o as PUBLIC_SITE_ORIGIN,s as bearerAuthHeaders,c as defaultEnvironmentHost,l as environmentNames,u as normalizeEnvironmentName,d as prepareCallEnv,f as publicApiHost,p as readEnv,m as requestTimeoutMs}from"./env-D87fitNv.js";
@@ -1 +1 @@
1
- import{c as e,r as t}from"./result-envelope-Cqvvr4zX.js";var n=[`localhost`,`127.0.0.1`,`0.0.0.0`,`[::1]`];function r(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0]??``;return n.some(e=>t===e||t.startsWith(`${e}:`))}function i(e){let t=e.host.trim();return/^https?:\/\//i.test(t)?t===e.host?e:{...e,host:t}:{...e,host:`${r(t)?`http`:`https`}://${t}`}}var a={authToken:`AUTH_TOKEN`},o=[a.authToken],s=`production`,c={production:{host:`api.aventure.vc`},local:{host:`localhost:8080`}},l=`https://${c.production.host}`,u=`https://aventure.vc`,d=11e4;function f(){let e=Number(process.env.AVENTURE_API_REQUEST_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:d}function p(){return{host:x(process.env.API_URL)??y(process.env.API_ENV)?.host??h(),userBearerToken:process.env[a.authToken]}}function m(){let e=p().host,t=r(e)?null:v(process.env.API_ENV);return(t===null?void 0:c[t]?.host)??e}function h(){let e=c[s]?.host;if(e===void 0)throw Error(`Default API environment is unavailable`);return e}function g(e){if(!e.userBearerToken)throw Error(r(e.host)?`For a loopback API, set ${a.authToken} to a user API key issued by the Clerk instance serving that API`:`Sign in with \`auth login\`, or set ${a.authToken} to an aVenture API key from ${u}/settings/api-keys`);return{Authorization:`Bearer ${e.userBearerToken}`}}function _(){return Object.keys(c)}function v(e){let t=e?.trim().toLowerCase();if(!t)return null;switch(t){case`stage`:case`staging`:return`staging`;case`prod`:case`production`:return`production`;case`dev`:case`development`:case`localhost`:case`local`:return`local`;default:return null}}function y(e){let t=v(e);if(t===null){if(!e?.trim())return null;throw Error(`Unknown aVenture environment '${e}'. Use one of: ${_().join(`, `)}`)}let n=c[t];if(n===void 0)throw Error(`Environment '${t}' is unavailable in this distribution`);return n}function b(n){try{let t=p();return e(`env ready`,n===`none`?{env:t,headers:{},credential:null}:{env:t,headers:g(t),credential:a.authToken})}catch(e){return t(e.message)}}function x(...e){return e.find(e=>e!==void 0&&e.trim().length>0)}export{l as a,h as c,b as d,m as f,i as h,d as i,_ as l,f as m,o as n,u as o,p,s as r,g as s,a as t,v as u};
1
+ import{c as e,r as t}from"./result-envelope-B3yDteWk.js";var n=[`localhost`,`127.0.0.1`,`0.0.0.0`,`[::1]`];function r(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0]??``;return n.some(e=>t===e||t.startsWith(`${e}:`))}function i(e){let t=e.host.trim();return/^https?:\/\//i.test(t)?t===e.host?e:{...e,host:t}:{...e,host:`${r(t)?`http`:`https`}://${t}`}}var a={authToken:`AUTH_TOKEN`},o=[a.authToken],s=`production`,c={production:{host:`api.aventure.vc`},local:{host:`localhost:8080`}},l=`https://${c.production.host}`,u=`https://aventure.vc`,d=11e4;function f(){let e=Number(process.env.AVENTURE_API_REQUEST_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:d}function p(){return{host:x(process.env.API_URL)??y(process.env.API_ENV)?.host??h(),userBearerToken:process.env[a.authToken]}}function m(){let e=p().host,t=r(e)?null:v(process.env.API_ENV);return(t===null?void 0:c[t]?.host)??e}function h(){let e=c[s]?.host;if(e===void 0)throw Error(`Default API environment is unavailable`);return e}function g(e){if(!e.userBearerToken)throw Error(r(e.host)?`For a loopback API, set ${a.authToken} to a user API key issued by the Clerk instance serving that API`:`Sign in with \`auth login\`, or set ${a.authToken} to an aVenture API key from ${u}/settings/api-keys`);return{Authorization:`Bearer ${e.userBearerToken}`}}function _(){return Object.keys(c)}function v(e){let t=e?.trim().toLowerCase();if(!t)return null;switch(t){case`stage`:case`staging`:return`staging`;case`prod`:case`production`:return`production`;case`dev`:case`development`:case`localhost`:case`local`:return`local`;default:return null}}function y(e){let t=v(e);if(t===null){if(!e?.trim())return null;throw Error(`Unknown aVenture environment '${e}'. Use one of: ${_().join(`, `)}`)}let n=c[t];if(n===void 0)throw Error(`Environment '${t}' is unavailable in this distribution`);return n}function b(n){try{let t=p();return e(`env ready`,n===`none`?{env:t,headers:{},credential:null}:{env:t,headers:g(t),credential:a.authToken})}catch(e){return t(e.message)}}function x(...e){return e.find(e=>e!==void 0&&e.trim().length>0)}export{l as a,h as c,b as d,m as f,i as h,d as i,_ as l,f as m,o as n,u as o,p,s as r,g as s,a as t,v as u};
@@ -1,2 +1,2 @@
1
- import{a as e}from"./package-DEeHDoOT.js";import{C as t,S as n,_ as r,c as i,d as a,g as o,i as s,s as c}from"./iso-DzqMxtky.js";import{t as ee}from"./confidence-CjeYTBnf.js";import{c as te,d as ne,l as re,s as l,u as ie}from"./tool-policy-BmDEaARa.js";import{i as ae,t as u}from"./human-text-cap-dR2SJQJC.js";import{n as oe,t as se}from"./contract-parameter-BsYdHniz.js";var d=2,ce=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 f(e,t){let n=g(t);if(n.length!==0){e.add(n),(n===`individual`||n===`individuals`)&&f(e,`person`);for(let t of le(n))p(e,t,n);p(e,ue(n),n)}}function le(e){if(e===`people`)return[`person`];let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=d&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return[`${t}y`];let n=e.endsWith(`es`)?e.slice(0,-2):``;return n.length>=d&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n)?[n,`${n}e`]:e.length>d&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`?[e.slice(0,-1)]:[]}function ue(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=d&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=d&&e.endsWith(`es`)))return e.length>=d&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function p(e,t,n){t!==void 0&&t!==n&&t.length>=d&&/^[a-z]+$/u.test(t)&&e.add(t)}function m(e){let t=new Set(h(e)),n=Array.from(t);for(let e of n)f(t,e);return t}function de(e){return h(e).map(m)}function fe(e,t){if(e.length===0)return!1;let n=m(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function h(e){return g(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!ce.has(e))}function g(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`)}function _(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>v(e)),...n.flatMap(e=>e.parameter.map(t=>v(t,n.length>1?e.contentType:void 0))),...pe(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||ie(e.intent),o=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:re(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse?null:ne(e,`public`),body:{hasBody:o!==void 0,kind:o?.kind??null,...o!==void 0&&n.length>1?{contentType:o.contentType}:{},required:o?.required??!1,description:o?.description??``,requiredPath:o?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},...e.header===void 0||e.header.length===0?{}:{header:e.header},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function v(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 pe(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 y(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var me=[`-id`,`-slug`,`-url`],b=[`--id`,`--slug`,`--url`],he=`--from-file "<path>"`;function ge(t,n,r=e().bin[0]){let i=_(n,r),a=i.find(e=>e.operationId===t);return a===void 0?[]:C(a,i)}function x(t,n,r=e().bin[0]){let i=n.find(e=>e.operationId===t),[a]=i===void 0?[]:_([i],r);return a&&S(a,T(a,!1))}function _e(t,n,r,i=e().bin[0]){let a=e=>{let t=e.findIndex((e,t)=>r[t]!==e);return t===-1?e.length:t},o=`${r[0]} get`,[s,c]=n.filter(({method:e,path:n,parameters:r,cliPath:i})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return e===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===t&&n.endsWith(`/{${c.name}}`)&&(a(i)>1||i.join(` `)===o)}).toSorted((e,t)=>a(t.cliPath)-a(e.cliPath));if(s!==void 0&&(c===void 0||a(c.cliPath)!==a(s.cliPath)))return x(s.operationId,n,i)}function S(e,t){return[e.cli.command,...t,`--data`].join(` `)}function C(e,t){return[`example: ${S(e,T(e))}`,...ve(e,t)]}function ve(e,t){return y(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} ${E(i)} --data`;return[`lookup: ${e.name} from a slug: ${a}`]})}var w=/(?:^|\.)text$/u;function T(e,t=!0){let n=y(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&w.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:ye(e)).map(E);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,he]:o}function ye(e){let t=new Set;f(t,e.resource);for(let n of me)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 b){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function E(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var be=s([`PAID_PLAN`,`DAILY_ALLOWANCE`]),D=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),O=Object.assign(t([D,n()]),{enum:D.enum}),k=r({billingAccess:be.nullish(),excerpt:n(),sourceId:n(),sourceType:O,sourceVersion:n().nullish()}),A=r({instruction:n(),operationId:n(),planTaskKey:c(n()).optional(),publishesAnalysis:i().optional(),stepKey:n().optional(),title:n().nullish()}),j=r({body:n(),expectation:n(),method:c(n()),override:n(),reject:c(n()),typeCatalog:n()}),M=r({cliCommand:n(),mcpTool:n().nullish(),step:A,title:n().nullish(),writeGuidance:j.nullish()}),N=s([`ENTITY`,`NEWS`,`TEXT`,`FACT`,`WRITER_BRIEF`]),xe=Object.assign(t([N,n()]),{enum:N.enum}),Se=r({allowedValue:n().nullish(),description:n(),key:n(),required:i().default(!0).optional(),type:xe}),P=r({catalogRevision:a().optional(),gateId:c(n()).optional(),input:c(Se),step:c(M),taskKey:n().optional()}),F=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),Ce=r({candidate:c(k),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),we=r({answer:n(),citation:c(k),confidence:ee,resolution:Ce.nullish()});function I(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>L(t,oe(e,t))),r=(t?.parameter??[]).map(t=>L(t,se(e,t)));return{selector:n.filter(e=>e.location===`path`||R(e)),pagination:n.filter(z),filter:[...n.filter(B),...r.filter(B)],body:r.filter(e=>!B(e))}}function L(e,t){let{in:n,inputName:r,nullable:i,...a}=e;return{...a,flag:te(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function R(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function z(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function B(e){return e.location!==`path`&&!R(e)&&!z(e)}function V(e){let t=U(e);return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,tool:l(e),scope:e.projection.scope,requiredInput:De(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))],...t===void 0?{}:{paidPlan:t}}}function H(e,t){let n=e.requestBody?.[0];return t?{...V(e),description:e.description,resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:I(e)}:{...V(e),optionalInput:Oe(e),arrayInput:ke(e)}}function Te(e){let t=I(e),n=e=>e.filter(e=>e.required);return{...H(e,!1),description:e.description,arrayInput:void 0,optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function Ee(e){let{cli:t,scope:n,...r}=V(e);return{...r,optionalDetailOmitted:!0}}function De(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Oe(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 U(e){return e.response.find(({status:e})=>e===`402`)?.description}function ke(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var W=160,G=`Operation catalog matches`,Ae=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],K=e=>`${[G,...e].join(`
1
+ import{a as e}from"./package-DEeHDoOT.js";import{C as t,S as n,_ as r,c as i,d as a,g as o,i as s,s as c}from"./iso-DzqMxtky.js";import{t as ee}from"./confidence-CjeYTBnf.js";import{c as te,d as ne,l as re,s as l,u as ie}from"./tool-policy-Cn4OoupR.js";import{i as ae,t as u}from"./human-text-cap-dR2SJQJC.js";import{n as oe,t as se}from"./contract-parameter-BEjNGBMH.js";var d=2,ce=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 f(e,t){let n=g(t);if(n.length!==0){e.add(n),(n===`individual`||n===`individuals`)&&f(e,`person`);for(let t of le(n))p(e,t,n);p(e,ue(n),n)}}function le(e){if(e===`people`)return[`person`];let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=d&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return[`${t}y`];let n=e.endsWith(`es`)?e.slice(0,-2):``;return n.length>=d&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n)?[n,`${n}e`]:e.length>d&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`?[e.slice(0,-1)]:[]}function ue(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=d&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=d&&e.endsWith(`es`)))return e.length>=d&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function p(e,t,n){t!==void 0&&t!==n&&t.length>=d&&/^[a-z]+$/u.test(t)&&e.add(t)}function m(e){let t=new Set(h(e)),n=Array.from(t);for(let e of n)f(t,e);return t}function de(e){return h(e).map(m)}function fe(e,t){if(e.length===0)return!1;let n=m(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function h(e){return g(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!ce.has(e))}function g(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`)}function _(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>v(e)),...n.flatMap(e=>e.parameter.map(t=>v(t,n.length>1?e.contentType:void 0))),...pe(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||ie(e.intent),o=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:re(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse?null:ne(e,`public`),body:{hasBody:o!==void 0,kind:o?.kind??null,...o!==void 0&&n.length>1?{contentType:o.contentType}:{},required:o?.required??!1,description:o?.description??``,requiredPath:o?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},...e.header===void 0||e.header.length===0?{}:{header:e.header},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function v(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 pe(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 y(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var me=[`-id`,`-slug`,`-url`],b=[`--id`,`--slug`,`--url`],he=`--from-file "<path>"`;function ge(t,n,r=e().bin[0]){let i=_(n,r),a=i.find(e=>e.operationId===t);return a===void 0?[]:C(a,i)}function x(t,n,r=e().bin[0]){let i=n.find(e=>e.operationId===t),[a]=i===void 0?[]:_([i],r);return a&&S(a,T(a,!1))}function _e(t,n,r,i=e().bin[0]){let a=e=>{let t=e.findIndex((e,t)=>r[t]!==e);return t===-1?e.length:t},o=`${r[0]} get`,[s,c]=n.filter(({method:e,path:n,parameters:r,cliPath:i})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return e===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===t&&n.endsWith(`/{${c.name}}`)&&(a(i)>1||i.join(` `)===o)}).toSorted((e,t)=>a(t.cliPath)-a(e.cliPath));if(s!==void 0&&(c===void 0||a(c.cliPath)!==a(s.cliPath)))return x(s.operationId,n,i)}function S(e,t){return[e.cli.command,...t,`--data`].join(` `)}function C(e,t){return[`example: ${S(e,T(e))}`,...ve(e,t)]}function ve(e,t){return y(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} ${E(i)} --data`;return[`lookup: ${e.name} from a slug: ${a}`]})}var w=/(?:^|\.)text$/u;function T(e,t=!0){let n=y(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&w.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:ye(e)).map(E);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,he]:o}function ye(e){let t=new Set;f(t,e.resource);for(let n of me)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 b){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function E(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var be=s([`PAID_PLAN`,`DAILY_ALLOWANCE`]),D=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),O=Object.assign(t([D,n()]),{enum:D.enum}),k=r({billingAccess:be.nullish(),excerpt:n(),sourceId:n(),sourceType:O,sourceVersion:n().nullish()}),A=r({instruction:n(),operationId:n(),planTaskKey:c(n()).optional(),publishesAnalysis:i().optional(),stepKey:n().optional(),title:n().nullish()}),j=r({body:n(),expectation:n(),method:c(n()),override:n(),reject:c(n()),typeCatalog:n()}),M=r({cliCommand:n(),mcpTool:n().nullish(),step:A,title:n().nullish(),writeGuidance:j.nullish()}),N=s([`ENTITY`,`NEWS`,`TEXT`,`FACT`,`WRITER_BRIEF`]),xe=Object.assign(t([N,n()]),{enum:N.enum}),Se=r({allowedValue:n().nullish(),description:n(),key:n(),required:i().default(!0).optional(),type:xe}),P=r({catalogRevision:a().optional(),gateId:c(n()).optional(),input:c(Se),step:c(M),taskKey:n().optional()}),F=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),Ce=r({candidate:c(k),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),we=r({answer:n(),citation:c(k),confidence:ee,resolution:Ce.nullish()});function I(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>L(t,oe(e,t))),r=(t?.parameter??[]).map(t=>L(t,se(e,t)));return{selector:n.filter(e=>e.location===`path`||R(e)),pagination:n.filter(z),filter:[...n.filter(B),...r.filter(B)],body:r.filter(e=>!B(e))}}function L(e,t){let{in:n,inputName:r,nullable:i,...a}=e;return{...a,flag:te(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function R(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function z(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function B(e){return e.location!==`path`&&!R(e)&&!z(e)}function V(e){let t=U(e);return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,tool:l(e),scope:e.projection.scope,requiredInput:De(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))],...t===void 0?{}:{paidPlan:t}}}function H(e,t){let n=e.requestBody?.[0];return t?{...V(e),description:e.description,resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:I(e)}:{...V(e),optionalInput:Oe(e),arrayInput:ke(e)}}function Te(e){let t=I(e),n=e=>e.filter(e=>e.required);return{...H(e,!1),description:e.description,arrayInput:void 0,optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function Ee(e){let{cli:t,scope:n,...r}=V(e);return{...r,optionalDetailOmitted:!0}}function De(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Oe(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 U(e){return e.response.find(({status:e})=>e===`402`)?.description}function ke(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var W=160,G=`Operation catalog matches`,Ae=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],K=e=>`${[G,...e].join(`
2
2
  `)}\n`;function je(e,t=[],n=`mcp`){if(!Array.isArray(e)||e.length===0||!e.every(Pe))return null;let r=e,i=n===`mcp`?`structuredContent.data`:`the --data --to-file <path> output`,a=e=>ae([G,...e,...t]);for(let e of Ae){let t=[...r.flatMap(t=>Y(t,e)),...J(r,e,i)];if(a(t))return K(t)}let o=(e,t=r.length-e)=>{let n=r.slice(e),a=n.length-t;return[...r.slice(0,e).flatMap(e=>Y(e,`optionalGrouped`)),...J(r.slice(0,e),`optionalGrouped`,i),...n.length===0?[]:[`... ${n.length} more operations omitted to fit ${u} UTF-8 bytes: ${[...n.slice(0,t).map(({operationId:e})=>e),...a>0?[`and ${a} more in ${i}`]:[]].join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`]]},s=[...r.keys()].findLast(e=>a(o(e)));return K(s===void 0?o(0,[...r.keys()].findLast(e=>a(o(0,e)))??0):o(s))}var q=e=>`call aventure_help with q=<operationId> and limit=1; inspect argument and optionalInput in ${e} for the retained inputs`;function J(e,t,n){let r=t===`optionalGrouped`&&e.some(e=>Y(e,t).some(e=>e.includes(`.{`)))?[`... optional input names sharing a prefix are grouped: a.{b, c} names a.b and a.c.`]:[];return[...Me(e,t,n),...r]}function Me(e,t,n){let r=e.flatMap(e=>`argument`in e?Object.values(e.argument).flat():[]),i=t===`whole`?0:r.filter(e=>e.description.length>W&&(t===`described`||e.required)).length,a=i===0?[]:[`... ${i} argument descriptions shortened; inspect each row's argument in ${n} for full descriptions.`];if(e.some(e=>`optionalDetailOmitted`in e))return[...a,e.some(e=>`argument`in e)?`... optional argument details omitted: the full list exceeds the result cap; ${q(n)}.`:`... optional inputs omitted: the full list exceeds the result cap; call aventure_help with q=<operationId> and limit=1 to read one operation's inputs.`];if(t===`whole`||!e.some(e=>`argument`in e))return[];if(t===`described`)return a;let o=t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`,s=r.filter(({required:e})=>!e).length;return[...a,`... ${s} ${o} omitted to fit ${u} UTF-8 bytes; ${n} carries them, and ${q(n)}.`]}function Y(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} (${e.tool})`,` ${e.summary}`,...`description`in e&&e.description?[` ${e.description}`]:[],` 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,n])=>` optional ${e}: ${X(n,t)}`):[],...`arrayInput`in e&&e.arrayInput?.length?[` JSON array inputs: ${e.arrayInput.join(`, `)}`]:[],...`paidPlan`in e&&e.paidPlan!==void 0?[` paid plan: ${e.paidPlan}`]:[],...n.filter(({required:e})=>e||t!==`optionalNamed`&&t!==`optionalGrouped`).map(e=>Ne(e,e.required||t!==`requiredDescribed`,t)),...(t===`optionalNamed`||t===`optionalGrouped`)&&r.length>0?[` optional inputs: ${X(r,t)}`]:[]]}function X(e,t){if(t!==`optionalGrouped`)return e.join(`, `);let n=new Map;for(let t of e){let e=n,r=t.split(`.`);r.forEach((t,n)=>{let i=e.get(t)??{end:!1,child:new Map};e.set(t,i),n===r.length-1&&(i.end=!0),e=i.child})}let r=(e,t)=>{let n=[...t.child].flatMap(([n,i])=>t.child.size===1?r(`${e}.${n}`,i):r(n,i));return[...t.end?[e]:[],...t.child.size>1?[`${e}.{${n.join(`, `)}}`]:n]};return[...n].flatMap(([e,t])=>r(e,t)).join(`, `)}function Ne(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<=W?e.description:`${e.description.slice(0,157)}...`}`:i}function Pe(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 Z(e){let t=t=>{let n=(`parameter`in e?e.parameter:e.parameters.map(e=>({...e,in:e.location,schemaDefault:e.defaultValue}))).filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map(({name:e})=>[e,`<${e}>`]);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`);return{tool:l(e),arguments:{operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Q(e)}}}}var Fe=4;function Q(e){let t=e.requestBody?.[0];if(t===void 0)return{};if(t.requiredPath.length>0||e.intent!==`lookup`||t.schemaType===`array`)return Ie(t.requiredPath);let n=t.parameter;return Object.fromEntries(n.flatMap(e=>{let{name:t,schemaType:n,schemaFormat:r}=e,i=`optionKey`in e?e.choices:e.schemaEnum;return t.includes(`.`)||n!==`string`||r!==void 0?[]:i===void 0?[[t,`<${t}>`]]:i.length>Fe?[]:[[t,`<${i.join(`|`)}>`]]}))}function Ie(e){let t={},n=e.filter(t=>!e.some(e=>e.startsWith(`${t}.`)||e.startsWith(`${t}[]`)));for(let e of n){let n=e.split(`.`),r=n.slice(0,-1).reduce(Le,t);r[n.at(-1)??e]=`<${e}>`}return t}function Le(e,t){let n=t.replace(/\[\]$/u,``),r=e[n],i=Array.isArray(r)?r[0]:r;if(typeof i==`object`&&i&&!Array.isArray(i))return i;let a={};return e[n]=t.endsWith(`[]`)?[a]:a,a}function Re(e){let t=U(e);return{mcpCall:Z(e),...t===void 0?{}:{paidPlan:t}}}function ze(e){let t=$(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function $(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()??``}}export{m as C,de as E,fe as S,g as T,_e as _,je as a,x as b,Ee as c,F as d,P as f,ge as g,y as h,Re as i,Te as l,w as m,$ as n,Z as o,O as p,ze as r,H as s,G as t,we as u,C as v,h as w,f as x,_ as y};
@@ -1 +1 @@
1
- import{c as e,i as t,r as n}from"./result-envelope-Cqvvr4zX.js";import{U as r,m as i,n as a,u as o}from"./tool-policy-BmDEaARa.js";import{t as s}from"./openapi-snapshot-C3NgiUZo.js";import{C as c,E as l,S as u,T as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b,w as x,x as S}from"./help-catalog-BgXKbrdt.js";var C=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,w=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,T=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,E=250,D=40,O=100;function ee(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(w,()=>(n.add(`uuid`),` `)).replace(C,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&&T.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=T.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 k(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function A(e,t){let n=new Set;for(let r of e){let e=new Set;S(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 te(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(x(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>k(t,e,n.path))&&(i+=E,r.has(t)&&(i+=D));if(i===0)return 0;let a=new Set(x(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return S(t,e),[...t].some(e=>a.has(e))}))&&(i+=O),i}var j=40,M=4,N=3,P=1,F=new Map,I=new WeakMap;function L(e){let t=F.get(e);if(t!==void 0)return t;let n=s(),a=r(n.paths,e),o=a===null?new Map:i(n,a.operation.responses,N);return F.set(e,o),o}function R(e,t,n){let r=0,i=z(n);for(let[e,i]of n)t.has(e.toLowerCase())&&(r+=j*(4-i)/4);for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=P&&(r+=M*(2-e))}return r}function z(e){let t=I.get(e);if(t!==void 0)return t;let n=new Map;for(let[t,r]of e){if(r>P)continue;let e=new Set;for(let n of x(t))S(e,n);for(let t of e)n.set(t,Math.min(n.get(t)??r,r))}return I.set(e,n),n}var B=5,V=.5,H=15,U=30,W=2,G=100,K=.5;function q(e,t,n){if(e.trim().length===0)return t.map(e=>({item:e,score:1}));let r=t.map(e=>({item:e,fields:n(e)})),i=ee(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=A(i.urlPathWord,r.map(({fields:e})=>e)),o=d(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=c(o),u=l(o),f=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:Q({normalizedQuery:o,tokens:s,termForm:u,queryWord:f},t))+te(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}))}var J=new WeakMap;function Y(e){let t=J.get(e);if(t!==void 0)return t;let n=e.requestBody??[],r=[...e.parameter,...n.flatMap(e=>e.parameter)],i={...e,cliPath:e.projection.cliPath,enumParameter:r.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:r.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...r,...n].map(({description:e})=>e),responseFieldLevel:L(e.operationId)};return J.set(e,i),i}function X(n,r){let i=n.q?.trim()??``,a=q(i,r.filter(e=>Z(n,e)&&(i.length>0||e.deprecated!==!0)),Y),o=(a[0]?.score??0)*V,s=a.filter(({score:e})=>e>=o),c=n.limit===void 0||!Number.isFinite(n.limit)?B:n.limit,l=Math.min(s.length,Math.max(0,Math.trunc(c))),u=s.slice(0,l).map(({item:e})=>e),d={totalOperations:r.length,matched:s.length,returned:u.length},p=u.length===1,h=u.map(e=>v(e,p)),g=e(y,h,{counts:d}),_=t(g),b=p?u.map(m):u.map(f);return{summary:y,data:_?h:b,counts:d}}function Z(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 Q({normalizedQuery:e,tokens:t,termForm:n,queryWord:r},i){let a=oe(i),s=ie(i),c=0;a.some(t=>t===e)&&(c+=100),a.some(t=>t.includes(e))&&(c+=40),c+=ae(e,a);let l=new Set(a.flatMap(x)),f=new Set(s.flatMap(x));for(let e of t)a.some(t=>t===e)?c+=20:f.has(e)?c+=8:l.has(e)&&(c+=W);for(let e of i.cliPath){let n=new Set;for(let t of e.split(`-`))S(n,t);[...n].some(e=>t.has(e))&&(c+=H)}u(n,s)&&(c+=200),n.length>1&&s.some(t=>t.includes(e))&&(c+=G),i.parameterName.some(t=>d(t)===e)&&(c+=U);let p=new Set(i.parameterDescription.flatMap(x));for(let e of t)p.has(e)&&(c+=W);return c+=ce(t,i.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(i.operationId)&&(c+=30),c+=R(n,r,i.responseFieldLevel),c-=se(e,t,i.description),o(i.intent)&&!re(r)?c*K:c}var ne=`edit change set fix rename link unlink mark publish correct`.split(` `),$=new Set([...Object.entries(a).filter(([,e])=>o(e)).map(([e])=>e),...ne]);function re(e){return[...e].some(e=>$.has(e))}function ie(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(d).filter(e=>e.length>0)}function ae(e,t){let n=x(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 oe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,(h(e.description).useFor||e.description).slice(0,240)].map(d).filter(e=>e.length>0))]}function se(e,t,n){let r=d(h(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(x(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function ce(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>le(e,t))&&(n+=i?40:10);return n}function le(e,t){let n=x(t);return n.length>0&&n.every(t=>e.has(t))}function ue(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function de(t,r,i,a){let o=t.q?.trim()??``;if(o.length===0)return n(`Provide q to resolve a request to one operation.`);let s=i.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(s===void 0)return n(`This build ships no help resolve operation.`);let c=await a(s,{body:{question:o,resolve:!0,...t.scope===void 0?{}:{scope:t.scope===`read`?`READ`:`WRITE`}}});if(!c.ok)return{...c,data:null};let l=b.safeParse(ue(c));if(!l.success||l.data.resolution==null)return n(`The help resolve operation returned no resolution.`,c.warnings,{httpStatus:c.httpStatus});let{answer:u,resolution:d}=l.data,f=e=>r.find(t=>t.operationId===e),m=f(d.operationId),h=d.taskPlan??void 0,v=(h?.step??[]).map(({step:e})=>({step:e,contract:f(e.operationId)})),y=[...new Set([...d.operationId!=null&&m===void 0?[d.operationId]:[],...v.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return y.some(e=>!i.some(t=>t.operationId===e))?n(`No operation on this connection answers that request.`):e(y.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${y.join(`, `)}.`,{outcome:d.outcome,probability:d.probability,answer:u,candidate:d.candidate.filter(({sourceId:e})=>i.some(({operationId:t})=>t===e)).map(({sourceId:e})=>{let t=f(e);return t===void 0?{sourceId:e}:Object.assign({sourceId:e},p(t))}),...m===void 0?{}:{operation:{operationId:m.operationId,apiRoute:`${m.method} ${m.path}`,..._(m),...p(m)}},...(d.taskKey,{}),...h===void 0?{}:{taskPlan:{input:h.input,step:v.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:g(e)})}}},{warnings:y.map(e=>i.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.`)})}export{L as a,de as i,q as n,X as r,Y as t};
1
+ import{c as e,i as t,r as n}from"./result-envelope-B3yDteWk.js";import{U as r,m as i,n as a,u as o}from"./tool-policy-Cn4OoupR.js";import{t as s}from"./openapi-snapshot-C3NgiUZo.js";import{C as c,E as l,S as u,T as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b,w as x,x as S}from"./help-catalog-C0gb6USI.js";var C=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,w=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,T=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,E=250,D=40,O=100;function ee(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(w,()=>(n.add(`uuid`),` `)).replace(C,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&&T.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=T.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 k(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function A(e,t){let n=new Set;for(let r of e){let e=new Set;S(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 te(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(x(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>k(t,e,n.path))&&(i+=E,r.has(t)&&(i+=D));if(i===0)return 0;let a=new Set(x(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return S(t,e),[...t].some(e=>a.has(e))}))&&(i+=O),i}var j=40,M=4,N=3,P=1,F=new Map,I=new WeakMap;function L(e){let t=F.get(e);if(t!==void 0)return t;let n=s(),a=r(n.paths,e),o=a===null?new Map:i(n,a.operation.responses,N);return F.set(e,o),o}function R(e,t,n){let r=0,i=z(n);for(let[e,i]of n)t.has(e.toLowerCase())&&(r+=j*(4-i)/4);for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=P&&(r+=M*(2-e))}return r}function z(e){let t=I.get(e);if(t!==void 0)return t;let n=new Map;for(let[t,r]of e){if(r>P)continue;let e=new Set;for(let n of x(t))S(e,n);for(let t of e)n.set(t,Math.min(n.get(t)??r,r))}return I.set(e,n),n}var B=5,V=.5,H=15,U=30,W=2,G=100,K=.5;function q(e,t,n){if(e.trim().length===0)return t.map(e=>({item:e,score:1}));let r=t.map(e=>({item:e,fields:n(e)})),i=ee(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=A(i.urlPathWord,r.map(({fields:e})=>e)),o=d(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=c(o),u=l(o),f=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:Q({normalizedQuery:o,tokens:s,termForm:u,queryWord:f},t))+te(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}))}var J=new WeakMap;function Y(e){let t=J.get(e);if(t!==void 0)return t;let n=e.requestBody??[],r=[...e.parameter,...n.flatMap(e=>e.parameter)],i={...e,cliPath:e.projection.cliPath,enumParameter:r.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:r.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...r,...n].map(({description:e})=>e),responseFieldLevel:L(e.operationId)};return J.set(e,i),i}function X(n,r){let i=n.q?.trim()??``,a=q(i,r.filter(e=>Z(n,e)&&(i.length>0||e.deprecated!==!0)),Y),o=(a[0]?.score??0)*V,s=a.filter(({score:e})=>e>=o),c=n.limit===void 0||!Number.isFinite(n.limit)?B:n.limit,l=Math.min(s.length,Math.max(0,Math.trunc(c))),u=s.slice(0,l).map(({item:e})=>e),d={totalOperations:r.length,matched:s.length,returned:u.length},p=u.length===1,h=u.map(e=>v(e,p)),g=e(y,h,{counts:d}),_=t(g),b=p?u.map(m):u.map(f);return{summary:y,data:_?h:b,counts:d}}function Z(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 Q({normalizedQuery:e,tokens:t,termForm:n,queryWord:r},i){let a=oe(i),s=ie(i),c=0;a.some(t=>t===e)&&(c+=100),a.some(t=>t.includes(e))&&(c+=40),c+=ae(e,a);let l=new Set(a.flatMap(x)),f=new Set(s.flatMap(x));for(let e of t)a.some(t=>t===e)?c+=20:f.has(e)?c+=8:l.has(e)&&(c+=W);for(let e of i.cliPath){let n=new Set;for(let t of e.split(`-`))S(n,t);[...n].some(e=>t.has(e))&&(c+=H)}u(n,s)&&(c+=200),n.length>1&&s.some(t=>t.includes(e))&&(c+=G),i.parameterName.some(t=>d(t)===e)&&(c+=U);let p=new Set(i.parameterDescription.flatMap(x));for(let e of t)p.has(e)&&(c+=W);return c+=ce(t,i.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(i.operationId)&&(c+=30),c+=R(n,r,i.responseFieldLevel),c-=se(e,t,i.description),o(i.intent)&&!re(r)?c*K:c}var ne=`edit change set fix rename link unlink mark publish correct`.split(` `),$=new Set([...Object.entries(a).filter(([,e])=>o(e)).map(([e])=>e),...ne]);function re(e){return[...e].some(e=>$.has(e))}function ie(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(d).filter(e=>e.length>0)}function ae(e,t){let n=x(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 oe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,(h(e.description).useFor||e.description).slice(0,240)].map(d).filter(e=>e.length>0))]}function se(e,t,n){let r=d(h(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(x(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function ce(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>le(e,t))&&(n+=i?40:10);return n}function le(e,t){let n=x(t);return n.length>0&&n.every(t=>e.has(t))}function ue(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function de(t,r,i,a){let o=t.q?.trim()??``;if(o.length===0)return n(`Provide q to resolve a request to one operation.`);let s=i.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(s===void 0)return n(`This build ships no help resolve operation.`);let c=await a(s,{body:{question:o,resolve:!0,...t.scope===void 0?{}:{scope:t.scope===`read`?`READ`:`WRITE`}}});if(!c.ok)return{...c,data:null};let l=b.safeParse(ue(c));if(!l.success||l.data.resolution==null)return n(`The help resolve operation returned no resolution.`,c.warnings,{httpStatus:c.httpStatus});let{answer:u,resolution:d}=l.data,f=e=>r.find(t=>t.operationId===e),m=f(d.operationId),h=d.taskPlan??void 0,v=(h?.step??[]).map(({step:e})=>({step:e,contract:f(e.operationId)})),y=[...new Set([...d.operationId!=null&&m===void 0?[d.operationId]:[],...v.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return y.some(e=>!i.some(t=>t.operationId===e))?n(`No operation on this connection answers that request.`):e(y.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${y.join(`, `)}.`,{outcome:d.outcome,probability:d.probability,answer:u,candidate:d.candidate.filter(({sourceId:e})=>i.some(({operationId:t})=>t===e)).map(({sourceId:e})=>{let t=f(e);return t===void 0?{sourceId:e}:Object.assign({sourceId:e},p(t))}),...m===void 0?{}:{operation:{operationId:m.operationId,apiRoute:`${m.method} ${m.path}`,..._(m),...p(m)}},...(d.taskKey,{}),...h===void 0?{}:{taskPlan:{input:h.input,step:v.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:g(e)})}}},{warnings:y.map(e=>i.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.`)})}export{L as a,de as i,q as n,X as r,Y as t};