@aventurevc/aventure-cli 0.8.475 → 0.8.476
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.
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/agent-help-text-8ut6LeVk.js +2 -0
- package/dist/chunks/{api-key-bearer-credential-BL9NY_h2.js → api-key-bearer-credential-BNS7-3R-.js} +1 -1
- package/dist/chunks/{api-key-bearer-credential-BLbiarOv.js → api-key-bearer-credential-CHfmmHTt.js} +1 -1
- package/dist/chunks/{api-key-credential-DrvODZrB.js → api-key-credential-BLQCjL5J.js} +1 -1
- package/dist/chunks/{api-key-credential-ChwcRoVO.js → api-key-credential-CMHcFfw4.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-B6VCxfTh.js → api-key-credential-verification-DOsNU5e7.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-De09H4Dl.js → api-key-credential-verification-mI21YXIM.js} +1 -1
- package/dist/chunks/{api-key-login-CatPgTN5.js → api-key-login-Ca5kxgbi.js} +1 -1
- package/dist/chunks/auth-resolver-DOC8Ptsn.js +1 -0
- package/dist/chunks/{auth-resolver-1SqKr6sv.js → auth-resolver-EsmIu2-o.js} +1 -1
- package/dist/chunks/{auth-status-check-DQQsLwHS.js → auth-status-check-DZ1RwNpw.js} +1 -1
- package/dist/chunks/{auth-status-check-Lnuh9JqN.js → auth-status-check-zOOGRzaD.js} +1 -1
- package/dist/chunks/{auth-status-render-DeqlqncA.js → auth-status-render-YhS214YV.js} +1 -1
- package/dist/chunks/aventure-cli-CQa7HuJe.js +11 -0
- package/dist/chunks/{batch-io-BWxtesXN.js → batch-io-CyJoecAW.js} +1 -1
- package/dist/chunks/{builtin-auth-2JEciG7h.js → builtin-auth-vU5myzfg.js} +4 -4
- package/dist/chunks/{builtin-run-wait-DN6I2Wx7.js → builtin-run-wait-Bu_PCeUM.js} +1 -1
- package/dist/chunks/{builtin-update-geeMfMZJ.js → builtin-update-DzImpYa3.js} +1 -1
- package/dist/chunks/{cli-help-policy-BEnaH89v.js → cli-help-policy-CmWKcXMu.js} +1 -1
- package/dist/chunks/{completion-CkH55Tdg.js → completion-v2VNZOGN.js} +1 -1
- package/dist/chunks/contract-Sco2Ak44.js +1 -0
- package/dist/chunks/{credential-redaction-CcGktg8k.js → credential-redaction-Dg07sxTc.js} +1 -1
- package/dist/chunks/{credential-store-0RPGLCFR.js → credential-store-C1q3Ti_4.js} +1 -1
- package/dist/chunks/{env-DoAriNfh.js → env--Qwb27zw.js} +1 -1
- package/dist/chunks/{generated-option-order-D9HXEhic.js → generated-option-order-C9EDX2OQ.js} +1 -1
- package/dist/chunks/help-catalog-B2pUdIHU.js +17 -0
- package/dist/chunks/help-intent-Fr7qddNs.js +1 -0
- package/dist/chunks/{logging-DGnKgFda.js → logging-84v8ephs.js} +1 -1
- package/dist/chunks/{logging-Dm4-IZw0.js → logging-tctCAAM3.js} +1 -1
- package/dist/chunks/logout-CXT_EVLP.js +1 -0
- package/dist/chunks/{logout-De9wAaDj.js → logout-CXqzC3VA.js} +1 -1
- package/dist/chunks/oauth-bearer-credential-GdEbD3cl.js +1 -0
- package/dist/chunks/{oauth-bearer-credential-ByV8MSw5.js → oauth-bearer-credential-ngiMC6Tn.js} +1 -1
- package/dist/chunks/{oauth-credential-C8quXs0J.js → oauth-credential-Ee--7E1f.js} +1 -1
- package/dist/chunks/{oauth-credential-vgDwUMoV.js → oauth-credential-SAVxesLg.js} +1 -1
- package/dist/chunks/{oauth-login-DaQLrBYu.js → oauth-login-LmVLLnSS.js} +1 -1
- package/dist/chunks/{oauth-login-CRB25uGh.js → oauth-login-TgrrKrmk.js} +1 -1
- package/dist/chunks/{openapi-call-DTLukW7r.js → openapi-call-CGT81pGS.js} +2 -2
- package/dist/chunks/{openapi-call-CSOyWtns.js → openapi-call-DDmKW_d9.js} +1 -1
- package/dist/chunks/openapi-snapshot.json +1 -1
- package/dist/chunks/{operations-kvV6HTxR.js → operations-Co-E4WFJ.js} +1 -1
- package/dist/chunks/operations-catalog-D_c9U3Co.js +1 -0
- package/dist/chunks/{operations-catalog-C_NHlK6i.js → operations-catalog-Wl8_R7cK.js} +1 -1
- package/dist/chunks/{operations-metadata-DG12wjZa.js → operations-metadata-KNNp-nIU.js} +1 -1
- package/dist/chunks/{output-DDkZmZUV.js → output-bYaez__X.js} +1 -1
- package/dist/chunks/output-mode-CjIEi9Ak.js +1 -0
- package/dist/chunks/{output-mode-CO-iRvt8.js → output-mode-DP5-RYpo.js} +1 -1
- package/dist/chunks/{output-BdxJSZbB.js → output-nbkata_u.js} +1 -1
- package/dist/chunks/{output-spill-BNCzyHGC.js → output-spill-CTRpKGuX.js} +1 -1
- package/dist/chunks/{parse-error-hint-CvWM1YK5.js → parse-error-hint-D1rXCVZG.js} +2 -2
- package/dist/chunks/{payload-operand-guard-CisvVW-h.js → payload-operand-guard-B_RvylsW.js} +1 -1
- package/dist/chunks/{private-readback-CvY3UYHu.js → private-readback-FPT29Ioq.js} +1 -1
- package/dist/chunks/{request-replay-PgG2xNDo.js → request-replay-CHUMkRcI.js} +1 -1
- package/dist/chunks/{request-replay-Dwrt7IaD.js → request-replay-TI2KzJyi.js} +1 -1
- package/dist/chunks/{response-problem-BtBbph_9.js → response-problem-CbcU7D-E.js} +1 -1
- package/dist/chunks/response-problem-V9O17Ku7.js +1 -0
- package/dist/chunks/result-envelope-xEGBjFmo.js +1 -0
- package/dist/chunks/{startup-auth-DO3DbDPM.js → startup-auth-77f4swl7.js} +1 -1
- package/dist/chunks/{startup-auth-DLlTp1uA.js → startup-auth-CSEzokDt.js} +1 -1
- package/dist/chunks/text-response-BJChV-OC.js +17 -0
- package/dist/chunks/{tool-policy-DthqSCty.js → tool-policy-CnZ_DgRh.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/auth-resolver-2CLsbq6z.js +0 -1
- package/dist/chunks/aventure-cli-K2Hx3WO6.js +0 -11
- package/dist/chunks/contract-Bp3lW3OR.js +0 -1
- package/dist/chunks/contract-parameter-V0kQHinO.js +0 -1
- package/dist/chunks/help-catalog-BExrYg_X.js +0 -2
- package/dist/chunks/help-intent-XtdGwTW8.js +0 -1
- package/dist/chunks/human-text-cap-dR2SJQJC.js +0 -16
- package/dist/chunks/logout-1dcRkeOm.js +0 -1
- package/dist/chunks/oauth-bearer-credential-DSxklCsd.js +0 -1
- package/dist/chunks/operations-catalog-BfTe1tIc.js +0 -1
- package/dist/chunks/output-mode-BCVAiH8W.js +0 -1
- package/dist/chunks/response-problem-DSkVKOEo.js +0 -1
- package/dist/chunks/result-envelope-Ds29nFJ0.js +0 -1
- package/dist/chunks/text-response-VRC-i7Ue.js +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-DEeHDoOT.js";import{C as n,S as r,_ as i,b as a,c as o,g as s,i as c,m as l,p as u,s as d,x as f}from"./iso-DzqMxtky.js";import{A as p,O as ee,S as te,_ as ne,b as re,d as m,h as ie,i as h,l as g,n as _,p as v,w as y,x as ae}from"./esm-lPyPa01D.js";import{c as b,p as x,r as S}from"./result-envelope-Ds29nFJ0.js";import{C,G as oe,K as se,L as ce,M as le,N as ue,O as de,Q as w,R as fe,T as pe,U as me,V as T,W as he,X as ge,Y as E,_ as _e,at as ve,d as ye,f as be,g as xe,h as Se,it as Ce,j as we,k as Te,m as Ee,nt as D,ot as De,q as Oe,s as ke,tt as Ae,v as je,x as Me,y as Ne,z as O}from"./logging-Dm4-IZw0.js";import{basename as Pe,extname as Fe}from"node:path";import{AsyncLocalStorage as Ie}from"node:async_hooks";import{readFile as Le}from"node:fs/promises";_(),i({bodyPath:r(),valueField:d(i({path:d(r().nullable()).readonly(),type:c([`object`,`array`,`string`,`number`,`integer`,`boolean`]),nullable:o()})).readonly()});var k=n([l(``),r().regex(/^(?:\/(?:[^~/]|~[01])*)+$/)]),Re=f({readOperationId:r().min(1),writePointer:k,readPointer:k,readParameter:r().min(1).optional(),submittedMap:d(f({bodyPointer:k,readPointer:k,identityPointer:k})).min(1).optional(),fallback:f({writePointer:k,readPointer:k,readQueryName:r().min(1),readQueryValue:r().min(1)}).optional()});f({readPointer:k,equals:o(),omittedIn:l(`public`)});var ze=c([`QUEUED`,`STARTED`,`SEARCH`,`READ`,`CHECK`,`WRITE`,`FINISHED`]),A=Object.assign(n([ze,r()]),{enum:ze.enum});function Be(e){return new URL(e,`https://placeholder.invalid`).pathname}function Ve(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean);return n.length!==r.length||r.some(Ue)?!1:n.every((e,t)=>He(e)||e===r[t])}function He(e){let t=e.slice(1,-1);return e.startsWith(`{`)&&e.endsWith(`}`)&&t.length>0&&!t.includes(`/`)&&!t.includes(`{`)&&!t.includes(`}`)}function Ue(e){if(He(e))return!0;let t=e.toLowerCase(),n=e.slice(3,-3);return t.startsWith(`%7b`)&&t.endsWith(`%7d`)&&n.length>0&&!n.includes(`/`)&&!n.includes(`%`)&&!n.includes(`{`)&&!n.includes(`}`)}var j=[`get`,`post`,`put`,`patch`,`delete`],We=c([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]);function Ge(e){let t=We.safeParse(e.toUpperCase());if(!t.success)throw Error(`Unsupported OpenAPI method: ${e}`);return t.data}function Ke(e){let t=e.toLowerCase(),n=j.find(e=>e===t);if(n===void 0)throw Error(`Unsupported OpenAPI method: ${e}`);return n}var qe=[`oauth`,`start`,`poll`,`acknowledge`,`revoke`],Je=f({name:r().regex(/^[A-Z][A-Z0-9_]*$/u)}),M=n([l(`private`),i({scope:r().optional(),value:r().optional()})]),Ye=()=>({$ref:r().optional(),description:r().optional(),type:n([r(),d(r())]).optional(),format:r().optional(),default:x.optional(),enum:d(x).optional(),"x-extensible-enum":d(x).optional(),"x-aventure-parsed-enum":o().optional(),readOnly:o().optional(),items:N.optional(),minItems:s().int().nonnegative().optional(),maxItems:s().int().nonnegative().optional(),properties:a(r(),N).optional(),required:d(r()).optional(),oneOf:d(N).optional(),anyOf:d(N).optional(),allOf:d(N).optional(),propertyNames:N.optional(),additionalProperties:n([N,o()]).optional(),"x-aventure-visibility":M.optional(),"x-aventure-cli-conflicts":d(d(r().min(1)).min(2)).min(1).optional(),"x-aventure-env":Je.optional(),"x-aventure-detail":l(!0).optional(),"x-aventure-follow-job":l(`committed`).optional(),"x-aventure-operation-only":d(r().min(1)).min(1).optional()}),N=u(()=>i(Ye())),Xe=i({in:r(),name:r(),required:o().optional(),description:r().optional(),schema:N.optional(),"x-aventure-visibility":M.optional(),"x-aventure-legacy-name":f({name:r().trim().min(1)}).optional()}).superRefine((e,t)=>{let n=e[`x-aventure-legacy-name`]?.name;n!==void 0&&(e.in!==`path`&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`],message:`x-aventure-legacy-name is valid only for path parameters`}),n===e.name&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name must differ from its canonical name`}))}),Ze=a(r(),i({schema:N.optional()})),Qe=i({$ref:r().optional(),description:r().optional(),required:o().optional(),schema:N.optional(),"x-aventure-visibility":M.optional()}),$e=i({description:r().optional(),headers:a(r(),Qe).optional(),content:Ze.optional(),"x-aventure-standard-response":o().optional()}),et=i({description:r().optional(),required:o().optional(),content:Ze.optional()}),tt=f({auth:c([`none`,`read`,`billing`]),mutates:o()}).partial().optional(),nt=r().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)* [a-z0-9]+(?:-[a-z0-9]+)*$/u),rt=r().regex(/^[a-z][A-Za-z0-9]*$/u),it=r().regex(/^--(?:no-)?[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u),at=f({command:nt,role:c(qe),summary:r().trim().min(1).optional(),description:r().trim().min(1).optional(),bodyOption:d(rt).min(1).optional(),localOption:d(f({optionKey:rt,flag:it,description:r().trim().min(1)})).min(1).optional()}).superRefine((t,n)=>{let r=[t.bodyOption??[],(t.localOption??[]).map(e=>e.optionKey),(t.localOption??[]).map(e=>e.flag)].some(e=>new Set(e).size!==e.length),i=(t.localOption??[]).some(t=>new e(t.flag).attributeName()!==t.optionKey);(r||i)&&n.addIssue({code:`custom`,message:`Composite CLI options must be unique and match their local flags`})}).optional(),ot=i({operationId:r(),summary:r().optional(),description:r().optional(),tags:d(r()).optional(),deprecated:o().optional(),hidden:o().optional(),security:d(a(r(),d(r()))).optional(),parameters:d(Xe).optional(),requestBody:et.optional(),responses:a(r(),$e),"x-aventure-visibility":M.optional(),"x-aventure-tool":tt,"x-aventure-mutation-readback":Re.optional(),"x-aventure-completion-evidence":l(`response`).optional(),"x-aventure-respond-async":c([`default`,`prerequisite`]).optional(),"x-aventure-run-activity":c([A.enum.SEARCH,A.enum.READ,A.enum.CHECK,A.enum.WRITE]).optional(),"x-aventure-cli-composite":at,"x-aventure-cli":f({listed:l(!1)}).optional()}).superRefine((e,t)=>{let n=e.parameters??[];for(let[e,r]of n.entries()){let i=r[`x-aventure-legacy-name`]?.name;r.in===`path`&&i!==void 0&&n.some((t,n)=>n!==e&&t.in===`path`&&(t.name===i||t[`x-aventure-legacy-name`]?.name===i))&&t.addIssue({code:`custom`,path:[`parameters`,e,`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name '${i}' collides with another declared path parameter`})}}),st=i(Object.fromEntries(j.map(e=>[e,ot.optional()]))),ct=i({...Ye(),"x-aventure-noun":f({one:r().trim().min(1),other:r().trim().min(1)}).optional()});i({info:i({description:r().optional()}).optional(),tags:d(i({name:r(),description:r().optional(),"x-aventure-cli":f({section:c([`researchData`,`account`,`administration`,`cli`])}).optional()})).optional(),paths:a(r(),st),webhooks:a(r(),i({post:i({description:r(),requestBody:et})})).optional(),components:i({schemas:a(r(),ct),headers:a(r(),Qe).optional()})}).superRefine((e,t)=>{for(let[n,r]of Object.entries(e.paths))for(let i of j){for(let[a,o]of Object.entries(r[i]?.responses??{}))for(let[r,s]of Object.entries(o.headers??{}))ft(e,s)||t.addIssue({code:`custom`,path:[`paths`,n,i,`responses`,a,`headers`,r,`$ref`],message:`response header '${r}' has an unresolved or malformed $ref`});let a=r[i]?.[`x-aventure-mutation-readback`];a!==void 0&&pt(e.paths,a.readOperationId)===null&&t.addIssue({code:`custom`,path:[`paths`,n,i,`x-aventure-mutation-readback`,`readOperationId`],message:`mutation readback names '${a.readOperationId}', which no operation in this document emits`})}});var lt=new Set([`page`,`size`,`sort`]);function P(e){return dt(e?.$ref,`schemas`)}function ut(e){return dt(e?.$ref,`headers`)}function dt(e,t){let n=`#/components/${t}/`;return e?.startsWith(n)===!0&&e.slice(n.length)||void 0}function ft(e,t){let n=ut(t);if(t.$ref!==void 0&&n===void 0)return!1;let r=n===void 0?t:e.components.headers?.[n];if(r===void 0||r.$ref!==void 0)return!1;let i=P(r.schema);return r.schema?.$ref===void 0||!!(i&&e.components.schemas[i])}function pt(e,t){for(let[n,r]of Object.entries(e))for(let e of j){let i=r[e];if(i?.operationId===t)return{method:e,template:n,operation:i}}return null}function mt(e,t,n){let r=Be(n),i=e[r]?.[t];if(i)return{method:t,template:r,operation:i};for(let[n,i]of Object.entries(e)){let e=i[t];if(e&&Ve(n,r))return{method:t,template:n,operation:e}}return null}function ht(e,t,n=e){return e.replace(/\{([^}]+)}/g,(...e)=>{let r=e[1],i=t[r];if(i==null)throw Error(`Missing path parameter '${r}' for ${n}`);return encodeURIComponent(String(i))})}function gt(e,t,n){let r=t;for(let i of e.parameters??[]){let e=i[`x-aventure-legacy-name`]?.name;if(i.in!==`path`||e===void 0)continue;let a=t[e];if(Object.hasOwn(t,e)&&a!==void 0){if(Object.hasOwn(t,i.name))throw Error(`Path parameters '${i.name}' and legacy alias '${e}' were both supplied for ${n}`);r===t&&(r={...t}),r[i.name]=a,delete r[e]}}return r}function _t(e,t){let n={};for(let r of e.parameters??[]){if(r.in!==`query`||lt.has(r.name))continue;let e=t?.[r.name]??yt(r.schema?.default);e!==void 0&&(n[r.name]=e)}return Object.keys(n).length===0?void 0:n}var vt=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`;function yt(e){return vt(e)||Array.isArray(e)&&e.every(vt)?e:void 0}var bt={name:`span`,countItems:e=>e.length},xt=256,St=512;function Ct(e,t){let n=e&255|xt;return t&&(n|=St),n}function wt(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:_e(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Et(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>Tt(e,t)),droppedLinksCount:e.droppedLinksCount,flags:Ct(n.traceFlags,e.parentSpanContext?.isRemote)}}function Tt(e,t){return{attributes:e.attributes?_e(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Ct(e.context.traceFlags,e.context.isRemote)}}function Et(e,t){return{attributes:e.attributes?_e(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Dt(e,t){return{resourceSpans:kt(e,t)}}function Ot(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function kt(e,t){let n=Ot(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>wt(e,t));o.push({scope:Se(e[0].instrumentationScope,t),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=xe(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}var At={serializeRequest:e=>{let t=Dt(e,Ee);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return g.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}},jt=`otlp_http_span_exporter`,Mt=class extends De{constructor(e={}){super(be(ye(e,`TRACES`,`v1/traces`,{"Content-Type":`application/json`}),At,jt,bt,e.selfObsMeterProvider))}};me(),C(),je();var Nt=`exception`,F=Symbol.for(`nodejs.util.inspect.custom`);function Pt(e){let t={};for(let[n,r]of e.getRawAttributes())typeof r?.then!=`function`&&r!=null&&(t[n]??=r);return t}function Ft(e,t,n,r,i){if(typeof n==`number`&&n<0){let t=`[${e}]`;return r?.stylize?r.stylize(t,`special`):t}return typeof i!=`function`||!r?t:`${e} ${i(t,{...r,depth:r.depth==null?r.depth:r.depth-1})}`}_();var It=class{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:v.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=T.now(),this._performanceOffset=t-(this._performanceStartTime+T.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return g.warn(`Invalid attribute key: ${e}`),this;if(!Ae(t))return g.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return g.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&g.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),ce(t)&&(ce(n)||(n=t),t=void 0);let i=D(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];a!==void 0&&c>=a?s++:(o[e]=this._truncateToSize(t),c++)}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&g.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=D(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];n!==void 0&&o>=n?a++:(i[e]=this._truncateToSize(t),o++)}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===v.UNSET||this.status.code===v.OK)return this;let t={code:e.code};return e.code===v.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&g.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){this._isSpanEnded()?g.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(e),this._duration=ue(this.startTime,this.endTime),this._duration[0]<0&&(g.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&g.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&g.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(e){if(typeof e==`number`&&e<=T.now())return le(e+this._performanceOffset);if(typeof e==`number`)return O(e);if(e instanceof Date)return O(e.getTime());if(fe(e))return e;if(this._startTimeProvided)return O(Date.now());let t=T.now()-this._performanceStartTime;return we(this.startTime,O(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[oe]=e:e&&(e.code?n[Oe]=e.code.toString():e.name&&(n[Oe]=e.name),e.message&&(n[oe]=e.message),e.stack&&(n[se]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(Nt,n,t):g.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);g.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(g.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}[F](e,t,n){return Ft(`SpanImpl`,{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:Pt(this.resource)}},e,t,n)}},I;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(I||={});var Lt=`otel.component.name`,Rt=`otel.component.type`,zt=`otel.span.parent.origin`,Bt=`otel.span.sampling_result`,Vt=`otel.sdk.processor.span.processed`,Ht=`otel.sdk.processor.span.queue.capacity`,Ut=`otel.sdk.processor.span.queue.size`,Wt=`otel.sdk.span.live`,Gt=`otel.sdk.span.started`,Kt=`batching_span_processor`,qt=class{startedSpans;liveSpans;constructor(e){this.startedSpans=e.createCounter(Gt,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(Wt,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=Yt(t);if(this.startedSpans.add(1,{[zt]:Jt(e),[Bt]:n}),t===I.NOT_RECORD)return()=>{};let r={[Bt]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function Jt(e){return e?e.isRemote?`remote`:`local`:`none`}function Yt(e){switch(e){case I.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case I.RECORD:return`RECORD_ONLY`;case I.NOT_RECORD:return`DROP`}}var Xt=`2.11.0`;_(),C();var Zt=class{_sampler;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(e,t){this.instrumentationScope=e,this._sampler=t.sampler,this._spanLimits=t.spanLimits,this._resource=t.resource,this._idGenerator=t.idGenerator,this._spanProcessor=t.spanProcessor;let n=t.meterProvider.getMeter(`@opentelemetry/sdk-trace`,Xt);this._tracerMetrics=new qt(n)}startSpan(e,t={},n=m.active()){t.root&&(n=h.deleteSpan(n));let r=h.getSpan(n);if(Ce(n))return g.debug(`Instrumentation suppressed, returning Noop Span`),h.wrapSpanContext(te);let i=r?.spanContext(),a=this._idGenerator.generateSpanId(),o,s,c;!i||!h.isSpanContextValid(i)?s=this._idGenerator.generateTraceId():(s=i.traceId,c=i.traceState,o=i);let l=t.kind??ie.INTERNAL,u=(t.links??[]).map(e=>({context:e.context,attributes:D(e.attributes)})),d=D(t.attributes),f=this._sampler.shouldSample(n,s,e,l,d,u),p=this._tracerMetrics.startSpan(i,f.decision);c=f.traceState??c;let ee=f.decision===ne.RECORD_AND_SAMPLED?y.SAMPLED:y.NONE,re={traceId:s,spanId:a,traceFlags:ee,traceState:c};if(f.decision===ne.NOT_RECORD)return g.debug(`Recording is off, propagating context in a non-recording span`),h.wrapSpanContext(re);let _=D(Object.assign(d,f.attributes));return new It({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:re,name:e,kind:l,links:u,parentSpanContext:o,attributes:_,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:p})}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??m.active(),c=this.startSpan(e,i,s),l=h.setSpan(s,c);return m.with(l,o,void 0,c)}[F](e,t,n){return Ft(`Tracer`,{instrumentationScope:this.instrumentationScope,resource:{attributes:Pt(this._resource)},spanLimits:this._spanLimits},e,t,n)}};C();var Qt=class{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{w(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},L=class{shouldSample(){return{decision:I.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},R=class{shouldSample(){return{decision:I.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};_(),C();var z=class{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||=(w(Error(`ParentBasedSampler must have a root sampler configured`)),new R),this._remoteParentSampled=e.remoteParentSampled??new R,this._remoteParentNotSampled=e.remoteParentNotSampled??new L,this._localParentSampled=e.localParentSampled??new R,this._localParentNotSampled=e.localParentNotSampled??new L}shouldSample(e,t,n,r,i,a){let o=h.getSpanContext(e);return!o||!re(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&y.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&y.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};me();var $t=new Map,en=class{processedSpans;queueSize;queueSizeCallback;standardAttrs;droppedAttrs;constructor(e,t,n){let r=$t.get(e)??0;if($t.set(e,r+1),this.standardAttrs={[Rt]:e,[Lt]:`${e}/${r}`},this.droppedAttrs={...this.standardAttrs,[he]:`queue_full`},this.processedSpans=t.createCounter(Vt,{unit:`{span}`,description:`The number of spans for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter(Ht,{unit:`{span}`,description:`The maximum number of spans the queue of a given instance of an SDK span processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(Ut,{unit:`{span}`,description:`The number of spans in the queue of a given instance of an SDK span processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(e){this.processedSpans.add(e,this.droppedAttrs)}finishSpans(e,t){if(!t){this.processedSpans.add(e,this.standardAttrs);return}let n={...this.standardAttrs,[he]:t.name};this.processedSpans.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};_(),C();var tn=class{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_metrics;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(e){this._exporter=e.exporter,this._maxExportBatchSize=e.maxExportBatchSize??512,this._maxQueueSize=e.maxQueueSize??2048,this._scheduledDelayMillis=e.scheduledDelayMillis??5e3,this._exportTimeoutMillis=e.exportTimeoutMillis??3e4,this._shutdownOnce=new pe(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(g.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let t=e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-trace`):ee();this._metrics=new en(Kt,t,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&y.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>(this._metrics.shutdown(),this._exporter.shutdown()))}_addToBuffer(e){this._finishedSpans.length>=this._maxQueueSize?(this._droppedSpansCount===0&&g.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++,this._metrics.dropSpans(1)):(this._droppedSpansCount>0&&(g.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer())}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);m.with(ve(m.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,i=>{clearTimeout(n),this._metrics.finishSpans(r.length,i.error),i.code===Te.SUCCESS?e():t(i.error??Error(`BatchSpanProcessor: span export failed`))}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??=[],a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{w(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,w(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},nn=class extends tn{onShutdown(){}},rn=8,an=16,on=class{generateTraceId=sn(an);generateSpanId=sn(rn)},B=Buffer.allocUnsafe(an);function sn(e){return function(){for(let t=0;t<e/4;t++)B.writeUInt32BE(Math.random()*2**32>>>0,t*4);for(let t=0;t<e&&!(B[t]>0);t++)t===e-1&&(B[e-1]=1);return B.toString(`hex`,0,e)}}_();var V;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(V||={});var cn=class{_resource;_activeSpanProcessor;_forceFlushTimeoutMillis;_tracerOptions;_tracers=new Map;constructor(e={}){this._forceFlushTimeoutMillis=e.forceFlushTimeoutMillis??3e4,this._resource=e.resource??Ne();let t=e.spanProcessors??[];this._activeSpanProcessor=new Qt(t),this._tracerOptions={resource:this._resource,sampler:e.sampler??new z({root:new R}),spanLimits:{attributeCountLimit:e.spanLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.spanLimits?.attributeValueLengthLimit??1/0,eventCountLimit:e.spanLimits?.eventCountLimit??128,linkCountLimit:e.spanLimits?.linkCountLimit??128,attributePerEventCountLimit:e.spanLimits?.attributePerEventCountLimit??128,attributePerLinkCountLimit:e.spanLimits?.attributePerLinkCountLimit??128},idGenerator:e.idGenerator||new on,spanProcessor:this._activeSpanProcessor,meterProvider:e.meterProvider??{getMeter(){return ee()}}}}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new Zt({name:e,version:t,schemaUrl:n?.schemaUrl},this._tracerOptions)),this._tracers.get(r)}forceFlush(e){let t=e?.timeoutMillis??this._forceFlushTimeoutMillis,n=this._activeSpanProcessor._spanProcessors.map(e=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${t} ms`)),r=V.timeout},t);e.forceFlush().then(()=>{clearTimeout(i),r!==V.timeout&&(r=V.resolved,n(r))}).catch(e=>{clearTimeout(i),r=V.error,n(e)})}));return new Promise((e,t)=>{Promise.all(n).then(n=>{let r=n.filter(e=>e!==V.resolved);r.length>0?t(r):e()}).catch(e=>t([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}[F](e,t,n){let r=this._activeSpanProcessor._spanProcessors;return Ft(`TracerProvider`,{resource:{attributes:Pt(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:r.map(e=>e.constructor?.name??`SpanProcessor`)},e,t,n)}};_();var ln=class{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=this._ratio===1?4294967296:Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:ae(t)&&this._accumulate(t)<this._upperBound?I.RECORD_AND_SAMPLED:I.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}};_(),C();var H;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(H||={});var U=1;function un(){return{sampler:dn(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:E(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:E(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128},spanLimits:{attributeValueLengthLimit:E(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:E(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??128,linkCountLimit:E(`OTEL_SPAN_LINK_COUNT_LIMIT`)??128,eventCountLimit:E(`OTEL_SPAN_EVENT_COUNT_LIMIT`)??128,attributePerEventCountLimit:E(`OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT`)??128,attributePerLinkCountLimit:E(`OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT`)??128}}}function dn(){let e=ge(`OTEL_TRACES_SAMPLER`)??H.ParentBasedAlwaysOn;switch(e){case H.AlwaysOn:return new R;case H.AlwaysOff:return new L;case H.ParentBasedAlwaysOn:return new z({root:new R});case H.ParentBasedAlwaysOff:return new z({root:new L});case H.TraceIdRatio:return new ln(fn());case H.ParentBasedTraceIdRatio:return new z({root:new ln(fn())});default:return g.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${H.ParentBasedAlwaysOn}".`),new z({root:new R})}}function fn(){let e=E(`OTEL_TRACES_SAMPLER_ARG`);return e==null?(g.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${U}.`),U):e<0||e>1?(g.error(`OTEL_TRACES_SAMPLER_ARG=${e} was given, but it is out of range ([0..1]), defaulting to ${U}.`),U):e}C();function pn(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??E(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??E(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??E(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??E(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,Object.assign({},e,{spanLimits:t})}C();var mn=class extends cn{constructor(e={}){let t=de({},un(),pn(e));delete t.generalLimits,super(t)}};C();var hn=class extends nn{constructor(e,t){t||={};for(let[e,n]of[[`maxExportBatchSize`,`OTEL_BSP_MAX_EXPORT_BATCH_SIZE`],[`maxQueueSize`,`OTEL_BSP_MAX_QUEUE_SIZE`],[`scheduledDelayMillis`,`OTEL_BSP_SCHEDULE_DELAY`],[`exportTimeoutMillis`,`OTEL_BSP_EXPORT_TIMEOUT`]])if(t[e]===void 0){let r=E(n);r!==void 0&&(t[e]=r)}super({exporter:e,...t})}};_(),je();var gn=`aventure-mcp-server`,_n=`aventure=mcp`,vn=`langfuse.session.id`,yn=`/api/public/otel/v1/traces`,bn=5e3,xn=new Set([`langfuse.observation.input`,`langfuse.observation.output`,`langfuse.observation.status_message`]),Sn=[`OTEL_EXPORTER_OTLP_HEADERS`,`OTEL_EXPORTER_OTLP_TRACES_HEADERS`],W,G;function K(e){return e?.trim()||void 0}function Cn(){return K(process.env.GIT_SHA)??K(process.env.SENTRY_RELEASE)??t().version}function wn(){let e=K(process.env.LANGFUSE_BASE_URL),t=K(process.env.LANGFUSE_PUBLIC_KEY),n=K(process.env.LANGFUSE_SECRET_KEY);if(e!==void 0&&t!==void 0&&n!==void 0){for(let e of Sn){let t=(process.env[e]??``).split(`,`).map(e=>e.split(`=`,1)[0]?.trim().toLowerCase()??``).filter(e=>e!==``&&e!==`authorization`);if(t.length>0)throw Error(`${e} sets ${t.join(`, `)}, which the Langfuse trace exporter would forward`)}return new Mt({url:new URL(yn,e).href,headers:{Authorization:`Basic ${Buffer.from(`${t}:${n}`).toString(`base64`)}`,"x-langfuse-ingestion-version":`4`},timeoutMillis:bn})}}function Tn(e){let t={};for(let[n,r]of Object.entries(e.attributes))xn.has(n)||(t[n]=r);return{name:e.name,kind:e.kind,spanContext:()=>e.spanContext(),...e.parentSpanContext===void 0?{}:{parentSpanContext:e.parentSpanContext},startTime:e.startTime,endTime:e.endTime,status:e.status,attributes:t,links:e.links,events:e.events,duration:e.duration,ended:e.ended,resource:e.resource,instrumentationScope:e.instrumentationScope,droppedAttributesCount:e.droppedAttributesCount,droppedEventsCount:e.droppedEventsCount,droppedLinksCount:e.droppedLinksCount}}function En(e){return{export:(t,n)=>e.export(t.map(Tn),n),shutdown:()=>e.shutdown(),forceFlush:()=>e.forceFlush?.()??Promise.resolve()}}function Dn(){if(W!==void 0)return G;let e=K(process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT),t=[...e===void 0?[]:[En(new Mt({url:e,timeoutMillis:bn}))],...[wn()].filter(e=>e!==void 0)];return W=new mn({sampler:new R,resource:Me({...ke(),"service.version":Cn()}),spanProcessors:t.map(e=>new hn(e,{exportTimeoutMillis:bn}))}),G=t.length===0?void 0:W.getTracer(gn),G}function On(){Dn()}var kn=/^00-(?<traceId>[0-9a-f]{32})-(?<spanId>[0-9a-f]{16})-(?<flags>[0-9a-f]{2})$/u,An=/[13579bdf]$/u;function jn(e,t,n){let r=Dn();if(r===void 0)return;let i=kn.exec(n??``)?.groups,a=i?.traceId===void 0||i.spanId===void 0?p:h.setSpanContext(p,{traceId:i.traceId,spanId:i.spanId,traceFlags:An.test(i.flags??``)?y.SAMPLED:y.NONE,isRemote:!0});return r.startSpan(e,{kind:ie.SERVER,attributes:{"langfuse.trace.name":e,...t,"langfuse.environment":ke()[`deployment.environment.name`],"langfuse.release":Cn()}},a)}function Mn(e){let{traceId:t,spanId:n,traceFlags:r}=e.spanContext();return`00-${t}-${n}-${(r&y.SAMPLED)===0?`00`:`01`}`}function Nn(e,t,n){e.setAttributes(t),e.setStatus({code:n?v.ERROR:v.OK}),e.end()}async function Pn(){let e=W;W=void 0,G=void 0,await e?.shutdown()}var q=new Ie,Fn=`X-Client-Request-Id`,In=()=>q.getStore()?.requestId,Ln=()=>q.getStore()?.toolApiCall,Rn=()=>q.getStore()?.responseDeadline,zn=()=>q.getStore()?.userBearerToken;function Bn(){let e=q.getStore(),t=[...e?.sessionId===void 0?[]:[`${vn}=${encodeURIComponent(e.sessionId)}`],...e?.traceName===void 0?[]:[`langfuse.trace.name=${encodeURIComponent(e.traceName)}`],...e?.traceTag===void 0?[]:[`langfuse.trace.tags=${encodeURIComponent(e.traceTag.map(encodeURIComponent).join(`,`))}`]].join(`,`);return{...e?.requestId===void 0?{}:{[Fn]:e.requestId},...e?.traceparent===void 0?{}:{traceparent:e.traceparent,tracestate:_n,...t.length===0?{}:{baggage:t}}}}function Vn(e,t){return q.run({...q.getStore(),requestId:e,toolApiCall:{failed:!1}},t)}function Hn(e,t){return q.run({...q.getStore(),responseDeadline:e},t)}function Un(e,t){return q.run({...q.getStore(),userBearerToken:e},t)}function Wn(e,t){return q.run({...q.getStore(),...e},t)}var Gn=Object.freeze({total:8,perOrigin:2,originLimit:64,failureThreshold:3,cooldownMs:3e4,idleMs:3e4,halfOpenProbes:1}),Kn=Object.freeze({total:128,perOrigin:64,originLimit:64,failureThreshold:5,cooldownMs:15e3,idleMs:3e5,halfOpenProbes:1}),qn=new WeakMap,J=class extends Error{reason;constructor(e){super(e===`capacity`?`Origin capacity exceeded; try again later.`:`Origin circuit is open; try again later.`),this.reason=e}};function Jn(e,t){let n=Date.now(),r=qn.get(t);r===void 0&&(r={active:0,origin:new Map},qn.set(t,r));for(let[i,a]of r.origin)i!==e&&a.active===0&&a.updatedAt+t.idleMs<=n&&r.origin.delete(i);let i=r.origin.get(e);if(i===void 0){if(r.origin.size>=t.originLimit)throw new J(`capacity`);i={active:0,failures:0,openUntil:0,updatedAt:n},r.origin.set(e,i)}if(i.openUntil>n||i.failures>=t.failureThreshold&&i.active>=t.halfOpenProbes)throw new J(`circuit`);if(r.active>=t.total||i.active>=t.perOrigin)throw new J(`capacity`);return i.active++,r.active++,{finish:Yn(r,i,t)}}function Yn(e,t,n){let r=!1;return i=>{r||(r=!0,t.active--,e.active--,t.updatedAt=Date.now(),i===`failure`?(t.failures++,t.failures>=n.failureThreshold&&(t.openUntil=t.updatedAt+n.cooldownMs)):i===`success`&&(t.failures=0,t.openUntil=0))}}var Xn=3e4,Zn=20,Y=52428800;async function Qn(e,t,n,r={}){let i=rr(X(e.requestBody?.content),n);if(!i.ok||i.data===null)return S(i.summary,i.warnings);let a=i.data;if(e.requestBody?.required===!0&&t===void 0&&a?.kind!==`multipart`)return S(`Request body is required.`);if(a?.kind===`multipart`)return await ar(e.requestBody?.required===!0,a.schema,t,r);let o=a?.contentType??r.defaultContentType;return b(`Request body prepared`,{...t===void 0?{}:{body:t},...o===void 0?{}:{contentType:o}})}function $n(e){if(typeof e!=`string`)return b(`Request body unchanged`,e);let t=e.trimStart().slice(0,1);if(t!==`{`&&t!==`[`)return b(`Request body unchanged`,e);try{let t=x.safeParse(JSON.parse(e));if(!t.success)throw t.error;return b(`Request body parsed`,t.data)}catch(e){return S(`Request body string must be valid JSON: ${e instanceof Error?e.message:String(e)}`)}}function er(e,t){let n=e?.schema;if(n===void 0)return!1;let r=P(n),i=n.type??(r===void 0?void 0:t[r]?.type);return Array.isArray(i)?i.includes(`array`):i===`array`}function tr(e){return X(e)[0]?.kind??`json`}function nr(e){return e===void 0||Object.keys(e).length===0||X(e).length>0}function X(e){let t=Object.entries(e??{});return[...t.flatMap(e=>vr(e[0])?[ir(e,`json`)]:[]),...t.flatMap(e=>yr(e[0])?[ir(e,`multipart`)]:[])]}function rr(e,t){if(t===void 0)return b(`Default request content selected`,e[0]);let n=Q(t),r=e.find(e=>Q(e.contentType)===n);return r===void 0?S(`Request Content-Type '${t}' is not supported. Supported choices: ${e.map(({contentType:e})=>e).join(`, `)||`none`}.`):b(`Explicit request content selected`,r)}function ir(e,t){let n=e[1].schema;return{contentType:e[0],kind:t,...n===void 0?{}:{schema:n}}}async function ar(e,t,n,r){if(!e&&n==null)return b(`Optional multipart body omitted`,{});let i=or(n);if(!i.ok||i.data===null)return S(i.summary,i.warnings);let a=new FormData;for(let e of sr(t)){let t=i.data[e.name];if(t==null){if(e.required)return S(`Multipart body requires '${e.name}'.`)}else{if(Array.isArray(t)&&t.length<(e.schema.minItems??0))return S(`Multipart part '${e.name}' requires more entries.`);if(Array.isArray(t)&&t.length>(e.schema.maxItems??2**53-1))return S(`Multipart part '${e.name}' has too many entries.`);if(cr(e.schema)||lr(e.schema)){let n=lr(e.schema)?t:[t];if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))return S(`Multipart part '${e.name}' must contain file paths or URLs.`);for(let t of n){if(typeof t!=`string`)continue;let n=await fr(t,r);if(!n.ok||n.data===null)return S(n.summary,n.warnings,{httpStatus:n.httpStatus});a.append(e.name,n.data.blob,n.data.filename)}}else if(ur(e.schema,t)){let n=JSON.stringify(t);a.append(e.name,new Blob([n],{type:`application/json`}),`${e.name}.json`)}else{let n=dr(a,e.name,t);if(!n.ok)return n}}}return b(`Multipart body prepared`,{body:a})}function or(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=Object.fromEntries(Object.entries(e));return b(`Multipart input parsed`,t)}return S(`Multipart request body must be a JSON object keyed by form part name.`)}function sr(e){let t=new Set(e?.required??[]);return Object.entries(e?.properties??{}).map(([e,n])=>({name:e,schema:n,required:t.has(e)}))}function cr(e){return e.type===`string`&&e.format===`binary`}function lr(e){return e.type===`array`&&e.items!==void 0&&cr(e.items)}function ur(e,t){return typeof t!=`object`||!t||Array.isArray(t)?!1:e.type===`object`||typeof e.$ref==`string`&&e.$ref.length>0}function dr(e,t,n){if(Array.isArray(n)){for(let r of n){let n=dr(e,t,r);if(!n.ok)return n}return b(`Multipart scalar array appended`,null)}return typeof n==`object`?S(`Multipart part '${t}' must be scalar.`):(e.append(t,String(n)),b(`Multipart scalar appended`,null))}async function fr(e,t){if(t.signal?.aborted||(t.deadline??1/0)<=Date.now()){let e=Ln();return e!==void 0&&!Z(t.signal)&&(e.failed=!0),S(`Media preparation canceled or invocation deadline exceeded.`)}return gr(e)?In()===void 0?await pr(e,t):S(`MCP media URL fetching is disabled. Pass the page as sourceUrl in the JSON body instead.`):In()===void 0?await hr(e,t.signal):S(`MCP callers cannot upload local files: pass an http(s) URL as the multipart part, or send media by sourceUrl in a JSON body. Local file paths are CLI-only.`)}async function pr(e,t){let n=new AbortController,r=Math.min(Xn,(t.deadline??1/0)-Date.now()),i=setTimeout(()=>n.abort(),Math.max(r,1)),a=t.signal?AbortSignal.any([n.signal,t.signal]):n.signal,o,s,c=`neutral`;try{if(a.throwIfAborted(),r<=0)throw Error(`Invocation deadline exceeded.`);let t=new URL(e),n=t;for(let e=0;;e++){a.throwIfAborted(),o=Jn(n.origin,Gn),c=`failure`,s=await fetch(n.href,{signal:a,redirect:`manual`});let t=s.headers.get(`location`);if(![301,302,303,307,308].includes(s.status)||t===null)break;if(await s.body?.cancel(),e>=Zn)throw Error(`Media URL exceeded the redirect limit.`);let r=new URL(t,n);o.finish(`success`),o=void 0,s=void 0,n=r}if(c=s.status===429||s.status>=500?`failure`:`success`,!s.ok)return await s.body?.cancel(),S(`Failed to fetch media URL: ${s.status} ${s.statusText}`,[],{httpStatus:s.status});c=`failure`;let i=s.headers.get(`content-type`)?.split(`;`)[0]?.trim()??_r(t.pathname)??``,l=await mr(s,{type:i,signal:a});return c=`success`,b(`URL media fetched`,{blob:l,filename:Pe(t.pathname)||`upload`})}catch(e){(e instanceof J||a.aborted||r<=0)&&(c=`failure`),e instanceof RangeError&&(c=`success`),Z(t.signal)&&(c=`neutral`),s?.body&&!s.body.locked&&!s.bodyUsed&&await s.body.cancel();let i=Z(t.signal)?`Failed to fetch media URL: canceled.`:t.signal?.aborted?`Failed to fetch media URL: invocation deadline exceeded.`:n.signal.aborted?`Failed to fetch media URL: timed out after ${r}ms.`:`Failed to fetch media URL: ${e instanceof Error?e.message:String(e)}`;return S(i,[],{httpStatus:e instanceof RangeError?void 0:s?.status})}finally{clearTimeout(i);let e=Ln();e!==void 0&&c===`failure`&&!Z(t.signal)&&(e.failed=!0),o?.finish(c)}}function Z(e){return e?.aborted===!0&&!(e.reason instanceof DOMException&&e.reason.name===`TimeoutError`)}async function mr(e,{type:t,signal:n}){let r=e.body?.getReader();if(r===void 0)throw Error(`Media URL returned no body.`);let i=[],a=0,o=!1,s,c=new Promise(e=>{s=()=>e({done:!0,value:void 0}),n.addEventListener(`abort`,s,{once:!0})});try{if(Number(e.headers.get(`content-length`))>Y)throw RangeError(`Media exceeds the ${Y}-byte upload limit.`);for(;;){n.throwIfAborted();let e=await Promise.race([r.read(),c]);if(n.throwIfAborted(),e.done)break;if(a+=e.value.byteLength,a>Y)throw RangeError(`Media exceeds the ${Y}-byte upload limit.`);i.push(new Blob([e.value.slice()]))}return o=!0,new Blob(i,{type:t})}finally{s&&n.removeEventListener(`abort`,s),o||await r.cancel(),r.releaseLock()}}async function hr(e,t){try{let n=_r(e)??``,r=await Le(e,{signal:t});return b(`File media read`,{blob:new Blob([r],{type:n}),filename:Pe(e)})}catch(t){return S(`Failed to read media file '${e}': ${t instanceof Error?t.message:String(t)}`)}}function gr(e){return e.startsWith(`http://`)||e.startsWith(`https://`)}function _r(e){return br[Fe(e).toLowerCase()]}function vr(e){let t=Q(e);return t===`*/*`||t===`application/json`||t.endsWith(`+json`)}function yr(e){return Q(e)===`multipart/form-data`}var Q=e=>e.split(`;`)[0]?.trim().toLowerCase()??``,br={".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`};function xr(e,t,n){let r=new Map,i=(t,a,o)=>{let s=P(t);if(a>n||s!==void 0&&o.includes(s))return;let c=s===void 0?o:[...o,s],l=Cr(e,t);for(let e of[...l.items===void 0?[]:[l.items],...l.oneOf??[],...l.anyOf??[],...l.allOf??[]])i(e,a,c);for(let[e,t]of Object.entries(l.properties??{}))r.set(e,Math.min(r.get(e)??a,a)),i(t,a+1,c)};for(let[e,n]of Object.entries(t))e.startsWith(`2`)&&i(Sr(n.content),0,[]);return r}function Sr(e){return e?.[`application/json`]?.schema??Object.values(e??{}).find(e=>e.schema!==void 0)?.schema}function Cr(e,t){let n=P(t);return{...n===void 0?void 0:e.components.schemas[n],...t}}function wr(e){if(e===`private`||typeof e==`object`&&(e.scope===`private`||e.value===`private`))return`private`}var Tr=`format`;function Er(e){return e===`write`||e===`delete`}function Dr(e){return Er(e)||e===`job`}function Or(e,t){return e===`DELETE`||t===`delete`}var kr=`Shell-safe input: single-quote string flag values that contain $; use --from-file or stdin for JSON bodies, multiline text, and free text with currency amounts.`;function Ar(e,t){let n=e===`array`?t:e;return n===void 0||n===`string`}function jr(e){let t=e.operation[`x-aventure-tool`];if(!Rr(e.path,e.operation,e.method===`GET`&&t?.auth===`none`,e.includeBinary===!0))return null;let n=Lr(e.operation.operationId),r=Jr(e.path,n),i=Ir(r,n,e.method),a=Nr(e.method,e.operation);if(a===null)return null;let o=t?.auth===`read`&&i===`write`?`lookup`:i,s=e.method===`GET`||a===`read`||a===`none`;return{resource:Yr(e.path),intent:o,cliPath:r,scope:s&&!Er(o)?`read`:`write`,auth:a,visibility:wr(e.operation[`x-aventure-visibility`]),mutates:t?.mutates===!0||void 0,selfCredential:Mr(e.operation)||void 0,billingAuthorization:t?.auth===`billing`||void 0,stdinBody:e.operation.requestBody!==void 0&&tr(e.operation.requestBody.content)===`json`,destructive:Or(e.method,o)}}function Mr(e){let t=e.security??[];return t.length>0&&t.every(e=>Object.keys(e).every(e=>e===`clerkApiKeyAuth`))}function Nr(e,t){let n=t[`x-aventure-tool`]?.auth;if(n===`none`)return`none`;if(n===`read`)return`read`;if(e===`GET`&&(t.security?.length??0)===0)return`none`;let r=!1,i=!1,a=!1;for(let e of t.security??[]){let t=Object.keys(e);t.includes(`clientSecretAuth`)&&(r=!0),t.includes(`adminApiKeyAuth`)&&(a=!0),(t.includes(`bearerAuth`)||t.includes(`clerkApiKeyAuth`))&&(i=!0)}return e===`GET`&&r||r&&!a&&!i?`read`:a?`write`:i?`bearer`:e===`GET`?`read`:null}var Pr={add:`write`,answer:`search`,ask:`search`,attach:`write`,audit:`read`,batch:`lookup`,convert:`write`,create:`write`,delete:`delete`,enrich:`write`,filter:`search`,get:`read`,import:`write`,join:`write`,list:`read`,lookup:`lookup`,merge:`write`,preview:`lookup`,reconcile:`write`,remove:`delete`,replace:`write`,resolve:`lookup`,search:`search`,status:`read`,suggest:`read`,update:`write`,upload:`write`},Fr=`status`;function Ir(e,t,n){if(e.length===1&&e[0]===Fr)return`status`;let r=Object.hasOwn(Pr,t)?Pr[t]:void 0;return r===void 0?n===`GET`?`read`:n===`DELETE`?`delete`:`write`:r}function Lr(e){let t=/^[a-z]+/u.exec(e)?.[0];if(t===void 0)throw Error(`operationId '${e}' has no verb`);return t}function Rr(e,t,n,r){return zr(e)&&t.hidden!==!0&&(n||!Br.some(t=>t.test(e)))&&nr(t.requestBody?.content)&&(Wr(t.responses)||r&&Ur(t))}function zr(e){return e.startsWith(`/v1/`)||e.startsWith(`/v2/`)}var Br=[/^\/v1\/auth\/(?:session|login|ui|registrations|password-resets|cli-authorizations|linkedin)(?:\/|$)/u,/^\/v1\/addresses\/locations(?:\/|$)/u,/^\/v1\/(?:chat\/completions|embeddings)$/u,/^\/v1\/observability(?:\/|$)/u,/^\/v1\/media\/identicons(?:\/|$)/u],Vr=/(?:^|-)(?:runs|jobs|turns)$/u;function Hr(e,t){let{intent:n,method:r,mutates:i}=e;if(e.selfCredential===!0||e.deprecated===!0)return null;if(!Dr(n)&&i!==!0&&r!==`PUT`&&r!==`PATCH`)return`aventure_read`;if(t===`private`)return n===`delete`?`aventure_delete`:`aventure_write`;if(e.billingAuthorization===!0&&n===`write`)return`aventure_write`;if(n===`job`||i===!0)return`aventure_job`;let a=Lr(e.operationId),o=a===`enrich`||a===`create`&&Vr.test(e.cliPath.at(-2)??``);return n===`write`&&o?`aventure_job`:null}function Ur(e){let t=Object.entries(e.responses).filter(([e])=>e.startsWith(`2`));return t.length>0&&t.every(([,e])=>{let t=Object.values(e.content??{});return t.length>0&&t.every(e=>qr(e.schema))})}function Wr(e){return Object.entries(e).filter(([e])=>e.startsWith(`2`)).every(([,e])=>Gr(e.content))}function Gr(e){if(e===void 0)return!0;let t=Object.entries(e);return t.length===0||t.some(([e,t])=>Kr(e)&&!qr(t.schema))}function Kr(e){return e===`*/*`||e===`application/json`||e.endsWith(`+json`)}function qr(e){return e?.format===`byte`||e?.format===`binary`}function Jr(e,t){let n=Qr(e).map($),r=n.length===1&&t===`get`&&!e.includes(`{`),i=n.some(e=>e.split(`-`).includes(t));return r||i?n:[...n,t]}function Yr(e){return $(Qr(e).at(0)??`system`)}function Xr({operationId:e,tool:t}){if(t===void 0)throw Error(`Operation ${e} is not in the MCP catalog.`);return t}function $(e){return e.replace(/([a-z0-9])([A-Z])/gu,`$1-$2`).replace(/[^A-Za-z0-9]+/gu,`-`).replace(/^-+|-+$/gu,``).toLowerCase()}var Zr=e=>`--${$(e)}`;function Qr(e){return $r(e).filter(e=>!ei(e)&&!ti(e))}function $r(e){return e.split(`/`).filter(e=>e.length>0)}function ei(e){return/^v\d+$/u.test(e)}function ti(e){return e.startsWith(`{`)&&e.endsWith(`}`)}export{Hn as A,Ge as B,Fn as C,Bn as D,Ln as E,Pn as F,_t as G,gt as H,jn as I,Be as J,mt as K,On as L,Un as M,vn as N,zn as O,Nn as P,Mn as R,Jn as S,Rn as T,pt as U,ht as V,Ke as W,X as _,Dr as a,Kn as b,Zr as c,Hr as d,$ as f,Qn as g,$n as h,Ur as i,Wn as j,Vn as k,Or as l,xr as m,Pr as n,Ar as o,jr as p,P as q,Tr as r,Xr as s,kr as t,Er as u,er as v,In as w,J as x,rr as y,j as z};
|
|
1
|
+
import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-DEeHDoOT.js";import{C as n,S as r,_ as i,b as a,c as o,g as s,i as c,m as l,p as u,s as d,x as f}from"./iso-DzqMxtky.js";import{A as p,O as ee,S as te,_ as ne,b as re,d as m,h as ie,i as h,l as g,n as _,p as v,w as y,x as ae}from"./esm-lPyPa01D.js";import{c as b,p as x,r as S}from"./result-envelope-xEGBjFmo.js";import{C,G as oe,K as se,L as ce,M as le,N as ue,O as de,Q as w,R as fe,T as pe,U as me,V as T,W as he,X as ge,Y as E,_ as _e,at as ve,d as ye,f as be,g as xe,h as Se,it as Ce,j as we,k as Te,m as Ee,nt as D,ot as De,q as Oe,s as ke,tt as Ae,v as je,x as Me,y as Ne,z as O}from"./logging-tctCAAM3.js";import{basename as Pe,extname as Fe}from"node:path";import{AsyncLocalStorage as Ie}from"node:async_hooks";import{readFile as Le}from"node:fs/promises";_(),i({bodyPath:r(),valueField:d(i({path:d(r().nullable()).readonly(),type:c([`object`,`array`,`string`,`number`,`integer`,`boolean`]),nullable:o()})).readonly()});var k=n([l(``),r().regex(/^(?:\/(?:[^~/]|~[01])*)+$/)]),Re=f({readOperationId:r().min(1),writePointer:k,readPointer:k,readParameter:r().min(1).optional(),submittedMap:d(f({bodyPointer:k,readPointer:k,identityPointer:k})).min(1).optional(),fallback:f({writePointer:k,readPointer:k,readQueryName:r().min(1),readQueryValue:r().min(1)}).optional()});f({readPointer:k,equals:o(),omittedIn:l(`public`)});var ze=c([`QUEUED`,`STARTED`,`SEARCH`,`READ`,`CHECK`,`WRITE`,`FINISHED`]),A=Object.assign(n([ze,r()]),{enum:ze.enum});function Be(e){return new URL(e,`https://placeholder.invalid`).pathname}function Ve(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean);return n.length!==r.length||r.some(Ue)?!1:n.every((e,t)=>He(e)||e===r[t])}function He(e){let t=e.slice(1,-1);return e.startsWith(`{`)&&e.endsWith(`}`)&&t.length>0&&!t.includes(`/`)&&!t.includes(`{`)&&!t.includes(`}`)}function Ue(e){if(He(e))return!0;let t=e.toLowerCase(),n=e.slice(3,-3);return t.startsWith(`%7b`)&&t.endsWith(`%7d`)&&n.length>0&&!n.includes(`/`)&&!n.includes(`%`)&&!n.includes(`{`)&&!n.includes(`}`)}var j=[`get`,`post`,`put`,`patch`,`delete`],We=c([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`]);function Ge(e){let t=We.safeParse(e.toUpperCase());if(!t.success)throw Error(`Unsupported OpenAPI method: ${e}`);return t.data}function Ke(e){let t=e.toLowerCase(),n=j.find(e=>e===t);if(n===void 0)throw Error(`Unsupported OpenAPI method: ${e}`);return n}var qe=[`oauth`,`start`,`poll`,`acknowledge`,`revoke`],Je=f({name:r().regex(/^[A-Z][A-Z0-9_]*$/u)}),M=n([l(`private`),i({scope:r().optional(),value:r().optional()})]),Ye=()=>({$ref:r().optional(),description:r().optional(),type:n([r(),d(r())]).optional(),format:r().optional(),default:x.optional(),enum:d(x).optional(),"x-extensible-enum":d(x).optional(),"x-aventure-parsed-enum":o().optional(),readOnly:o().optional(),items:N.optional(),minItems:s().int().nonnegative().optional(),maxItems:s().int().nonnegative().optional(),properties:a(r(),N).optional(),required:d(r()).optional(),oneOf:d(N).optional(),anyOf:d(N).optional(),allOf:d(N).optional(),propertyNames:N.optional(),additionalProperties:n([N,o()]).optional(),"x-aventure-visibility":M.optional(),"x-aventure-cli-conflicts":d(d(r().min(1)).min(2)).min(1).optional(),"x-aventure-env":Je.optional(),"x-aventure-detail":l(!0).optional(),"x-aventure-follow-job":l(`committed`).optional(),"x-aventure-operation-only":d(r().min(1)).min(1).optional()}),N=u(()=>i(Ye())),Xe=i({in:r(),name:r(),required:o().optional(),description:r().optional(),schema:N.optional(),"x-aventure-visibility":M.optional(),"x-aventure-legacy-name":f({name:r().trim().min(1)}).optional()}).superRefine((e,t)=>{let n=e[`x-aventure-legacy-name`]?.name;n!==void 0&&(e.in!==`path`&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`],message:`x-aventure-legacy-name is valid only for path parameters`}),n===e.name&&t.addIssue({code:`custom`,path:[`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name must differ from its canonical name`}))}),Ze=a(r(),i({schema:N.optional()})),Qe=i({$ref:r().optional(),description:r().optional(),required:o().optional(),schema:N.optional(),"x-aventure-visibility":M.optional()}),$e=i({description:r().optional(),headers:a(r(),Qe).optional(),content:Ze.optional(),"x-aventure-standard-response":o().optional()}),et=i({description:r().optional(),required:o().optional(),content:Ze.optional()}),tt=f({auth:c([`none`,`read`,`billing`]),mutates:o()}).partial().optional(),nt=r().trim().regex(/^[a-z0-9]+(?:-[a-z0-9]+)* [a-z0-9]+(?:-[a-z0-9]+)*$/u),rt=r().regex(/^[a-z][A-Za-z0-9]*$/u),it=r().regex(/^--(?:no-)?[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u),at=f({command:nt,role:c(qe),summary:r().trim().min(1).optional(),description:r().trim().min(1).optional(),bodyOption:d(rt).min(1).optional(),localOption:d(f({optionKey:rt,flag:it,description:r().trim().min(1)})).min(1).optional()}).superRefine((t,n)=>{let r=[t.bodyOption??[],(t.localOption??[]).map(e=>e.optionKey),(t.localOption??[]).map(e=>e.flag)].some(e=>new Set(e).size!==e.length),i=(t.localOption??[]).some(t=>new e(t.flag).attributeName()!==t.optionKey);(r||i)&&n.addIssue({code:`custom`,message:`Composite CLI options must be unique and match their local flags`})}).optional(),ot=i({operationId:r(),summary:r().optional(),description:r().optional(),tags:d(r()).optional(),deprecated:o().optional(),hidden:o().optional(),security:d(a(r(),d(r()))).optional(),parameters:d(Xe).optional(),requestBody:et.optional(),responses:a(r(),$e),"x-aventure-visibility":M.optional(),"x-aventure-tool":tt,"x-aventure-mutation-readback":Re.optional(),"x-aventure-completion-evidence":l(`response`).optional(),"x-aventure-respond-async":c([`default`,`prerequisite`]).optional(),"x-aventure-run-activity":c([A.enum.SEARCH,A.enum.READ,A.enum.CHECK,A.enum.WRITE]).optional(),"x-aventure-cli-composite":at,"x-aventure-cli":f({listed:l(!1)}).optional()}).superRefine((e,t)=>{let n=e.parameters??[];for(let[e,r]of n.entries()){let i=r[`x-aventure-legacy-name`]?.name;r.in===`path`&&i!==void 0&&n.some((t,n)=>n!==e&&t.in===`path`&&(t.name===i||t[`x-aventure-legacy-name`]?.name===i))&&t.addIssue({code:`custom`,path:[`parameters`,e,`x-aventure-legacy-name`,`name`],message:`Legacy path parameter name '${i}' collides with another declared path parameter`})}}),st=i(Object.fromEntries(j.map(e=>[e,ot.optional()]))),ct=i({...Ye(),"x-aventure-noun":f({one:r().trim().min(1),other:r().trim().min(1)}).optional()});i({info:i({description:r().optional()}).optional(),tags:d(i({name:r(),description:r().optional(),"x-aventure-cli":f({section:c([`researchData`,`account`,`administration`,`cli`])}).optional()})).optional(),paths:a(r(),st),webhooks:a(r(),i({post:i({description:r(),requestBody:et})})).optional(),components:i({schemas:a(r(),ct),headers:a(r(),Qe).optional()})}).superRefine((e,t)=>{for(let[n,r]of Object.entries(e.paths))for(let i of j){for(let[a,o]of Object.entries(r[i]?.responses??{}))for(let[r,s]of Object.entries(o.headers??{}))ft(e,s)||t.addIssue({code:`custom`,path:[`paths`,n,i,`responses`,a,`headers`,r,`$ref`],message:`response header '${r}' has an unresolved or malformed $ref`});let a=r[i]?.[`x-aventure-mutation-readback`];a!==void 0&&pt(e.paths,a.readOperationId)===null&&t.addIssue({code:`custom`,path:[`paths`,n,i,`x-aventure-mutation-readback`,`readOperationId`],message:`mutation readback names '${a.readOperationId}', which no operation in this document emits`})}});var lt=new Set([`page`,`size`,`sort`]);function P(e){return dt(e?.$ref,`schemas`)}function ut(e){return dt(e?.$ref,`headers`)}function dt(e,t){let n=`#/components/${t}/`;return e?.startsWith(n)===!0&&e.slice(n.length)||void 0}function ft(e,t){let n=ut(t);if(t.$ref!==void 0&&n===void 0)return!1;let r=n===void 0?t:e.components.headers?.[n];if(r===void 0||r.$ref!==void 0)return!1;let i=P(r.schema);return r.schema?.$ref===void 0||!!(i&&e.components.schemas[i])}function pt(e,t){for(let[n,r]of Object.entries(e))for(let e of j){let i=r[e];if(i?.operationId===t)return{method:e,template:n,operation:i}}return null}function mt(e,t,n){let r=Be(n),i=e[r]?.[t];if(i)return{method:t,template:r,operation:i};for(let[n,i]of Object.entries(e)){let e=i[t];if(e&&Ve(n,r))return{method:t,template:n,operation:e}}return null}function ht(e,t,n=e){return e.replace(/\{([^}]+)}/g,(...e)=>{let r=e[1],i=t[r];if(i==null)throw Error(`Missing path parameter '${r}' for ${n}`);return encodeURIComponent(String(i))})}function gt(e,t,n){let r=t;for(let i of e.parameters??[]){let e=i[`x-aventure-legacy-name`]?.name;if(i.in!==`path`||e===void 0)continue;let a=t[e];if(Object.hasOwn(t,e)&&a!==void 0){if(Object.hasOwn(t,i.name))throw Error(`Path parameters '${i.name}' and legacy alias '${e}' were both supplied for ${n}`);r===t&&(r={...t}),r[i.name]=a,delete r[e]}}return r}function _t(e,t){let n={};for(let r of e.parameters??[]){if(r.in!==`query`||lt.has(r.name))continue;let e=t?.[r.name]??yt(r.schema?.default);e!==void 0&&(n[r.name]=e)}return Object.keys(n).length===0?void 0:n}var vt=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`;function yt(e){return vt(e)||Array.isArray(e)&&e.every(vt)?e:void 0}var bt={name:`span`,countItems:e=>e.length},xt=256,St=512;function Ct(e,t){let n=e&255|xt;return t&&(n|=St),n}function wt(e,t){let n=e.spanContext(),r=e.status,i=e.parentSpanContext?.spanId?t.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:t.encodeSpanContext(n.traceId),spanId:t.encodeSpanContext(n.spanId),parentSpanId:i,traceState:n.traceState?.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:_e(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Et(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:r.code,message:r.message},links:e.links.map(e=>Tt(e,t)),droppedLinksCount:e.droppedLinksCount,flags:Ct(n.traceFlags,e.parentSpanContext?.isRemote)}}function Tt(e,t){return{attributes:e.attributes?_e(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:Ct(e.context.traceFlags,e.context.isRemote)}}function Et(e,t){return{attributes:e.attributes?_e(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Dt(e,t){return{resourceSpans:kt(e,t)}}function Ot(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function kt(e,t){let n=Ot(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>wt(e,t));o.push({scope:Se(e[0].instrumentationScope,t),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=xe(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}var At={serializeRequest:e=>{let t=Dt(e,Ee);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return g.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}},jt=`otlp_http_span_exporter`,Mt=class extends De{constructor(e={}){super(be(ye(e,`TRACES`,`v1/traces`,{"Content-Type":`application/json`}),At,jt,bt,e.selfObsMeterProvider))}};me(),C(),je();var Nt=`exception`,F=Symbol.for(`nodejs.util.inspect.custom`);function Pt(e){let t={};for(let[n,r]of e.getRawAttributes())typeof r?.then!=`function`&&r!=null&&(t[n]??=r);return t}function Ft(e,t,n,r,i){if(typeof n==`number`&&n<0){let t=`[${e}]`;return r?.stylize?r.stylize(t,`special`):t}return typeof i!=`function`||!r?t:`${e} ${i(t,{...r,depth:r.depth==null?r.depth:r.depth-1})}`}_();var It=class{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:v.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(e){let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=T.now(),this._performanceOffset=t-(this._performanceStartTime+T.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return g.warn(`Invalid attribute key: ${e}`),this;if(!Ae(t))return g.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return g.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&g.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),ce(t)&&(ce(n)||(n=t),t=void 0);let i=D(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];a!==void 0&&c>=a?s++:(o[e]=this._truncateToSize(t),c++)}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&g.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=D(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];n!==void 0&&o>=n?a++:(i[e]=this._truncateToSize(t),o++)}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===v.UNSET||this.status.code===v.OK)return this;let t={code:e.code};return e.code===v.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&g.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){this._isSpanEnded()?g.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(e),this._duration=ue(this.startTime,this.endTime),this._duration[0]<0&&(g.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&g.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&g.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(e){if(typeof e==`number`&&e<=T.now())return le(e+this._performanceOffset);if(typeof e==`number`)return O(e);if(e instanceof Date)return O(e.getTime());if(fe(e))return e;if(this._startTimeProvided)return O(Date.now());let t=T.now()-this._performanceStartTime;return we(this.startTime,O(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[oe]=e:e&&(e.code?n[Oe]=e.code.toString():e.name&&(n[Oe]=e.name),e.message&&(n[oe]=e.message),e.stack&&(n[se]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(Nt,n,t):g.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);g.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(g.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}[F](e,t,n){return Ft(`SpanImpl`,{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:Pt(this.resource)}},e,t,n)}},I;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(I||={});var Lt=`otel.component.name`,Rt=`otel.component.type`,zt=`otel.span.parent.origin`,Bt=`otel.span.sampling_result`,Vt=`otel.sdk.processor.span.processed`,Ht=`otel.sdk.processor.span.queue.capacity`,Ut=`otel.sdk.processor.span.queue.size`,Wt=`otel.sdk.span.live`,Gt=`otel.sdk.span.started`,Kt=`batching_span_processor`,qt=class{startedSpans;liveSpans;constructor(e){this.startedSpans=e.createCounter(Gt,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(Wt,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=Yt(t);if(this.startedSpans.add(1,{[zt]:Jt(e),[Bt]:n}),t===I.NOT_RECORD)return()=>{};let r={[Bt]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function Jt(e){return e?e.isRemote?`remote`:`local`:`none`}function Yt(e){switch(e){case I.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case I.RECORD:return`RECORD_ONLY`;case I.NOT_RECORD:return`DROP`}}var Xt=`2.11.0`;_(),C();var Zt=class{_sampler;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(e,t){this.instrumentationScope=e,this._sampler=t.sampler,this._spanLimits=t.spanLimits,this._resource=t.resource,this._idGenerator=t.idGenerator,this._spanProcessor=t.spanProcessor;let n=t.meterProvider.getMeter(`@opentelemetry/sdk-trace`,Xt);this._tracerMetrics=new qt(n)}startSpan(e,t={},n=m.active()){t.root&&(n=h.deleteSpan(n));let r=h.getSpan(n);if(Ce(n))return g.debug(`Instrumentation suppressed, returning Noop Span`),h.wrapSpanContext(te);let i=r?.spanContext(),a=this._idGenerator.generateSpanId(),o,s,c;!i||!h.isSpanContextValid(i)?s=this._idGenerator.generateTraceId():(s=i.traceId,c=i.traceState,o=i);let l=t.kind??ie.INTERNAL,u=(t.links??[]).map(e=>({context:e.context,attributes:D(e.attributes)})),d=D(t.attributes),f=this._sampler.shouldSample(n,s,e,l,d,u),p=this._tracerMetrics.startSpan(i,f.decision);c=f.traceState??c;let ee=f.decision===ne.RECORD_AND_SAMPLED?y.SAMPLED:y.NONE,re={traceId:s,spanId:a,traceFlags:ee,traceState:c};if(f.decision===ne.NOT_RECORD)return g.debug(`Recording is off, propagating context in a non-recording span`),h.wrapSpanContext(re);let _=D(Object.assign(d,f.attributes));return new It({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:re,name:e,kind:l,links:u,parentSpanContext:o,attributes:_,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:p})}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??m.active(),c=this.startSpan(e,i,s),l=h.setSpan(s,c);return m.with(l,o,void 0,c)}[F](e,t,n){return Ft(`Tracer`,{instrumentationScope:this.instrumentationScope,resource:{attributes:Pt(this._resource)},spanLimits:this._spanLimits},e,t,n)}};C();var Qt=class{_spanProcessors;constructor(e){this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{w(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},L=class{shouldSample(){return{decision:I.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},R=class{shouldSample(){return{decision:I.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};_(),C();var z=class{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(e){this._root=e.root,this._root||=(w(Error(`ParentBasedSampler must have a root sampler configured`)),new R),this._remoteParentSampled=e.remoteParentSampled??new R,this._remoteParentNotSampled=e.remoteParentNotSampled??new L,this._localParentSampled=e.localParentSampled??new R,this._localParentNotSampled=e.localParentNotSampled??new L}shouldSample(e,t,n,r,i,a){let o=h.getSpanContext(e);return!o||!re(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&y.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&y.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};me();var $t=new Map,en=class{processedSpans;queueSize;queueSizeCallback;standardAttrs;droppedAttrs;constructor(e,t,n){let r=$t.get(e)??0;if($t.set(e,r+1),this.standardAttrs={[Rt]:e,[Lt]:`${e}/${r}`},this.droppedAttrs={...this.standardAttrs,[he]:`queue_full`},this.processedSpans=t.createCounter(Vt,{unit:`{span}`,description:`The number of spans for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter(Ht,{unit:`{span}`,description:`The maximum number of spans the queue of a given instance of an SDK span processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(Ut,{unit:`{span}`,description:`The number of spans in the queue of a given instance of an SDK span processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(e){this.processedSpans.add(e,this.droppedAttrs)}finishSpans(e,t){if(!t){this.processedSpans.add(e,this.standardAttrs);return}let n={...this.standardAttrs,[he]:t.name};this.processedSpans.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};_(),C();var tn=class{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_metrics;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(e){this._exporter=e.exporter,this._maxExportBatchSize=e.maxExportBatchSize??512,this._maxQueueSize=e.maxQueueSize??2048,this._scheduledDelayMillis=e.scheduledDelayMillis??5e3,this._exportTimeoutMillis=e.exportTimeoutMillis??3e4,this._shutdownOnce=new pe(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(g.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let t=e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-trace`):ee();this._metrics=new en(Kt,t,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&y.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>(this._metrics.shutdown(),this._exporter.shutdown()))}_addToBuffer(e){this._finishedSpans.length>=this._maxQueueSize?(this._droppedSpansCount===0&&g.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++,this._metrics.dropSpans(1)):(this._droppedSpansCount>0&&(g.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer())}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);m.with(ve(m.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,i=>{clearTimeout(n),this._metrics.finishSpans(r.length,i.error),i.code===Te.SUCCESS?e():t(i.error??Error(`BatchSpanProcessor: span export failed`))}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??=[],a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{w(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,w(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},nn=class extends tn{onShutdown(){}},rn=8,an=16,on=class{generateTraceId=sn(an);generateSpanId=sn(rn)},B=Buffer.allocUnsafe(an);function sn(e){return function(){for(let t=0;t<e/4;t++)B.writeUInt32BE(Math.random()*2**32>>>0,t*4);for(let t=0;t<e&&!(B[t]>0);t++)t===e-1&&(B[e-1]=1);return B.toString(`hex`,0,e)}}_();var V;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(V||={});var cn=class{_resource;_activeSpanProcessor;_forceFlushTimeoutMillis;_tracerOptions;_tracers=new Map;constructor(e={}){this._forceFlushTimeoutMillis=e.forceFlushTimeoutMillis??3e4,this._resource=e.resource??Ne();let t=e.spanProcessors??[];this._activeSpanProcessor=new Qt(t),this._tracerOptions={resource:this._resource,sampler:e.sampler??new z({root:new R}),spanLimits:{attributeCountLimit:e.spanLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.spanLimits?.attributeValueLengthLimit??1/0,eventCountLimit:e.spanLimits?.eventCountLimit??128,linkCountLimit:e.spanLimits?.linkCountLimit??128,attributePerEventCountLimit:e.spanLimits?.attributePerEventCountLimit??128,attributePerLinkCountLimit:e.spanLimits?.attributePerLinkCountLimit??128},idGenerator:e.idGenerator||new on,spanProcessor:this._activeSpanProcessor,meterProvider:e.meterProvider??{getMeter(){return ee()}}}}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new Zt({name:e,version:t,schemaUrl:n?.schemaUrl},this._tracerOptions)),this._tracers.get(r)}forceFlush(e){let t=e?.timeoutMillis??this._forceFlushTimeoutMillis,n=this._activeSpanProcessor._spanProcessors.map(e=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${t} ms`)),r=V.timeout},t);e.forceFlush().then(()=>{clearTimeout(i),r!==V.timeout&&(r=V.resolved,n(r))}).catch(e=>{clearTimeout(i),r=V.error,n(e)})}));return new Promise((e,t)=>{Promise.all(n).then(n=>{let r=n.filter(e=>e!==V.resolved);r.length>0?t(r):e()}).catch(e=>t([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}[F](e,t,n){let r=this._activeSpanProcessor._spanProcessors;return Ft(`TracerProvider`,{resource:{attributes:Pt(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:r.map(e=>e.constructor?.name??`SpanProcessor`)},e,t,n)}};_();var ln=class{_ratio;_upperBound;constructor(e=0){this._ratio=this._normalize(e),this._upperBound=this._ratio===1?4294967296:Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:ae(t)&&this._accumulate(t)<this._upperBound?I.RECORD_AND_SAMPLED:I.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}};_(),C();var H;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(H||={});var U=1;function un(){return{sampler:dn(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:E(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:E(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128},spanLimits:{attributeValueLengthLimit:E(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:E(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??128,linkCountLimit:E(`OTEL_SPAN_LINK_COUNT_LIMIT`)??128,eventCountLimit:E(`OTEL_SPAN_EVENT_COUNT_LIMIT`)??128,attributePerEventCountLimit:E(`OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT`)??128,attributePerLinkCountLimit:E(`OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT`)??128}}}function dn(){let e=ge(`OTEL_TRACES_SAMPLER`)??H.ParentBasedAlwaysOn;switch(e){case H.AlwaysOn:return new R;case H.AlwaysOff:return new L;case H.ParentBasedAlwaysOn:return new z({root:new R});case H.ParentBasedAlwaysOff:return new z({root:new L});case H.TraceIdRatio:return new ln(fn());case H.ParentBasedTraceIdRatio:return new z({root:new ln(fn())});default:return g.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${H.ParentBasedAlwaysOn}".`),new z({root:new R})}}function fn(){let e=E(`OTEL_TRACES_SAMPLER_ARG`);return e==null?(g.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${U}.`),U):e<0||e>1?(g.error(`OTEL_TRACES_SAMPLER_ARG=${e} was given, but it is out of range ([0..1]), defaulting to ${U}.`),U):e}C();function pn(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??E(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??E(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??E(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??E(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,Object.assign({},e,{spanLimits:t})}C();var mn=class extends cn{constructor(e={}){let t=de({},un(),pn(e));delete t.generalLimits,super(t)}};C();var hn=class extends nn{constructor(e,t){t||={};for(let[e,n]of[[`maxExportBatchSize`,`OTEL_BSP_MAX_EXPORT_BATCH_SIZE`],[`maxQueueSize`,`OTEL_BSP_MAX_QUEUE_SIZE`],[`scheduledDelayMillis`,`OTEL_BSP_SCHEDULE_DELAY`],[`exportTimeoutMillis`,`OTEL_BSP_EXPORT_TIMEOUT`]])if(t[e]===void 0){let r=E(n);r!==void 0&&(t[e]=r)}super({exporter:e,...t})}};_(),je();var gn=`aventure-mcp-server`,_n=`aventure=mcp`,vn=`langfuse.session.id`,yn=`/api/public/otel/v1/traces`,bn=5e3,xn=new Set([`langfuse.observation.input`,`langfuse.observation.output`,`langfuse.observation.status_message`]),Sn=[`OTEL_EXPORTER_OTLP_HEADERS`,`OTEL_EXPORTER_OTLP_TRACES_HEADERS`],W,G;function K(e){return e?.trim()||void 0}function Cn(){return K(process.env.GIT_SHA)??K(process.env.SENTRY_RELEASE)??t().version}function wn(){let e=K(process.env.LANGFUSE_BASE_URL),t=K(process.env.LANGFUSE_PUBLIC_KEY),n=K(process.env.LANGFUSE_SECRET_KEY);if(e!==void 0&&t!==void 0&&n!==void 0){for(let e of Sn){let t=(process.env[e]??``).split(`,`).map(e=>e.split(`=`,1)[0]?.trim().toLowerCase()??``).filter(e=>e!==``&&e!==`authorization`);if(t.length>0)throw Error(`${e} sets ${t.join(`, `)}, which the Langfuse trace exporter would forward`)}return new Mt({url:new URL(yn,e).href,headers:{Authorization:`Basic ${Buffer.from(`${t}:${n}`).toString(`base64`)}`,"x-langfuse-ingestion-version":`4`},timeoutMillis:bn})}}function Tn(e){let t={};for(let[n,r]of Object.entries(e.attributes))xn.has(n)||(t[n]=r);return{name:e.name,kind:e.kind,spanContext:()=>e.spanContext(),...e.parentSpanContext===void 0?{}:{parentSpanContext:e.parentSpanContext},startTime:e.startTime,endTime:e.endTime,status:e.status,attributes:t,links:e.links,events:e.events,duration:e.duration,ended:e.ended,resource:e.resource,instrumentationScope:e.instrumentationScope,droppedAttributesCount:e.droppedAttributesCount,droppedEventsCount:e.droppedEventsCount,droppedLinksCount:e.droppedLinksCount}}function En(e){return{export:(t,n)=>e.export(t.map(Tn),n),shutdown:()=>e.shutdown(),forceFlush:()=>e.forceFlush?.()??Promise.resolve()}}function Dn(){if(W!==void 0)return G;let e=K(process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT),t=[...e===void 0?[]:[En(new Mt({url:e,timeoutMillis:bn}))],...[wn()].filter(e=>e!==void 0)];return W=new mn({sampler:new R,resource:Me({...ke(),"service.version":Cn()}),spanProcessors:t.map(e=>new hn(e,{exportTimeoutMillis:bn}))}),G=t.length===0?void 0:W.getTracer(gn),G}function On(){Dn()}var kn=/^00-(?<traceId>[0-9a-f]{32})-(?<spanId>[0-9a-f]{16})-(?<flags>[0-9a-f]{2})$/u,An=/[13579bdf]$/u;function jn(e,t,n){let r=Dn();if(r===void 0)return;let i=kn.exec(n??``)?.groups,a=i?.traceId===void 0||i.spanId===void 0?p:h.setSpanContext(p,{traceId:i.traceId,spanId:i.spanId,traceFlags:An.test(i.flags??``)?y.SAMPLED:y.NONE,isRemote:!0});return r.startSpan(e,{kind:ie.SERVER,attributes:{"langfuse.trace.name":e,...t,"langfuse.environment":ke()[`deployment.environment.name`],"langfuse.release":Cn()}},a)}function Mn(e){let{traceId:t,spanId:n,traceFlags:r}=e.spanContext();return`00-${t}-${n}-${(r&y.SAMPLED)===0?`00`:`01`}`}function Nn(e,t,n){e.setAttributes(t),e.setStatus({code:n?v.ERROR:v.OK}),e.end()}async function Pn(){let e=W;W=void 0,G=void 0,await e?.shutdown()}var q=new Ie,Fn=`X-Client-Request-Id`,In=()=>q.getStore()?.requestId,Ln=()=>q.getStore()?.toolApiCall,Rn=()=>q.getStore()?.responseDeadline,zn=()=>q.getStore()?.userBearerToken;function Bn(){let e=q.getStore(),t=[...e?.sessionId===void 0?[]:[`${vn}=${encodeURIComponent(e.sessionId)}`],...e?.traceName===void 0?[]:[`langfuse.trace.name=${encodeURIComponent(e.traceName)}`],...e?.traceTag===void 0?[]:[`langfuse.trace.tags=${encodeURIComponent(e.traceTag.map(encodeURIComponent).join(`,`))}`]].join(`,`);return{...e?.requestId===void 0?{}:{[Fn]:e.requestId},...e?.traceparent===void 0?{}:{traceparent:e.traceparent,tracestate:_n,...t.length===0?{}:{baggage:t}}}}function Vn(e,t){return q.run({...q.getStore(),requestId:e,toolApiCall:{failed:!1}},t)}function Hn(e,t){return q.run({...q.getStore(),responseDeadline:e},t)}function Un(e,t){return q.run({...q.getStore(),userBearerToken:e},t)}function Wn(e,t){return q.run({...q.getStore(),...e},t)}var Gn=Object.freeze({total:8,perOrigin:2,originLimit:64,failureThreshold:3,cooldownMs:3e4,idleMs:3e4,halfOpenProbes:1}),Kn=Object.freeze({total:128,perOrigin:64,originLimit:64,failureThreshold:5,cooldownMs:15e3,idleMs:3e5,halfOpenProbes:1}),qn=new WeakMap,J=class extends Error{reason;constructor(e){super(e===`capacity`?`Origin capacity exceeded; try again later.`:`Origin circuit is open; try again later.`),this.reason=e}};function Jn(e,t){let n=Date.now(),r=qn.get(t);r===void 0&&(r={active:0,origin:new Map},qn.set(t,r));for(let[i,a]of r.origin)i!==e&&a.active===0&&a.updatedAt+t.idleMs<=n&&r.origin.delete(i);let i=r.origin.get(e);if(i===void 0){if(r.origin.size>=t.originLimit)throw new J(`capacity`);i={active:0,failures:0,openUntil:0,updatedAt:n},r.origin.set(e,i)}if(i.openUntil>n||i.failures>=t.failureThreshold&&i.active>=t.halfOpenProbes)throw new J(`circuit`);if(r.active>=t.total||i.active>=t.perOrigin)throw new J(`capacity`);return i.active++,r.active++,{finish:Yn(r,i,t)}}function Yn(e,t,n){let r=!1;return i=>{r||(r=!0,t.active--,e.active--,t.updatedAt=Date.now(),i===`failure`?(t.failures++,t.failures>=n.failureThreshold&&(t.openUntil=t.updatedAt+n.cooldownMs)):i===`success`&&(t.failures=0,t.openUntil=0))}}var Xn=3e4,Zn=20,Y=52428800;async function Qn(e,t,n,r={}){let i=rr(X(e.requestBody?.content),n);if(!i.ok||i.data===null)return S(i.summary,i.warnings);let a=i.data;if(e.requestBody?.required===!0&&t===void 0&&a?.kind!==`multipart`)return S(`Request body is required.`);if(a?.kind===`multipart`)return await ar(e.requestBody?.required===!0,a.schema,t,r);let o=a?.contentType??r.defaultContentType;return b(`Request body prepared`,{...t===void 0?{}:{body:t},...o===void 0?{}:{contentType:o}})}function $n(e){if(typeof e!=`string`)return b(`Request body unchanged`,e);let t=e.trimStart().slice(0,1);if(t!==`{`&&t!==`[`)return b(`Request body unchanged`,e);try{let t=x.safeParse(JSON.parse(e));if(!t.success)throw t.error;return b(`Request body parsed`,t.data)}catch(e){return S(`Request body string must be valid JSON: ${e instanceof Error?e.message:String(e)}`)}}function er(e,t){let n=e?.schema;if(n===void 0)return!1;let r=P(n),i=n.type??(r===void 0?void 0:t[r]?.type);return Array.isArray(i)?i.includes(`array`):i===`array`}function tr(e){return X(e)[0]?.kind??`json`}function nr(e){return e===void 0||Object.keys(e).length===0||X(e).length>0}function X(e){let t=Object.entries(e??{});return[...t.flatMap(e=>vr(e[0])?[ir(e,`json`)]:[]),...t.flatMap(e=>yr(e[0])?[ir(e,`multipart`)]:[])]}function rr(e,t){if(t===void 0)return b(`Default request content selected`,e[0]);let n=Q(t),r=e.find(e=>Q(e.contentType)===n);return r===void 0?S(`Request Content-Type '${t}' is not supported. Supported choices: ${e.map(({contentType:e})=>e).join(`, `)||`none`}.`):b(`Explicit request content selected`,r)}function ir(e,t){let n=e[1].schema;return{contentType:e[0],kind:t,...n===void 0?{}:{schema:n}}}async function ar(e,t,n,r){if(!e&&n==null)return b(`Optional multipart body omitted`,{});let i=or(n);if(!i.ok||i.data===null)return S(i.summary,i.warnings);let a=new FormData;for(let e of sr(t)){let t=i.data[e.name];if(t==null){if(e.required)return S(`Multipart body requires '${e.name}'.`)}else{if(Array.isArray(t)&&t.length<(e.schema.minItems??0))return S(`Multipart part '${e.name}' requires more entries.`);if(Array.isArray(t)&&t.length>(e.schema.maxItems??2**53-1))return S(`Multipart part '${e.name}' has too many entries.`);if(cr(e.schema)||lr(e.schema)){let n=lr(e.schema)?t:[t];if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))return S(`Multipart part '${e.name}' must contain file paths or URLs.`);for(let t of n){if(typeof t!=`string`)continue;let n=await fr(t,r);if(!n.ok||n.data===null)return S(n.summary,n.warnings,{httpStatus:n.httpStatus});a.append(e.name,n.data.blob,n.data.filename)}}else if(ur(e.schema,t)){let n=JSON.stringify(t);a.append(e.name,new Blob([n],{type:`application/json`}),`${e.name}.json`)}else{let n=dr(a,e.name,t);if(!n.ok)return n}}}return b(`Multipart body prepared`,{body:a})}function or(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=Object.fromEntries(Object.entries(e));return b(`Multipart input parsed`,t)}return S(`Multipart request body must be a JSON object keyed by form part name.`)}function sr(e){let t=new Set(e?.required??[]);return Object.entries(e?.properties??{}).map(([e,n])=>({name:e,schema:n,required:t.has(e)}))}function cr(e){return e.type===`string`&&e.format===`binary`}function lr(e){return e.type===`array`&&e.items!==void 0&&cr(e.items)}function ur(e,t){return typeof t!=`object`||!t||Array.isArray(t)?!1:e.type===`object`||typeof e.$ref==`string`&&e.$ref.length>0}function dr(e,t,n){if(Array.isArray(n)){for(let r of n){let n=dr(e,t,r);if(!n.ok)return n}return b(`Multipart scalar array appended`,null)}return typeof n==`object`?S(`Multipart part '${t}' must be scalar.`):(e.append(t,String(n)),b(`Multipart scalar appended`,null))}async function fr(e,t){if(t.signal?.aborted||(t.deadline??1/0)<=Date.now()){let e=Ln();return e!==void 0&&!Z(t.signal)&&(e.failed=!0),S(`Media preparation canceled or invocation deadline exceeded.`)}return gr(e)?In()===void 0?await pr(e,t):S(`MCP media URL fetching is disabled. Pass the page as sourceUrl in the JSON body instead.`):In()===void 0?await hr(e,t.signal):S(`MCP callers cannot upload local files: pass an http(s) URL as the multipart part, or send media by sourceUrl in a JSON body. Local file paths are CLI-only.`)}async function pr(e,t){let n=new AbortController,r=Math.min(Xn,(t.deadline??1/0)-Date.now()),i=setTimeout(()=>n.abort(),Math.max(r,1)),a=t.signal?AbortSignal.any([n.signal,t.signal]):n.signal,o,s,c=`neutral`;try{if(a.throwIfAborted(),r<=0)throw Error(`Invocation deadline exceeded.`);let t=new URL(e),n=t;for(let e=0;;e++){a.throwIfAborted(),o=Jn(n.origin,Gn),c=`failure`,s=await fetch(n.href,{signal:a,redirect:`manual`});let t=s.headers.get(`location`);if(![301,302,303,307,308].includes(s.status)||t===null)break;if(await s.body?.cancel(),e>=Zn)throw Error(`Media URL exceeded the redirect limit.`);let r=new URL(t,n);o.finish(`success`),o=void 0,s=void 0,n=r}if(c=s.status===429||s.status>=500?`failure`:`success`,!s.ok)return await s.body?.cancel(),S(`Failed to fetch media URL: ${s.status} ${s.statusText}`,[],{httpStatus:s.status});c=`failure`;let i=s.headers.get(`content-type`)?.split(`;`)[0]?.trim()??_r(t.pathname)??``,l=await mr(s,{type:i,signal:a});return c=`success`,b(`URL media fetched`,{blob:l,filename:Pe(t.pathname)||`upload`})}catch(e){(e instanceof J||a.aborted||r<=0)&&(c=`failure`),e instanceof RangeError&&(c=`success`),Z(t.signal)&&(c=`neutral`),s?.body&&!s.body.locked&&!s.bodyUsed&&await s.body.cancel();let i=Z(t.signal)?`Failed to fetch media URL: canceled.`:t.signal?.aborted?`Failed to fetch media URL: invocation deadline exceeded.`:n.signal.aborted?`Failed to fetch media URL: timed out after ${r}ms.`:`Failed to fetch media URL: ${e instanceof Error?e.message:String(e)}`;return S(i,[],{httpStatus:e instanceof RangeError?void 0:s?.status})}finally{clearTimeout(i);let e=Ln();e!==void 0&&c===`failure`&&!Z(t.signal)&&(e.failed=!0),o?.finish(c)}}function Z(e){return e?.aborted===!0&&!(e.reason instanceof DOMException&&e.reason.name===`TimeoutError`)}async function mr(e,{type:t,signal:n}){let r=e.body?.getReader();if(r===void 0)throw Error(`Media URL returned no body.`);let i=[],a=0,o=!1,s,c=new Promise(e=>{s=()=>e({done:!0,value:void 0}),n.addEventListener(`abort`,s,{once:!0})});try{if(Number(e.headers.get(`content-length`))>Y)throw RangeError(`Media exceeds the ${Y}-byte upload limit.`);for(;;){n.throwIfAborted();let e=await Promise.race([r.read(),c]);if(n.throwIfAborted(),e.done)break;if(a+=e.value.byteLength,a>Y)throw RangeError(`Media exceeds the ${Y}-byte upload limit.`);i.push(new Blob([e.value.slice()]))}return o=!0,new Blob(i,{type:t})}finally{s&&n.removeEventListener(`abort`,s),o||await r.cancel(),r.releaseLock()}}async function hr(e,t){try{let n=_r(e)??``,r=await Le(e,{signal:t});return b(`File media read`,{blob:new Blob([r],{type:n}),filename:Pe(e)})}catch(t){return S(`Failed to read media file '${e}': ${t instanceof Error?t.message:String(t)}`)}}function gr(e){return e.startsWith(`http://`)||e.startsWith(`https://`)}function _r(e){return br[Fe(e).toLowerCase()]}function vr(e){let t=Q(e);return t===`*/*`||t===`application/json`||t.endsWith(`+json`)}function yr(e){return Q(e)===`multipart/form-data`}var Q=e=>e.split(`;`)[0]?.trim().toLowerCase()??``,br={".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".png":`image/png`,".webp":`image/webp`};function xr(e,t,n){let r=new Map,i=(t,a,o)=>{let s=P(t);if(a>n||s!==void 0&&o.includes(s))return;let c=s===void 0?o:[...o,s],l=Cr(e,t);for(let e of[...l.items===void 0?[]:[l.items],...l.oneOf??[],...l.anyOf??[],...l.allOf??[]])i(e,a,c);for(let[e,t]of Object.entries(l.properties??{}))r.set(e,Math.min(r.get(e)??a,a)),i(t,a+1,c)};for(let[e,n]of Object.entries(t))e.startsWith(`2`)&&i(Sr(n.content),0,[]);return r}function Sr(e){return e?.[`application/json`]?.schema??Object.values(e??{}).find(e=>e.schema!==void 0)?.schema}function Cr(e,t){let n=P(t);return{...n===void 0?void 0:e.components.schemas[n],...t}}function wr(e){if(e===`private`||typeof e==`object`&&(e.scope===`private`||e.value===`private`))return`private`}var Tr=`format`;function Er(e){return e===`write`||e===`delete`}function Dr(e){return Er(e)||e===`job`}function Or(e,t){return e===`DELETE`||t===`delete`}var kr=`Shell-safe input: single-quote string flag values that contain $; use --from-file or stdin for JSON bodies, multiline text, and free text with currency amounts.`;function Ar(e,t){let n=e===`array`?t:e;return n===void 0||n===`string`}function jr(e){let t=e.operation[`x-aventure-tool`];if(!Rr(e.path,e.operation,e.method===`GET`&&t?.auth===`none`,e.includeBinary===!0))return null;let n=Lr(e.operation.operationId),r=Jr(e.path,n),i=Ir(r,n,e.method),a=Nr(e.method,e.operation);if(a===null)return null;let o=t?.auth===`read`&&i===`write`?`lookup`:i,s=e.method===`GET`||a===`read`||a===`none`;return{resource:Yr(e.path),intent:o,cliPath:r,scope:s&&!Er(o)?`read`:`write`,auth:a,visibility:wr(e.operation[`x-aventure-visibility`]),mutates:t?.mutates===!0||void 0,selfCredential:Mr(e.operation)||void 0,billingAuthorization:t?.auth===`billing`||void 0,stdinBody:e.operation.requestBody!==void 0&&tr(e.operation.requestBody.content)===`json`,destructive:Or(e.method,o)}}function Mr(e){let t=e.security??[];return t.length>0&&t.every(e=>Object.keys(e).every(e=>e===`clerkApiKeyAuth`))}function Nr(e,t){let n=t[`x-aventure-tool`]?.auth;if(n===`none`)return`none`;if(n===`read`)return`read`;if(e===`GET`&&(t.security?.length??0)===0)return`none`;let r=!1,i=!1,a=!1;for(let e of t.security??[]){let t=Object.keys(e);t.includes(`clientSecretAuth`)&&(r=!0),t.includes(`adminApiKeyAuth`)&&(a=!0),(t.includes(`bearerAuth`)||t.includes(`clerkApiKeyAuth`))&&(i=!0)}return e===`GET`&&r||r&&!a&&!i?`read`:a?`write`:i?`bearer`:e===`GET`?`read`:null}var Pr={add:`write`,answer:`search`,ask:`search`,attach:`write`,audit:`read`,batch:`lookup`,convert:`write`,create:`write`,delete:`delete`,enrich:`write`,filter:`search`,get:`read`,import:`write`,join:`write`,list:`read`,lookup:`lookup`,merge:`write`,preview:`lookup`,reconcile:`write`,remove:`delete`,replace:`write`,resolve:`lookup`,search:`search`,status:`read`,suggest:`read`,update:`write`,upload:`write`},Fr=`status`;function Ir(e,t,n){if(e.length===1&&e[0]===Fr)return`status`;let r=Object.hasOwn(Pr,t)?Pr[t]:void 0;return r===void 0?n===`GET`?`read`:n===`DELETE`?`delete`:`write`:r}function Lr(e){let t=/^[a-z]+/u.exec(e)?.[0];if(t===void 0)throw Error(`operationId '${e}' has no verb`);return t}function Rr(e,t,n,r){return zr(e)&&t.hidden!==!0&&(n||!Br.some(t=>t.test(e)))&&nr(t.requestBody?.content)&&(Wr(t.responses)||r&&Ur(t))}function zr(e){return e.startsWith(`/v1/`)||e.startsWith(`/v2/`)}var Br=[/^\/v1\/auth\/(?:session|login|ui|registrations|password-resets|cli-authorizations|linkedin)(?:\/|$)/u,/^\/v1\/addresses\/locations(?:\/|$)/u,/^\/v1\/(?:chat\/completions|embeddings)$/u,/^\/v1\/observability(?:\/|$)/u,/^\/v1\/media\/identicons(?:\/|$)/u],Vr=/(?:^|-)(?:runs|jobs|turns)$/u;function Hr(e,t){let{intent:n,method:r,mutates:i}=e;if(e.selfCredential===!0||e.deprecated===!0)return null;if(!Dr(n)&&i!==!0&&r!==`PUT`&&r!==`PATCH`)return`aventure_read`;if(t===`private`)return n===`delete`?`aventure_delete`:`aventure_write`;if(e.billingAuthorization===!0&&n===`write`)return`aventure_write`;if(n===`job`||i===!0)return`aventure_job`;let a=Lr(e.operationId),o=a===`enrich`||a===`create`&&Vr.test(e.cliPath.at(-2)??``);return n===`write`&&o?`aventure_job`:null}function Ur(e){let t=Object.entries(e.responses).filter(([e])=>e.startsWith(`2`));return t.length>0&&t.every(([,e])=>{let t=Object.values(e.content??{});return t.length>0&&t.every(e=>qr(e.schema))})}function Wr(e){return Object.entries(e).filter(([e])=>e.startsWith(`2`)).every(([,e])=>Gr(e.content))}function Gr(e){if(e===void 0)return!0;let t=Object.entries(e);return t.length===0||t.some(([e,t])=>Kr(e)&&!qr(t.schema))}function Kr(e){return e===`*/*`||e===`application/json`||e.endsWith(`+json`)}function qr(e){return e?.format===`byte`||e?.format===`binary`}function Jr(e,t){let n=Qr(e).map($),r=n.length===1&&t===`get`&&!e.includes(`{`),i=n.some(e=>e.split(`-`).includes(t));return r||i?n:[...n,t]}function Yr(e){return $(Qr(e).at(0)??`system`)}function Xr({operationId:e,tool:t}){if(t===void 0)throw Error(`Operation ${e} is not in the MCP catalog.`);return t}function $(e){return e.replace(/([a-z0-9])([A-Z])/gu,`$1-$2`).replace(/[^A-Za-z0-9]+/gu,`-`).replace(/^-+|-+$/gu,``).toLowerCase()}var Zr=e=>`--${$(e)}`;function Qr(e){return $r(e).filter(e=>!ei(e)&&!ti(e))}function $r(e){return e.split(`/`).filter(e=>e.length>0)}function ei(e){return/^v\d+$/u.test(e)}function ti(e){return e.startsWith(`{`)&&e.endsWith(`}`)}export{Hn as A,Ge as B,Fn as C,Bn as D,Ln as E,Pn as F,_t as G,gt as H,jn as I,Be as J,mt as K,On as L,Un as M,vn as N,zn as O,Nn as P,Mn as R,Jn as S,Rn as T,pt as U,ht as V,Ke as W,X as _,Dr as a,Kn as b,Zr as c,Hr as d,$ as f,Qn as g,$n as h,Ur as i,Wn as j,Vn as k,Or as l,xr as m,Pr as n,Ar as o,jr as p,P as q,Tr as r,Xr as s,kr as t,Er as u,er as v,In as w,J as x,rr as y,j as z};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventurevc/aventure-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.476",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Command-line access to aVenture research data on companies, people, funding, and news.",
|
|
6
6
|
"homepage": "https://docs.aventure.vc/cli",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
},
|
|
34
34
|
"aventurePublicApi": {
|
|
35
35
|
"repository": "aventurevc/aventure-docs",
|
|
36
|
-
"commit": "
|
|
36
|
+
"commit": "51eaa3c6a65649e85823b41e25403fb7d2de169c",
|
|
37
37
|
"openapiPath": "openapi/openapi.json",
|
|
38
|
-
"openapiSha256": "
|
|
38
|
+
"openapiSha256": "48d919035f3eac695595e0666fa86a5c6e4b2e4f413b8765259b9ba3dc72e5e6"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {}
|
|
41
41
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{a as resolveAuthStatus}from"./auth-resolver-1SqKr6sv.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r,t as i}from"./commander-DEj7N1b9.js";import{a}from"./package-DEeHDoOT.js";import{l as o,o as s,r as c}from"./env-DoAriNfh.js";import{c as l,p as u,r as d}from"./result-envelope-Ds29nFJ0.js";import{B as f,o as p,t as m,u as h,y as g,z as _}from"./tool-policy-DthqSCty.js";import{i as v}from"./logging-Dm4-IZw0.js";import{r as y,t as b}from"./cli-help-policy-BEnaH89v.js";import{a as x,c as S,d as ee,f as te,i as C,l as w,m as ne,n as re,p as ie,r as ae,s as oe,t as se,u as ce}from"./startup-auth-DO3DbDPM.js";import{t as T}from"./openapi-commands-DmaFa6G7.js";import{g as le,m as ue}from"./help-catalog-BExrYg_X.js";import{n as de,t as fe}from"./operations-metadata-DG12wjZa.js";import{a as E,i as pe,t as D}from"./output-mode-CO-iRvt8.js";import{S as me,_ as O,a as he,b as k,c as ge,d as _e,f as ve,g as ye,h as be,i as xe,l as Se,m as A,n as j,o as Ce,p as we,r as Te,s as Ee,t as De,u as Oe,v as M,x as ke,y as N}from"./generated-option-order-D9HXEhic.js";import{n as Ae,t as je}from"./deprecated-command-bF9Q8_F6.js";import{a as Me,i as Ne,n as Pe,r as Fe}from"./payload-operand-guard-CisvVW-h.js";import{fileURLToPath as Ie}from"node:url";import{readFile as Le}from"node:fs/promises";async function Re(e){let t;try{t=e===`-`?await ze():await Le(e,`utf8`)}catch(t){return d(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return l(`No input provided`,null);let e=JSON.parse(t);return l(`Input parsed`,e)}catch(e){return d(`Input is not valid JSON: ${e.message}`)}}async function ze(){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 P=`--content-type`;function Be(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(P)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${P} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(He(a)))}if(z(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>`,he(r,r.requiredPath)).argParser(F(`--from-file`)))}let o=Ce(a).filter(e=>i(I(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>j(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(xe(n),a.length>1?Te(n):ge(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Ee(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Ve):M(i.name)||i.schemaType===`array`?o.argParser(Ue):o.argParser(F(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`)})}nt(e,n,o)}function Ve(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function He(e){return(t,r)=>{if(r!==void 0)throw new n(`${P} was already given; pass it once.`);let i=g(e,t);if(!i.ok)throw new n(i.summary);return t}}function Ue(e,t){return[...t??[],e]}function F(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 We(e,t){let n=w(e,t),r=g(e.requestBody??[],n);if(!r.ok||r.data===null)return d(r.summary,r.warnings);let i=r.data;if(i===void 0)return l(`No body`,void 0);let a=Ge(e,i,t);if(a!==null)return d(a);let o=A(e.operationId,i,t);if(!o.ok)return d(o.summary,o.warnings);t=o.data;let s=Ke(i,t);if(s!==null)return d(s);let c=await Xe(t);if(!c.ok)return d(c.summary,c.warnings);let u=be(e.requestBody??[],i,c.data);if(u!==null)return d(u);let f=Ye(e.operationId,i,c.data);if(!f.ok)return f;let p=ye(e.operationId,i,c.data);if(p!==null)return d(p);let m=Ze(e.operationId,i,t);if(!m.ok)return m;if(c.data===void 0&&m.data===void 0)return i.required?d(tt(e.operationId,i)):l(`No body`,void 0);let h=$e(e.operationId,i,c.data,m.data);if(!h.ok||h.data===void 0)return h;if(i.schemaType===`array`&&!Array.isArray(h.data))return d(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!N(h.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return d(`${e.operationId} requires a JSON object${t}.`)}let _=Je(i,h.data);if(_.length>0)return d(`${e.operationId} requires body option(s): ${_.join(`, `)}`);let v=h.data,y=N(v)?k(i).filter(e=>!O(v,e)):[];return y.length>0?d(qe(e.operationId,i,y)):h}function Ge(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${I(t)} requires ${P} ${i.join(` or `)}.`}return null}function Ke(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 qe(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 Je(e,t){return N(t)?e.parameter.filter(e=>e.required&&!O(t,e.name)).map(I):[]}function Ye(e,t,n){let r=me(t,n);return r===null?l(`Body file paths validated`,null):d(`${e} --from-file contains ${r.message}`)}async function Xe(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return l(`No body file`,void 0);let n=await Re(t);if(!n.ok)return d(n.summary,n.warnings);let r=u.safeParse(n.data);return r.success?l(`Input parsed`,r.data):d(`Input is not valid JSON value: ${r.error.message}`)}function Ze(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=ke(e,n[e.optionKey]);if(!a.ok||a.data===null)return d(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Qe(t,n,r,e,o);if(!s.ok)return d(s.summary,s.warnings);i=!0}if(!i)return l(`No direct body options`,void 0);let a=_e(e,t,n,r);return a===null?l(`Direct body options parsed`,r):a}function Qe(e,t,n,r,i){let a=Se(e,t,r);if(a===null){let e=et(r,i);return e.ok?ve(n,r.name,e.data,r.schemaType===`array`):d(e.summary,e.warnings)}let o=Oe(e,t,r,a);if(o!==null)return d(o);let s=r.schemaType===`array`,c=s?r.itemSchemaType:r.schemaType;for(let[e,t]of a.rows){let i=[];for(let e of t){let t=R(r,c,e);if(!t.ok)return d(t.summary,t.warnings);i.push(t.data)}for(let t of s?[i]:i){let i=we(n,r.name,e,t);if(!i.ok)return i}}return l(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function $e(e,t,n,r){if(n===void 0)return l(`Direct body parsed`,r);if(r===void 0)return l(`Input parsed`,n);if(N(n)&&N(r))try{return l(`Input parsed`,L(t,n,r))}catch(t){return d(`${e} ${t instanceof Error?t.message:String(t)}`)}return d(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function L(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(N(n)&&N(a))i[t]=L(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`:ue.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function et(e,t){if(typeof t==`boolean`)return l(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return R(e,e.schemaType,t??``);let n=[],r=M(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=R(e,r,i);if(!t.ok)return t;n.push(t.data)}return l(`Body value parsed`,n)}function R(e,t,n){if(n===`null`&&e.nullable&&t===e.schemaType)return l(`Body value parsed`,null);let r=e.name;if(t===`boolean`)return n===`true`?l(`Body value parsed`,!0):n===`false`?l(`Body value parsed`,!1):d(`${r} must be true or false.`);if(t===`number`||t===`integer`){let e=n.trim(),i=Number(e);return e===``||!Number.isFinite(i)?d(`${r} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?d(`${r} must be an integer.`):l(`Body value parsed`,i)}return l(`Body value parsed`,n)}function tt(e,t){let n=t.parameter.filter(e=>e.required);if(n.length>0&&t.requiredPath.every(e=>n.some(({name:t})=>t===e||t.startsWith(`${e}.`))))return`${e} requires body option(s): ${n.map(I).join(`, `)}`;let r=k(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(I).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function nt(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:P,location:`body`}),z(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),De(e.options,r)}function z(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function rt(e,t,n=a().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show full documentation for a command, search the catalog, or ask a question`).description("Show a command's full documentation offline. Select it by command path,\noperationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.\n`help catalog [query...]` searches or lists every operation;\n`help ask <question>` answers a platform question.").argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new it(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()}),D(r),r.action(async function(r){let i=r.flatMap(e=>e.split(/\s+/u).filter(Boolean)),{emit:a}=await import(`./output-DDkZmZUV.js`),o=this.optsWithGlobals();if(o.help&&i.length===0){this.outputHelp();return}let s=G(e,i),c=t.find(t=>s!==void 0&&G(e,t.cliPath)===s);if(o.help||s!==void 0&&c===void 0){s===void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${n} --help\` for the command tree)`),s.outputHelp();return}let u=c===void 0?await st(i,t):l(`Resolved by command path`,{operationId:c.operationId});if(u.ok&&u.data?.command!==void 0&&this.error(`unknown command '${i.join(` `)}' (run \`${n} --help\` for the command tree)`),!u.ok||u.data===null){a({mode:E(o)},u);return}let{writeShowResult:d}=await import(`./operations-catalog-BfTe1tIc.js`);d({...o,...u.data},t,E(o,`text`),n)}),ot(e,t,n)}var it=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},B=2,V=6,at={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>S[e.name()]?.listed!==!1):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(B)}${e}\n${H(n,a,i)}`}};function H(e,t,n){return n.boxWrap(e,t-V).replace(/^/gmu,` `.repeat(V))}function ot(e,t,n){for(let r of t){let i=G(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=le(r.operationId,t,n),c=U(de(r.header),o,e),l=U(fe(r.errorResponse),o,e);return`\n${[...s,...c,...l].join(`
|
|
2
|
-
`)}\n`})}}function U(e,t,n){let[r,...i]=e;return r===void 0?[]:[``,r,...i.map(e=>H(e.trimStart(),t,n).replace(/^ +/u,` `.repeat(B)))]}var W='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';async function st(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?l(`Resolved by route`,{operationId:i.operationId}):d(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[W]);let o=_.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return l(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=f(o),c=r.join(``),u=t.find(e=>e.method===s&&e.path===c);if(u!==void 0)return l(`Resolved by route template`,{operationId:u.operationId});let{resolveOpenApiOperationSelector:p}=await import(`./openapi-call-CSOyWtns.js`),m=p({method:s,path:c});return!m.ok||m.data===null?d(m.summary,[...m.warnings,W]):l(`Resolved by method and path`,{operationId:m.data.operation.operationId})}function G(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}function ct(e,t,n){if(e.cliPath[0]!==`lookup`||!lt(n))return null;let r=[...(e.requestBody??[]).flatMap(e=>e.parameter),...e.parameters,{name:`fromFile`,optionKey:`fromFile`}],i=r.filter(({optionKey:e},t)=>r.findIndex(t=>t.optionKey===e)===t).filter(({optionKey:e})=>t[e]!==void 0).map(({name:e,optionKey:n})=>`${e}=${String(t[n])}`),a=`no record for ${i.length===0?`the given input`:i.join(`, `)}`;return n.ok?d(a):d(a,[],{httpStatus:n.httpStatus,problem:n.problem})}function lt(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function ut(t,n,r,i){let a=dt(t,r),o=a instanceof e?[]:a,s=o[0],c=i.bin[0],l=[{selected:s===`auth`,register:async()=>{let{registerBuiltinAuthCommands:e}=await import(`./builtin-auth-2JEciG7h.js`);e(n,c)}},{selected:s===`agents`,register:async()=>{let{registerBuiltinAgentSetupCommand:e}=await import(`./builtin-agent-setup-B2Xvqera.js`);e(n,c)}},{selected:s===`update`,register:async()=>{let{registerBuiltinUpdateCommand:e}=await import(`./builtin-update-geeMfMZJ.js`);e(n,i)}},{selected:s===`batch`,register:async()=>{let{registerBuiltinBatchCommand:e}=await import(`./builtin-batch-DdGyCjlR.js`);e(n,r,c)}},{selected:s===`research`||s===`research-runs`||s===`data-engineering`,register:async()=>{let{registerBuiltinRunWaitCommand:e}=await import(`./builtin-run-wait-DN6I2Wx7.js`);await e(n)}},{selected:s===`completion`,register:async()=>{let{registerCompletionCommand:e}=await import(`./completion-CkH55Tdg.js`);e(n,r,c)}},{selected:s===`help`,register:async()=>{let{registerHelpCatalogCommand:e}=await import(`./operations-kvV6HTxR.js`);e(n,r,c)}},{selected:s===`command-catalog`,register:async()=>{let{registerRetiredCommandCatalog:e}=await import(`./operations-kvV6HTxR.js`);e(n,r,c)}}],u=s===void 0||s===`help`||s===`completion`||s===`command-catalog`||!l.some(e=>e.selected)&&!r.some(e=>e.cliPath[0]===s),d=1;for(;d<o.length&&r.some(e=>o.slice(0,d+1).every((t,n)=>e.cliPath[n]===t));)d++;let f=o.slice(0,d),p=u?r:r.filter(e=>f.slice(0,e.cliPath.length).every((t,n)=>e.cliPath[n]===t)),m=new Set,h=async(e=!1)=>{for(let t of l)(e||u||t.selected)&&!m.has(t)&&(await t.register(),m.add(t))};return{generated:p,fullTree:u,rootHelp:t.length>0&&t.every(e=>e===`--help`||e===`-h`),registerBuiltin:h,async completeTree(e){e(n,r.filter(e=>!p.includes(e))),await h(!0)}}}function dt(t,n){try{return new i().parseOptions([...C(t,n).commandArgv]).operands}catch(t){if(!(t instanceof e))throw t;return t}}var K=new Set(T.map(e=>e.cliPath.join(` `)));function q(e,t){e.showHelpAfterError(!1).exitOverride(t(e)),e.commands.length===0?e.hook(`preAction`,Pe):e.registeredArguments.length===0&&!K.has(Me(e).join(` `))&&e.addHelpOption(new Ne(e));for(let n of e.commands)q(n,t)}function J(e){return b[y(e,S)??`cli`]}function Y(e,t,n,{rootHelp:r=!1}={}){let i=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:J(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),a=new Set(i.filter(e=>se(e.cliPath[0])).map(e=>e.cliPath[0]??``)),o=new Set,s=new Set;for(let{cliPath:e,deprecated:t}of i)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);o.add(r),t!==!0&&s.add(r)}let c=new Set(i.map(({cliPath:e})=>e.join(` `)));for(let t of i){let i=!1;for(let e=1;e<t.cliPath.length;e++)i||=c.has(t.cliPath.slice(0,e).join(` `));ft(e,t,a,s,o.has(t.cliPath.join(` `))||i,n,!r||t.cliPath.length===1)}}function ft(e,n,r,i,a,o,s){let c=n.cliPath,l=e,u=``,f=!r.has(c[0]??``);for(let e of c.slice(0,-1)){u=u===``?e:`${u} ${e}`;let t=f&&u===e||!i.has(u);l=pt(l,e,u,t)}let g=c.at(-1)??n.operationId,_=n.deprecated===!0&&i.has(c.join(` `)),v=l.commands.find(e=>e.name()===g)??l.command(g,n.deprecated===!0&&!_?{hidden:!0}:{}),y=n.requestBody?.flatMap(({parameter:e})=>e)??[];if(v.summary((_?S[c.join(` `)]?.summary:void 0)??(n.summary||n.operationId)).description([`${n.method} ${n.path}.`,n.summary||n.description,`Full documentation: ${o} help ${n.cliPath.join(` `)}`,n.requestBody?.[0]?.kind===`json`||[...n.parameters,...y].some(e=>p(e.schemaType,e.itemSchemaType))?m:``].filter(Boolean).join(`
|
|
3
|
-
`)),!s)return;let b=ie(n);for(let e of n.parameters)mt(v,e,a||e===b);Be(v,n),h(n.intent)&&!v.options.some(e=>e.long===`--execute`)&&v.addOption(new t(`--execute`).hideHelp()),D(v),v.hook(`preAction`,e=>te(e,n)),n.explain===!0&&v.option(`--explain`,`Print the search strategy and parsed constraints before the results`),b!==void 0&&v.argument(`[text...]`,b.description||`Same as ${ce(b.flag)}.`),v.action(async function(){let{emit:e,emitSearchExplanation:t}=await import(`./output-DDkZmZUV.js`),r=Object.assign(this.optsWithGlobals(),{environment:this.opts().environment}),i=E(r),a=r;if(b!==void 0){let t=ne(b,this.args,r);if(!t.ok)return e({mode:i},{...t,notDispatched:!0});if(t.data===null)return e({mode:i},t);a=t.data}let o=ee(n,a);if(o.length>0){let t=`missing required options: ${o.join(`, `)}`;return e({mode:i},d(t,[],{notDispatched:!0}))}let s=await ht(n,a,i),c=ct(n,a,s);if(c!==null)return e({mode:i},c);r.explain===!0&&s.ok&&t(i,s.data),s.ok&&s.data instanceof Uint8Array&&i!==`csv`&&i!==`xlsx`?process.stdout.write(s.data):e({mode:i},s)})}function pt(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=S[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function mt(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()];a===void 0?!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`}):(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`)})}else a===void 0?n.required&&!r?e.requiredOption(n.flag,i):e.option(n.flag,i):e.option(n.flag,i,a)}async function ht(e,t,n){let{buildOpenApiPath:r,runOpenApiCall:i}=await import(`./openapi-call-CSOyWtns.js`),{pendingResult:a}=await import(`./output-DDkZmZUV.js`),o=await We(e,t);if(!o.ok)return{...o,notDispatched:!0};let s=!1,c=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)]})),l=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]]})),u=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)]]})),d=await i({method:e.method,path:r(e.operationId,c),searchParams:l,headers:u,body:o.data,contentType:w(e,t),auth:e.auth,responseFormat:pe(n),responseBytes:e.binaryResponse===!0,pendingResult:a,onDispatch:()=>{s=!0}});return je(e,d.ok||s?d:{...d,notDispatched:!0})}async function gt(e,n){let r=n.bin[0],i=Ae(T),a=re(e,i),l=a===`required`?i:oe(i),u=new Fe;u.enablePositionalOptions(!x(e)&&C(e,i).positionalOptions).name(r).usage(`[--environment <environment>] <command> [subcommand] [options]`).configureHelp(at).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,
|
|
4
|
-
people, and news — carry everything else: funding, publications, and tags.
|
|
5
|
-
|
|
6
|
-
Mutations execute directly; --execute is a deprecated no-op.
|
|
7
|
-
The aVenture MCP server runs these same operations through the same API client.`).addOption(new t(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${c})`).choices([...o()])).showHelpAfterError(`(run \`${r} --help\` for usage)`),(x(e)||e.every(e=>e.startsWith(`-`)))&&u.version(n.version);let d=ut(e,u,l,n);Y(u,d.generated,r,{rootHelp:d.rootHelp}),await d.registerBuiltin(),rt(u,l,r);for(let e of u.commands)e.helpGroup()||e.helpGroup(J(e.name()).heading);let f;if(q(u,e=>t=>{throw f=(async()=>{!d.fullTree&&![`commander.helpDisplayed`,`commander.version`].includes(t.code)&&await d.completeTree((e,t)=>Y(e,t,r));let{commandExitHandler:n}=await import(`./parse-error-hint-CvWM1YK5.js`);try{n(e)(t)}catch(e){if(e!==t)throw e}})(),t}),a===`required`){let e=[u];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&await ae(`required`)}))}}let p=new Set(u.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));return u.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find one news article; companies and people use the root lookup`],[`get`,` get Read one record`],[`list`,` list Read many records`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>p.has(e)?[t]:[]),``,`Authentication (every command that calls aVenture needs a credential):`,` Create one at ${s}/sign-up, then run: ${r} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Check what this shell holds with: ${r} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --csv Print CSV rows or preserve server CSV bytes.`,` --xlsx Write server XLSX bytes with --to-file; use --csv otherwise.`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
|
|
8
|
-
`,`Exit codes:`,` 0 envelope.ok === true
|
|
9
|
-
1 envelope.ok === false
|
|
10
|
-
`,`Examples:`,` $ ${r} auth login`,` $ ${r} lookup --name Stripe --url https://stripe.com`,` $ ${r} search "fintech companies in Austin"\n`,`Run \`${r} <command> --help\` for its subcommands and options,`,`or \`${r} help <command>\` for its full documentation.`].join(`
|
|
11
|
-
`)),{program:u,exitPreparation:()=>f}}var X=a(Ie(import.meta.url)),Z=X.bin[0];async function Q(e,t){process.exitCode=1;let n=e instanceof Error?e:Error(String(e)),r={...d(`${Z} ${t}: ${n.message}`,[n.name||`Error`]),counts:{exitCode:1}};v({component:Z,event:`fatal`,message:n.message,error:n}),process.stderr.write(`${Z} fatal (${t}): ${n.stack??n.message}\n`);try{let{BearerVerificationUnavailableError:e}=await import(`./openapi-call-CSOyWtns.js`),{emitJson:t}=await import(`./output-DDkZmZUV.js`),i=n instanceof e?{httpStatus:n.problem.status,problem:n.problem}:{};r={...r,...i},t(r)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`${Z} fatal reporting failed: ${t}\n`),process.stdout.write(`${JSON.stringify(r)}\n`)}}var _t=e=>{if(e.code!==`EPIPE`)throw e;process.exit(0)};for(let e of[process.stdout,process.stderr])e.on(`error`,_t);process.on(`uncaughtException`,e=>Q(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>Q(e,`unhandledRejection`));var $=await gt(process.argv.slice(2),X);try{await $.program.parseAsync()}catch(t){await $.exitPreparation(),t instanceof e?process.exitCode=t.exitCode:await Q(t,`parseAsync`)}export{};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./commander-DEj7N1b9.js";import{c as t}from"./tool-policy-DthqSCty.js";import{a as n,i as r}from"./cli-help-policy-BEnaH89v.js";import{n as i,t as a}from"./contract-parameter-V0kQHinO.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$/,``),{stdinBody:m,destructive:h,...g}=r;return Object.assign(o,g,{requestBody:u,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 +0,0 @@
|
|
|
1
|
-
import"./tool-policy-DthqSCty.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)&&!/^no[A-Z]/u.test(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,2 +0,0 @@
|
|
|
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"./task-no-write-outcome-BDqB8HQA.js";import{t as te}from"./confidence-CjeYTBnf.js";import{c as ne,d as re,l as ie,s as l,u}from"./tool-policy-DthqSCty.js";import{i as ae,t as d}from"./human-text-cap-dR2SJQJC.js";import{n as oe,t as se}from"./contract-parameter-V0kQHinO.js";var f=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 p(e,t){let n=_(t);if(n.length!==0){e.add(n),(n===`individual`||n===`individuals`)&&p(e,`person`);for(let t of le(n))m(e,t,n);m(e,ue(n),n)}}function le(e){if(e===`people`)return[`person`];let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=f&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return[`${t}y`];let n=e.endsWith(`es`)?e.slice(0,-2):``;return n.length>=f&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n)?[n,`${n}e`]:e.length>f&&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>=f&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=f&&e.endsWith(`es`)))return e.length>=f&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function m(e,t,n){t!==void 0&&t!==n&&t.length>=f&&/^[a-z]+$/u.test(t)&&e.add(t)}function h(e){let t=new Set(g(e)),n=Array.from(t);for(let e of n)p(t,e);return t}function de(e){return g(e).map(h)}function fe(e,t){if(e.length===0)return!1;let n=h(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function g(e){return _(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!ce.has(e))}function _(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 v(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>y(e)),...n.flatMap(e=>e.parameter.map(t=>y(t,n.length>1?e.contentType:void 0))),...pe(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||u(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:ie(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse?null:re(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 y(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 b(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var me=[`-id`,`-slug`,`-url`],he=[`--id`,`--slug`,`--url`],ge=`--from-file "<path>"`;function _e(t,n,r=e().bin[0]){let i=v(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?[]:v([i],r);return a&&S(a,T(a,!1))}function ve(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))}`,...ye(e,t)]}function ye(e,t){return b(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${E(i)} --data`;return[`lookup: ${e.name} from a slug: ${a}`]})}var w=/(?:^|\.)text$/u;function T(e,t=!0){let n=b(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:be(e)).map(E);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,ge]:o}function be(e){let t=new Set;p(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 he){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 xe=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:xe.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`]),Se=Object.assign(t([N,n()]),{enum:N.enum}),Ce=r({allowedValue:n().nullish(),description:n(),key:n(),required:i().default(!0).optional(),type:Se}),P=r({catalogRevision:a().optional(),gateId:c(n()).optional(),input:c(Ce),noWriteCompletion:i().optional(),noWriteOutcome:c(ee).optional(),step:c(M),taskKey:n().optional()}),F=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),we=r({candidate:c(k),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),I=r({answer:n(),citation:c(k),confidence:te,resolution:we.nullish()});function L(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>R(t,oe(e,t))),r=(t?.parameter??[]).map(t=>R(t,se(e,t)));return{selector:n.filter(e=>e.location===`path`||z(e)),pagination:n.filter(B),filter:[...n.filter(V),...r.filter(V)],body:r.filter(e=>!V(e))}}function R(e,t){let{in:n,inputName:r,nullable:i,...a}=e;return{...a,flag:ne(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function z(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function B(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function V(e){return e.location!==`path`&&!z(e)&&!B(e)}function H(e){let t=W(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 U(e,t){let n=e.requestBody?.[0];return t?{...H(e),description:e.description,resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:L(e)}:{...H(e),optionalInput:Oe(e),arrayInput:ke(e)}}function Te(e){let t=L(e),n=e=>e.filter(e=>e.required);return{...U(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}=H(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 W(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 G=160,K=`Operation catalog matches`,Ae=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],q=e=>`${[K,...e].join(`
|
|
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([K,...e,...t]);for(let e of Ae){let t=[...r.flatMap(t=>X(t,e)),...Y(r,e,i)];if(a(t))return q(t)}let o=(e,t=r.length-e)=>{let n=r.slice(e),a=n.length-t;return[...r.slice(0,e).flatMap(e=>X(e,`optionalGrouped`)),...Y(r.slice(0,e),`optionalGrouped`,i),...n.length===0?[]:[`... ${n.length} more operations omitted to fit ${d} 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 q(s===void 0?o(0,[...r.keys()].findLast(e=>a(o(0,e)))??0):o(s))}var J=e=>`call aventure_help with q=<operationId> and limit=1; inspect argument and optionalInput in ${e} for the retained inputs`;function Y(e,t,n){let r=t===`optionalGrouped`&&e.some(e=>X(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>G&&(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; ${J(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 ${d} UTF-8 bytes; ${n} carries them, and ${J(n)}.`]}function X(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}: ${Z(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: ${Z(r,t)}`]:[]]}function Z(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<=G?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 Q(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:Ie(e)}}}}var Fe=4;function Ie(e){let t=e.requestBody?.[0];if(t===void 0)return{};if(t.requiredPath.length>0||e.intent!==`lookup`||t.schemaType===`array`)return Le(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 Le(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(Re,t);r[n.at(-1)??e]=`<${e}>`}return t}function Re(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 ze(e){let t=W(e);return{mcpCall:Q(e),...t===void 0?{}:{paidPlan:t}}}function Be(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{h as C,de as E,fe as S,_ as T,ve as _,je as a,x as b,Ee as c,F as d,P as f,_e as g,b as h,ze as i,Te as l,w as m,$ as n,Q as o,O as p,Be as r,U as s,K as t,I as u,C as v,g as w,p as x,v as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./result-envelope-Ds29nFJ0.js";import{U as r,m as i,n as a,u as o}from"./tool-policy-DthqSCty.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-BExrYg_X.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}})=>Object.assign({instruction:n},e===void 0?{operationId:r}:{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,16 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./text-field-jFKOGMzr.js";import{Buffer as t}from"node:buffer";var n=16e3,r=(e,r=n)=>e.length<=120&&t.byteLength(`${e.join(`
|
|
2
|
-
`)}\n`,`utf8`)<=r,i=(r,{appendNewline:i=!1,preservedTrailerLines:a,transport:o=`cli`,...s}={})=>{let c=e(r),l=i||c.endsWith(`
|
|
3
|
-
`),u=c.endsWith(`
|
|
4
|
-
`)?c.slice(0,-1):c,d=u.length===0?[]:u.split(`
|
|
5
|
-
`),f=t.byteLength(`${d.join(`
|
|
6
|
-
`)}\n`,`utf8`);if(d.length<=120&&f<=16e3)return`${d.join(`
|
|
7
|
-
`)}${l?`
|
|
8
|
-
`:``}`;s.onOmission?.();let p=a===void 0?0:Math.min(Math.max(1,a),118),m=p>0?d.slice(-p):[],h=m.length===0?d:d.slice(0,-m.length),g=[d.length>120?`120 physical lines`:``,f>16e3?`${n} UTF-8 bytes`:``].filter(Boolean).join(` and `),_=t=>e(`... output truncated: ${t} more lines omitted to stay within ${g}; ${o===`mcp`?`inspect structuredContent.data, or call aventure_help with q set to your intent for a narrower read's operationId and query arguments.`:s.exactRecovery??`recover omitted response content with --data --to-file <path>, narrower server-side filters, or the relevant sub-resource operation.`}`),v=(e,t)=>[...e,...m,t].join(`
|
|
9
|
-
`),y=120-m.length-1,b=h.slice(0,y),x=_(d.length-b.length-m.length);for(;t.byteLength(`${v(b,x)}\n`,`utf8`)>n;){if(b.length>0)b=b.slice(0,-1);else if(m.length>0)m=m.slice(1);else break;x=_(d.length-b.length-m.length)}return`${v(b,x)}${l?`
|
|
10
|
-
`:``}`};function a(e){return e===void 0?[]:[`... response truncated: ${e.omitted.join(`; `)}`,`Recovery: ${e.recovery}`,`Recovery: inspect structuredContent.truncation.omitted (kept/total counts), ids and references; call aventure_help with q set to the operation intent for a narrower read, then pass query.page/query.size or split a batch body into smaller calls. Do not repeat a write to recover its response.`]}var o=(e,t,n={})=>i([e.trimEnd(),...t].join(`
|
|
11
|
-
`),{appendNewline:t.length>0||e.endsWith(`
|
|
12
|
-
`),preservedTrailerLines:t.length>0?t.length:void 0,...n}),s=(e,t,n)=>t.length===0?e:o(e,t,{transport:n}),c=(e,r={},i=[])=>o(`${p(e.trimEnd().split(`
|
|
13
|
-
`),120-i.length,n-t.byteLength(i.map(e=>`${e}\n`).join(``),`utf8`),r).join(`
|
|
14
|
-
`)}${e.endsWith(`
|
|
15
|
-
`)?`
|
|
16
|
-
`:``}`,i,r),l=new Set([`core`,`nameFull`,`nameBrand`,`name`,`title`,`fundingDetail`,`round`,`dateAnnounced`,`amountRaised`,`person`,`fundraiseRound`]),u=5,d=(e,t=``,n)=>e===`mcp`?`see structuredContent.data.response${t}`:n??`read it whole with --data --to-file <path>`,f=(e,t)=>e===`mcp`?`inspect structuredContent.data, or call aventure_help with q set to your intent for a narrower read and its query arguments.`:t??`read it whole with --data --to-file <path> or the section's sub-resource operation.`;function p(e,t,i=n,{transport:a=`cli`,...o}={}){let s=e=>e.length<=t&&r(e,i);if(s(e))return e;o.onOmission?.();let c=m(e),l=e=>[...E(c,e-1,d(a,``,o.exactRecovery)),`... output folded to fit 120 lines and ${n} UTF-8 bytes; "(+N lines)" and "N more" mark hidden content in the named section; ${f(a,o.exactRecovery)}`],u=2,p=t,h=l(u);for(;u<=p;){let e=Math.floor((u+p)/2),t=l(e);s(t)?(h=t,u=e+1):p=e-1}return h}function m(e){let t={line:``,child:[]},n=[{node:t,indent:-1}];for(let t of e){let e=_(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 h=new WeakMap,g=e=>{let t=h.get(e);if(t!==void 0)return t;let n=e.child.reduce((e,t)=>e+g(t),1);return h.set(e,n),n},_=e=>e.length-e.trimStart().length,v=/^(?:- ?|\d+\.(?: |$))/u,y=e=>(e.line.trimStart().replace(v,``).split(/[:= ]/u)[0]??``).split(`.`).at(-1)?.replace(/\[\d+\]$/u,``)??``,b=e=>l.has(y(e)),x=e=>b(e)||!C(e)&&e.child.some(x),S=e=>b(e)?g(e):x(e)?e.child.reduce((e,t)=>e+S(t),1):1,C=e=>v.test(e.line.trimStart()),w=e=>e.line.trimStart().startsWith(`... `),T=e=>[e.line,...e.child.flatMap(T)];function E(e,t,n){if(e.reduce((e,t)=>e+g(t),0)<=t)return e.flatMap(T);if(!e.some(C)||!e.every(e=>C(e)||w(e)))return k(e,t,n);let r=e.filter(w).map(({line:e})=>e);return[...O(e.filter(C),t-r.length,n),...r]}function D(e,t,n){if(t>=g(e))return T(e);if(t<=1){let t=e.child.map(y).filter(Boolean).join(`, `)||`nested content`;return[`${e.line} (+${g(e)-1} lines) omitted: ${t}; ${n}`]}return[e.line,...E(e.child,t-1,n)]}function O(e,t,n){let r=Math.max(1,Math.floor((t-1)/Math.min(e.length,u))),i=[],a=0;for(let o of e){let e=Math.min(r,g(o));if(i.length+e>t-1)break;i.push(...D(o,e,n)),a+=1}let o=` `.repeat(_(e[0]?.line??``));return a===e.length?i:[...i,`${o}... ${e.length-a} more items omitted; ${n}`]}function k(e,t,n){let r=e=>e.reduce((e,t)=>e+S(t),0);if(e.length>t||r(e)>t&&e.some(e=>S(e)===1)){let i=e.toSorted((e,t)=>Number(x(t))-Number(x(e))||g(e)-g(t)).slice(0,Math.max(0,t-1));for(;i.length>1&&S(i.at(-1)??e[0]??{line:``,child:[]})===1&&r(i)>t-1;)i.pop();let a=` `.repeat(_(e[0]?.line??``)),o=k(e.filter(e=>i.includes(e)),t-1,n),s=e.filter(e=>!i.includes(e)).map(y),c=s.slice(0,10).join(`, `),l=s.length>10?`, ...`:``;return[...o,`${a}... ${s.length} more fields: ${c}${l}`]}let i=e.map(e=>({node:e,allotted:1})),a=t-e.length,o=(e,t)=>e.forEach((n,r)=>{let i=Math.min(t(n.node)-n.allotted,Math.floor(a/(e.length-r)));n.allotted+=i,a-=i});return o(i.filter(({node:e})=>S(e)>1).toSorted((e,t)=>S(e.node)-S(t.node)),S),o(i.toSorted((e,t)=>g(e.node)-e.allotted-(g(t.node)-t.allotted)),g),i.flatMap(({node:e,allotted:t})=>D(e,t,n))}export{p as a,a as c,r as i,s as l,i as n,c as o,o as r,d as s,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as logoutCliCredentials}from"./logout-De9wAaDj.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{n as materializeCliOAuthBearerCredential,r as materializeSavedCliOAuthBearerCredential}from"./oauth-bearer-credential-ByV8MSw5.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{s as writeShowResult}from"./operations-catalog-C_NHlK6i.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{n as cliMachineOutputSelected}from"./output-mode-CO-iRvt8.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{u as retrySeconds}from"./response-problem-BtBbph_9.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,E as t,S as n,_ as r,a as i,b as a,c as o,d as s,g as c,i as l,m as u,n as d,p as f,s as p,w as m}from"./iso-DzqMxtky.js";import{t as h}from"./person-owner-BW4xz8uH.js";import{n as g,t as _}from"./allowance-type-BVr12WiL.js";import{Buffer as v}from"node:buffer";var y=f(()=>e([n(),c(),o(),i(),p(y),a(n(),y)])),b=l([`URL_DUPLICATE`,`STRICT_URL_LOOKUP`,`DUPLICATE_CREATE_REVIEW`,`CLASSIFICATION_INACTIVE_TAG`,`NEWS_SOURCE_URL`]),x=Object.assign(e([b,n()]),{enum:b.enum}),S=l([`REACTIVATE`,`ATTACH_INACTIVE`]),C=r({availableOverrides:p(S),conflictType:x,slug:n(),tagId:s()}),ee=r({externalId:n().nullish(),id:s(),publicationScore:s(),reason:p(n()),score:s(),slug:n().regex(/^[a-z0-9_-]+$/).max(255).nullish()}),te=r({externalId:n().nullish(),id:t(),name:n().nullish(),operatingStatus:n().nullish(),publicPath:n().nullish(),reason:p(n()),score:s().optional(),slug:n().regex(/^[a-z0-9_-]+$/).max(255).nullish(),typeRecord:g.nullish()}),ne=r({candidate:p(te).nullish(),conflictType:x,newsCandidate:p(ee).nullish(),overridePath:n().nullish(),threshold:s()}),re=r({conflictingArticleId:s(),conflictingArticleSlug:n(),conflictingArticleTitle:n(),conflictType:x}),ie=r({candidateEntityId:p(t()),candidatePersonId:p(t()),conflictType:x,hint:n(),normalizedUrl:n().nullish(),url:n(),urlType:n().nullish()}),ae=r({owner:h,urlId:s()}),w=r({conflictType:x,existingJoin:p(ae),fragmentIgnored:o(),guidance:n(),normalizedUrl:n().nullish(),requestedOwner:h,url:n(),urlType:n()}),T=e([w,ie,ne,C,re]),E=l([`NAME_NOT_DECLARED`,`REGISTRY_CONTACT_MISSING`,`REGISTRY_CONTACT_NOT_STATED`,`SITE_UNREADABLE`]),D=Object.assign(e([E,n()]),{enum:E.enum}),oe=r({acceptedValue:p(n()).nullish(),action:l([`setField`,`setParameter`,`removeParameter`,`useEndpoint`,`reviewCandidates`,`authenticate`]),endpoint:n().nullish(),fieldPath:n().nullish(),parameter:n().nullish(),retryable:o().nullish()}),O=l([`source`,`record`,`disclaimer`,`voice`,`marketing`,`chained`,`structured`,`tense`,`temporal`,`factList`,`mojibake`,`markup`,`contact`,`unsupported`,`legalSource`,`textContract`,`evidenceAuthority`,`internalRepetition`,`promotionalClaim`,`analysis`]),se=Object.assign(e([O,n()]),{enum:O.enum}),ce=r({overridable:o(),passage:n(),problem:se,reason:n(),supportedWording:n().nullish(),unsupportedSpan:p(n()).nullish()}),k=l([`entity`,`person`,`news`,`blog`,`content`]),le=r({deletedAt:d({offset:!0}).nullish(),id:n(),isHidden:o(),nameBrand:n().nullish(),resourceType:k,showOnSitemap:o(),slug:n()}),ue=r({newUrl:n().nullish(),oldUrl:n(),targetCurrentSlug:n().nullish(),targetId:n().nullish(),targetResourceType:k.nullish()}),A=r({allowanceType:_.nullish(),campusProofRefusal:D.nullish(),circuitBreaker:n().nullish(),code:e([l(`harness_suppression_unverified.async_lookup_sign_in_required.not_authorized.rateLimited.rate_limited.subscription_required.subscription_canceled.subscription_past_due.subscription_paused.billing_allowance_exhausted.billing_additional_usage_cap_reached.billing_credit_checkout_closed.billing_plan_change_required.account_exists.origin_detail_capacity.origin_detail_shutdown.query_deadline_shed.primary_read_saturated.suspectedShellStrip.suspected_shell_strip.prose_rejected.prose_evidence_too_large.text_send_limit_reached.entity_name_casing_rejected.fundraise_evidence_unsupported.website_not_own_live_site.cvc_inherited_headcount.source_grounding_at_capacity.url_surface_misclassification.JOBRUNR_DISABLED.jobrunr_disabled.task_plan_operation_unserved.JOBRUNR_STORAGE_UNAVAILABLE.jobrunr_storage_unavailable.rbac_lookup_unavailable.GEOCODE_PROVIDER_ERROR.geocode_provider_error.image_blocklist_match.image_monochrome.image_too_small.image_wrong_aspect.image_monogram.image_unreadable.image_processing_error.image_brand_mismatch.image_reference_unavailable.logo_first_party_missing.logo_source_dead.image_photographic.web_crawl_fetch_failed.source_document_fetch_busy.primary_website_missing.news_rss_feed_fetch_failed.news_rss_article_fetch_failed.callback_connection_refused.callback_timeout.callback_tls_error.callback_http_4xx.callback_http_5xx.callback_challenge_failed.news_subscription_limit.r2_fetch_failed.r2_delete_failed.r2_upload_failed.source_document_body_unavailable.source_document_capture_limit_exceeded.news_similarity_embedding_unavailable.search_provider_not_configured.search_provider_error.search_still_running.lookup_still_running.sec_edgar_fetch_failed.github_fetch_failed.clerk_m2m_unavailable.clerk_oauth_unavailable.researchly_usage_unavailable.INFERENCE_PROVIDER_ERROR.inference_provider_error.text_write_job_ended.INFERENCE_PROVIDER_RESPONSE_EMPTY.inference_provider_response_empty.INFERENCE_PROVIDER_INVALID_JSON.inference_provider_invalid_json.INFERENCE_PROFILES_MISSING.inference_profiles_missing.INFERENCE_PROFILE_API_KEY_MISSING.inference_profile_api_key_missing`.split(`.`)),n().max(128)]).nullish(),conflictingRecord:le.nullish(),coveringRunId:t().nullish(),detail:n().optional(),details:T.nullish(),disposition:l([`TRANSIENT`,`TERMINAL`]).nullish(),error:a(n(),n()).nullish(),existingRecordId:n().nullish(),existingRedirect:ue.nullish(),feId:n().nullish(),field:n().nullish(),filedRunId:p(t()).nullish(),hammingDistance:c().int().nullish(),hint:n().nullish(),instance:n().optional(),limit:c().int().nullish(),limitType:e([l([`FORM`,`GLOBAL`,`SUBNET`,`IP`,`UNKNOWN`,`WEB_SEARCH`,`AGENT_HELP`,`NATURAL_SEARCH`,`BILLING_ALLOWANCE`,`BILLING_ADDITIONAL_USAGE`]),n()]).nullish(),matchedBlocklistKey:n().nullish(),mediaType:n().nullish(),moderationReason:n().nullish(),mutationNotApplied:o().nullish(),path:n().nullish(),properties:a(n(),y).optional(),proseViolation:p(ce).nullish(),remaining:c().int().nullish(),requiredRole:n().nullish(),resetAt:d({offset:!0}).nullish(),resolution:oe.nullish(),retryAfterSeconds:c().int().nullish(),spanId:n().nullish(),status:s().optional(),suggestion:n().nullish(),suggestions:a(n(),n()).nullish(),suspectedFragment:n().nullish(),title:n().optional(),traceId:n().nullish(),type:n().optional(),unknownParameters:p(n()).nullish(),unmetGateId:p(n()).nullish(),used:c().int().nullish(),validParameters:p(n()).nullish(),value:n().nullish(),windowSeconds:c().int().nullish()}),de=e=>e>=400&&e<500,fe=e=>e>=500&&e<600,pe=1e3,me=/^(?:bio|biography|body|content|description|evidence|fulltext|notes|snippet|summary|text)$/u,he=/(?:description|snippet|summary|text)$/u,j=e=>e===`data.response.entity.answer`||e===`data.response.answer`,M=e=>`\n[truncated byteLength=${e.byteLength} maxBytes=${e.maxBytes}]`;function N(e){return typeof e!=`object`||!e?!1:Array.isArray(e)?e.length>0:Object.values(e).some(N)}function P(e,t,n,r){if(typeof e==`string`){let i=(t.split(`.`).at(-1)??t).replace(/\[\d+\]$/,``).toLowerCase(),a=me.test(i)||he.test(i)||e.length>1e3,o=r.stringLimit??320;return!a||e.length<=o?{value:e,omitted:[]}:{value:`${e.slice(0,o).trimEnd()}${M(n)}`,omitted:[t]}}if(typeof e!=`object`||!e)return{value:e,omitted:[]};if(Array.isArray(e))return F(e,t,n,r);if(j(t))return{value:e,omitted:[]};let i={},a=[],{foldDepth:o}=r;for(let[s,c]of Object.entries(e)){if(c===void 0)continue;let e=typeof c==`object`&&!!c;if(e&&o!==void 0&&(o===0||Array.isArray(c))){a.push(`${t.replaceAll(/\[\d+\]/gu,`[]`)}.${s} (folded)`);continue}let l=e&&o!==void 0?{...r,foldDepth:o-1}:r,u=P(c,`${t}.${s}`,n,l);i[s]=u.value,a.push(...u.omitted)}return{value:i,omitted:a}}function F(e,t,n,r){let i=e.slice(0,r.prefix?.get(t)??e.length),a=r.foldRows===!0?1:r.foldDepth,o={...r,foldDepth:a},s=i.map((e,r)=>P(e,`${t}[${r}]`,n,o)),c=s.flatMap(e=>e.omitted),l=`${t}[${i.length}..] (kept ${i.length} of ${e.length})`;return{value:s.map(e=>e.value),omitted:e.length>i.length?[...c,l]:c}}var I=()=>({bytes:0,characters:0,omissionBytes:0,omissionCharacters:0,omissions:0}),L=(e,t)=>({bytes:e.bytes+t.bytes,characters:e.characters+t.characters,omissionBytes:e.omissionBytes+t.omissionBytes,omissionCharacters:e.omissionCharacters+t.omissionCharacters,omissions:e.omissions+t.omissions}),R=e=>{let t=JSON.stringify(e);return{...I(),bytes:v.byteLength(t,`utf8`),characters:t.length}},z=e=>{let t=R(e);return{...I(),omissionBytes:t.bytes+1,omissionCharacters:t.characters+1,omissions:1}},ge=(e,t)=>({bytes:e.bytes-t.bytes,characters:e.characters-t.characters,omissionBytes:e.omissionBytes-t.omissionBytes,omissionCharacters:e.omissionCharacters-t.omissionCharacters,omissions:e.omissions-t.omissions}),B=(e,t)=>{let n=I();for(let r=t;r>0;r-=r&-r)n=L(n,e.cost[r]);return n},_e=(e,t,n)=>{for(let r=t+1;r<e.cost.length;r+=r&-r)e.cost[r]=L(e.cost[r],n)};function ve(e,t,n,r,i,a){let o=P(e,`data`,t,{prefix:n}),s=new Map(o.omitted.map(e=>[e.replace(/\[\d+\.\.\] \(kept \d+ of \d+\)$/u,``),e])),c=new Map,l=(e,t,n)=>{let r=s.get(t),i=r===void 0?I():z(r);if(typeof e!=`object`||!e||j(t))return L(R(e),i);if(Array.isArray(e)){let a=[I()],o=I();e.forEach((e,r)=>{let i=l(e,`${t}[${r}]`,{path:t,index:r,parent:n}),s={...i,bytes:i.bytes+1,characters:i.characters+1};a.push(s),o=L(o,s)});for(let e=1;e<a.length;e++){let t=e+(e&-e);t<a.length&&(a[t]=L(a[t],a[e]))}c.set(t,{path:t,length:e.length,originalLength:Number(/ of (\d+)\)$/u.exec(r??``)?.[1]??e.length),parent:n,cost:a,ownOmission:i,revision:0});let s=e.length===0?2:1;return L({...o,bytes:o.bytes+s,characters:o.characters+s},i)}let a=L(R({}),i),o=0;for(let[r,i]of Object.entries(e)){if(i===void 0)continue;let e=R(r),s=l(i,`${t}.${r}`,n),c=o++===0?1:2;a=L(a,L(s,{...e,bytes:e.bytes+c,characters:e.characters+c}))}return a},u=l(o.value,`data`),d=i({prefix:n},o),f=R(d),p=f.bytes,m=f.characters,h=d.truncation?.omitted??[],g=h.length;u.omissions===0&&h.length===1&&h[0]===`data`&&(g=0);let _=R([`data`]).bytes-2,v=e=>e===0?_:-1,y=e=>{let n=L(B(e,e.length),e.ownOmission);return Math.max((n.bytes+n.omissionBytes)/t.maxBytes,(n.characters+n.omissionCharacters)/a)},b=[],x=e=>{if(e.parent!==void 0!==r||e.length===0)return;let t={item:e,pressure:y(e),revision:e.revision},n=b.length;for(b.push(t);n>0;){let e=Math.floor((n-1)/2);if(b[e].pressure>=t.pressure)break;b[n]=b[e],n=e}b[n]=t},S=()=>{let e=b[0],t=b.pop();if(b.length===0||t===void 0)return e;let n=0;for(;n*2+1<b.length;){let e=n*2+1;if(e+1<b.length&&b[e+1].pressure>b[e].pressure&&e++,t.pressure>=b[e].pressure)break;b[n]=b[e],n=e}return b[n]=t,e};for(let e of c.values())x(e);for(;p>t.maxBytes||m>=a;){let e=S();if(e===void 0)break;let r=e.item;if(e.revision!==r.revision)continue;let i=r.parent;for(;i&&i.index<(n.get(i.path)??1/0);)i=i.parent;if(i)continue;let o=B(r,r.length),s=L(o,r.ownOmission),l=e=>{let t=B(r,e),n=z(`${r.path}[${e}..] (kept ${e} of ${r.originalLength})`),i=g-o.omissions+t.omissions-r.ownOmission.omissions+1,a=v(i)-v(g);return{bytes:p-o.bytes+t.bytes+ +(e===0)-o.omissionBytes+t.omissionBytes-r.ownOmission.omissionBytes+n.omissionBytes+a,characters:m-o.characters+t.characters+ +(e===0)-o.omissionCharacters+t.omissionCharacters-r.ownOmission.omissionCharacters+n.omissionCharacters+a,count:i,retained:t,tail:n}},u=r.length===1?0:1,d=r.length-1;for(;u<d;){let e=Math.ceil((u+d)/2),n=l(e);n.bytes<=t.maxBytes&&n.characters<a?u=e:d=e-1}let f=l(u);if(f.bytes>=p&&f.characters>=m)continue;n.set(r.path,u),p=f.bytes,m=f.characters,g=f.count,r.length=u,r.ownOmission=f.tail,r.revision++,x(r);let h=ge(L(f.retained,f.tail),s);for(u===0&&(h.bytes++,h.characters++),i=r.parent;i;){let e=c.get(i.path);_e(e,i.index,h),e.revision++,x(e),i=i.parent}}}var ye=1048576;function V(e){return e.ok&&e.operationId===`searchFederated`}function be(e,t=ye){if(!V(e))return;let n=`Search exceeds the ${t}-byte transport budget; the full result was retained without trimming.`;return e.warnings.includes(n)||v.byteLength(JSON.stringify(e),`utf8`)<=t?e:{...e,warnings:[...e.warnings,n]}}var H=e([n(),c(),o()]),U=r({number:c().optional(),size:c().optional(),numberOfElements:c().optional(),totalElements:c().optional(),totalPages:c().optional(),first:o().optional(),last:o().optional(),empty:o().optional()}),xe=r({byteLength:c(),maxBytes:c(),omitted:p(n()),recovery:n(),spill:r({spilledTo:n().min(1),byteLength:s().nonnegative(),readableView:n().min(1).optional()}).optional()}),Se=r({status:c(),title:n(),type:n()}).catchall(y.optional()).and(A),Ce=r({ok:o(),summary:n(),httpStatus:c().optional(),operationId:n().optional(),method:n().optional(),endpoint:n().optional(),format:l([`json`,`text`]).optional(),count:c().optional(),page:U.optional(),filters:a(n(),e([H,p(H)])).optional(),truncated:o().optional(),trimmed:p(n()).optional(),truncation:xe.optional(),omitted:p(n()).default([]),ids:p(n()).default([]),counts:a(n(),c()).default({}),references:p(n()).default([]),warnings:p(n()).default([]),problem:Se.optional(),notDispatched:u(!0).optional(),data:m()}),we=160,Te=48,W=5e4,Ee=3e4;function De(e){let t=Ce.safeParse(e);return t.success?t.data:null}function Oe(e){let t=U.safeParse(e);return t.success&&Object.values(t.data).some(e=>e!==void 0)?t.data:void 0}function ke(e,t){if(t?.numberOfElements!==void 0)return t.numberOfElements;if(Array.isArray(e))return e.length;let n=$(e)?e.content:void 0;return Array.isArray(n)?n.length:void 0}function G(e,t,n={}){return{ok:!0,summary:e,...n,omitted:n.omitted??[],ids:n.ids??[],counts:n.counts??{},references:n.references??[],warnings:n.warnings??[],data:t}}function Ae(e,t=[],n={}){return{...G(e,null,{...n,warnings:t}),ok:!1}}function K(e,t={}){let n=t.savesCappedPayload===!0&&t.foldRows!==!1?void 0:be(e);if(n!==void 0)return n;let r=t.maxBytes??5e4;if(Y(e,r))return e;let i={byteLength:v.byteLength(JSON.stringify(e),`utf8`),maxBytes:r,spill:t.spill??e.truncation?.spill},a=e.httpStatus??0;if(t.write===!0&&e.ok&&a>=200&&a<300)return je(e,i,t.exactRecovery);let o=e.ok?Me:`Refetch a narrower result through read operations using ids/references or filters; do not retry the failed operation.`,s=t.exactRecovery??t.narrowerRead??o,c=y.safeParse(JSON.parse(JSON.stringify(e.data))),l=`response truncated (caps); metadata named in truncation.omitted was removed; follow truncation.recovery for the full result`,u=e,d=[],f=(e,t)=>{let n=t??(c.success?P(c.data,`data`,i,e):{value:Q(i),omitted:[`data`]});return{...u,truncated:!0,truncation:Z(i,[...n.omitted,...d],s),warnings:[...u.warnings,...e.prefix===void 0?[]:[`kept list prefixes; ${s}`],`response truncated (caps); follow truncation.recovery for the full result`],data:n.value}},p=e;for(let e of[24e3,1e4,320])if(p=f({stringLimit:e}),Y(p,i.maxBytes))return p;if(c.success){let e={...p,data:null};N(c.data)&&!Y(e,i.maxBytes)&&(u=q(e,i,s,l,[]),d=u.truncation?.omitted??[]);let n=new Map;for(let e of[!0,!1])if(ve(c.data,i,n,e,f,Ee),p=f({prefix:n}),Y(p,i.maxBytes))return p;if(t.foldRows!==!1&&(p=f({prefix:n,foldRows:!0}),Y(p,i.maxBytes)))return p}if(p.truncation?.omitted.some(e=>/\[\d+\.\.\]/u.test(e))){let e=q(p,i,s,l,[...p.truncation.omitted]);if(Y(e,i.maxBytes))return e}let m=Q(i);return q({...p,truncation:Z(i,[`data`],s),data:m},i,s,l)}function je(e,t,n=`Read the full result through the GET operation on ${e.endpoint??`this route`}.`){let r={...e.counts},i=(e,n)=>{let a={};for(let[o,s]of Object.entries($(e)?e:{}))Array.isArray(s)?r[`${n}${o}`]=s.length:typeof s==`string`?a[o]=X(s,t,320):typeof s!=`object`||!s?a[o]=s:n===``&&o===`response`?a[o]=i(s,`response.`):o===`core`&&$(s)&&(a[o]={id:s.id});return a},a={...e,summary:`${e.method} succeeded (HTTP ${e.httpStatus}); response body omitted (${t.byteLength} bytes, over caps); do not retry the write`,truncated:!0,truncation:Z(t,[`data`],n),counts:r,data:i(e.data,``)},o=[`data`];for(let r of[`references`,`ids`,`warnings`]){if(Y(a,t.maxBytes))return a;o.push(r),Object.assign(a,{[r]:[],omitted:[...e.omitted,...o.slice(1)],truncation:Z(t,o,n)})}return Y(a,t.maxBytes)?a:q({...a,data:Q(t),warnings:[`response truncated (caps); do not retry the write`]},t,n,`response truncated (caps); metadata named in truncation.omitted was removed; do not retry the write`)}function q(e,t,n,r,i=[`data`]){if(Y(e,t.maxBytes))return e;let a=e.warnings.slice(0,-1),o=e,s=e=>(o={...o,...e,truncation:Z(t,i,n)},Y(o,t.maxBytes));if(o.problem!==void 0){let e=J(o.problem);if(JSON.stringify(e).length<JSON.stringify(o.problem).length&&(i.push(`problem`),s({problem:e})))return o}let c=[`filters`,`omitted`,`ids`,`counts`,`references`].filter(t=>Object.keys(e[t]??{}).length>0);if(i.push(...c),s({filters:void 0,omitted:[],ids:[],counts:{},references:[],warnings:c.length===0?e.warnings:[...a,r]}))return o;let l=e=>e===void 0?void 0:X(e,t),u={summary:X(o.summary,t),operationId:l(o.operationId),method:l(o.method),endpoint:l(o.endpoint),warnings:o.warnings.map(e=>X(e,t)),problem:o.problem&&J(o.problem,t)},d=new Map(Object.entries(o));for(let[e,t]of Object.entries(u))JSON.stringify(t)!==JSON.stringify(d.get(e))&&i.push(e);if(s(u))return o;if(o.problem!==void 0){let e=J(o.problem,t,we,Te);if(JSON.stringify(e).length<JSON.stringify(o.problem).length&&(i.push(`problem.reasons`),s({problem:e})))return o}for(let e of[`error`,`proseViolation`])if(o.problem?.[e]!==void 0&&(i.push(`problem.${e}`),s({problem:{...o.problem,[e]:void 0}})))return o;i.push(`warnings`),o.page!==void 0&&i.push(`page`);let f=X(o.summary,t,320);return f!==o.summary&&i.push(`summary`),{...o,summary:f,page:void 0,truncation:Z(t,i,n),warnings:[r]}}function J(e,t,n=320,r=n){let i=e=>t===void 0?e:X(e,t);return{status:e.status,title:i(e.title),type:i(e.type),...e.detail===void 0?{}:{detail:i(e.detail)},...e.field==null?{}:{field:i(e.field)},...e.hint==null?{}:{hint:i(e.hint)},...e.error==null?{}:{error:Object.fromEntries(Object.entries(e.error).map(([e,r])=>[e,t===void 0?r:X(r,t,n)]))},...e.proseViolation==null?{}:{proseViolation:e.proseViolation.map(e=>({...e,passage:t===void 0?e.passage:X(e.passage,t,r),reason:t===void 0?e.reason:X(e.reason,t,n)}))},...e.instance===void 0?{}:{instance:i(e.instance)},...e.code===void 0?{}:{code:typeof e.code==`string`?i(e.code):e.code},...e.retryAfterSeconds===void 0?{}:{retryAfterSeconds:e.retryAfterSeconds},...e.disposition==null?{}:{disposition:e.disposition},mutationNotApplied:e.mutationNotApplied??void 0,...e.resetAt===void 0?{}:{resetAt:e.resetAt}}}function Y(e,t=W){let n=JSON.stringify(e);return n.length<3e4&&v.byteLength(n,`utf8`)<=t}function X(e,t,n=pe){if(v.byteLength(JSON.stringify(e),`utf8`)<=n)return e;let r=M(t),i=``,a=v.byteLength(JSON.stringify(r),`utf8`);for(let t of e){let e=v.byteLength(JSON.stringify(t),`utf8`)-2;if(a+e>n)break;i+=t,a+=e}return`${i.trimEnd()}${r}`}var Me=`Save the full response with --to-file <path>, then inspect the needed section; use narrower reads, filters, or pagination only where the operation supports them.`,Z=(e,t,n)=>({...e,omitted:t.length===0?[`data`]:[...new Set(t)],recovery:X(n,e)}),Q=({byteLength:e,maxBytes:t})=>({truncated:!0,byteLength:e,maxBytes:t}),$=e=>typeof e==`object`&&!!e&&!Array.isArray(e);export{Oe as a,G as c,fe as d,A as f,Y as i,V as l,K as n,De as o,y as p,Ae as r,ke as s,W as t,de as u};
|