@aventurevc/aventure-cli 0.7.295 → 0.7.296
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/README.md +16 -8
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/{auth-DVA6KxqF.js → auth-Bb-9biQe.js} +1 -1
- package/dist/chunks/{aventure-cli-CeQTzpF6.js → aventure-cli-D8DWnUUN.js} +2 -2
- package/dist/chunks/{index.node-DLQhh1RA.js → index.node-BBdAsEIu.js} +1 -1
- package/dist/chunks/{mcp-generation-contract-Df9WpBvs.js → mcp-generation-contract-TKBneuCS.js} +1 -1
- package/dist/chunks/{oauth-credential-BvaMUsLv.js → oauth-credential-CayH9z1e.js} +1 -1
- package/dist/chunks/oauth-login-DXqj8AHE.js +3 -0
- package/dist/chunks/oauth-login-eW2jq0F0.js +1 -0
- package/dist/chunks/{openapi-commands-CM6Yhmi3.js → openapi-commands-DoiIrMC_.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/oauth-login-BL08wbH6.js +0 -1
- package/dist/chunks/oauth-login-DpbqrJ94.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,D as t,_ as n,a as r,k as i,v as a,x as o}from"./person-owner-ChqQWHII.js";import{$ as s,C as c,Ct as l,E as u,J as d,L as f,M as p,N as m,O as h,P as ee,Q as te,S as ne,T as re,U as g,X as _,Y as v,Z as ie,b as ae,c as oe,et as y,f as se,g as ce,h as le,it as b,j as ue,k as x,l as S,m as de,nt as fe,o as pe,p as me,q as C,rt as w,s as he,v as ge,w as _e,z as ve}from"./auth-DVA6KxqF.js";import{C as T,S as ye,a as be,c as xe,f as Se,h as Ce,i as we,o as Te,r as Ee,t as De,u as Oe,w as ke,y as Ae}from"./oauth-credential-BvaMUsLv.js";import{C as je,S as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,l as Ve,m as He,n as Ue,o as E,p as We,r as D,s as Ge,t as O,u as Ke,v as qe,x as Je,y as Ye}from"./openapi-commands-CM6Yhmi3.js";import{a as Xe,f as Ze,i as Qe,l as $e,n as et,r as tt,s as nt,t as rt}from"./mcp-generation-contract-Df9WpBvs.js";import{i as it,n as at,o as ot,r as st,s as ct,t as lt}from"./oauth-login-DpbqrJ94.js";import{spawnSync as ut}from"node:child_process";import{createHash as dt,webcrypto as ft}from"node:crypto";import{readFile as pt}from"node:fs/promises";import{homedir as mt,hostname as ht,platform as gt}from"node:os";import{basename as _t,dirname as k,join as A,resolve as j,sep as vt}from"node:path";import M,{stderr as N,stdin as yt}from"node:process";import{appendFileSync as bt,copyFileSync as xt,existsSync as P,lstatSync as St,mkdirSync as Ct,mkdtempSync as wt,readFileSync as F,readlinkSync as Tt,realpathSync as Et,renameSync as Dt,rmSync as Ot,rmdirSync as kt,unlinkSync as At,writeFileSync as I}from"node:fs";import{fileURLToPath as jt}from"node:url";import{TextDecoder as Mt,inspect as Nt}from"node:util";import{setTimeout as Pt}from"node:timers/promises";import{createInterface as Ft}from"node:readline/promises";function It(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...w(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function Lt(e,t,n){if(!L(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!Zt(n,r.name))continue;let a=Xt(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function Rt(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function zt(e,t,n,r=!1){if(r||!en(t)||!Array.isArray(n))return nn(e,t,n);for(let[r,i]of n.entries()){let n=nn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function Bt(e,t,n,r){return nn(e,t,r,n)}function Vt(e){let t=[];for(let n of e.split(`.`)){let e=an(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Ht(e,t){let n=Vt(t);if(n===null)return null;let r=Yt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Jt(r)}:null}function Ut(e,t){if(en(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):w(`${n} was already given; pass it once.`)}var Wt=/^(?<row>\d+):(?<item>.*)$/su;function Gt(e,t){let n=Vt(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=Wt.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function Kt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Vt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function qt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Ht(r,i.name);if(a===null)continue;if(a.firstHole!==null)return w(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Gt(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return w(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function Jt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Yt(e,t){let n=e;for(let e of t){if(!L(n))return;n=n[e]??null}return n}function Xt(e,t){if(!en(t))return Yt(e,t.split(`.`))}function Zt(e,t){return $t(e,t.split(`.`))}function Qt(e,t,n){if(!L(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&Zt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function $t(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=an(n);if(!L(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>$t(e,r)):$t(a,r)}function en(e){return e.split(`.`).some(e=>an(e).isArray)}function tn(e,t){return e.parameter.length===0||!L(t)?null:sn(t,[],on(e.parameter))}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=an(o),c=e===i.length-1,l=rn(a,s,t,c,n,r);if(!l.ok||l.data===null)return w(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return w(`${t} is not a valid body option path.`)}function rn(e,t,n,r,i,a){let o=()=>w(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return L(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return L(s)?b(`Body path stepped`,s):o()}function an(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function on(e){let t=new Set,n=new Set,r=new Map;for(let i of e){let e=`${i.name}${i.schemaType===`array`?`[]`:``}`;t.add(e),r.set(e,i.flag.split(` `)[0]??i.name);let a=e.split(`.`);for(let e=1;e<a.length;e+=1)n.add(a.slice(0,e).join(`.`))}return{leaf:t,prefix:n,flagByLeaf:r}}function sn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=sn(r,t,n);if(e!==null)return e}return null}if(!L(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!cn(a,n)){if(!ln(e))continue;return{path:a,suggestion:un(e,n)}}let o=sn(i,e,n);if(o!==null)return o}return null}function cn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function ln(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function un(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``,[i]=[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:dn(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path));if(i!==void 0)return{path:i.path,flag:t.flagByLeaf.get(i.path)??i.path}}function dn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}function fn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&t.helpGroup(We(e))}e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?bn(r,i):r===void 0?i===void 0?0:1:-1})}function pn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function mn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function hn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:vn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function gn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function _n(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function vn(e,t){return`${Le(t.description,void 0)}${e.kind!==`multipart`&&en(t.name)?` Repeat to add another value.`:``}${yn(e,t)}`}function yn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Vt(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function bn(e,t){return Re(e)-Re(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function xn(e){let t;try{t=e===`-`?await Sn():await pt(e,`utf8`)}catch(t){return w(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return w(`Input is not valid JSON: ${e.message}`)}}async function Sn(){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 Cn=`--content-type`;function wn(e,t){let n=t.requestBody??[];if(n.length>1){let t=n.map(({contentType:e})=>e);e.addOption(new u(`${Cn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(En(n)))}if(Kn(t)){let r=n[0];if(r===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new u(`--from-file <path>`,_n(r,r.requiredPath)).argParser(On(`--from-file`)))}let r=pn(n);for(let t of r.toSorted((e,t)=>bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=t.variant[0],a=new u(mn(t),n.length>1?hn(t):vn(r,i));n.length===1&&i.envName!==void 0&&a.env(i.envName);let o=n.length===1?gn(r,i.optionKey):[];o.length>0&&a.conflicts(o),n.length>1?a.argParser(Tn):en(i.name)||i.schemaType===`array`?a.argParser(Dn):a.argParser(On(i.flag)),e.addOption(a)}Gn(e,t,r)}function Tn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function En(e){return(t,n)=>{if(n!==void 0)throw new h(`${Cn} was already given; pass it once.`);let r=_e(e,t);if(!r.ok)throw new h(r.summary);return t}}function Dn(e,t){return[...t??[],e]}function On(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new h(`${t} was already given; pass it once.`);return e}}async function kn(e,t){let n=typeof t.contentType==`string`?t.contentType:void 0,r=_e(e.requestBody??[],n);if(!r.ok||r.data===null)return w(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=An(e,i,t);if(a!==null)return w(a);let o=It(e.operationId,i,t);if(!o.ok)return w(o.summary,o.warnings);t=o.data;let s=jn(i,t);if(s!==null)return w(s);let c=await Fn(t);if(!c.ok)return w(c.summary,c.warnings);let l=Qt(e.requestBody??[],i,c.data);if(l!==null)return w(l);let u=Pn(e.operationId,i,c.data);if(!u.ok)return u;let d=Lt(e.operationId,i,c.data);if(d!==null)return w(d);let f=In(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?w(Wn(e.operationId,i)):b(`No body`,void 0);let p=zn(e.operationId,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return w(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!L(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return w(`${e.operationId} requires a JSON object${t}.`)}let m=Nn(i,p.data);if(m.length>0)return w(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,ee=L(h)?Rt(i).filter(e=>!Zt(h,e)):[];return ee.length>0?w(Mn(e.operationId,i,ee)):p}function An(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`${Rn(t)} requires ${Cn} ${i.join(` or `)}.`}return null}function jn(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 Mn(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 Nn(e,t){return L(t)?e.parameter.filter(e=>e.required&&!Zt(t,e.name)).map(Rn):[]}function Pn(e,t,n){let r=tn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion.path} (${r.suggestion.flag}).`;return w(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function Fn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await xn(t);if(!n.ok)return w(n.summary,n.warnings);let r=l.safeParse(n.data);return r.success?b(`Input parsed`,r.data):w(`Input is not valid JSON value: ${r.error.message}`)}function In(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Ut(e,n[e.optionKey]);if(!a.ok||a.data===null)return w(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Ln(t,n,r,e,o);if(!s.ok)return w(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=qt(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function Ln(e,t,n,r,i){let a=Gt(r,i);if(a===null){let e=Hn(r,i);return e.ok?zt(n,r.name,e.data,r.schemaType===`array`):w(e.summary,e.warnings)}if(a.plain.length>0)return w(`${Rn(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=Kt(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return w(`${Rn(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=Un(r.name,r.itemSchemaType,e);if(!t.ok)return w(t.summary,t.warnings);i.push(t.data)}let a=Bt(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}function Rn(e){return e.flag.split(` `)[0]??e.name}function zn(e,t,n){if(t===void 0)return b(`Direct body parsed`,n);if(n===void 0)return b(`Input parsed`,t);if(L(t)&&L(n))try{return b(`Input parsed`,Bn(t,n))}catch(t){return w(`${e} ${t.message}`)}return w(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Bn(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(Array.isArray(t)&&Array.isArray(r))throw Error(`cannot combine --from-file array '${e}' with array body options at the same key — move the per-item fields inside the matching '${e}[]' object(s) in the file body.`);if(t!==void 0&&Vn(t)!==Vn(r))throw Error(`cannot combine --from-file ${Vn(t)} '${e}' with ${Vn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=L(t)&&L(r)?Bn(t,r):r}return n}function Vn(e){return Array.isArray(e)?`array`:L(e)?`object`:`scalar`}function Hn(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Un(e.name,e.schemaType,t??``);let n=[],r=en(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Un(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function Un(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):w(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?w(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?w(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function Wn(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(Rn).join(`, `)}`;let r=Rt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(Rn).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Gn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Cn,location:`body`}),Kn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),fn(e.options,r)}function Kn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function qn(e){let t=fe(e);return er(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Jn(e){er(e);let t=et(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
1
|
+
import{C as e,D as t,_ as n,a as r,k as i,v as a,x as o}from"./person-owner-ChqQWHII.js";import{$ as s,C as c,Ct as l,E as u,J as d,L as f,M as p,N as m,O as h,P as ee,Q as te,S as ne,T as re,U as g,X as _,Y as v,Z as ie,b as ae,c as oe,et as y,f as se,g as ce,h as le,it as b,j as ue,k as x,l as S,m as de,nt as fe,o as pe,p as me,q as C,rt as w,s as he,v as ge,w as _e,z as ve}from"./auth-Bb-9biQe.js";import{C as T,S as ye,a as be,c as xe,f as Se,h as Ce,i as we,o as Te,r as Ee,t as De,u as Oe,w as ke,y as Ae}from"./oauth-credential-CayH9z1e.js";import{C as je,S as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,l as Ve,m as He,n as Ue,o as E,p as We,r as D,s as Ge,t as O,u as Ke,v as qe,x as Je,y as Ye}from"./openapi-commands-DoiIrMC_.js";import{a as Xe,f as Ze,i as Qe,l as $e,n as et,r as tt,s as nt,t as rt}from"./mcp-generation-contract-TKBneuCS.js";import{i as it,n as at,o as ot,r as st,s as ct,t as lt}from"./oauth-login-DXqj8AHE.js";import{spawnSync as ut}from"node:child_process";import{createHash as dt,webcrypto as ft}from"node:crypto";import{readFile as pt}from"node:fs/promises";import{homedir as mt,hostname as ht,platform as gt}from"node:os";import{basename as _t,dirname as k,join as A,resolve as j,sep as vt}from"node:path";import M,{stderr as N,stdin as yt}from"node:process";import{appendFileSync as bt,copyFileSync as xt,existsSync as P,lstatSync as St,mkdirSync as Ct,mkdtempSync as wt,readFileSync as F,readlinkSync as Tt,realpathSync as Et,renameSync as Dt,rmSync as Ot,rmdirSync as kt,unlinkSync as At,writeFileSync as I}from"node:fs";import{fileURLToPath as jt}from"node:url";import{TextDecoder as Mt,inspect as Nt}from"node:util";import{setTimeout as Pt}from"node:timers/promises";import{createInterface as Ft}from"node:readline/promises";function It(e,t,n){let r={...n};for(let n of t.parameter){let t=n.envName;if(t===void 0)continue;let i=process.env[t]?.trim();if(i===void 0||i.length===0)continue;let a=r[n.optionKey];if(a!==void 0&&(typeof a!=`string`||a!==i))return{...w(`${e} ${n.flag.split(` `)[0]??n.name} conflicts with ${t}; omit the flag or use ${i}.`),data:r};a===void 0&&(r[n.optionKey]=i)}return b(`Environment-bound options applied`,r)}function Lt(e,t,n){if(!L(n))return null;for(let r of t.parameter){let t=r.envName,i=t===void 0?void 0:process.env[t]?.trim();if(t===void 0||i===void 0||i.length===0||!Zt(n,r.name))continue;let a=Xt(n,r.name);if(typeof a!=`string`||a!==i)return`${e} ${r.name} in --from-file conflicts with ${t}; omit the field or use ${i}.`}return null}function Rt(e){let t=new Set(e.parameter.map(({name:e})=>e));return e.kind===`multipart`?e.requiredPath:e.requiredPath.filter(e=>!t.has(e))}function zt(e,t,n,r=!1){if(r||!en(t)||!Array.isArray(n))return nn(e,t,n);for(let[r,i]of n.entries()){let n=nn(e,t,i,r);if(!n.ok)return n}return b(`Body value assigned`,null)}function Bt(e,t,n,r){return nn(e,t,r,n)}function Vt(e){let t=[];for(let n of e.split(`.`)){let e=an(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Ht(e,t){let n=Vt(t);if(n===null)return null;let r=Yt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:Jt(r)}:null}function Ut(e,t){if(en(e.name)||e.schemaType===`array`)return b(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return b(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?b(`Scalar body option selected`,t[0]):w(`${n} was already given; pass it once.`)}var Wt=/^(?<row>\d+):(?<item>.*)$/su;function Gt(e,t){let n=Vt(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=Wt.exec(e)?.groups,n=t?.row,a=t?.item;if(n===void 0||a===void 0){i.push(e);continue}let o=r.get(Number(n));o===void 0?r.set(Number(n),[a]):o.push(a)}return r.size===0?null:{container:n,rows:r,plain:i}}function Kt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Vt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function qt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Ht(r,i.name);if(a===null)continue;if(a.firstHole!==null)return w(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Gt(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return w(`${o} fills one ${a.path}[] row's list, so ${e} cannot also build ${a.rowCount} ${a.path}[] rows from direct options — prefix each value with its 0-based ${a.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function Jt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Yt(e,t){let n=e;for(let e of t){if(!L(n))return;n=n[e]??null}return n}function Xt(e,t){if(!en(t))return Yt(e,t.split(`.`))}function Zt(e,t){return $t(e,t.split(`.`))}function Qt(e,t,n){if(!L(n))return null;let r=new Set(t.parameter.map(({name:e})=>e));for(let i of e)if(i!==t){for(let e of i.parameter)if(!r.has(e.name)&&Zt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function $t(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=an(n);if(!L(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>$t(e,r)):$t(a,r)}function en(e){return e.split(`.`).some(e=>an(e).isArray)}function tn(e,t){return e.parameter.length===0||!L(t)?null:sn(t,[],on(e.parameter))}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nn(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=an(o),c=e===i.length-1,l=rn(a,s,t,c,n,r);if(!l.ok||l.data===null)return w(l.summary,l.warnings);if(c)return b(`Body value assigned`,null);a=l.data}return w(`${t} is not a valid body option path.`)}function rn(e,t,n,r,i,a){let o=()=>w(`${n} cannot be combined with another body option at ${t.key}.`),s=e[t.key];if(t.isArray){if(s!==void 0&&!Array.isArray(s))return o();let n=s??[];if(s===void 0&&(e[t.key]=n),r)return n[a]===void 0?(n[a]=i,b(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,b(`Body path created`,e)}return L(c)?b(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,b(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,b(`Body path created`,n)}return L(s)?b(`Body path stepped`,s):o()}function an(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function on(e){let t=new Set,n=new Set,r=new Map;for(let i of e){let e=`${i.name}${i.schemaType===`array`?`[]`:``}`;t.add(e),r.set(e,i.flag.split(` `)[0]??i.name);let a=e.split(`.`);for(let e=1;e<a.length;e+=1)n.add(a.slice(0,e).join(`.`))}return{leaf:t,prefix:n,flagByLeaf:r}}function sn(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=sn(r,t,n);if(e!==null)return e}return null}if(!L(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!cn(a,n)){if(!ln(e))continue;return{path:a,suggestion:un(e,n)}}let o=sn(i,e,n);if(o!==null)return o}return null}function cn(e,t){return t.prefix.has(e)||t.leaf.has(e)}function ln(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function un(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``,[i]=[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:dn(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path));if(i!==void 0)return{path:i.path,flag:t.flagByLeaf.get(i.path)??i.path}}function dn(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();return n===e?0:n.endsWith(e)||e.endsWith(n)?1:n.includes(e)||e.includes(n)?2:1/0}function fn(e,t){let n=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&n.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:n.get(t.long);e!==void 0&&t.helpGroup(We(e))}e.sort((e,t)=>{let r=e.long===void 0?void 0:n.get(e.long),i=t.long===void 0?void 0:n.get(t.long);return r!==void 0&&i!==void 0?bn(r,i):r===void 0?i===void 0?0:1:-1})}function pn(e){let t=new Map;for(let n of e)for(let e of n.parameter){let r=e.flag.split(` `)[0]??e.flag,i=t.get(r);i===void 0?t.set(r,{variant:[{descriptor:n,parameter:e}]}):t.set(r,{variant:[...i.variant,{descriptor:n,parameter:e}]})}return[...t.values()]}function mn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function hn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:vn(e,t)})),n=t[0];return n===void 0?``:t.every(({text:e})=>e===n.text)?`${n.text===``?``:`${n.text} `}Request content: ${t.map(({contentType:e})=>e).join(`, `)}.`:t.map(({contentType:e,text:t})=>`${e}: ${t}`).join(` `)}function gn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function _n(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?He(n):`${He(n)} Required JSON paths: ${r.join(`, `)}.`}function vn(e,t){return`${Le(t.description,void 0)}${e.kind!==`multipart`&&en(t.name)?` Repeat to add another value.`:``}${yn(e,t)}`}function yn(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Vt(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function bn(e,t){return Re(e)-Re(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function xn(e){let t;try{t=e===`-`?await Sn():await pt(e,`utf8`)}catch(t){return w(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return b(`No input provided`,null);let e=JSON.parse(t);return b(`Input parsed`,e)}catch(e){return w(`Input is not valid JSON: ${e.message}`)}}async function Sn(){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 Cn=`--content-type`;function wn(e,t){let n=t.requestBody??[];if(n.length>1){let t=n.map(({contentType:e})=>e);e.addOption(new u(`${Cn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(En(n)))}if(Kn(t)){let r=n[0];if(r===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new u(`--from-file <path>`,_n(r,r.requiredPath)).argParser(On(`--from-file`)))}let r=pn(n);for(let t of r.toSorted((e,t)=>bn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=t.variant[0],a=new u(mn(t),n.length>1?hn(t):vn(r,i));n.length===1&&i.envName!==void 0&&a.env(i.envName);let o=n.length===1?gn(r,i.optionKey):[];o.length>0&&a.conflicts(o),n.length>1?a.argParser(Tn):en(i.name)||i.schemaType===`array`?a.argParser(Dn):a.argParser(On(i.flag)),e.addOption(a)}Gn(e,t,r)}function Tn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function En(e){return(t,n)=>{if(n!==void 0)throw new h(`${Cn} was already given; pass it once.`);let r=_e(e,t);if(!r.ok)throw new h(r.summary);return t}}function Dn(e,t){return[...t??[],e]}function On(e){let t=e.split(/\s+/u)[0]??e;return(e,n)=>{if(n!==void 0)throw new h(`${t} was already given; pass it once.`);return e}}async function kn(e,t){let n=typeof t.contentType==`string`?t.contentType:void 0,r=_e(e.requestBody??[],n);if(!r.ok||r.data===null)return w(r.summary,r.warnings);let i=r.data;if(i===void 0)return b(`No body`,void 0);let a=An(e,i,t);if(a!==null)return w(a);let o=It(e.operationId,i,t);if(!o.ok)return w(o.summary,o.warnings);t=o.data;let s=jn(i,t);if(s!==null)return w(s);let c=await Fn(t);if(!c.ok)return w(c.summary,c.warnings);let l=Qt(e.requestBody??[],i,c.data);if(l!==null)return w(l);let u=Pn(e.operationId,i,c.data);if(!u.ok)return u;let d=Lt(e.operationId,i,c.data);if(d!==null)return w(d);let f=In(e.operationId,i,t);if(!f.ok)return f;if(c.data===void 0&&f.data===void 0)return i.required?w(Wn(e.operationId,i)):b(`No body`,void 0);let p=zn(e.operationId,c.data,f.data);if(!p.ok||p.data===void 0)return p;if(i.schemaType===`array`&&!Array.isArray(p.data))return w(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!L(p.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return w(`${e.operationId} requires a JSON object${t}.`)}let m=Nn(i,p.data);if(m.length>0)return w(`${e.operationId} requires body option(s): ${m.join(`, `)}`);let h=p.data,ee=L(h)?Rt(i).filter(e=>!Zt(h,e)):[];return ee.length>0?w(Mn(e.operationId,i,ee)):p}function An(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`${Rn(t)} requires ${Cn} ${i.join(` or `)}.`}return null}function jn(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 Mn(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 Nn(e,t){return L(t)?e.parameter.filter(e=>e.required&&!Zt(t,e.name)).map(Rn):[]}function Pn(e,t,n){let r=tn(t,n);if(r===null)return b(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion.path} (${r.suggestion.flag}).`;return w(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function Fn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return b(`No body file`,void 0);let n=await xn(t);if(!n.ok)return w(n.summary,n.warnings);let r=l.safeParse(n.data);return r.success?b(`Input parsed`,r.data):w(`Input is not valid JSON value: ${r.error.message}`)}function In(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Ut(e,n[e.optionKey]);if(!a.ok||a.data===null)return w(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Ln(t,n,r,e,o);if(!s.ok)return w(s.summary,s.warnings);i=!0}if(!i)return b(`No direct body options`,void 0);let a=qt(e,t,n,r);return a===null?b(`Direct body options parsed`,r):a}function Ln(e,t,n,r,i){let a=Gt(r,i);if(a===null){let e=Hn(r,i);return e.ok?zt(n,r.name,e.data,r.schemaType===`array`):w(e.summary,e.warnings)}if(a.plain.length>0)return w(`${Rn(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=Kt(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return w(`${Rn(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=Un(r.name,r.itemSchemaType,e);if(!t.ok)return w(t.summary,t.warnings);i.push(t.data)}let a=Bt(n,r.name,e,i);if(!a.ok)return a}return b(`Body value assigned`,null)}function Rn(e){return e.flag.split(` `)[0]??e.name}function zn(e,t,n){if(t===void 0)return b(`Direct body parsed`,n);if(n===void 0)return b(`Input parsed`,t);if(L(t)&&L(n))try{return b(`Input parsed`,Bn(t,n))}catch(t){return w(`${e} ${t.message}`)}return w(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Bn(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];if(Array.isArray(t)&&Array.isArray(r))throw Error(`cannot combine --from-file array '${e}' with array body options at the same key — move the per-item fields inside the matching '${e}[]' object(s) in the file body.`);if(t!==void 0&&Vn(t)!==Vn(r))throw Error(`cannot combine --from-file ${Vn(t)} '${e}' with ${Vn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=L(t)&&L(r)?Bn(t,r):r}return n}function Vn(e){return Array.isArray(e)?`array`:L(e)?`object`:`scalar`}function Hn(e,t){if(typeof t==`boolean`)return b(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Un(e.name,e.schemaType,t??``);let n=[],r=en(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Un(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return b(`Body value parsed`,n)}function Un(e,t,n){if(t===`boolean`)return n===`true`?b(`Body value parsed`,!0):n===`false`?b(`Body value parsed`,!1):w(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?w(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?w(`${e} must be an integer.`):b(`Body value parsed`,i)}return b(`Body value parsed`,n)}function Wn(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(Rn).join(`, `)}`;let r=Rt(t);if(r.length>0)return`${e} requires --from-file with JSON body path(s): ${r.join(`, `)}`;let i=t.parameter.map(Rn).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function Gn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:Cn,location:`body`}),Kn(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),fn(e.options,r)}function Kn(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function qn(e){let t=fe(e);return er(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Jn(e){er(e);let t=et(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
2
2
|
`)?t:`${t}\n`),Yn(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&Zn(e.problem),Yn(e)}function Yn(e){e.ids.length>0&&process.stdout.write(` ids: ${e.ids.join(`, `)}\n`);for(let[t,n]of Object.entries(e.counts))process.stdout.write(` ${t}: ${n}\n`);for(let t of e.references)process.stdout.write(` ref: ${t}\n`);if(e.truncation!==void 0){let t=e.truncation.omitted.join(`, `);process.stdout.write(` truncated: byteLength=${e.truncation.byteLength} maxBytes=${e.truncation.maxBytes} omitted=${t}\n`),process.stdout.write(` recovery: ${e.truncation.recovery}\n`)}for(let t of e.warnings)process.stdout.write(` warn: ${t}\n`)}function R(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?fe(t):t;er(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?Xn(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?qn(t):t;e.mode===`text`&&Jn(n),n.ok||(process.exitCode=1)}function Xn(e){return typeof e!=`object`||!e||Array.isArray(e)||!Reflect.has(e,`method`)||!Reflect.has(e,`endpoint`)||!(`response`in e)||e.response===void 0?e:e.response}function Zn(e){typeof e.code==`string`&&process.stdout.write(` code: ${e.code}\n`),typeof e.detail==`string`&&process.stdout.write(` detail: ${e.detail}\n`),typeof e.hint==`string`&&process.stdout.write(` hint: ${e.hint}\n`),typeof e.suggestion==`string`&&process.stdout.write(` suggestion: ${e.suggestion}\n`);let t=Object.entries(e.suggestions??{});if(t.length>0){let e=t.map(([e,t])=>`${e}=${t}`).join(`; `);process.stdout.write(` suggestions: ${e}\n`)}Qn(`unknownParameters`,e.unknownParameters),Qn(`validParameters`,e.validParameters),$n(e.resolution)}function Qn(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function $n(e){if(e==null)return;let t=[`action=${e.action}`];typeof e.parameter==`string`&&t.push(`parameter=${e.parameter}`),typeof e.fieldPath==`string`&&t.push(`fieldPath=${e.fieldPath}`),typeof e.endpoint==`string`&&t.push(`endpoint=${e.endpoint}`),e.acceptedValue!==null&&e.acceptedValue!==void 0&&e.acceptedValue.length>0&&t.push(`acceptedValue=${e.acceptedValue.join(`, `)}`),typeof e.retryable==`boolean`&&t.push(`retryable=${e.retryable}`),process.stdout.write(` resolution: ${t.join(` `)}\n`)}function er(e){e.ok&&e.warnings.length===0||ve({component:`aventure-cli`,event:e.ok?`command_warning`:`command_failed`,message:e.warnings.length>0?e.warnings.join(` | `):e.summary,fields:{warningCount:e.warnings.length,summary:e.summary}})}function tr(e,t,n=C().bin[0]){let r=t.length,i=nt(e.q?.trim()??``),a=Xe(i),o=$e(i),s=ir(t,n).filter(t=>cr(t,e)).map(e=>({operation:e,score:ur(i,a,o,e)})).filter(({score:e})=>i===``||e>0).toSorted((e,t)=>t.score-e.score||e.operation.cli.command.localeCompare(t.operation.cli.command)||e.operation.operationId.localeCompare(t.operation.operationId)).map(({operation:e})=>e),c=hr(e.limit,s.length),l=s.slice(0,c);return b(`Operation catalog matches`,{operation:l,count:{totalOperations:r,matched:s.length,returned:l.length}})}function nr(e,t,n=C().bin[0]){let r=ir(t,n),i=e.operationId===void 0?rr(r,e.command):r.find(t=>t.operationId===e.operationId);return i===void 0?w(`Generated operation not found`,[`List candidates with \`${n} command-catalog search "<text>"\`.`]):b(`Generated operation detail`,{operation:i,usage:gr(i)})}function rr(e,t){if(t===void 0)return;let n=Tr(t);return e.find(e=>Tr(e.cli.command)===n||e.cli.alias!==null&&Tr(e.cli.alias)===n)}function ir(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>ar(e)),...n.flatMap(e=>e.parameter.map(t=>ar(t,n.length>1?e.contentType:void 0))),...or(n)],i=`${t} ${e.cliPath.join(` `)}`,a=e.cliAliasPath===void 0?null:`${t} ${e.cliAliasPath.join(` `)}`,o=ne(e.intent),s=e.method===`DELETE`||e.intent===`delete`,l=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:o,destructive:s,auth:e.auth,cli:{command:i,path:e.cliPath,alias:a,aliasPath:e.cliAliasPath??null},mcpTool:e.binaryResponse?null:c(e.intent),body:{hasBody:l!==void 0,kind:l?.kind??null,...l!==void 0&&n.length>1?{contentType:l.contentType}:{},required:l?.required??!1,description:l?.description??``,requiredPath:l?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,summary:e.summary,description:e.description}})}function ar(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 or(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 content type; omit for ${t[0]}.`,choices:t}]}function sr(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function cr(e,t){return!(t.root!==void 0&&!lr(e,t.root)||t.scope!==void 0&&t.scope!==`all`&&t.scope!==e.scope||t.mutates!==void 0&&t.mutates!==`any`&&t.mutates===`true`!==e.mutates||t.destructive!==void 0&&t.destructive!==`any`&&t.destructive===`true`!==e.destructive||t.intent!==void 0&&t.intent!==`all`&&t.intent!==e.intent||t.method!==void 0&&t.method!==`all`&&t.method!==e.method)}function lr(e,t){let n=nt(t);return n.length===0||nt(e.cli.path.at(0)??``)===n||nt(e.cli.aliasPath?.at(0)??``)===n}function ur(e,t,n,r){if(e.length===0)return 1;let i=fr(r),a=dr(e,t,i,{exactQuery:120,partialQuery:60,exactToken:18,partialToken:6})+dr(e,t,pr(r),{exactQuery:12,partialQuery:6,exactToken:2,partialToken:1});Qe(n,i)&&(a+=200);for(let e of r.cli.path){let n=new Set;tt(n,e),[...n].some(e=>t.has(e))&&(a+=15)}return nt(r.cli.command).endsWith(e)&&(a+=40),a}function dr(e,t,n,r){let i=0;n.includes(e)&&(i+=r.exactQuery),n.some(t=>t.includes(e))&&(i+=r.partialQuery);for(let e of t)n.includes(e)?i+=r.exactToken:n.some(t=>t.includes(e))&&(i+=r.partialToken);return i}function fr(e){return mr([e.operationId,e.cli.command,e.cli.alias??``,e.summary])}function pr(e){return mr([e.method,e.path,e.resource,e.intent,e.scope,e.mutates?`mutates mutation write`:`read only no mutation`,e.destructive?`destructive delete`:`non destructive`,e.mcpTool??``,e.body.kind??``,e.body.description,e.body.requiredPath.join(` `),e.description,...e.flags.flatMap(e=>[e.name,e.optionKey,e.wireName,e.description,e.choices.join(` `)])])}function mr(e){return e.map(nt).filter(e=>e.length>0)}function hr(e,t){if(e===void 0)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.trunc(n)):t}function gr(e){let t=sr(e),n=t.filter(e=>e.required),r=t.filter(e=>!e.required);return[`cli: ${e.cli.command}`,e.cli.alias===null?``:`alias: ${e.cli.alias}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (binary CLI operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,z(`required path flags`,n,`path`),z(`required query flags`,n,`query`),z(`required header flags`,n,`header`),z(`required body flags`,n,`body`),z(`optional path flags`,r,`path`),z(`optional query flags`,r,`query`),z(`optional header flags`,r,`header`),z(`optional body flags`,r,`body`),...xr(e),..._r(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
3
3
|
`)}function _r(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var vr=[`-id`,`-slug`,`-url`],yr=[`--id`,`--slug`,`--url`],br=`--from-file "<path>"`;function xr(e){return[`example: ${[e.cli.command,...Sr(e),`--data`].join(` `)}`]}function Sr(e){let t=sr(e).filter(e=>e.required),n=(t.length>0?t:Cr(e)).map(wr);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,br]:n}function Cr(e){let t=new Set;tt(t,e.resource);for(let n of vr)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of yr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function wr(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function z(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function Tr(e){return e.trim().replace(/^aventure(?:-cli)?\s+/u,``).replaceAll(/\s+/gu,` `)}function Er(e,t,n=C().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show command help, or ask the platform a grounded question`).description([`Show local --help output for a command path (deterministic, offline),`,`or answer a natural-language platform question with --ask via the grounded`,"help operation (the same generated operation as `help ask`)."].join(`
|
|
4
4
|
`)).argument(`[command...]`,"command path to show help for, e.g. `help search entities`"),r.addOption(new Dr(r));let i=kr(t);i!==void 0&&r.option(`--ask <question>`,i.summary),D(r),r.action(async function(t){let r=this.optsWithGlobals();if(r.help&&t.length===0){this.outputHelp();return}if(!r.help&&i!==void 0&&r.ask!==void 0){let e=E(r);if(t.length>0){R({mode:e},w(`Use either a command path or --ask, not both.`));return}R({mode:e},await jr(i,r.ask,r.environment,e));return}let a=Ar(e,t);a===void 0&&this.error(`unknown command '${t.join(` `)}' (run \`${n} --help\` for the command tree)`),a.outputHelp()}),Or(e,t)}var Dr=class extends u{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))}};function Or(e,t){let n=new Set;for(let r of t){let t=_r(r.errorResponse);if(t.length!==0)for(let i of[r.cliPath,r.cliAliasPath]){let r=i===void 0?void 0:Ar(e,i);r===void 0||n.has(r)||(n.add(r),r.addHelpText(`after`,`\n${t.join(`
|
|
@@ -7,7 +7,7 @@ import{C as e,D as t,_ as n,a as r,k as i,v as a,x as o}from"./person-owner-ChqQ
|
|
|
7
7
|
`),null}async function Ti(e){let t=new Date(e.expiresAt).getTime(),n=ki(e.intervalSeconds);for(;;)try{return await ai(e.id,e.pollSecret)}catch(e){if(e instanceof ti){if(!e.retryable)throw e;n=ki(e.retryAfterSeconds??n)}else if(!(e instanceof ni))throw e;if(Date.now()>=t)throw e;N.write(`Broker acknowledgment was interrupted; retrying.
|
|
8
8
|
`),await Ai(n,t)}}async function Ei(e){let t=new Date(e.expiresAt).getTime(),n=ki(e.intervalSeconds),r;for(N.write(`Waiting for browser approval...
|
|
9
9
|
`);Date.now()<t;){let i;try{i=await ii(e.id,e.pollSecret)}catch(e){if(e instanceof ti){if(!e.retryable)throw e;n=ki(e.retryAfterSeconds??n)}r=e,N.write(`Authorization poll was interrupted; retrying.
|
|
10
|
-
`),await Ai(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=ki(i.retryAfterSeconds??n),await Ai(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:throw Error(ce(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${T(r,[e.pollSecret])}`)}function Di(e,t,n){let r=e.state===`opened`;return!r&&!N.isTTY?!1:(N.write([
|
|
10
|
+
`),await Ai(n,t);continue}r=void 0;let a=i.authorization;switch(a.status){case`PENDING`:case`ISSUING`:case`REVOKING`:n=ki(i.retryAfterSeconds??n),await Ai(n,t);break;case`KEY_READY`:if(a.delivery===null||a.delivery===void 0)throw Error(`broker returned KEY_READY without an encrypted delivery`);return a.delivery;case`DENIED`:case`EXPIRED`:case`FAILED`:throw Error(ce(a.terminalReason?.trim()??``,[e.pollSecret])||`broker entered terminal state ${a.status}`);case`CONSUMED`:throw Error(`broker credential was already consumed; restart login`)}}throw Error(r===void 0?`browser authorization expired before approval completed`:`browser authorization expired after a retryable broker failure: ${T(r,[e.pollSecret])}`)}function Di(e,t,n){let r=e.state===`opened`;return!r&&!N.isTTY?!1:(N.write([r?`Browser approval opened for this request.`:`Browser not opened automatically (${e.reason}).`,...N.isTTY?[`Open this one-time approval URL in your browser:`,t.verificationUrl]:[`Approval reference: ${n}`],`Comparison code: ${t.comparisonCode}`,`Confirm that the browser shows the same code before approving.`,``].join(`
|
|
11
11
|
`)),!0)}function Oi(){switch(gt()){case`darwin`:return`MACOS`;case`linux`:return`LINUX`;case`win32`:return`WINDOWS`;default:return`OTHER`}}function ki(e){return Math.min(bi,Math.max(yi,e))}async function Ai(e,t){let n=t-Date.now();n>0&&await Pt(Math.min(e*1e3,n))}function ji(e,t){return{host:e.host,provider:e.provider,personalApiKeyId:e.credential.apiKey.id,name:ce(e.credential.apiKey.name,[e.credential.secret]),activation:e.activation,verified:t}}function H(e,t,n,r){return{...w(n,r===void 0?[]:[r]),data:ji(e,t)}}function Mi(e,t){return e.expiresAt===null||e.expiresAt===void 0||t.expiresAt===null||t.expiresAt===void 0?!1:new Date(e.expiresAt)>new Date(t.expiresAt)}function Ni(e,t){let n=t.state===`found`?t.stored:void 0,r=n?.credential.apiKey.expiresAt??null;return{host:e,present:n!==void 0,provider:n?.provider??null,activation:n?.activation??null,apiKeyId:n?.credential.apiKey.id??null,subject:n?.credential.apiKey.subject??null,scope:n?.credential.apiKey.scopes??[],name:n===void 0?null:ce(n.credential.apiKey.name,[n.credential.secret]),status:n?.credential.apiKey.status??null,expiresAt:r,metadataSource:n===void 0?null:`store-cache`,expiresInDay:Fi(r),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}var Pi=864e5;function Fi(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/Pi)}var Ii=7;function Li(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,Ii)}\u2026${e.slice(-4)}`}var Ri=13,zi=14;function Bi(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.personal.host}`+(e.apiVersion===null?` (api unreachable)`:` (api ${e.apiVersion})`),``,...Vi(e.oauth,e.cliName),...Hi(e.personal,e.oauth,e.cliName),``,U(`Providers`,Gi(e.providers)),...Ki(e.resolved,e.config),...e.systemOk?[]:[U(`System`,`uptime read failed`)]].join(`
|
|
12
12
|
`)}function U(e,t){return` ${e.padEnd(Ri)}${t}`}function W(e){return` ${``.padEnd(Ri)}${e}`}function Vi(e,t){switch(e.state){case`found`:return[U(`OAuth`,`stored via ${e.stored.provider}; identity is not cached`),W(Te(e.stored.credential)?e.stored.credential.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:`access token expired — the next command renews it with the refresh token`:`cached expiry ${e.stored.credential.expiresAt}`)];case`missing`:return[U(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[W(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[U(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[U(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function Hi(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[U(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[W(`stored credential invalid: ${e.error}`)]]:[U(`Signed in`,`credential storage unavailable`),W(r)]}return[U(t.state===`found`?`Personal key`:`Signed in`,e.subject??`unknown subject`),W(`via ${e.provider??`unknown store`}`),U(`Key`,`${e.name??`unnamed`} ${Li(e.apiKeyId)}`),...Ui(e,n),U(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function Ui(e,t){let n=`${e.status??`unknown`} when stored`,r=e.expiresInDay,i=e.expiresAt===null?null:e.expiresAt.slice(0,10);return[U(`Key state`,n),...i===null||r===null?[W(`no expiry recorded`)]:[W(Wi(i,r))],W(`Clerk owns the live verdict \u2014 \`${t} auth login --key\` refreshes this cache`)]}function Wi(e,t){return t<0?`cached expiry ${e} passed ${Math.abs(t)}d ago`:t<=zi?`cached expiry ${e}, ${t}d away`:`cached expiry ${e}`}function Gi(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`clerk browser sign-in`:`no browser sign-in`,t?`oauth ${xe(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function Ki(e,t){return[U(`Secrets`,v.map(t=>Ji(t,e)).join(` `)),U(`Config`,t===null?`none`:`doppler ${t.project}/${t.config}`)]}function qi(e){return v.map(t=>Ji(t,e)).join(` `)}function Ji(e,t){let n=t[e];return n.present?`${e}=${n.source??`resolved`}`:`${e}=${n.source===`config`?`config (unresolved)`:`unset`}`}var Yi=r([`PROMPT`,`SKILL`,`AGENT`]),Xi=a({kind:Yi,name:e(),version:e()}),Zi=a({content:e(),core:Xi}),Qi=a({key:e(),version:e()}),$i=a({agent:o(e(),Qi),prompt:o(e(),Qi),skill:o(e(),Qi)}),G=`aventure`,ea=`SKILL.md`,ta=`.aventure-skills.json`,na=`claude`,ra=2e4,ia=2,aa=[{name:`claude-code`,base:`home`,detect:[`.claude`],skill:[`.claude`,`skills`],mcp:{shape:`claude-cli`,file:[`.claude.json`],key:`mcpServers`}},{name:`codex`,base:`home`,detect:[`.codex`],skill:[`.agents`,`skills`],mcp:{shape:`toml`,file:[`.codex`,`config.toml`]}},{name:`cursor`,base:`home`,detect:[`.cursor`],skill:null,mcp:{shape:`json`,file:[`.cursor`,`mcp.json`],key:`mcpServers`,entry:e=>({type:`http`,url:e})}},{name:`opencode`,base:`config`,detect:[`opencode`],skill:[`opencode`,`skills`],mcp:{shape:`json`,file:[`opencode`,`opencode.json`],key:`mcp`,entry:e=>({type:`remote`,url:e,enabled:!0})}}];function oa(e){return P(sa(e))}function sa(e){return A(ua(e),...e.detect)}function ca(e){return e.skill===null?null:A(ua(e),...e.skill)}function la(e){return A(ua(e),...e.mcp.file)}function ua(e){return e.base===`home`?fa(`HOME`)??mt():da()}function da(){return fa(`XDG_CONFIG_HOME`)??A(fa(`HOME`)??mt(),`.config`)}function fa(e){let t=process.env[e]?.trim();return t===void 0||t.length===0?void 0:t}function pa(e){return A(k(e),ta)}function ma(e){if(!P(e))return{};try{let t=$i.safeParse(JSON.parse(F(e,`utf8`)));return t.success?t.data.skill:{}}catch{return{}}}function ha(e,t,n){let r=pa(e),i={...ma(r)};for(let e of n){let n=t.skill[e];n!==void 0&&(i[e]=n)}return _a(r,`${JSON.stringify({prompt:{},skill:i,agent:{}},null,ia)}\n`)}function ga(e,t,n){let r=A(e,t,ea);return k(k(r))===e?_a(r,n):`refusing to install ${t}: it does not name one directory inside ${e}`}function _a(e,t){try{va(e,t)}catch(t){return`cannot write ${e}: ${T(t)}`}return null}function va(e,t){Ct(k(e),{recursive:!0});let n=`${e}.aventure-tmp`;try{I(n,t,`utf8`),Dt(n,e)}finally{Ot(n,{force:!0})}}var ya=RegExp(`^[ \\t]*\\[[ \\t]*mcp_servers[ \\t]*\\.[ \\t]*"?${G}"?[ \\t]*\\]`),ba=/^[ \t]*mcp_servers[ \t]*=/m;function xa(e){let t=la(e);if(!P(t))return null;try{let n=F(t,`utf8`);if(e.mcp.shape===`toml`)return Ca(n);let r=Oa(n)?.[e.mcp.key],i=(r!==void 0&&ka(r)?r:void 0)?.[G];return i===void 0||!ka(i)?null:typeof i.url==`string`?i.url:Sa}catch{return null}}var Sa=`unknown`;function Ca(e){let t=e.split(`
|
|
13
13
|
`),n=t.findIndex(e=>ya.test(e));if(n<0)return null;for(let e of t.slice(n+1)){if(e.trimStart().startsWith(`[`))break;let t=/^[ \t]*url[ \t]*=[ \t]*"([^"]*)"/.exec(e);if(t?.[1]!==void 0)return t[1]}return Sa}function wa(e,t){let n=e.mcp,r=la(e);if(n.shape===`claude-cli`)return Da(t);try{if(n.shape===`toml`)return Ta(r,t);Ea(r,n.key,n.entry(t))}catch(e){return`cannot write ${r}: ${T(e)}`}return null}function Ta(e,t){let n=P(e)?F(e,`utf8`):``,r=`[mcp_servers.${G}]\nurl = "${t}"\n`;return ba.test(n)?`${e} declares mcp_servers as an inline table, which this command cannot extend; add by hand:\n${r}`:_a(e,`${n}${n.length===0||n.endsWith(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,T as t,_ as n,a as r,b as ee,c as i,d as te,g as a,h as o,k as ne,l as s,o as re,p as ie,u as ae,v as c,w as l,x as u,y as d}from"./person-owner-ChqQWHII.js";import{a as oe}from"./auth-DVA6KxqF.js";var se=c({clerkPublishableKey:e().nullish(),oauthClient:oe.nullish()}),ce=`2025-11-25`,le=`2025-03-26`,ue=[ce,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],de=`io.modelcontextprotocol/related-task`,f=ae(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),fe=l([e(),n().int()]),pe=e();a({ttl:n().optional(),pollInterval:n().optional()});var me=c({ttl:n().optional()}),he=c({taskId:e()}),p=a({progressToken:fe.optional(),[de]:he.optional()}),m=c({_meta:p.optional()}),h=m.extend({task:me.optional()}),ge=e=>h.safeParse(e).success,g=c({method:e(),params:m.loose().optional()}),_=c({_meta:p.optional()}),v=c({method:e(),params:_.loose().optional()}),y=a({_meta:p.optional()}),b=l([e(),n().int()]),_e=c({jsonrpc:o(`2.0`),id:b,...g.shape}).strict(),ve=e=>_e.safeParse(e).success,ye=c({jsonrpc:o(`2.0`),...v.shape}).strict(),be=e=>ye.safeParse(e).success,x=c({jsonrpc:o(`2.0`),id:b,result:y}).strict(),xe=e=>x.safeParse(e).success,S;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(S||={});var Se=c({jsonrpc:o(`2.0`),id:b.optional(),error:c({code:n().int(),message:e(),data:t().optional()})}).strict(),Ce=e=>Se.safeParse(e).success,we=l([_e,ye,x,Se]);l([x,Se]);var C=y.strict(),Te=_.extend({requestId:b.optional(),reason:e().optional()}),w=v.extend({method:o(`notifications/cancelled`),params:Te}),Ee=c({src:e(),mimeType:e().optional(),sizes:i(e()).optional(),theme:r([`light`,`dark`]).optional()}),T=c({icons:i(Ee).optional()}),E=c({name:e(),title:e().optional()}),De=E.extend({...E.shape,...T.shape,version:e(),websiteUrl:e().optional(),description:e().optional()}),Oe=ie(c({applyDefaults:s().optional()}),u(e(),t())),ke=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ie(c({form:Oe.optional(),url:f.optional()}),u(e(),t()).optional())),Ae=a({list:f.optional(),cancel:f.optional(),requests:a({sampling:a({createMessage:f.optional()}).optional(),elicitation:a({create:f.optional()}).optional()}).optional()}),je=a({list:f.optional(),cancel:f.optional(),requests:a({tools:a({call:f.optional()}).optional()}).optional()}),Me=c({experimental:u(e(),f).optional(),sampling:c({context:f.optional(),tools:f.optional()}).optional(),elicitation:ke.optional(),roots:c({listChanged:s().optional()}).optional(),tasks:Ae.optional(),extensions:u(e(),f).optional()}),Ne=m.extend({protocolVersion:e(),capabilities:Me,clientInfo:De}),D=g.extend({method:o(`initialize`),params:Ne}),Pe=e=>D.safeParse(e).success,Fe=c({experimental:u(e(),f).optional(),logging:f.optional(),completions:f.optional(),prompts:c({listChanged:s().optional()}).optional(),resources:c({subscribe:s().optional(),listChanged:s().optional()}).optional(),tools:c({listChanged:s().optional()}).optional(),tasks:je.optional(),extensions:u(e(),f).optional()}),Ie=y.extend({protocolVersion:e(),capabilities:Fe,serverInfo:De,instructions:e().optional()}),Le=v.extend({method:o(`notifications/initialized`),params:_.optional()}),O=g.extend({method:o(`ping`),params:m.optional()}),Re=c({progress:n(),total:d(n()),message:d(e())}),ze=c({..._.shape,...Re.shape,progressToken:fe}),Be=v.extend({method:o(`notifications/progress`),params:ze}),Ve=m.extend({cursor:pe.optional()}),k=g.extend({params:Ve.optional()}),A=y.extend({nextCursor:pe.optional()}),He=r([`working`,`input_required`,`completed`,`failed`,`cancelled`]),j=c({taskId:e(),status:He,ttl:l([n(),re()]),createdAt:e(),lastUpdatedAt:e(),pollInterval:d(n()),statusMessage:d(e())}),M=y.extend({task:j}),Ue=_.merge(j),N=v.extend({method:o(`notifications/tasks/status`),params:Ue}),P=g.extend({method:o(`tasks/get`),params:m.extend({taskId:e()})}),F=y.merge(j),I=g.extend({method:o(`tasks/result`),params:m.extend({taskId:e()})});y.loose();var L=k.extend({method:o(`tasks/list`)}),R=A.extend({tasks:i(j)}),z=g.extend({method:o(`tasks/cancel`),params:m.extend({taskId:e()})}),We=y.merge(j),Ge=c({uri:e(),mimeType:d(e()),_meta:u(e(),t()).optional()}),Ke=Ge.extend({text:e()}),B=e().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),qe=Ge.extend({blob:B}),V=r([`user`,`assistant`]),H=c({audience:i(V).optional(),priority:n().min(0).max(1).optional(),lastModified:ne({offset:!0}).optional()}),Je=c({...E.shape,...T.shape,uri:e(),description:d(e()),mimeType:d(e()),size:d(n()),annotations:H.optional(),_meta:d(a({}))}),Ye=c({...E.shape,...T.shape,uriTemplate:e(),description:d(e()),mimeType:d(e()),annotations:H.optional(),_meta:d(a({}))}),Xe=k.extend({method:o(`resources/list`)}),Ze=A.extend({resources:i(Je)}),Qe=k.extend({method:o(`resources/templates/list`)}),$e=A.extend({resourceTemplates:i(Ye)}),U=m.extend({uri:e()}),et=U,tt=g.extend({method:o(`resources/read`),params:et}),nt=y.extend({contents:i(l([Ke,qe]))}),rt=v.extend({method:o(`notifications/resources/list_changed`),params:_.optional()}),it=U,at=g.extend({method:o(`resources/subscribe`),params:it}),ot=U,st=g.extend({method:o(`resources/unsubscribe`),params:ot}),ct=_.extend({uri:e()}),lt=v.extend({method:o(`notifications/resources/updated`),params:ct}),ut=c({name:e(),description:d(e()),required:d(s())}),dt=c({...E.shape,...T.shape,description:d(e()),arguments:d(i(ut)),_meta:d(a({}))}),ft=k.extend({method:o(`prompts/list`)}),pt=A.extend({prompts:i(dt)}),mt=m.extend({name:e(),arguments:u(e(),e()).optional()}),ht=g.extend({method:o(`prompts/get`),params:mt}),W=c({type:o(`text`),text:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),G=c({type:o(`image`),data:B,mimeType:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),gt=c({type:o(`audio`),data:B,mimeType:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),_t=c({type:o(`tool_use`),name:e(),id:e(),input:u(e(),t()),_meta:u(e(),t()).optional()}),vt=c({type:o(`resource`),resource:l([Ke,qe]),annotations:H.optional(),_meta:u(e(),t()).optional()}),yt=Je.extend({type:o(`resource_link`)}),K=l([W,G,gt,yt,vt]),bt=c({role:V,content:K}),xt=y.extend({description:e().optional(),messages:i(bt)}),St=v.extend({method:o(`notifications/prompts/list_changed`),params:_.optional()}),Ct=c({title:e().optional(),readOnlyHint:s().optional(),destructiveHint:s().optional(),idempotentHint:s().optional(),openWorldHint:s().optional()}),wt=c({taskSupport:r([`required`,`optional`,`forbidden`]).optional()}),Tt=c({...E.shape,...T.shape,description:e().optional(),inputSchema:c({type:o(`object`),properties:u(e(),f).optional(),required:i(e()).optional()}).catchall(t()),outputSchema:c({type:o(`object`),properties:u(e(),f).optional(),required:i(e()).optional()}).catchall(t()).optional(),annotations:Ct.optional(),execution:wt.optional(),_meta:u(e(),t()).optional()}),Et=k.extend({method:o(`tools/list`)}),Dt=A.extend({tools:i(Tt)}),q=y.extend({content:i(K).default([]),structuredContent:u(e(),t()).optional(),isError:s().optional()});q.or(y.extend({toolResult:t()}));var Ot=h.extend({name:e(),arguments:u(e(),t()).optional()}),kt=g.extend({method:o(`tools/call`),params:Ot}),At=v.extend({method:o(`notifications/tools/list_changed`),params:_.optional()});c({autoRefresh:s().default(!0),debounceMs:n().int().nonnegative().default(300)});var J=r([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),jt=m.extend({level:J}),Mt=g.extend({method:o(`logging/setLevel`),params:jt}),Nt=_.extend({level:J,logger:e().optional(),data:t()}),Pt=v.extend({method:o(`notifications/message`),params:Nt}),Ft=c({name:e().optional()}),It=c({hints:i(Ft).optional(),costPriority:n().min(0).max(1).optional(),speedPriority:n().min(0).max(1).optional(),intelligencePriority:n().min(0).max(1).optional()}),Lt=c({mode:r([`auto`,`required`,`none`]).optional()}),Rt=c({type:o(`tool_result`),toolUseId:e().describe(`The unique identifier for the corresponding tool call.`),content:i(K).default([]),structuredContent:c({}).loose().optional(),isError:s().optional(),_meta:u(e(),t()).optional()}),zt=te(`type`,[W,G,gt]),Y=te(`type`,[W,G,gt,_t,Rt]),Bt=c({role:V,content:l([Y,i(Y)]),_meta:u(e(),t()).optional()}),Vt=h.extend({messages:i(Bt),modelPreferences:It.optional(),systemPrompt:e().optional(),includeContext:r([`none`,`thisServer`,`allServers`]).optional(),temperature:n().optional(),maxTokens:n().int(),stopSequences:i(e()).optional(),metadata:f.optional(),tools:i(Tt).optional(),toolChoice:Lt.optional()}),Ht=g.extend({method:o(`sampling/createMessage`),params:Vt}),Ut=y.extend({model:e(),stopReason:d(r([`endTurn`,`stopSequence`,`maxTokens`]).or(e())),role:V,content:zt}),Wt=y.extend({model:e(),stopReason:d(r([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(e())),role:V,content:l([Y,i(Y)])}),Gt=c({type:o(`boolean`),title:e().optional(),description:e().optional(),default:s().optional()}),Kt=c({type:o(`string`),title:e().optional(),description:e().optional(),minLength:n().optional(),maxLength:n().optional(),format:r([`email`,`uri`,`date`,`date-time`]).optional(),default:e().optional()}),qt=c({type:r([`number`,`integer`]),title:e().optional(),description:e().optional(),minimum:n().optional(),maximum:n().optional(),default:n().optional()}),Jt=c({type:o(`string`),title:e().optional(),description:e().optional(),enum:i(e()),default:e().optional()}),Yt=c({type:o(`string`),title:e().optional(),description:e().optional(),oneOf:i(c({const:e(),title:e()})),default:e().optional()}),Xt=c({type:o(`string`),title:e().optional(),description:e().optional(),enum:i(e()),enumNames:i(e()).optional(),default:e().optional()}),Zt=l([Jt,Yt]),Qt=c({type:o(`array`),title:e().optional(),description:e().optional(),minItems:n().optional(),maxItems:n().optional(),items:c({type:o(`string`),enum:i(e())}),default:i(e()).optional()}),$t=c({type:o(`array`),title:e().optional(),description:e().optional(),minItems:n().optional(),maxItems:n().optional(),items:c({anyOf:i(c({const:e(),title:e()}))}),default:i(e()).optional()}),en=l([Qt,$t]),tn=l([Xt,Zt,en]),nn=l([tn,Gt,Kt,qt]),rn=h.extend({mode:o(`form`).optional(),message:e(),requestedSchema:c({type:o(`object`),properties:u(e(),nn),required:i(e()).optional()})}),an=h.extend({mode:o(`url`),message:e(),elicitationId:e(),url:e().url()}),on=l([rn,an]),sn=g.extend({method:o(`elicitation/create`),params:on}),cn=_.extend({elicitationId:e()}),ln=v.extend({method:o(`notifications/elicitation/complete`),params:cn}),un=y.extend({action:r([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,u(e(),l([e(),n(),s(),i(e())])).optional())}),dn=c({type:o(`ref/resource`),uri:e()}),fn=c({type:o(`ref/prompt`),name:e()}),pn=m.extend({ref:l([fn,dn]),argument:c({name:e(),value:e()}),context:c({arguments:u(e(),e()).optional()}).optional()}),mn=g.extend({method:o(`completion/complete`),params:pn});function hn(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function gn(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var _n=y.extend({completion:a({values:i(e()).max(100),total:d(n().int()),hasMore:d(s())})}),vn=c({uri:e().startsWith(`file://`),name:e().optional(),_meta:u(e(),t()).optional()}),yn=g.extend({method:o(`roots/list`),params:m.optional()}),bn=y.extend({roots:i(vn)}),xn=v.extend({method:o(`notifications/roots/list_changed`),params:_.optional()});l([O,D,mn,Mt,ht,ft,Xe,Qe,tt,at,st,kt,Et,P,I,L,z]),l([w,Be,Le,xn,N]),l([C,Ut,Wt,un,bn,F,R,M]),l([O,Ht,sn,yn,P,I,L,z]),l([w,Be,Pt,lt,rt,At,St,N,ln]),l([C,Ie,_n,xt,pt,Ze,$e,nt,q,Dt,F,R,M]);var Sn=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===S.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Cn(e.elicitations,n)}return new e(t,n,r)}},Cn=class extends Sn{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(S.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},X=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Z=class extends X{};Z.errorCode=`invalid_request`;var wn=class extends X{};wn.errorCode=`invalid_client`;var Tn=class extends X{};Tn.errorCode=`invalid_grant`;var En=class extends X{};En.errorCode=`unauthorized_client`;var Dn=class extends X{};Dn.errorCode=`unsupported_grant_type`;var On=class extends X{};On.errorCode=`invalid_scope`;var Q=class extends X{};Q.errorCode=`access_denied`;var $=class extends X{};$.errorCode=`server_error`;var kn=class extends X{};kn.errorCode=`temporarily_unavailable`;var An=class extends X{};An.errorCode=`unsupported_response_type`;var jn=class extends X{};jn.errorCode=`unsupported_token_type`;var Mn=class extends X{};Mn.errorCode=`invalid_token`;var Nn=class extends X{};Nn.errorCode=`method_not_allowed`;var Pn=class extends X{};Pn.errorCode=`too_many_requests`;var Fn=class extends X{};Fn.errorCode=`invalid_client_metadata`;var In=class extends X{};In.errorCode=`insufficient_scope`;var Ln=class extends X{};Ln.errorCode=`invalid_target`;var Rn={[Z.errorCode]:Z,[wn.errorCode]:wn,[Tn.errorCode]:Tn,[En.errorCode]:En,[Dn.errorCode]:Dn,[On.errorCode]:On,[Q.errorCode]:Q,[$.errorCode]:$,[kn.errorCode]:kn,[An.errorCode]:An,[jn.errorCode]:jn,[Mn.errorCode]:Mn,[Nn.errorCode]:Nn,[Pn.errorCode]:Pn,[Fn.errorCode]:Fn,[In.errorCode]:In,[Ln.errorCode]:Ln},zn=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Bn(e){return(await zn).getRandomValues(new Uint8Array(e))}async function Vn(e){let t=``;for(;t.length<e;){let n=await Bn(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Hn(e){return await Vn(e)}async function Un(e){let t=await(await zn).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Wn(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Hn(e);return{code_verifier:t,code_challenge:await Un(t)}}export{R as A,N as B,we as C,Xe as D,Qe as E,Be as F,be as G,gn as H,de as I,ge as J,ve as K,tt as L,J as M,Sn as N,bn as O,O as P,ue as R,Le as S,ft as T,Pe as U,hn as V,Ce as W,se as Y,ht as _,q as a,F as b,w as c,Wt as d,M as f,S as g,C as h,kt as i,Et as j,L as k,mn as l,un as m,Rn as n,z as o,le as p,xe as q,$ as r,We as s,Wn as t,Ut as u,I as v,ce as w,D as x,P as y,Mt as z};
|
|
1
|
+
import{C as e,T as t,_ as n,a as r,b as ee,c as i,d as te,g as a,h as o,k as ne,l as s,o as re,p as ie,u as ae,v as c,w as l,x as u,y as d}from"./person-owner-ChqQWHII.js";import{a as oe}from"./auth-Bb-9biQe.js";var se=c({clerkPublishableKey:e().nullish(),oauthClient:oe.nullish()}),ce=`2025-11-25`,le=`2025-03-26`,ue=[ce,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],de=`io.modelcontextprotocol/related-task`,f=ae(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),fe=l([e(),n().int()]),pe=e();a({ttl:n().optional(),pollInterval:n().optional()});var me=c({ttl:n().optional()}),he=c({taskId:e()}),p=a({progressToken:fe.optional(),[de]:he.optional()}),m=c({_meta:p.optional()}),h=m.extend({task:me.optional()}),ge=e=>h.safeParse(e).success,g=c({method:e(),params:m.loose().optional()}),_=c({_meta:p.optional()}),v=c({method:e(),params:_.loose().optional()}),y=a({_meta:p.optional()}),b=l([e(),n().int()]),_e=c({jsonrpc:o(`2.0`),id:b,...g.shape}).strict(),ve=e=>_e.safeParse(e).success,ye=c({jsonrpc:o(`2.0`),...v.shape}).strict(),be=e=>ye.safeParse(e).success,x=c({jsonrpc:o(`2.0`),id:b,result:y}).strict(),xe=e=>x.safeParse(e).success,S;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(S||={});var Se=c({jsonrpc:o(`2.0`),id:b.optional(),error:c({code:n().int(),message:e(),data:t().optional()})}).strict(),Ce=e=>Se.safeParse(e).success,we=l([_e,ye,x,Se]);l([x,Se]);var C=y.strict(),Te=_.extend({requestId:b.optional(),reason:e().optional()}),w=v.extend({method:o(`notifications/cancelled`),params:Te}),Ee=c({src:e(),mimeType:e().optional(),sizes:i(e()).optional(),theme:r([`light`,`dark`]).optional()}),T=c({icons:i(Ee).optional()}),E=c({name:e(),title:e().optional()}),De=E.extend({...E.shape,...T.shape,version:e(),websiteUrl:e().optional(),description:e().optional()}),Oe=ie(c({applyDefaults:s().optional()}),u(e(),t())),ke=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ie(c({form:Oe.optional(),url:f.optional()}),u(e(),t()).optional())),Ae=a({list:f.optional(),cancel:f.optional(),requests:a({sampling:a({createMessage:f.optional()}).optional(),elicitation:a({create:f.optional()}).optional()}).optional()}),je=a({list:f.optional(),cancel:f.optional(),requests:a({tools:a({call:f.optional()}).optional()}).optional()}),Me=c({experimental:u(e(),f).optional(),sampling:c({context:f.optional(),tools:f.optional()}).optional(),elicitation:ke.optional(),roots:c({listChanged:s().optional()}).optional(),tasks:Ae.optional(),extensions:u(e(),f).optional()}),Ne=m.extend({protocolVersion:e(),capabilities:Me,clientInfo:De}),D=g.extend({method:o(`initialize`),params:Ne}),Pe=e=>D.safeParse(e).success,Fe=c({experimental:u(e(),f).optional(),logging:f.optional(),completions:f.optional(),prompts:c({listChanged:s().optional()}).optional(),resources:c({subscribe:s().optional(),listChanged:s().optional()}).optional(),tools:c({listChanged:s().optional()}).optional(),tasks:je.optional(),extensions:u(e(),f).optional()}),Ie=y.extend({protocolVersion:e(),capabilities:Fe,serverInfo:De,instructions:e().optional()}),Le=v.extend({method:o(`notifications/initialized`),params:_.optional()}),O=g.extend({method:o(`ping`),params:m.optional()}),Re=c({progress:n(),total:d(n()),message:d(e())}),ze=c({..._.shape,...Re.shape,progressToken:fe}),Be=v.extend({method:o(`notifications/progress`),params:ze}),Ve=m.extend({cursor:pe.optional()}),k=g.extend({params:Ve.optional()}),A=y.extend({nextCursor:pe.optional()}),He=r([`working`,`input_required`,`completed`,`failed`,`cancelled`]),j=c({taskId:e(),status:He,ttl:l([n(),re()]),createdAt:e(),lastUpdatedAt:e(),pollInterval:d(n()),statusMessage:d(e())}),M=y.extend({task:j}),Ue=_.merge(j),N=v.extend({method:o(`notifications/tasks/status`),params:Ue}),P=g.extend({method:o(`tasks/get`),params:m.extend({taskId:e()})}),F=y.merge(j),I=g.extend({method:o(`tasks/result`),params:m.extend({taskId:e()})});y.loose();var L=k.extend({method:o(`tasks/list`)}),R=A.extend({tasks:i(j)}),z=g.extend({method:o(`tasks/cancel`),params:m.extend({taskId:e()})}),We=y.merge(j),Ge=c({uri:e(),mimeType:d(e()),_meta:u(e(),t()).optional()}),Ke=Ge.extend({text:e()}),B=e().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),qe=Ge.extend({blob:B}),V=r([`user`,`assistant`]),H=c({audience:i(V).optional(),priority:n().min(0).max(1).optional(),lastModified:ne({offset:!0}).optional()}),Je=c({...E.shape,...T.shape,uri:e(),description:d(e()),mimeType:d(e()),size:d(n()),annotations:H.optional(),_meta:d(a({}))}),Ye=c({...E.shape,...T.shape,uriTemplate:e(),description:d(e()),mimeType:d(e()),annotations:H.optional(),_meta:d(a({}))}),Xe=k.extend({method:o(`resources/list`)}),Ze=A.extend({resources:i(Je)}),Qe=k.extend({method:o(`resources/templates/list`)}),$e=A.extend({resourceTemplates:i(Ye)}),U=m.extend({uri:e()}),et=U,tt=g.extend({method:o(`resources/read`),params:et}),nt=y.extend({contents:i(l([Ke,qe]))}),rt=v.extend({method:o(`notifications/resources/list_changed`),params:_.optional()}),it=U,at=g.extend({method:o(`resources/subscribe`),params:it}),ot=U,st=g.extend({method:o(`resources/unsubscribe`),params:ot}),ct=_.extend({uri:e()}),lt=v.extend({method:o(`notifications/resources/updated`),params:ct}),ut=c({name:e(),description:d(e()),required:d(s())}),dt=c({...E.shape,...T.shape,description:d(e()),arguments:d(i(ut)),_meta:d(a({}))}),ft=k.extend({method:o(`prompts/list`)}),pt=A.extend({prompts:i(dt)}),mt=m.extend({name:e(),arguments:u(e(),e()).optional()}),ht=g.extend({method:o(`prompts/get`),params:mt}),W=c({type:o(`text`),text:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),G=c({type:o(`image`),data:B,mimeType:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),gt=c({type:o(`audio`),data:B,mimeType:e(),annotations:H.optional(),_meta:u(e(),t()).optional()}),_t=c({type:o(`tool_use`),name:e(),id:e(),input:u(e(),t()),_meta:u(e(),t()).optional()}),vt=c({type:o(`resource`),resource:l([Ke,qe]),annotations:H.optional(),_meta:u(e(),t()).optional()}),yt=Je.extend({type:o(`resource_link`)}),K=l([W,G,gt,yt,vt]),bt=c({role:V,content:K}),xt=y.extend({description:e().optional(),messages:i(bt)}),St=v.extend({method:o(`notifications/prompts/list_changed`),params:_.optional()}),Ct=c({title:e().optional(),readOnlyHint:s().optional(),destructiveHint:s().optional(),idempotentHint:s().optional(),openWorldHint:s().optional()}),wt=c({taskSupport:r([`required`,`optional`,`forbidden`]).optional()}),Tt=c({...E.shape,...T.shape,description:e().optional(),inputSchema:c({type:o(`object`),properties:u(e(),f).optional(),required:i(e()).optional()}).catchall(t()),outputSchema:c({type:o(`object`),properties:u(e(),f).optional(),required:i(e()).optional()}).catchall(t()).optional(),annotations:Ct.optional(),execution:wt.optional(),_meta:u(e(),t()).optional()}),Et=k.extend({method:o(`tools/list`)}),Dt=A.extend({tools:i(Tt)}),q=y.extend({content:i(K).default([]),structuredContent:u(e(),t()).optional(),isError:s().optional()});q.or(y.extend({toolResult:t()}));var Ot=h.extend({name:e(),arguments:u(e(),t()).optional()}),kt=g.extend({method:o(`tools/call`),params:Ot}),At=v.extend({method:o(`notifications/tools/list_changed`),params:_.optional()});c({autoRefresh:s().default(!0),debounceMs:n().int().nonnegative().default(300)});var J=r([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),jt=m.extend({level:J}),Mt=g.extend({method:o(`logging/setLevel`),params:jt}),Nt=_.extend({level:J,logger:e().optional(),data:t()}),Pt=v.extend({method:o(`notifications/message`),params:Nt}),Ft=c({name:e().optional()}),It=c({hints:i(Ft).optional(),costPriority:n().min(0).max(1).optional(),speedPriority:n().min(0).max(1).optional(),intelligencePriority:n().min(0).max(1).optional()}),Lt=c({mode:r([`auto`,`required`,`none`]).optional()}),Rt=c({type:o(`tool_result`),toolUseId:e().describe(`The unique identifier for the corresponding tool call.`),content:i(K).default([]),structuredContent:c({}).loose().optional(),isError:s().optional(),_meta:u(e(),t()).optional()}),zt=te(`type`,[W,G,gt]),Y=te(`type`,[W,G,gt,_t,Rt]),Bt=c({role:V,content:l([Y,i(Y)]),_meta:u(e(),t()).optional()}),Vt=h.extend({messages:i(Bt),modelPreferences:It.optional(),systemPrompt:e().optional(),includeContext:r([`none`,`thisServer`,`allServers`]).optional(),temperature:n().optional(),maxTokens:n().int(),stopSequences:i(e()).optional(),metadata:f.optional(),tools:i(Tt).optional(),toolChoice:Lt.optional()}),Ht=g.extend({method:o(`sampling/createMessage`),params:Vt}),Ut=y.extend({model:e(),stopReason:d(r([`endTurn`,`stopSequence`,`maxTokens`]).or(e())),role:V,content:zt}),Wt=y.extend({model:e(),stopReason:d(r([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(e())),role:V,content:l([Y,i(Y)])}),Gt=c({type:o(`boolean`),title:e().optional(),description:e().optional(),default:s().optional()}),Kt=c({type:o(`string`),title:e().optional(),description:e().optional(),minLength:n().optional(),maxLength:n().optional(),format:r([`email`,`uri`,`date`,`date-time`]).optional(),default:e().optional()}),qt=c({type:r([`number`,`integer`]),title:e().optional(),description:e().optional(),minimum:n().optional(),maximum:n().optional(),default:n().optional()}),Jt=c({type:o(`string`),title:e().optional(),description:e().optional(),enum:i(e()),default:e().optional()}),Yt=c({type:o(`string`),title:e().optional(),description:e().optional(),oneOf:i(c({const:e(),title:e()})),default:e().optional()}),Xt=c({type:o(`string`),title:e().optional(),description:e().optional(),enum:i(e()),enumNames:i(e()).optional(),default:e().optional()}),Zt=l([Jt,Yt]),Qt=c({type:o(`array`),title:e().optional(),description:e().optional(),minItems:n().optional(),maxItems:n().optional(),items:c({type:o(`string`),enum:i(e())}),default:i(e()).optional()}),$t=c({type:o(`array`),title:e().optional(),description:e().optional(),minItems:n().optional(),maxItems:n().optional(),items:c({anyOf:i(c({const:e(),title:e()}))}),default:i(e()).optional()}),en=l([Qt,$t]),tn=l([Xt,Zt,en]),nn=l([tn,Gt,Kt,qt]),rn=h.extend({mode:o(`form`).optional(),message:e(),requestedSchema:c({type:o(`object`),properties:u(e(),nn),required:i(e()).optional()})}),an=h.extend({mode:o(`url`),message:e(),elicitationId:e(),url:e().url()}),on=l([rn,an]),sn=g.extend({method:o(`elicitation/create`),params:on}),cn=_.extend({elicitationId:e()}),ln=v.extend({method:o(`notifications/elicitation/complete`),params:cn}),un=y.extend({action:r([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,u(e(),l([e(),n(),s(),i(e())])).optional())}),dn=c({type:o(`ref/resource`),uri:e()}),fn=c({type:o(`ref/prompt`),name:e()}),pn=m.extend({ref:l([fn,dn]),argument:c({name:e(),value:e()}),context:c({arguments:u(e(),e()).optional()}).optional()}),mn=g.extend({method:o(`completion/complete`),params:pn});function hn(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function gn(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var _n=y.extend({completion:a({values:i(e()).max(100),total:d(n().int()),hasMore:d(s())})}),vn=c({uri:e().startsWith(`file://`),name:e().optional(),_meta:u(e(),t()).optional()}),yn=g.extend({method:o(`roots/list`),params:m.optional()}),bn=y.extend({roots:i(vn)}),xn=v.extend({method:o(`notifications/roots/list_changed`),params:_.optional()});l([O,D,mn,Mt,ht,ft,Xe,Qe,tt,at,st,kt,Et,P,I,L,z]),l([w,Be,Le,xn,N]),l([C,Ut,Wt,un,bn,F,R,M]),l([O,Ht,sn,yn,P,I,L,z]),l([w,Be,Pt,lt,rt,At,St,N,ln]),l([C,Ie,_n,xt,pt,Ze,$e,nt,q,Dt,F,R,M]);var Sn=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===S.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Cn(e.elicitations,n)}return new e(t,n,r)}},Cn=class extends Sn{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(S.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},X=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Z=class extends X{};Z.errorCode=`invalid_request`;var wn=class extends X{};wn.errorCode=`invalid_client`;var Tn=class extends X{};Tn.errorCode=`invalid_grant`;var En=class extends X{};En.errorCode=`unauthorized_client`;var Dn=class extends X{};Dn.errorCode=`unsupported_grant_type`;var On=class extends X{};On.errorCode=`invalid_scope`;var Q=class extends X{};Q.errorCode=`access_denied`;var $=class extends X{};$.errorCode=`server_error`;var kn=class extends X{};kn.errorCode=`temporarily_unavailable`;var An=class extends X{};An.errorCode=`unsupported_response_type`;var jn=class extends X{};jn.errorCode=`unsupported_token_type`;var Mn=class extends X{};Mn.errorCode=`invalid_token`;var Nn=class extends X{};Nn.errorCode=`method_not_allowed`;var Pn=class extends X{};Pn.errorCode=`too_many_requests`;var Fn=class extends X{};Fn.errorCode=`invalid_client_metadata`;var In=class extends X{};In.errorCode=`insufficient_scope`;var Ln=class extends X{};Ln.errorCode=`invalid_target`;var Rn={[Z.errorCode]:Z,[wn.errorCode]:wn,[Tn.errorCode]:Tn,[En.errorCode]:En,[Dn.errorCode]:Dn,[On.errorCode]:On,[Q.errorCode]:Q,[$.errorCode]:$,[kn.errorCode]:kn,[An.errorCode]:An,[jn.errorCode]:jn,[Mn.errorCode]:Mn,[Nn.errorCode]:Nn,[Pn.errorCode]:Pn,[Fn.errorCode]:Fn,[In.errorCode]:In,[Ln.errorCode]:Ln};globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);export{Et as A,hn as B,ce as C,bn as D,Xe as E,de as F,ve as G,Pe as H,tt as I,se as J,xe as K,ue as L,Sn as M,O as N,L as O,Be as P,Mt as R,we as S,Qe as T,Ce as U,gn as V,be as W,I as _,z as a,D as b,mn as c,M as d,le as f,ht as g,S as h,q as i,J as j,R as k,Ut as l,C as m,$ as n,We as o,un as p,ge as q,kt as r,w as s,Rn as t,Wt as u,P as v,ft as w,Le as x,F as y,N as z};
|