@aventurevc/aventure-cli 0.8.28 → 0.8.29
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/{auth-ft5-pPnc.js → auth-C_jLPvth.js} +1 -1
- package/dist/chunks/{aventure-cli-CEHXPNGC.js → aventure-cli-BulTt7ID.js} +2 -2
- package/dist/chunks/{detail-C356ZD5R.js → detail-BhrPZbmH.js} +1 -1
- package/dist/chunks/{index.node-RpgUiq92.js → index.node-CWMdNV2l.js} +1 -1
- package/dist/chunks/{oauth-bearer-credential-D87-WID3.js → oauth-bearer-credential-BzAAtcOq.js} +2 -2
- package/dist/chunks/oauth-login-BPal4uKl.js +1 -0
- package/dist/chunks/{oauth-login-BBSn5hJ3.js → oauth-login-DCwh-0eS.js} +1 -1
- package/dist/chunks/{openapi-commands-BX4X2XP-.js → openapi-commands-B_yJaqCC.js} +1 -1
- package/dist/chunks/{text-response-CAyGTlx0.js → text-response-fgRJu0sN.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/oauth-login-Bgy57vgI.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as e,Bt as t,D as n,E as r,H as i,It as a,J as o,Lt as s,O as c,Q as l,Rt as u,S as d,X as f,_ as p,c as m,ct as h,d as g,et as _,g as v,h as y,it as b,l as ee,lt as te,m as ne,nt as re,ot as ie,p as ae,rt as oe,s as se,st as x,tt as ce,u as le,v as ue,w as de,x as fe}from"./auth-ft5-pPnc.js";import{C as S,D as pe,R as me,_ as he,a as ge,k as C,v as w}from"./person-owner-BqBLyw4S.js";import{A as _e,C as ve,D as ye,M as T,N as be,O as xe,S as Se,T as Ce,a as we,b as Te,c as Ee,d as De,g as Oe,j as ke,k as Ae,l as je,m as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve}from"./oauth-bearer-credential-D87-WID3.js";import{_ as He,a as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,l as Ye,m as Xe,n as Ze,o as E,p as Qe,r as D,s as $e,t as O,u as et}from"./openapi-commands-BX4X2XP-.js";import{a as tt}from"./text-field-BvxM-1gi.js";import{a as nt,n as rt,o as it,r as at,t as ot}from"./text-response-CAyGTlx0.js";import{n as st,r as ct,t as lt}from"./oauth-login-BBSn5hJ3.js";import{spawnSync as ut}from"node:child_process";import{basename as dt,dirname as k,resolve as A,sep as j}from"node:path";import{copyFileSync as ft,existsSync as pt,lstatSync as mt,mkdirSync as ht,mkdtempSync as gt,readFileSync as _t,readlinkSync as vt,realpathSync as yt,renameSync as bt,rmdirSync as xt,unlinkSync as St,writeFileSync as Ct}from"node:fs";import M,{stderr as N,stdin as wt}from"node:process";import{TextDecoder as Tt,inspect as Et}from"node:util";import{fileURLToPath as Dt}from"node:url";import{readFile as Ot}from"node:fs/promises";import{webcrypto as kt}from"node:crypto";import{homedir as At,hostname as jt,platform as Mt}from"node:os";import{setTimeout as Nt}from"node:timers/promises";import{createInterface as Pt}from"node:readline/promises";function Ft(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{...x(`${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 h(`Environment-bound options applied`,r)}function It(e,t,n){if(!F(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||!Xt(n,r.name))continue;let a=Yt(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 Lt(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 Rt(e,t,n,r=!1){if(r||!P(t)||!Array.isArray(n))return en(e,t,n);for(let[r,i]of n.entries()){let n=en(e,t,i,r);if(!n.ok)return n}return h(`Body value assigned`,null)}function zt(e,t,n,r){return en(e,t,r,n)}function Bt(e){let t=[];for(let n of e.split(`.`)){let e=nn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Vt(e,t){let n=Bt(t);if(n===null)return null;let r=Jt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:qt(r)}:null}function Ht(e,t){if(P(e.name)||e.schemaType===`array`)return h(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return h(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?h(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var Ut=/^(?<row>\d+):(?<item>.*)$/su;function Wt(e,t){let n=Bt(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=Ut.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 Gt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Bt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Kt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Vt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Wt(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${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 qt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Jt(e,t){let n=e;for(let e of t){if(!F(n))return;n=n[e]??null}return n}function Yt(e,t){if(!P(t))return Jt(e,t.split(`.`))}function Xt(e,t){return Qt(e,t.split(`.`))}function Zt(e,t,n){if(!F(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)&&Xt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function Qt(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=nn(n);if(!F(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>Qt(e,r)):Qt(a,r)}function P(e){return e.split(`.`).some(e=>nn(e).isArray)}function $t(e,t){return e.parameter.length===0||!F(t)?null:an(t,[],rn(e.parameter))}function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function en(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=nn(o),c=e===i.length-1,l=tn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return h(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function tn(e,t,n,r,i,a){let o=()=>x(`${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,h(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,h(`Body path created`,e)}return F(c)?h(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,h(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,h(`Body path created`,n)}return F(s)?h(`Body path stepped`,s):o()}function nn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function rn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function an(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=an(r,t,n);if(e!==null)return e}return null}if(!F(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!on(a,n)){if(!sn(e))continue;return{path:a,suggestion:cn(e,n)}}let o=an(i,e,n);if(o!==null)return o}return null}function on(e,t){return t.prefix.has(e)||t.leaf.has(e)}function sn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function cn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:ln(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function ln(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 un(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(qe(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?vn(r,i):r===void 0?i===void 0?0:1:-1})}function dn(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 fn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function pn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:gn(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 mn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function hn(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 gn(e,t){let n=Xe(t.description,void 0),r=e.kind!==`multipart`&&P(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${_n(e,t)}`}function _n(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Bt(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 vn(e,t){return Je(e)-Je(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function yn(e){let t;try{t=e===`-`?await bn():await Ot(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return h(`No input provided`,null);let e=JSON.parse(t);return h(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function bn(){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 xn=`--content-type`;function Sn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(xn)){let t=i.map(({contentType:e})=>e);e.addOption(new s(`${xn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(wn(i)))}if(Un(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new s(`--from-file <path>`,hn(n,n.requiredPath)).argParser(En(`--from-file`)))}let a=dn(i).filter(e=>r(I(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>vn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new s(fn(t),i.length>1?pn(t):gn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?mn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Cn):P(r.name)||r.schemaType===`array`?a.argParser(Tn):a.argParser(En(r.flag)),e.addOption(a),a.envVar!==void 0&&e.on(`optionEnv:${a.name()}`,()=>{let t=e.opts()[r.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(r.optionKey,t.trim(),`env`)})}Hn(e,t,a)}function Cn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function wn(e){return(n,r)=>{if(r!==void 0)throw new t(`${xn} was already given; pass it once.`);let i=c(e,n);if(!i.ok)throw new t(i.summary);return n}}function Tn(e,t){return[...t??[],e]}function En(e){let n=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new t(`${n} was already given; pass it once.`);return e}}async function Dn(e,t){let n=typeof t.contentType==`string`?t.contentType:void 0,r=c(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return h(`No body`,void 0);let a=On(e,i,t);if(a!==null)return x(a);let o=Ft(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=kn(i,t);if(s!==null)return x(s);let l=await Nn(t);if(!l.ok)return x(l.summary,l.warnings);let u=Zt(e.requestBody??[],i,l.data);if(u!==null)return x(u);let d=Mn(e.operationId,i,l.data);if(!d.ok)return d;let f=It(e.operationId,i,l.data);if(f!==null)return x(f);let p=Pn(e.operationId,i,t);if(!p.ok)return p;if(l.data===void 0&&p.data===void 0)return i.required?x(Vn(e.operationId,i)):h(`No body`,void 0);let m=In(e.operationId,l.data,p.data);if(!m.ok||m.data===void 0)return m;if(i.schemaType===`array`&&!Array.isArray(m.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!F(m.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let g=jn(i,m.data);if(g.length>0)return x(`${e.operationId} requires body option(s): ${g.join(`, `)}`);let _=m.data,v=F(_)?Lt(i).filter(e=>!Xt(_,e)):[];return v.length>0?x(An(e.operationId,i,v)):m}function On(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 ${xn} ${i.join(` or `)}.`}return null}function kn(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 An(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 jn(e,t){return F(t)?e.parameter.filter(e=>e.required&&!Xt(t,e.name)).map(I):[]}function Mn(e,t,n){let r=$t(t,n);if(r===null)return h(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function Nn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return h(`No body file`,void 0);let n=await yn(t);if(!n.ok)return x(n.summary,n.warnings);let r=te.safeParse(n.data);return r.success?h(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function Pn(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Ht(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Fn(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return h(`No direct body options`,void 0);let a=Kt(e,t,n,r);return a===null?h(`Direct body options parsed`,r):a}function Fn(e,t,n,r,i){let a=Wt(r,i);if(a===null){let e=zn(r,i);return e.ok?Rt(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${I(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=Gt(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${I(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=Bn(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=zt(n,r.name,e,i);if(!a.ok)return a}return h(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function In(e,t,n){if(t===void 0)return h(`Direct body parsed`,n);if(n===void 0)return h(`Input parsed`,t);if(F(t)&&F(n))try{return h(`Input parsed`,Ln(t,n))}catch(t){return x(`${e} ${t.message}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Ln(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&&Rn(t)!==Rn(r))throw Error(`cannot combine --from-file ${Rn(t)} '${e}' with ${Rn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=F(t)&&F(r)?Ln(t,r):r}return n}function Rn(e){return Array.isArray(e)?`array`:F(e)?`object`:`scalar`}function zn(e,t){if(typeof t==`boolean`)return h(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Bn(e.name,e.schemaType,t??``);let n=[],r=P(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Bn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return h(`Body value parsed`,n)}function Bn(e,t,n){if(t===`boolean`)return n===`true`?h(`Body value parsed`,!0):n===`false`?h(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):h(`Body value parsed`,i)}return h(`Body value parsed`,n)}function Vn(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=Lt(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 Hn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:xn,location:`body`}),Un(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),un(e.options,r)}function Un(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Wn(e){let t=ie(e);return $n(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Gn(e){$n(e);let t=ot(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
1
|
+
import{B as e,Bt as t,D as n,E as r,H as i,It as a,J as o,Lt as s,O as c,Q as l,Rt as u,S as d,X as f,_ as p,c as m,ct as h,d as g,et as _,g as v,h as y,it as b,l as ee,lt as te,m as ne,nt as re,ot as ie,p as ae,rt as oe,s as se,st as x,tt as ce,u as le,v as ue,w as de,x as fe}from"./auth-C_jLPvth.js";import{C as S,D as pe,R as me,_ as he,a as ge,k as C,v as w}from"./person-owner-BqBLyw4S.js";import{A as _e,C as ve,D as ye,M as T,N as be,O as xe,S as Se,T as Ce,a as we,b as Te,c as Ee,d as De,g as Oe,j as ke,k as Ae,l as je,m as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve}from"./oauth-bearer-credential-BzAAtcOq.js";import{_ as He,a as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,l as Ye,m as Xe,n as Ze,o as E,p as Qe,r as D,s as $e,t as O,u as et}from"./openapi-commands-B_yJaqCC.js";import{a as tt}from"./text-field-BvxM-1gi.js";import{a as nt,n as rt,o as it,r as at,t as ot}from"./text-response-fgRJu0sN.js";import{n as st,r as ct,t as lt}from"./oauth-login-DCwh-0eS.js";import{spawnSync as ut}from"node:child_process";import{basename as dt,dirname as k,resolve as A,sep as j}from"node:path";import{copyFileSync as ft,existsSync as pt,lstatSync as mt,mkdirSync as ht,mkdtempSync as gt,readFileSync as _t,readlinkSync as vt,realpathSync as yt,renameSync as bt,rmdirSync as xt,unlinkSync as St,writeFileSync as Ct}from"node:fs";import M,{stderr as N,stdin as wt}from"node:process";import{TextDecoder as Tt,inspect as Et}from"node:util";import{fileURLToPath as Dt}from"node:url";import{readFile as Ot}from"node:fs/promises";import{webcrypto as kt}from"node:crypto";import{homedir as At,hostname as jt,platform as Mt}from"node:os";import{setTimeout as Nt}from"node:timers/promises";import{createInterface as Pt}from"node:readline/promises";function Ft(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{...x(`${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 h(`Environment-bound options applied`,r)}function It(e,t,n){if(!F(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||!Xt(n,r.name))continue;let a=Yt(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 Lt(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 Rt(e,t,n,r=!1){if(r||!P(t)||!Array.isArray(n))return en(e,t,n);for(let[r,i]of n.entries()){let n=en(e,t,i,r);if(!n.ok)return n}return h(`Body value assigned`,null)}function zt(e,t,n,r){return en(e,t,r,n)}function Bt(e){let t=[];for(let n of e.split(`.`)){let e=nn(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function Vt(e,t){let n=Bt(t);if(n===null)return null;let r=Jt(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:qt(r)}:null}function Ht(e,t){if(P(e.name)||e.schemaType===`array`)return h(`Repeated body option selected`,typeof t==`string`?[t]:t);if(!Array.isArray(t))return h(`Scalar body option selected`,t);let n=e.flag.split(` `)[0]??e.name;return t.length===1?h(`Scalar body option selected`,t[0]):x(`${n} was already given; pass it once.`)}var Ut=/^(?<row>\d+):(?<item>.*)$/su;function Wt(e,t){let n=Bt(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=Ut.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 Gt(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&Bt(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function Kt(e,t,n,r){for(let i of t.parameter){let t=n[i.optionKey];if(t===void 0)continue;let a=Vt(r,i.name);if(a===null)continue;if(a.firstHole!==null)return x(`${e} has no ${a.path}[] row ${a.firstHole} — number ${a.path}[] rows from 0 with no gaps.`);if(i.schemaType!==`array`||a.rowCount<=1||Wt(i,t)!==null)continue;let o=i.flag.split(` `)[0]??i.name;return x(`${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 qt(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function Jt(e,t){let n=e;for(let e of t){if(!F(n))return;n=n[e]??null}return n}function Yt(e,t){if(!P(t))return Jt(e,t.split(`.`))}function Xt(e,t){return Qt(e,t.split(`.`))}function Zt(e,t,n){if(!F(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)&&Xt(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function Qt(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=nn(n);if(!F(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>Qt(e,r)):Qt(a,r)}function P(e){return e.split(`.`).some(e=>nn(e).isArray)}function $t(e,t){return e.parameter.length===0||!F(t)?null:an(t,[],rn(e.parameter))}function F(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function en(e,t,n,r=0){let i=t.split(`.`),a=e;for(let[e,o]of i.entries()){let s=nn(o),c=e===i.length-1,l=tn(a,s,t,c,n,r);if(!l.ok||l.data===null)return x(l.summary,l.warnings);if(c)return h(`Body value assigned`,null);a=l.data}return x(`${t} is not a valid body option path.`)}function tn(e,t,n,r,i,a){let o=()=>x(`${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,h(`Body value assigned`,e)):o();let c=n[a];if(c===void 0){let e={};return n[a]=e,h(`Body path created`,e)}return F(c)?h(`Body path stepped`,c):o()}if(r)return s===void 0?(e[t.key]=i,h(`Body value assigned`,e)):o();if(s===void 0){let n={};return e[t.key]=n,h(`Body path created`,n)}return F(s)?h(`Body path stepped`,s):o()}function nn(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function rn(e){let t=new Set,n=new Set;for(let r of e){let e=`${r.name}${r.schemaType===`array`?`[]`:``}`;t.add(e);let i=e.split(`.`);for(let e=1;e<i.length;e+=1)n.add(i.slice(0,e).join(`.`))}return{leaf:t,prefix:n}}function an(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=an(r,t,n);if(e!==null)return e}return null}if(!F(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(!on(a,n)){if(!sn(e))continue;return{path:a,suggestion:cn(e,n)}}let o=an(i,e,n);if(o!==null)return o}return null}function on(e,t){return t.prefix.has(e)||t.leaf.has(e)}function sn(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}function cn(e,t){let n=e.slice(0,-1).join(`.`),r=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``;return[...t.leaf].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===n).map(e=>({path:e,score:ln(r,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path))[0]?.path}function ln(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 un(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(qe(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?vn(r,i):r===void 0?i===void 0?0:1:-1})}function dn(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 fn(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function pn(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:gn(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 mn(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function hn(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 gn(e,t){let n=Xe(t.description,void 0),r=e.kind!==`multipart`&&P(t.name),i=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${i?` --from-file JSON key: ${t.name}.`:``}${_n(e,t)}`}function _n(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=Bt(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 vn(e,t){return Je(e)-Je(t)||Number(e.required!==!0)-Number(t.required!==!0)}async function yn(e){let t;try{t=e===`-`?await bn():await Ot(e,`utf8`)}catch(t){return x(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return h(`No input provided`,null);let e=JSON.parse(t);return h(`Input parsed`,e)}catch(e){return x(`Input is not valid JSON: ${e.message}`)}}async function bn(){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 xn=`--content-type`;function Sn(e,t,n){let r=e=>!n?.has(e)&&(n?.add(e),!0),i=t.requestBody??[];if(i.length>1&&r(xn)){let t=i.map(({contentType:e})=>e);e.addOption(new s(`${xn} <media-type>`,`Select the request content type; omit for ${t[0]}.`).choices(t).argParser(wn(i)))}if(Un(t)&&r(`--from-file`)){let n=i[0];if(n===void 0)throw Error(`${t.operationId} has no request body`);e.addOption(new s(`--from-file <path>`,hn(n,n.requiredPath)).argParser(En(`--from-file`)))}let a=dn(i).filter(e=>r(I(e.variant[0].parameter)));for(let t of a.toSorted((e,t)=>vn(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:n,parameter:r}=t.variant[0],a=new s(fn(t),i.length>1?pn(t):gn(n,r));i.length===1&&r.envName!==void 0&&a.env(r.envName);let o=i.length===1?mn(n,r.optionKey):[];o.length>0&&a.conflicts(o),i.length>1?a.argParser(Cn):P(r.name)||r.schemaType===`array`?a.argParser(Tn):a.argParser(En(r.flag)),e.addOption(a),a.envVar!==void 0&&e.on(`optionEnv:${a.name()}`,()=>{let t=e.opts()[r.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(r.optionKey,t.trim(),`env`)})}Hn(e,t,a)}function Cn(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function wn(e){return(n,r)=>{if(r!==void 0)throw new t(`${xn} was already given; pass it once.`);let i=c(e,n);if(!i.ok)throw new t(i.summary);return n}}function Tn(e,t){return[...t??[],e]}function En(e){let n=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new t(`${n} was already given; pass it once.`);return e}}async function Dn(e,t){let n=typeof t.contentType==`string`?t.contentType:void 0,r=c(e.requestBody??[],n);if(!r.ok||r.data===null)return x(r.summary,r.warnings);let i=r.data;if(i===void 0)return h(`No body`,void 0);let a=On(e,i,t);if(a!==null)return x(a);let o=Ft(e.operationId,i,t);if(!o.ok)return x(o.summary,o.warnings);t=o.data;let s=kn(i,t);if(s!==null)return x(s);let l=await Nn(t);if(!l.ok)return x(l.summary,l.warnings);let u=Zt(e.requestBody??[],i,l.data);if(u!==null)return x(u);let d=Mn(e.operationId,i,l.data);if(!d.ok)return d;let f=It(e.operationId,i,l.data);if(f!==null)return x(f);let p=Pn(e.operationId,i,t);if(!p.ok)return p;if(l.data===void 0&&p.data===void 0)return i.required?x(Vn(e.operationId,i)):h(`No body`,void 0);let m=In(e.operationId,l.data,p.data);if(!m.ok||m.data===void 0)return m;if(i.schemaType===`array`&&!Array.isArray(m.data))return x(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!F(m.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return x(`${e.operationId} requires a JSON object${t}.`)}let g=jn(i,m.data);if(g.length>0)return x(`${e.operationId} requires body option(s): ${g.join(`, `)}`);let _=m.data,v=F(_)?Lt(i).filter(e=>!Xt(_,e)):[];return v.length>0?x(An(e.operationId,i,v)):m}function On(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 ${xn} ${i.join(` or `)}.`}return null}function kn(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 An(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 jn(e,t){return F(t)?e.parameter.filter(e=>e.required&&!Xt(t,e.name)).map(I):[]}function Mn(e,t,n){let r=$t(t,n);if(r===null)return h(`Body file paths validated`,null);let i=r.suggestion===void 0?``:` Use ${r.suggestion}.`;return x(`${e} --from-file contains unknown JSON path ${r.path}.${i}`)}async function Nn(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return h(`No body file`,void 0);let n=await yn(t);if(!n.ok)return x(n.summary,n.warnings);let r=te.safeParse(n.data);return r.success?h(`Input parsed`,r.data):x(`Input is not valid JSON value: ${r.error.message}`)}function Pn(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Ht(e,n[e.optionKey]);if(!a.ok||a.data===null)return x(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Fn(t,n,r,e,o);if(!s.ok)return x(s.summary,s.warnings);i=!0}if(!i)return h(`No direct body options`,void 0);let a=Kt(e,t,n,r);return a===null?h(`Direct body options parsed`,r):a}function Fn(e,t,n,r,i){let a=Wt(r,i);if(a===null){let e=zn(r,i);return e.ok?Rt(n,r.name,e.data,r.schemaType===`array`):x(e.summary,e.warnings)}if(a.plain.length>0)return x(`${I(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=Gt(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return x(`${I(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=Bn(r.name,r.itemSchemaType,e);if(!t.ok)return x(t.summary,t.warnings);i.push(t.data)}let a=zt(n,r.name,e,i);if(!a.ok)return a}return h(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function In(e,t,n){if(t===void 0)return h(`Direct body parsed`,n);if(n===void 0)return h(`Input parsed`,t);if(F(t)&&F(n))try{return h(`Input parsed`,Ln(t,n))}catch(t){return x(`${e} ${t.message}`)}return x(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function Ln(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&&Rn(t)!==Rn(r))throw Error(`cannot combine --from-file ${Rn(t)} '${e}' with ${Rn(r)} body option(s) at the same key — align the file body shape with the schema.`);n[e]=F(t)&&F(r)?Ln(t,r):r}return n}function Rn(e){return Array.isArray(e)?`array`:F(e)?`object`:`scalar`}function zn(e,t){if(typeof t==`boolean`)return h(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return Bn(e.name,e.schemaType,t??``);let n=[],r=P(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=Bn(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return h(`Body value parsed`,n)}function Bn(e,t,n){if(t===`boolean`)return n===`true`?h(`Body value parsed`,!0):n===`false`?h(`Body value parsed`,!1):x(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?x(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?x(`${e} must be an integer.`):h(`Body value parsed`,i)}return h(`Body value parsed`,n)}function Vn(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=Lt(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 Hn(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:xn,location:`body`}),Un(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),un(e.options,r)}function Un(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function Wn(e){let t=ie(e);return $n(t),process.stdout.write(`${JSON.stringify(t)}\n`),t}function Gn(e){$n(e);let t=ot(e.data,e.summary);if(e.ok&&t!==null){process.stdout.write(t.endsWith(`
|
|
2
2
|
`)?t:`${t}\n`),Kn(e);return}let n=e.ok?`OK`:`FAIL`;process.stdout.write(`[${n}] ${e.summary}\n`),!e.ok&&e.problem!==void 0&&Yn(e.problem),Kn(e)}function Kn(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 L(e,t){if(e.mode===`data`||e.mode===`data-full`){let n=e.mode===`data`?ie(t):t;$n(n),process.stdout.write(`${JSON.stringify(n.ok&&n.truncated!==!0?qn(n.data):n)}\n`),n.ok||(process.exitCode=1);return}let n=e.mode===`json`?Wn(t):t;e.mode===`text`&&Gn(n),n.ok||(process.exitCode=1)}function qn(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 Jn(e,t){let n=rt(t);if(n===null){process.stderr.write(`explain: the response carried no search interpretation
|
|
3
3
|
`),process.exitCode=1;return}(e===`text`?process.stdout:process.stderr).write(n)}function Yn(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`)}typeof e.requiredRole==`string`&&process.stdout.write(` requiredRole: ${e.requiredRole}\n`),Xn(e),Zn(`unknownParameters`,e.unknownParameters),Zn(`validParameters`,e.validParameters),Qn(e.resolution)}function Xn(e){let t=[];typeof e.limitType==`string`&&t.push(`limitType=${e.limitType}`),typeof e.used==`number`&&t.push(`used=${e.used}`),typeof e.limit==`number`&&t.push(`limit=${e.limit}`),typeof e.remaining==`number`&&t.push(`remaining=${e.remaining}`),typeof e.resetAt==`string`&&t.push(`resetAt=${e.resetAt}`),typeof e.windowSeconds==`number`&&t.push(`windowSeconds=${e.windowSeconds}`),typeof e.retryAfterSeconds==`number`&&t.push(`retryAfterSeconds=${e.retryAfterSeconds}`),t.length>0&&process.stdout.write(` meter: ${t.join(` `)}\n`)}function Zn(e,t){t!=null&&t.length>0&&process.stdout.write(` ${e}: ${t.join(`, `)}\n`)}function Qn(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 $n(e){e.ok&&e.warnings.length===0||i({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 er(e,t,n=f().bin[0]){let r=e.limit===void 0?void 0:Number(e.limit);if(r!==void 0&&(e.limit?.trim()===``||!Number.isInteger(r)||r<0))return x(`Invalid --limit value: ${JSON.stringify(e.limit)} (expected a non-negative integer)`,["Pass a non-negative integer, e.g. `--limit 20`."]);let i=at(e.q??``,rr(t,n).filter(t=>sr(t,e)),e=>({...e,cliPath:e.cli.path,enumParameter:e.flags.map(({choices:e,location:t})=>({values:e,direct:t!==`body`})),parameterName:e.flags.flatMap(({wireName:e,optionKey:t})=>[e,t]),parameterDescription:[e.body.description,...e.flags.map(({description:e})=>e)]})).map(({item:e})=>e),a=i.slice(0,r);return h(`Operation catalog matches`,{operation:a,count:{totalOperations:t.length,matched:i.length,returned:a.length}})}function tr(e,t,n=f().bin[0]){let r=rr(t,n),i=e.operationId===void 0?nr(r,e.command):r.find(t=>t.operationId===e.operationId);if(i===void 0){let i=br(e.command??``),a=r.map(e=>e.cli.command).filter(e=>e.startsWith(`${n} ${i} `));if(a.length>0)return x(`${i} is a command group; show one of its subcommands.`,[`Run \`${n} command-catalog show --command "<subcommand>"\` with one of:`,...a]);let o=i.split(` `),s=new Set([...[...o.keys()].map(e=>o.slice(e+1).join(` `)),...o.slice(1).map((e,t)=>o.toSpliced(t,2,`${o[t]}-${e}`).join(` `))]),c=er({q:e.command??e.operationId},t,n),l=[...r.filter(({cli:e})=>e.path.length>1&&s.has(e.path.join(` `))).toSorted((e,t)=>t.cli.path.length-e.cli.path.length),...c.data?.operation??[]];return x(`Generated operation not found`,[...[...new Set(l.map(({cli:e,operationId:t})=>`${e.command} (operationId ${t})`))].slice(0,3).map(e=>`closest: ${e}`),`List candidates with \`${n} command-catalog search "<text>"\`.`])}return h(`Generated operation detail`,{operation:i,usage:lr(i,r)})}function nr(e,t){if(t===void 0)return;let{bin:n}=f(),r=br(t,n);return e.find(e=>br(e.cli.command,n)===r)}function rr(e,t){return e.map(e=>{let i=e.requestBody??[],a=[...e.parameters.map(e=>ir(e)),...i.flatMap(e=>e.parameter.map(t=>ir(t,i.length>1?e.contentType:void 0))),...ar(i)],o=[t,...e.cliPath].join(` `),s=r(e.intent),c=e.method===`DELETE`||e.intent===`delete`,l=i[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:s,destructive:c,auth:e.auth,cli:{command:o,path:e.cliPath},mcpTool:e.binaryResponse?null:n(e.intent),body:{hasBody:l!==void 0,kind:l?.kind??null,...l!==void 0&&i.length>1?{contentType:l.contentType}:{},required:l?.required??!1,description:l?.description??``,requiredPath:l?.requiredPath??[]},flags:a,errorResponse:e.errorResponse,summary:e.summary,description:e.description,deprecated:e.deprecated}})}function ir(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 ar(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 or(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}function sr(e,t){return!(t.root!==void 0&&!cr(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 cr(e,t){let n=it(t);return n.length===0||it(e.cli.path.at(0)??``)===n}function lr(e,t){let n=or(e),r=n.filter(e=>e.required),i=n.filter(e=>!e.required);return[`cli: ${e.cli.command}`,`${e.method} ${e.path}`,`operationId: ${e.operationId}`,`resource: ${e.resource}`,`intent: ${e.intent}`,`scope: ${e.scope}`,`mutates: ${e.mutates}`,`destructive: ${e.destructive}`,`mcpTool: ${e.mcpTool??`unavailable (binary CLI operation)`}`,e.body.hasBody?`body: kind=${e.body.kind??`unknown`} required=${e.body.required} requiredPath=${e.body.requiredPath.join(`,`)}`:`body: none`,R(`required path flags`,r,`path`),R(`required query flags`,r,`query`),R(`required header flags`,r,`header`),R(`required body flags`,r,`body`),R(`optional path flags`,i,`path`),R(`optional query flags`,i,`query`),R(`optional header flags`,i,`header`),R(`optional body flags`,i,`body`),...hr(e,t),...ur(e.errorResponse),``,e.summary,e.description].filter(e=>e.length>0).join(`
|
|
4
4
|
`)}function ur(e){return e.length===0?[]:[`Errors:`,...e.map(({status:e,description:t})=>` ${e} ${t}`)]}var dr=[`-id`,`-slug`,`-url`],fr=[`--id`,`--slug`,`--url`],pr=`--from-file "<path>"`;function mr(e,t,n=f().bin[0]){let r=rr(t,n),i=r.find(t=>t.operationId===e);return i===void 0?[]:hr(i,r)}function hr(e,t){return[`example: ${[e.cli.command,..._r(e),`--data`].join(` `)}`,...gr(e,t)]}function gr(e,t){return or(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} ${yr(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===r.path.replace(/-exact$/u,``)),s=o?.flags.find(e=>e.optionKey===`name`),c=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0?[c]:[c,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${yr(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}function _r(e){let t=or(e).filter(e=>e.required),n=(t.length>0?t:vr(e)).map(yr);return(e.body.required||e.body.requiredPath.length>0)&&!t.some(e=>e.location===`body`)?[...n,pr]:n}function vr(e){let t=new Set;nt(t,e.resource);for(let n of dr)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 fr){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function yr(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}function R(e,t,n){let r=t.filter(e=>e.location===n);return`${e}: ${r.length===0?`none`:r.map(e=>e.name).join(` `)}`}function br(e,t=f().bin){let[n=``,...r]=e.trim().split(/\s+/u);return(t.includes(n)?r:[n,...r]).join(` `)}var xr=`dist/aventure-cli/command-catalog.compact.txt`,Sr=` · `,Cr=`-`;function wr(e=f().bin[0]){return A(Tr(k(Dt(import.meta.url)),e),xr)}function Tr(e,t){let n=e;for(;;){if(pt(A(n,`package.json`)))return n;let r=k(n);if(r===n)throw Error(`No package.json above ${e}; ${t} is not in a package layout.`);n=r}}function Er(e,t){let n=t.join(` `).trim();return n.length===0?e:{...e,q:e.q===void 0?n:`${e.q} ${n}`}}function Dr(e,t,n,r=f().bin[0]){let i=er(e,t,r);if(!i.ok||i.data===null){L({mode:n},i);return}kr({opts:e,mode:n,data:i.data,defaultFormat:`lines`,rendered:jr(i.data,Ar(e.format,`lines`)),summary:`Generated operation matches`})}function Or(e,t,n,r=f().bin[0]){let i=tr(e,t,r);if(!i.ok||i.data===null){L({mode:n},i);return}kr({opts:e,mode:n,data:i.data,defaultFormat:`usage`,rendered:Mr(i.data,Ar(e.format,`usage`)),summary:`Generated operation detail`})}function kr(e){let t=e.mode,n=Ar(e.opts.format,e.defaultFormat),r=e.opts.text===!0||e.opts.allFields===!0;if(e.opts.output===void 0&&r&&(n===`json`||n===`ndjson`)){L({mode:t},x(`--text or --all-fields cannot be combined with --format json or ndjson`,[`Omit the text flag for machine output, or use --format lines, compact, or text.`]));return}let i=e.opts.output===void 0&&t===`text`&&`count`in e.data&&e.data.count.returned===0&&(r||e.opts.format===void 0||n===`text`)?`No generated operations matched.`:e.rendered,a=i.endsWith(`
|
|
@@ -25,7 +25,7 @@ import{B as e,Bt as t,D as n,E as r,H as i,It as a,J as o,Lt as s,O as c,Q as l,
|
|
|
25
25
|
`).slice(-3).join(` | `);return x(`npm ${e.join(` `)} exited ${a.status}`,[t||`no stderr`])}return h(`npm ok`,a.stdout??``)}function eo(e,t,n){let r=e===null?``:` --prefix ${JSON.stringify(e.installPrefix)}`;return[`Finish by hand: npm uninstall -g${r} ${o}`,`then: npm install -g${r} ${t}@${n} --@aventurevc:registry=`]}function to(e,t,n){let r;try{let n=f(A(e,`lib`,`node_modules`,...t.split(`/`),`package.json`));r=A(e,`bin`,n.bin[0])}catch(e){return x(`updated ${t} verification failed: ${K(e)}`,[`invalid_package_metadata`])}let i=ut(process.execPath,[r,`--version`],{encoding:`utf8`});if(i.error)return x(`updated ${t} verification failed: ${i.error.message}`,[`spawn_error`]);let a=(i.stdout??``).trim();if(i.status!==0||a!==n){let e=(i.stderr??``).trim().split(`
|
|
26
26
|
`).slice(-3).join(` | `);return x(`updated ${t} verification expected ${n} but active bin reported ${a||`empty output`}`,[e||`active bin: ${r}`])}return h(`active CLI version verified`,a)}function no(e){let t=`${j}lib${j}node_modules${j}${e.name.replace(`/`,j)}`,n=e.packageRoot.lastIndexOf(t);return n<0?null:{installPrefix:e.packageRoot.slice(0,n)}}function ro(e,t){if(e.name!==`@aventurevc/mcp-server`)return{backup:[],backupDirectory:null};if(t===null)throw Error(`the running MCP package is not in a verifiable global npm prefix`);if(!e.entryPath.startsWith(`${e.packageRoot}${j}`))throw Error(`the running CLI entry is outside the MCP package root`);let n=e.bin.filter(e=>e===`aventure`||e===`aventure-cli`).flatMap(n=>{let r=A(t.installPrefix,`bin`,n),i=mt(r,{throwIfNoEntry:!1});if(i===void 0)return[];if(!i.isSymbolicLink())throw Error(`${r} is not a symlink`);let a;try{a=yt(r)}catch(e){throw Error(`${r} has a missing target`,{cause:e})}if(a!==e.entryPath)throw Error(`${r} is not owned by the running MCP CLI`);return{binPath:r,linkTarget:vt(r)}});if(n.length===0)return{backup:[],backupDirectory:null};let r=gt(A(t.installPrefix,`bin`,`.aventure-cli-update-`)),i=n.map(({binPath:e,linkTarget:t})=>({backupPath:A(r,dt(e)),binPath:e,linkTarget:t})),a=[];try{for(let e of i)if(bt(e.binPath,e.backupPath),a.push(e),vt(e.backupPath)!==e.linkTarget)throw Error(`${e.binPath} changed ownership while preparing the update`)}catch(e){let t=io({backup:a,backupDirectory:r},null);throw Error(`could not displace verified MCP CLI bins${t===null?``:`; restoration failed: ${t}`}`,{cause:e})}return{backup:a,backupDirectory:r}}function io(e,t){let n=[];for(let r of e.backup.toReversed())try{let e=mt(r.binPath,{throwIfNoEntry:!1});if(e!==void 0){if(!e.isSymbolicLink())throw Error(`${r.binPath} is not a symlink`);let n=A(k(r.binPath),vt(r.binPath));if(t===null||n!==t&&!n.startsWith(`${t}${j}`))throw Error(`${r.binPath} is not owned by the standalone CLI package`);St(r.binPath)}bt(r.backupPath,r.binPath)}catch(e){n.push(K(e))}if(e.backupDirectory!==null)try{xt(e.backupDirectory)}catch(e){n.push(K(e))}return n.length===0?null:n.join(`; `)}function ao(e){let t=[];for(let n of e.backup)try{St(n.backupPath)}catch(e){t.push(K(e))}if(e.backupDirectory!==null)try{xt(e.backupDirectory)}catch(e){t.push(K(e))}return t.length===0?null:t.join(`; `)}function K(e){return e instanceof Error?e.message:String(e)}function oo(){try{return Na()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}var so=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers its generated status operation`},{name:`auth`,purpose:`which credential scope materialized locally, never the secret`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}],co=`operationFingerprint`;function lo(e,t=f().bin[0]){D(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",...so.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable)`,`does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
|
|
27
27
|
`))).action(async function(e){let n=this.optsWithGlobals();n.environment!==void 0&&(process.env.API_ENV=n.environment),L({mode:E(e)},await uo(t))})}async function uo(e){let t=po(),n=mo(e),[r,i]=await Promise.all([ho(e),go(t,e)]),a=[n.check,r,i.check,await vo(e),wo(t,i.servedFingerprint,n.upgradeAvailable,e)],o={pass:fo(a,`pass`),fail:fo(a,`fail`),skip:fo(a,`skip`)},s=a.filter(e=>e.status===`fail`).map(e=>e.message),c={ok:s.length===0,check:a},l=[`doctor: ${o.pass} pass, ${o.fail} fail, ${o.skip} skip`,...a.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
28
|
-
`);return c.ok?h(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function fo(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function po(){return O.find(e=>e.intent===`status`&&e.resource===`status`)}function mo(e){let t=f(),n=Qa(t,`check`);if(!n.ok||n.data===null)return{check:q(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?q(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):q(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function ho(e){try{let{EntityDetailSchema:e}=await import(`./detail-
|
|
28
|
+
`);return c.ok?h(l,c,{counts:o}):{...x(l,s,{counts:o}),data:c}}function fo(e,t){return e.filter(e=>e.status===t).length}function q(e,t,n){return{name:e,status:t,message:n}}function po(){return O.find(e=>e.intent===`status`&&e.resource===`status`)}function mo(e){let t=f(),n=Qa(t,`check`);if(!n.ok||n.data===null)return{check:q(`cli-version`,`skip`,`Could not compare ${t.version} against the registry (${n.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:r,currentVersion:i,latestVersion:a,upgradeAvailable:o}=n.data;return{check:o?q(`cli-version`,`fail`,`Upgrade ${r} from ${i} to ${a}: run \`${e} update\`.`):q(`cli-version`,`pass`,`${r} ${i} matches the latest published release.`),upgradeAvailable:o}}async function ho(e){try{let{EntityDetailSchema:e}=await import(`./detail-BhrPZbmH.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return q(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return q(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${T(t)}.`)}}async function go(e,t){if(e===void 0)return{check:q(`api-host`,`skip`,`No status operation resolved from the generated catalog; fix the catalog check first.`),servedFingerprint:null};let n;try{n=b().host}catch(e){return{check:q(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${T(e)}.`),servedFingerprint:null}}let r=await g({method:e.method,path:e.path,auth:e.auth,responseFormat:`json`}).catch(e=>x(T(e)));return r.ok?{check:q(`api-host`,`pass`,`${e.method} ${e.path} answered at ${n}.`),servedFingerprint:_o(r.data)}:{check:q(`api-host`,`fail`,r.httpStatus===401?`Replace or unset the credential ${n} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} returned ${r.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${e.method} ${e.path} at ${n} returned ${r.summary}.`),servedFingerprint:null}}function _o(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t[co];return typeof n==`string`&&n.length>0?n:null}async function vo(e){let t=ke(),[n,r]=await Promise.all([yo(),bo()]);if(r.state===`unavailable`&&r.cause===`environment`)return q(`auth`,`fail`,`Fix the environment configuration first — ${r.summary}.`);let i=t.present;return!i&&n.state===`invalid`?q(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${n.summary}.`):!i&&n.state===`found`&&Ee(n.stored.credential)&&n.stored.credential.tokens.refresh_token===void 0?q(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`):!i&&r.state!==`found`&&n.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${l.authToken} through the environment — ${n.summary}.`):i||n.state===`found`||r.state===`found`?q(`auth`,`pass`,`Credential source available: ${xo(t,n,r)}.`):r.state===`unavailable`?q(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${l.authToken} through the environment — ${r.summary}.`):q(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${l.authToken} in the environment.`)}async function yo(){let e;try{e=Pe(b().host)}catch(e){return{state:`unavailable`,summary:T(e)}}return await Fe(e)}async function bo(){let e;try{e=Ve(b().host)}catch(e){return{state:`unavailable`,summary:T(e),cause:`environment`}}try{return await Be(e)}catch(e){return{state:`unavailable`,summary:T(e),cause:`storage`}}}function xo(e,t,n){return[Ta(e),`oauth=${Co(t)}`,`api-key=${So(n)}`].join(` `)}function So(e){if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let t=Ve(b().host);return`${e.stored.activation}${ua(t,e)}`}function Co(e){switch(e.state){case`found`:return Ee(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function wo(e,t,n,r){let i=O.length;if(e===void 0)return q(`catalog`,`fail`,`Regenerate the command catalog with \`make mcp-generate-contracts\` and reinstall: none of its ${i} operations is the status operation.`);if(t===null)return q(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${Ze}.`);if(t===`4ff75f56bd34c7c5`)return q(`catalog`,`pass`,`${i} generated operations match the set the API serves (${Ze}).`);let a=`This catalog describes a different operation set than the API serves (${Ze} vs ${t})`;return n===!0?q(`catalog`,`fail`,`${a}: run \`${r} update\`.`):q(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var To=B(V,`oauth`),Eo=[B(V,`start`),B(V,`poll`),B(V,`acknowledge`)],Do=B(V,`revoke`);function Oo(e,t=f().bin[0]){let n=Ao(e);lo(n,t);let r=[`${To.description} Default method: OAuth in your browser.`,`With --key: ${Eo.map(({description:e})=>e).join(` `)}`].join(`
|
|
29
29
|
`),i=async function(e){jo(this);let t=E(e);if(e.providers===!0){L({mode:t},await Po());return}L({mode:t},e.key===!0?await Gi({noBrowser:!e.browser,clientLabel:e.clientLabel}):await ct({noBrowser:!e.browser}))};D(ko(n,[To,...Eo],r)).action(i),D(ko(n,[Do],Do.description)).action(async function(e){jo(this),L({mode:E(e)},await Pi({forgetLocal:e.forgetLocal===!0}))}),D(n.command(`status`).summary(`Keep saved credentials current and report them with API build and uptime`).description([`Runs the same credential materialization every command runs, then reports:`,` - auth: whether AUTH_TOKEN was already set in this shell's environment`,` - oauth: the saved OAuth identity and access-token expiry for the selected API host;`,` an expired token is renewed with its refresh token and a token the sign-in service rejects is retired`,` - api-key: the saved aVenture API key, re-verified with aVenture sign-in and its cached metadata updated`,` - selected: the credential the next command sends`,` - providers: GET /v1/auth/providers (browser sign-in and the CLI OAuth client)`,` - api: running CLI package version plus GET /info build metadata`,` - system: GET /v1/status response (uptime SLA)`,``,`Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.`,`--verify read|write additionally runs a live permission probe for that scope; it does not`,`execute or authorize an arbitrary API operation.`].join(`
|
|
30
30
|
`)).addOption(new s(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){jo(this),L({mode:E(e)},await Mo(t,e.verify))}),n.command(`token`).summary(`Print the bearer token the next command sends`).description([`Runs the same credential materialization every command runs, then prints the selected`,`bearer token alone on stdout: ${l.authToken} when set, otherwise the saved OAuth`,`access token (renewed when expired) or the saved aVenture API key.`,`Use it where another client needs this CLI's sign-in, such as an MCP client's header helper.`].join(`
|
|
31
31
|
`)).action(async function(){jo(this);let e=await na(t),n=process.env[l.authToken]?.trim();if(e.failure===null&&n!==void 0&&n.length>0){process.stdout.write(`${n}\n`);return}L({mode:`text`},e.failure===null?Bo(`auth token: no credentials resolved`,null,t,{oauth:!0,apiKey:!0}):x(`auth token: ${e.failure}`))})}function ko(e,t,n){let[r]=t,i=e.command(r.command.slice(r.command.indexOf(` `)+1)).summary(r.summary).description(n),a=new Set;for(let e of t)for(let t of[...e.bodyOption,...e.localOption])a.has(t.flag)||(a.add(t.flag),`required`in t&&t.required?i.requiredOption(t.flag,t.description):i.option(t.flag,t.description));return i}function Ao(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${To.command}\`: ${To.summary}; \`--key\` ${Eo[0].summary.toLowerCase()}.`,`\`${Do.command}\`: ${Do.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build and uptime.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,D as t,O as n,_ as r,a as i,c as a,f as o,k as s,l as c,n as l,p as u,t as d,v as f}from"./person-owner-BqBLyw4S.js";var p=i([`domicile`,`dominant`,`origin`]),m=f({endDate:n().nullish(),id:o(),isCurrent:c(),role:p.nullish(),startDate:n().nullish()}),h=f({id:o().nullish(),name:e()}),g=f({countryCodeChar2:e().nullish(),countryCodeChar3:e().nullish(),id:o().nullish(),name:e(),unRegion:e().nullish(),unSubregion:e().nullish()}),_=f({id:o().nullish(),name:e(),stateAbbrev:e().nullish()}),v=f({address:o().nullish(),addressLine1:e().nullish(),addressLine2:e().nullish(),association:a(m).optional(),city:h.nullish(),country:g.nullish(),countryAbbrev:e().nullish(),createdAt:s({offset:!0}).nullish(),fullAddress:e().nullish(),id:o().nullish(),isCurrent:c().nullish(),isHq:c().nullish(),isPrimary:c().nullish(),latitude:r().nullish(),longitude:r().nullish(),postalCode:e().nullish(),state:_.nullish(),stateAbbrev:e().nullish(),street:e().nullish(),updatedAt:s({offset:!0}).nullish()}),y=f({creatable:c(),isCurrent:c().nullish(),isPrimary:c().nullish(),name:e().max(255),writable:c()}),b=u(y,f({bucket:e().nullish(),classificationId:o().nullish(),creatable:c(),createdAt:s({offset:!0}).nullish(),id:o(),isCurrent:c().nullish(),isPrimary:c().nullish(),name:e().max(255),slug:e().regex(/^[a-z0-9_-]+$/).max(255).nullish(),type:e(),updatedAt:s({offset:!0}).nullish(),writable:c()})),x=u(y,f({category:e(),code:o().nullish(),creatable:c(),createdAt:s({offset:!0}).nullish(),entityClassificationId:o().nullish(),id:o(),isCurrent:c().nullish(),isPrimary:c().nullish(),level:o().nullish(),name:e().max(255),updatedAt:s({offset:!0}).nullish(),writable:c()})),S=f({geoLocationExposure:a(b).default([]).optional(),industry:a(b).default([]).optional(),mainProduct:a(b).default([]).optional(),standardizedClassification:a(x).default([]).optional(),tag:a(b).default([]).optional(),typeCustomer:a(b).default([]).optional(),typeModel:a(b).default([]).optional(),typeOwnership:a(b).default([]).optional(),typeRevenue:a(b).default([]).optional(),typeTechnologyUsed:a(b).default([]).optional()}),C=i(`Angel.Pre-Seed.Seed.Series A.Series B.Series C.Series D.Series E.Series F.Series G.Series H.Series I.Series J.Series K.Series L.Series M.Series N.Series O.Series P.Series Q.Series R.Series S.Series T.Series U.Series V.Series W.Series X.Series Y.Series Z.Investment Firm.Fund.Nonprofit.Government.Public.Acquired.Acquired Subsidiary`.split(`.`)),w=f({currency:e().nullish(),fundingRoundCount:o(),investorCount:o(),latestValuation:r().nullish(),mostRecentAmount:r().nullish(),mostRecentDate:n().nullish(),stage:C.nullish(),totalRaised:r()}),T=f({expanded:e().nullish(),generatedDescription:e().nullish(),short:e().nullish()}),ee=i([`cloudflare`,`akamai`,`fastly`,`awsCloudfront`,`vercel`,`netlify`,`sucuri`,`incapsula`,`bunny`,`keycdn`,`cdn77`,`gcore`,`cdnetworks`,`azureCdn`,`leaseweb`,`digitalocean`,`stackpath`,`googlecloudCdn`,`none`,`unknown`]),te=i([`static`,`jsRequired`,`jsEnhanced`]),ne=i(`website.linkedin.twitter.github.facebook.instagram.tiktok.youtube.subreddit.forum.documentation.support.statuspage.changelog.roadmap.discord.crunchbase.wellfound.angellist.glassdoor.theorg.ycombinator.wikipedia.pitchbook.morningstar.bloomberg.nyse.nasdaq.g2.producthunt.trustpilot.alternativeto.gartnerpeerinsights.getapp.sourceforge.appstore.googleplay.capterra.trustradius.hubspotmarketplace.slackappdirectory.awsmarketplace.salesforceappexchange.chromewebstore.vscodemarketplace.npm.pypi.maven.dockerhub.homebrew.crates.huggingface`.split(`.`)),E=f({crawlCdnProvider:ee.nullish(),crawlRenderMode:te.nullish(),createdAt:s({offset:!0}).nullish(),id:o().nullish(),isCurrent:c().nullish(),isPrimary:c().nullish(),owner:d.nullish(),sourceId:e().nullish(),status:e().nullish(),statusChecked:s({offset:!0}).nullish(),updatedAt:s({offset:!0}).nullish(),url:e(),urlType:ne}),D=f({address:a(v),classification:S,fundingDetail:w.nullish(),text:T,urlLink:a(E)}),O=f({isMonogram:c(),logo:e().nullish(),logoSquare:e().nullish()}),k=i([`alternativeDba`,`relatedLegal`]),A=f({displayable:c().nullish(),name:e(),type:k.nullish()}),j=f({hasAcquisitions:c().default(!1).optional(),hasAnalysis:c(),hasEmployees:c(),hasFundraising:c(),hasNews:c(),productServiceSlug:a(e())}),M=f({defaultCurrency:e().nullish(),foundedYear:o().nullish(),id:t(),image:O,lastModifiedAt:s({offset:!0}).nullish(),nameAlias:a(A),nameBrand:e(),nameLegal:e().nullish(),operatingStatus:e().nullish(),publicId:e().regex(/^e[0-9A-Za-z]{11}$/).nullish(),publicUrl:e().nullish(),sitemap:j.nullish(),slug:e().regex(/^[a-z0-9_-]+$/).max(255),typeRecord:l,updatedAt:s({offset:!0}).nullish()}),N=f({core:M,fundingDetail:w.nullish()}),P=i([`High`,`Medium`,`Low`,`Verified`]),F=i([`direct`,`managedFund`]),I=f({round:e()}),L=f({amountInvested:r().nullish(),attributionType:F,beneficialEntityId:t().nullish(),fundManagerRelationshipId:o().nullish(),joinId:t(),leadInvestor:c(),recordedEntityId:t().nullish(),round:I.nullish(),transactionId:t()}),R=f({amountRaised:r().int().nullish(),createdAt:s({offset:!0}).nullish(),currency:e().nullish(),dataConfidence:P.nullish(),dateAnnounced:s({offset:!0}).nullish(),dateFundingComplete:s({offset:!0}).nullish(),dateInvestorExit:s({offset:!0}).nullish(),entity:N.nullish(),id:t(),investorAttribution:L.nullish(),investorCount:o().nullish(),round:e().nullish(),sourceAttribution:a(L),updatedAt:s({offset:!0}).nullish(),valuationPostMoney:r().int().nullish(),valuationPreMoney:r().int().nullish()}),z=f({fundingStage:C.nullish(),ownership:a(e()),pricingModel:a(e()),sellsTo:a(e()),totalRaised:r().nullish(),website:e().nullish()}),B=f({
|
|
1
|
+
import{C as e,D as t,O as n,_ as r,a as i,c as a,f as o,k as s,l as c,n as l,p as u,t as d,v as f}from"./person-owner-BqBLyw4S.js";var p=i([`domicile`,`dominant`,`origin`]),m=f({endDate:n().nullish(),id:o(),isCurrent:c(),role:p.nullish(),startDate:n().nullish()}),h=f({id:o().nullish(),name:e()}),g=f({countryCodeChar2:e().nullish(),countryCodeChar3:e().nullish(),id:o().nullish(),name:e(),unRegion:e().nullish(),unSubregion:e().nullish()}),_=f({id:o().nullish(),name:e(),stateAbbrev:e().nullish()}),v=f({address:o().nullish(),addressLine1:e().nullish(),addressLine2:e().nullish(),association:a(m).optional(),city:h.nullish(),country:g.nullish(),countryAbbrev:e().nullish(),createdAt:s({offset:!0}).nullish(),fullAddress:e().nullish(),id:o().nullish(),isCurrent:c().nullish(),isHq:c().nullish(),isPrimary:c().nullish(),latitude:r().nullish(),longitude:r().nullish(),postalCode:e().nullish(),state:_.nullish(),stateAbbrev:e().nullish(),street:e().nullish(),updatedAt:s({offset:!0}).nullish()}),y=f({creatable:c(),isCurrent:c().nullish(),isPrimary:c().nullish(),name:e().max(255),writable:c()}),b=u(y,f({bucket:e().nullish(),classificationId:o().nullish(),creatable:c(),createdAt:s({offset:!0}).nullish(),id:o(),isCurrent:c().nullish(),isPrimary:c().nullish(),name:e().max(255),slug:e().regex(/^[a-z0-9_-]+$/).max(255).nullish(),type:e(),updatedAt:s({offset:!0}).nullish(),writable:c()})),x=u(y,f({category:e(),code:o().nullish(),creatable:c(),createdAt:s({offset:!0}).nullish(),entityClassificationId:o().nullish(),id:o(),isCurrent:c().nullish(),isPrimary:c().nullish(),level:o().nullish(),name:e().max(255),updatedAt:s({offset:!0}).nullish(),writable:c()})),S=f({geoLocationExposure:a(b).default([]).optional(),industry:a(b).default([]).optional(),mainProduct:a(b).default([]).optional(),standardizedClassification:a(x).default([]).optional(),tag:a(b).default([]).optional(),typeCustomer:a(b).default([]).optional(),typeModel:a(b).default([]).optional(),typeOwnership:a(b).default([]).optional(),typeRevenue:a(b).default([]).optional(),typeTechnologyUsed:a(b).default([]).optional()}),C=i(`Angel.Pre-Seed.Seed.Series A.Series B.Series C.Series D.Series E.Series F.Series G.Series H.Series I.Series J.Series K.Series L.Series M.Series N.Series O.Series P.Series Q.Series R.Series S.Series T.Series U.Series V.Series W.Series X.Series Y.Series Z.Investment Firm.Fund.Nonprofit.Government.Public.Acquired.Acquired Subsidiary`.split(`.`)),w=f({currency:e().nullish(),fundingRoundCount:o(),investorCount:o(),latestValuation:r().nullish(),mostRecentAmount:r().nullish(),mostRecentDate:n().nullish(),stage:C.nullish(),totalRaised:r()}),T=f({expanded:e().nullish(),generatedDescription:e().nullish(),short:e().nullish()}),ee=i([`cloudflare`,`akamai`,`fastly`,`awsCloudfront`,`vercel`,`netlify`,`sucuri`,`incapsula`,`bunny`,`keycdn`,`cdn77`,`gcore`,`cdnetworks`,`azureCdn`,`leaseweb`,`digitalocean`,`stackpath`,`googlecloudCdn`,`none`,`unknown`]),te=i([`static`,`jsRequired`,`jsEnhanced`]),ne=i(`website.linkedin.twitter.github.facebook.instagram.tiktok.youtube.subreddit.forum.documentation.support.statuspage.changelog.roadmap.discord.crunchbase.wellfound.angellist.glassdoor.theorg.ycombinator.wikipedia.pitchbook.morningstar.bloomberg.nyse.nasdaq.g2.producthunt.trustpilot.alternativeto.gartnerpeerinsights.getapp.sourceforge.appstore.googleplay.capterra.trustradius.hubspotmarketplace.slackappdirectory.awsmarketplace.salesforceappexchange.chromewebstore.vscodemarketplace.npm.pypi.maven.dockerhub.homebrew.crates.huggingface`.split(`.`)),E=f({crawlCdnProvider:ee.nullish(),crawlRenderMode:te.nullish(),createdAt:s({offset:!0}).nullish(),id:o().nullish(),isCurrent:c().nullish(),isPrimary:c().nullish(),owner:d.nullish(),sourceId:e().nullish(),status:e().nullish(),statusChecked:s({offset:!0}).nullish(),updatedAt:s({offset:!0}).nullish(),url:e(),urlType:ne}),D=f({address:a(v),classification:S,fundingDetail:w.nullish(),text:T,urlLink:a(E)}),O=f({isMonogram:c(),logo:e().nullish(),logoSquare:e().nullish()}),k=i([`alternativeDba`,`relatedLegal`]),A=f({displayable:c().nullish(),name:e(),type:k.nullish()}),j=f({hasAcquisitions:c().default(!1).optional(),hasAnalysis:c(),hasEmployees:c(),hasFundraising:c(),hasNews:c(),productServiceSlug:a(e())}),M=f({defaultCurrency:e().nullish(),foundedYear:o().nullish(),id:t(),image:O,lastModifiedAt:s({offset:!0}).nullish(),nameAlias:a(A),nameBrand:e(),nameLegal:e().nullish(),operatingStatus:e().nullish(),publicId:e().regex(/^e[0-9A-Za-z]{11}$/).nullish(),publicUrl:e().nullish(),sitemap:j.nullish(),slug:e().regex(/^[a-z0-9_-]+$/).max(255),typeRecord:l,updatedAt:s({offset:!0}).nullish()}),N=f({core:M,fundingDetail:w.nullish()}),P=i([`High`,`Medium`,`Low`,`Verified`]),F=i([`direct`,`managedFund`]),I=f({round:e()}),L=f({amountInvested:r().nullish(),attributionType:F,beneficialEntityId:t().nullish(),fundManagerRelationshipId:o().nullish(),joinId:t(),leadInvestor:c(),recordedEntityId:t().nullish(),round:I.nullish(),transactionId:t()}),R=f({amountRaised:r().int().nullish(),createdAt:s({offset:!0}).nullish(),currency:e().nullish(),dataConfidence:P.nullish(),dateAnnounced:s({offset:!0}).nullish(),dateFundingComplete:s({offset:!0}).nullish(),dateInvestorExit:s({offset:!0}).nullish(),entity:N.nullish(),id:t(),investorAttribution:L.nullish(),investorCount:o().nullish(),round:e().nullish(),sourceAttribution:a(L),updatedAt:s({offset:!0}).nullish(),valuationPostMoney:r().int().nullish(),valuationPreMoney:r().int().nullish()}),z=f({fundingStage:C.nullish(),ownership:a(e()),pricingModel:a(e()),sellsTo:a(e()),totalRaised:r().nullish(),website:e().nullish()}),B=f({lastFetchedAt:s({offset:!0}).nullish(),publishedAt:s({offset:!0}).nullish(),recordedAt:s({offset:!0}),sourceDetail:e()}),V=f({asOf:n().nullish(),comparisonSignals:z.nullish(),createdAt:s({offset:!0}).nullish(),detail:e().nullish(),entity:M,id:o().nullish(),isCurrent:c().nullish(),isPrimary:c().nullish(),publicSource:B.nullish(),get relationship(){return a(V)},relationshipType:e(),sourceEntityId:t().nullish(),targetEntityId:t().nullish(),updatedAt:s({offset:!0}).nullish()}),H=V,U=f({accelerator:M,acceleratorName:e(),asOfDate:s({offset:!0}),batch:e().nullish(),id:e(),program:e().nullish(),status:e().nullish()}),W=i([`text`,`numeric`,`monetary`,`percentage`,`date`]),G=i([`pastDue`,`withinThreeMonths`,`threeToSixMonths`,`sixToTwelveMonths`,`twelveToTwentyFourMonths`,`beyondTwoYears`]),re=f({asOfDate:s({offset:!0}),bucket:G,monthsFromNow:o(),targetDate:s({offset:!0})}),K=f({asOfDate:s({offset:!0}).nullish(),derivedRange:re.nullish(),discreteValue:r().nullish(),entityId:t(),id:o(),publicSource:B.nullish(),textValue:e().nullish(),typeResearchDetail:e(),updatedAt:s({offset:!0}).nullish(),valueResearchDetail:e().nullish(),valueType:W}),q=f({characterCount:o(),meetsRequirements:c(),violation:a(e()),wordCount:o()}),J=f({compliance:q.nullish(),entityId:t(),id:o(),publicSource:B.nullish(),text:e(),textType:e(),updatedAt:s({offset:!0}).nullish()}),Y=f({acceleratorParticipation:a(U),detail:a(K),snippet:a(J)}),X=f({author:e().nullish(),category:e().nullish(),createdAt:s({offset:!0}).nullish(),excerpt:e().nullish(),externalNewsArticle:c().nullish(),id:o(),newsImageThumbnail:e().nullish(),newsUrlOriginal:e().nullish(),publication:e().nullish(),publishedAt:s({offset:!0}).nullish(),slug:e().regex(/^[a-z0-9_-]+$/).max(255).nullish(),title:e(),updatedAt:s({offset:!0}).nullish()}),ie=i([`nickname`,`maidenName`,`formerName`,`stageName`]),Z=f({displayable:c().nullish(),name:e(),type:ie.nullish()}),Q=f({isMonogram:c(),picture:e().nullish()}),ae=f({associationId:o(),endDate:s({offset:!0}).nullish(),entityAddress:a(v),entityId:t(),entityLogo:O,entityName:e().nullish(),entityOperatingStatus:e().nullish(),entitySlug:e().regex(/^[a-z0-9_-]+$/).max(255),entityType:l.nullish(),entityUrlLink:a(E),isCurrent:c().nullish(),personAddress:a(v),personId:t(),personImage:Q,personName:e(),personSlug:e().regex(/^[a-z0-9_-]+$/).max(255),personUrlLink:a(E),score:o().nullish(),startDate:s({offset:!0}).nullish(),titleFunction:e().nullish(),titleId:o().nullish(),titleLevel:e().nullish(),titleName:e().nullish()}),oe=f({address:a(v),urlLink:a(E)}),se=f({amountRaised:r().nullish(),dateAnnounced:s({offset:!0}).nullish(),id:t(),image:O,investorCount:o().nullish(),nameBrand:e(),round:e().nullish(),status:e().nullish(),valuationPostMoney:r().nullish()}),ce=f({entity:M}),le=f({amount:r().nullish(),company:ce,date:s({offset:!0}).nullish(),fundraiseTransaction:se.nullish(),fundraiseTransactionId:t(),id:e(),investmentDate:s({offset:!0}),investorAttribution:L.nullish(),round:e().nullish()}),$=i([`entity`,`person`,`newsArticle`,`blogPost`,`text`,`classificationTag`,`classificationCode`,`product`,`service`,`agentHelpDoc`]),ue=f({computedAt:s({offset:!0}),cosineDistance:r(),cosineScore:r(),modelVersion:e(),rank:o(),sourceHash:e(),sourceId:e(),sourceJson:e(),sourceText:e(),sourceType:$}),de=f({createdAt:s({offset:!0}).nullish(),gender:e().nullish(),id:t(),image:Q,lastModifiedAt:s({offset:!0}).nullish(),nameAlias:a(Z),nameFirst:e().nullish(),nameFull:e(),nameLast:e().nullish(),nameMiddle:e().nullish(),nickname:e().nullish(),publicId:e().regex(/^p[0-9A-Za-z]{12}$/).nullish(),semanticMatch:ue.nullish(),slug:e().regex(/^[a-z0-9_-]+$/).max(255),suffix:e().nullish(),text:T,updatedAt:s({offset:!0}).nullish()}),fe=f({articleCount:o().nullish(),association:a(ae),core:de,enrichment:oe,investment:a(le),nameAlias:a(Z)}),pe=i([`ein`,`secCik`,`ticker`,`lei`,`duns`,`isin`,`cusip`,`crd`,`orcid`]),me=f({createdAt:s({offset:!0}),id:o(),identifier:e(),idType:pe,owner:d,source:e().nullish(),updatedAt:s({offset:!0})}),he=f({core:M,enrichment:D,fundraiseRound:a(R),newsArticle:a(X),person:a(fe),publicUrl:e().nullish(),relationship:a(H),research:Y,sitemap:j,uniqueId:a(me)});export{he as EntityDetailSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./auth-ft5-pPnc.js";import{C as t,T as n,_ as r,a as i,b as ee,c as a,d as te,g as o,h as s,k as ne,l as c,o as re,p as ie,u as ae,v as l,w as u,x as d,y as f}from"./person-owner-BqBLyw4S.js";var oe=l({clerkPublishableKey:t().nullish(),oauthClient:e.nullish()}),se=`2025-11-25`,ce=`2025-03-26`,le=[se,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],ue=`io.modelcontextprotocol/related-task`,p=ae(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),de=u([t(),r().int()]),fe=t();o({ttl:r().optional(),pollInterval:r().optional()});var pe=l({ttl:r().optional()}),me=l({taskId:t()}),m=o({progressToken:de.optional(),[ue]:me.optional()}),h=l({_meta:m.optional()}),g=h.extend({task:pe.optional()}),he=e=>g.safeParse(e).success,_=l({method:t(),params:h.loose().optional()}),v=l({_meta:m.optional()}),y=l({method:t(),params:v.loose().optional()}),b=o({_meta:m.optional()}),x=u([t(),r().int()]),ge=l({jsonrpc:s(`2.0`),id:x,..._.shape}).strict(),_e=e=>ge.safeParse(e).success,ve=l({jsonrpc:s(`2.0`),...y.shape}).strict(),ye=e=>ve.safeParse(e).success,S=l({jsonrpc:s(`2.0`),id:x,result:b}).strict(),be=e=>S.safeParse(e).success,C;(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`})(C||={});var w=l({jsonrpc:s(`2.0`),id:x.optional(),error:l({code:r().int(),message:t(),data:n().optional()})}).strict(),xe=e=>w.safeParse(e).success,Se=u([ge,ve,S,w]);u([S,w]);var T=b.strict(),Ce=v.extend({requestId:x.optional(),reason:t().optional()}),E=y.extend({method:s(`notifications/cancelled`),params:Ce}),we=l({src:t(),mimeType:t().optional(),sizes:a(t()).optional(),theme:i([`light`,`dark`]).optional()}),D=l({icons:a(we).optional()}),O=l({name:t(),title:t().optional()}),Te=O.extend({...O.shape,...D.shape,version:t(),websiteUrl:t().optional(),description:t().optional()}),Ee=ie(l({applyDefaults:c().optional()}),d(t(),n())),De=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ie(l({form:Ee.optional(),url:p.optional()}),d(t(),n()).optional())),Oe=o({list:p.optional(),cancel:p.optional(),requests:o({sampling:o({createMessage:p.optional()}).optional(),elicitation:o({create:p.optional()}).optional()}).optional()}),ke=o({list:p.optional(),cancel:p.optional(),requests:o({tools:o({call:p.optional()}).optional()}).optional()}),Ae=l({experimental:d(t(),p).optional(),sampling:l({context:p.optional(),tools:p.optional()}).optional(),elicitation:De.optional(),roots:l({listChanged:c().optional()}).optional(),tasks:Oe.optional(),extensions:d(t(),p).optional()}),je=h.extend({protocolVersion:t(),capabilities:Ae,clientInfo:Te}),k=_.extend({method:s(`initialize`),params:je}),Me=e=>k.safeParse(e).success,Ne=l({experimental:d(t(),p).optional(),logging:p.optional(),completions:p.optional(),prompts:l({listChanged:c().optional()}).optional(),resources:l({subscribe:c().optional(),listChanged:c().optional()}).optional(),tools:l({listChanged:c().optional()}).optional(),tasks:ke.optional(),extensions:d(t(),p).optional()}),Pe=b.extend({protocolVersion:t(),capabilities:Ne,serverInfo:Te,instructions:t().optional()}),Fe=y.extend({method:s(`notifications/initialized`),params:v.optional()}),A=_.extend({method:s(`ping`),params:h.optional()}),Ie=l({progress:r(),total:f(r()),message:f(t())}),Le=l({...v.shape,...Ie.shape,progressToken:de}),j=y.extend({method:s(`notifications/progress`),params:Le}),Re=h.extend({cursor:fe.optional()}),M=_.extend({params:Re.optional()}),N=b.extend({nextCursor:fe.optional()}),ze=i([`working`,`input_required`,`completed`,`failed`,`cancelled`]),P=l({taskId:t(),status:ze,ttl:u([r(),re()]),createdAt:t(),lastUpdatedAt:t(),pollInterval:f(r()),statusMessage:f(t())}),F=b.extend({task:P}),Be=v.merge(P),I=y.extend({method:s(`notifications/tasks/status`),params:Be}),L=_.extend({method:s(`tasks/get`),params:h.extend({taskId:t()})}),R=b.merge(P),z=_.extend({method:s(`tasks/result`),params:h.extend({taskId:t()})});b.loose();var B=M.extend({method:s(`tasks/list`)}),V=N.extend({tasks:a(P)}),H=_.extend({method:s(`tasks/cancel`),params:h.extend({taskId:t()})}),Ve=b.merge(P),He=l({uri:t(),mimeType:f(t()),_meta:d(t(),n()).optional()}),Ue=He.extend({text:t()}),U=t().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),We=He.extend({blob:U}),W=i([`user`,`assistant`]),G=l({audience:a(W).optional(),priority:r().min(0).max(1).optional(),lastModified:ne({offset:!0}).optional()}),Ge=l({...O.shape,...D.shape,uri:t(),description:f(t()),mimeType:f(t()),size:f(r()),annotations:G.optional(),_meta:f(o({}))}),Ke=l({...O.shape,...D.shape,uriTemplate:t(),description:f(t()),mimeType:f(t()),annotations:G.optional(),_meta:f(o({}))}),qe=M.extend({method:s(`resources/list`)}),Je=N.extend({resources:a(Ge)}),Ye=M.extend({method:s(`resources/templates/list`)}),Xe=N.extend({resourceTemplates:a(Ke)}),K=h.extend({uri:t()}),Ze=K,Qe=_.extend({method:s(`resources/read`),params:Ze}),$e=b.extend({contents:a(u([Ue,We]))}),et=y.extend({method:s(`notifications/resources/list_changed`),params:v.optional()}),tt=K,nt=_.extend({method:s(`resources/subscribe`),params:tt}),rt=K,it=_.extend({method:s(`resources/unsubscribe`),params:rt}),at=v.extend({uri:t()}),ot=y.extend({method:s(`notifications/resources/updated`),params:at}),st=l({name:t(),description:f(t()),required:f(c())}),ct=l({...O.shape,...D.shape,description:f(t()),arguments:f(a(st)),_meta:f(o({}))}),lt=M.extend({method:s(`prompts/list`)}),ut=N.extend({prompts:a(ct)}),dt=h.extend({name:t(),arguments:d(t(),t()).optional()}),ft=_.extend({method:s(`prompts/get`),params:dt}),q=l({type:s(`text`),text:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),J=l({type:s(`image`),data:U,mimeType:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),Y=l({type:s(`audio`),data:U,mimeType:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),pt=l({type:s(`tool_use`),name:t(),id:t(),input:d(t(),n()),_meta:d(t(),n()).optional()}),mt=l({type:s(`resource`),resource:u([Ue,We]),annotations:G.optional(),_meta:d(t(),n()).optional()}),ht=Ge.extend({type:s(`resource_link`)}),X=u([q,J,Y,ht,mt]),gt=l({role:W,content:X}),_t=b.extend({description:t().optional(),messages:a(gt)}),vt=y.extend({method:s(`notifications/prompts/list_changed`),params:v.optional()}),yt=l({title:t().optional(),readOnlyHint:c().optional(),destructiveHint:c().optional(),idempotentHint:c().optional(),openWorldHint:c().optional()}),bt=l({taskSupport:i([`required`,`optional`,`forbidden`]).optional()}),xt=l({...O.shape,...D.shape,description:t().optional(),inputSchema:l({type:s(`object`),properties:d(t(),p).optional(),required:a(t()).optional()}).catchall(n()),outputSchema:l({type:s(`object`),properties:d(t(),p).optional(),required:a(t()).optional()}).catchall(n()).optional(),annotations:yt.optional(),execution:bt.optional(),_meta:d(t(),n()).optional()}),St=M.extend({method:s(`tools/list`)}),Ct=N.extend({tools:a(xt)}),Z=b.extend({content:a(X).default([]),structuredContent:d(t(),n()).optional(),isError:c().optional()});Z.or(b.extend({toolResult:n()}));var wt=g.extend({name:t(),arguments:d(t(),n()).optional()}),Tt=_.extend({method:s(`tools/call`),params:wt}),Et=y.extend({method:s(`notifications/tools/list_changed`),params:v.optional()});l({autoRefresh:c().default(!0),debounceMs:r().int().nonnegative().default(300)});var Q=i([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Dt=h.extend({level:Q}),Ot=_.extend({method:s(`logging/setLevel`),params:Dt}),kt=v.extend({level:Q,logger:t().optional(),data:n()}),At=y.extend({method:s(`notifications/message`),params:kt}),jt=l({name:t().optional()}),Mt=l({hints:a(jt).optional(),costPriority:r().min(0).max(1).optional(),speedPriority:r().min(0).max(1).optional(),intelligencePriority:r().min(0).max(1).optional()}),Nt=l({mode:i([`auto`,`required`,`none`]).optional()}),Pt=l({type:s(`tool_result`),toolUseId:t().describe(`The unique identifier for the corresponding tool call.`),content:a(X).default([]),structuredContent:l({}).loose().optional(),isError:c().optional(),_meta:d(t(),n()).optional()}),Ft=te(`type`,[q,J,Y]),$=te(`type`,[q,J,Y,pt,Pt]),It=l({role:W,content:u([$,a($)]),_meta:d(t(),n()).optional()}),Lt=g.extend({messages:a(It),modelPreferences:Mt.optional(),systemPrompt:t().optional(),includeContext:i([`none`,`thisServer`,`allServers`]).optional(),temperature:r().optional(),maxTokens:r().int(),stopSequences:a(t()).optional(),metadata:p.optional(),tools:a(xt).optional(),toolChoice:Nt.optional()}),Rt=_.extend({method:s(`sampling/createMessage`),params:Lt}),zt=b.extend({model:t(),stopReason:f(i([`endTurn`,`stopSequence`,`maxTokens`]).or(t())),role:W,content:Ft}),Bt=b.extend({model:t(),stopReason:f(i([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(t())),role:W,content:u([$,a($)])}),Vt=l({type:s(`boolean`),title:t().optional(),description:t().optional(),default:c().optional()}),Ht=l({type:s(`string`),title:t().optional(),description:t().optional(),minLength:r().optional(),maxLength:r().optional(),format:i([`email`,`uri`,`date`,`date-time`]).optional(),default:t().optional()}),Ut=l({type:i([`number`,`integer`]),title:t().optional(),description:t().optional(),minimum:r().optional(),maximum:r().optional(),default:r().optional()}),Wt=l({type:s(`string`),title:t().optional(),description:t().optional(),enum:a(t()),default:t().optional()}),Gt=l({type:s(`string`),title:t().optional(),description:t().optional(),oneOf:a(l({const:t(),title:t()})),default:t().optional()}),Kt=l({type:s(`string`),title:t().optional(),description:t().optional(),enum:a(t()),enumNames:a(t()).optional(),default:t().optional()}),qt=u([Wt,Gt]),Jt=l({type:s(`array`),title:t().optional(),description:t().optional(),minItems:r().optional(),maxItems:r().optional(),items:l({type:s(`string`),enum:a(t())}),default:a(t()).optional()}),Yt=l({type:s(`array`),title:t().optional(),description:t().optional(),minItems:r().optional(),maxItems:r().optional(),items:l({anyOf:a(l({const:t(),title:t()}))}),default:a(t()).optional()}),Xt=u([Jt,Yt]),Zt=u([Kt,qt,Xt]),Qt=u([Zt,Vt,Ht,Ut]),$t=g.extend({mode:s(`form`).optional(),message:t(),requestedSchema:l({type:s(`object`),properties:d(t(),Qt),required:a(t()).optional()})}),en=g.extend({mode:s(`url`),message:t(),elicitationId:t(),url:t().url()}),tn=u([$t,en]),nn=_.extend({method:s(`elicitation/create`),params:tn}),rn=v.extend({elicitationId:t()}),an=y.extend({method:s(`notifications/elicitation/complete`),params:rn}),on=b.extend({action:i([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,d(t(),u([t(),r(),c(),a(t())])).optional())}),sn=l({type:s(`ref/resource`),uri:t()}),cn=l({type:s(`ref/prompt`),name:t()}),ln=h.extend({ref:u([cn,sn]),argument:l({name:t(),value:t()}),context:l({arguments:d(t(),t()).optional()}).optional()}),un=_.extend({method:s(`completion/complete`),params:ln});function dn(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function fn(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var pn=b.extend({completion:o({values:a(t()).max(100),total:f(r().int()),hasMore:f(c())})}),mn=l({uri:t().startsWith(`file://`),name:t().optional(),_meta:d(t(),n()).optional()}),hn=_.extend({method:s(`roots/list`),params:h.optional()}),gn=b.extend({roots:a(mn)}),_n=y.extend({method:s(`notifications/roots/list_changed`),params:v.optional()});u([A,k,un,Ot,ft,lt,qe,Ye,Qe,nt,it,Tt,St,L,z,B,H]),u([E,j,Fe,_n,I]),u([T,zt,Bt,on,gn,R,V,F]),u([A,Rt,nn,hn,L,z,B,H]),u([E,j,At,ot,et,Et,vt,I,an]),u([T,Pe,pn,_t,ut,Je,Xe,$e,Z,Ct,R,V,F]);var vn=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===C.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new yn(e.elicitations,n)}return new e(t,n,r)}},yn=class extends vn{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(C.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},bn=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function xn(e){return(await bn).getRandomValues(new Uint8Array(e))}async function Sn(e){let t=``;for(;t.length<e;){let n=await xn(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Cn(e){return await Sn(e)}async function wn(e){let t=await(await bn).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Tn(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Cn(e);return{code_verifier:t,code_challenge:await wn(t)}}export{Q as A,fn as B,lt as C,B as D,gn as E,Qe as F,be as G,xe as H,le as I,he as K,Ot as L,A as M,j as N,V as O,ue as P,I as R,se as S,qe as T,ye as U,Me as V,_e as W,L as _,Ve as a,Fe as b,zt as c,ce as d,on as f,z as g,ft as h,H as i,vn as j,St as k,Bt as l,C as m,Tt as n,E as o,T as p,oe as q,Z as r,un as s,Tn as t,F as u,R as v,Ye as w,Se as x,k as y,dn as z};
|
|
1
|
+
import{o as e}from"./auth-C_jLPvth.js";import{C as t,T as n,_ as r,a as i,b as ee,c as a,d as te,g as o,h as s,k as ne,l as c,o as re,p as ie,u as ae,v as l,w as u,x as d,y as f}from"./person-owner-BqBLyw4S.js";var oe=l({clerkPublishableKey:t().nullish(),oauthClient:e.nullish()}),se=`2025-11-25`,ce=`2025-03-26`,le=[se,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],ue=`io.modelcontextprotocol/related-task`,p=ae(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),de=u([t(),r().int()]),fe=t();o({ttl:r().optional(),pollInterval:r().optional()});var pe=l({ttl:r().optional()}),me=l({taskId:t()}),m=o({progressToken:de.optional(),[ue]:me.optional()}),h=l({_meta:m.optional()}),g=h.extend({task:pe.optional()}),he=e=>g.safeParse(e).success,_=l({method:t(),params:h.loose().optional()}),v=l({_meta:m.optional()}),y=l({method:t(),params:v.loose().optional()}),b=o({_meta:m.optional()}),x=u([t(),r().int()]),ge=l({jsonrpc:s(`2.0`),id:x,..._.shape}).strict(),_e=e=>ge.safeParse(e).success,ve=l({jsonrpc:s(`2.0`),...y.shape}).strict(),ye=e=>ve.safeParse(e).success,S=l({jsonrpc:s(`2.0`),id:x,result:b}).strict(),be=e=>S.safeParse(e).success,C;(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`})(C||={});var w=l({jsonrpc:s(`2.0`),id:x.optional(),error:l({code:r().int(),message:t(),data:n().optional()})}).strict(),xe=e=>w.safeParse(e).success,Se=u([ge,ve,S,w]);u([S,w]);var T=b.strict(),Ce=v.extend({requestId:x.optional(),reason:t().optional()}),E=y.extend({method:s(`notifications/cancelled`),params:Ce}),we=l({src:t(),mimeType:t().optional(),sizes:a(t()).optional(),theme:i([`light`,`dark`]).optional()}),D=l({icons:a(we).optional()}),O=l({name:t(),title:t().optional()}),Te=O.extend({...O.shape,...D.shape,version:t(),websiteUrl:t().optional(),description:t().optional()}),Ee=ie(l({applyDefaults:c().optional()}),d(t(),n())),De=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ie(l({form:Ee.optional(),url:p.optional()}),d(t(),n()).optional())),Oe=o({list:p.optional(),cancel:p.optional(),requests:o({sampling:o({createMessage:p.optional()}).optional(),elicitation:o({create:p.optional()}).optional()}).optional()}),ke=o({list:p.optional(),cancel:p.optional(),requests:o({tools:o({call:p.optional()}).optional()}).optional()}),Ae=l({experimental:d(t(),p).optional(),sampling:l({context:p.optional(),tools:p.optional()}).optional(),elicitation:De.optional(),roots:l({listChanged:c().optional()}).optional(),tasks:Oe.optional(),extensions:d(t(),p).optional()}),je=h.extend({protocolVersion:t(),capabilities:Ae,clientInfo:Te}),k=_.extend({method:s(`initialize`),params:je}),Me=e=>k.safeParse(e).success,Ne=l({experimental:d(t(),p).optional(),logging:p.optional(),completions:p.optional(),prompts:l({listChanged:c().optional()}).optional(),resources:l({subscribe:c().optional(),listChanged:c().optional()}).optional(),tools:l({listChanged:c().optional()}).optional(),tasks:ke.optional(),extensions:d(t(),p).optional()}),Pe=b.extend({protocolVersion:t(),capabilities:Ne,serverInfo:Te,instructions:t().optional()}),Fe=y.extend({method:s(`notifications/initialized`),params:v.optional()}),A=_.extend({method:s(`ping`),params:h.optional()}),Ie=l({progress:r(),total:f(r()),message:f(t())}),Le=l({...v.shape,...Ie.shape,progressToken:de}),j=y.extend({method:s(`notifications/progress`),params:Le}),Re=h.extend({cursor:fe.optional()}),M=_.extend({params:Re.optional()}),N=b.extend({nextCursor:fe.optional()}),ze=i([`working`,`input_required`,`completed`,`failed`,`cancelled`]),P=l({taskId:t(),status:ze,ttl:u([r(),re()]),createdAt:t(),lastUpdatedAt:t(),pollInterval:f(r()),statusMessage:f(t())}),F=b.extend({task:P}),Be=v.merge(P),I=y.extend({method:s(`notifications/tasks/status`),params:Be}),L=_.extend({method:s(`tasks/get`),params:h.extend({taskId:t()})}),R=b.merge(P),z=_.extend({method:s(`tasks/result`),params:h.extend({taskId:t()})});b.loose();var B=M.extend({method:s(`tasks/list`)}),V=N.extend({tasks:a(P)}),H=_.extend({method:s(`tasks/cancel`),params:h.extend({taskId:t()})}),Ve=b.merge(P),He=l({uri:t(),mimeType:f(t()),_meta:d(t(),n()).optional()}),Ue=He.extend({text:t()}),U=t().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),We=He.extend({blob:U}),W=i([`user`,`assistant`]),G=l({audience:a(W).optional(),priority:r().min(0).max(1).optional(),lastModified:ne({offset:!0}).optional()}),Ge=l({...O.shape,...D.shape,uri:t(),description:f(t()),mimeType:f(t()),size:f(r()),annotations:G.optional(),_meta:f(o({}))}),Ke=l({...O.shape,...D.shape,uriTemplate:t(),description:f(t()),mimeType:f(t()),annotations:G.optional(),_meta:f(o({}))}),qe=M.extend({method:s(`resources/list`)}),Je=N.extend({resources:a(Ge)}),Ye=M.extend({method:s(`resources/templates/list`)}),Xe=N.extend({resourceTemplates:a(Ke)}),K=h.extend({uri:t()}),Ze=K,Qe=_.extend({method:s(`resources/read`),params:Ze}),$e=b.extend({contents:a(u([Ue,We]))}),et=y.extend({method:s(`notifications/resources/list_changed`),params:v.optional()}),tt=K,nt=_.extend({method:s(`resources/subscribe`),params:tt}),rt=K,it=_.extend({method:s(`resources/unsubscribe`),params:rt}),at=v.extend({uri:t()}),ot=y.extend({method:s(`notifications/resources/updated`),params:at}),st=l({name:t(),description:f(t()),required:f(c())}),ct=l({...O.shape,...D.shape,description:f(t()),arguments:f(a(st)),_meta:f(o({}))}),lt=M.extend({method:s(`prompts/list`)}),ut=N.extend({prompts:a(ct)}),dt=h.extend({name:t(),arguments:d(t(),t()).optional()}),ft=_.extend({method:s(`prompts/get`),params:dt}),q=l({type:s(`text`),text:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),J=l({type:s(`image`),data:U,mimeType:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),Y=l({type:s(`audio`),data:U,mimeType:t(),annotations:G.optional(),_meta:d(t(),n()).optional()}),pt=l({type:s(`tool_use`),name:t(),id:t(),input:d(t(),n()),_meta:d(t(),n()).optional()}),mt=l({type:s(`resource`),resource:u([Ue,We]),annotations:G.optional(),_meta:d(t(),n()).optional()}),ht=Ge.extend({type:s(`resource_link`)}),X=u([q,J,Y,ht,mt]),gt=l({role:W,content:X}),_t=b.extend({description:t().optional(),messages:a(gt)}),vt=y.extend({method:s(`notifications/prompts/list_changed`),params:v.optional()}),yt=l({title:t().optional(),readOnlyHint:c().optional(),destructiveHint:c().optional(),idempotentHint:c().optional(),openWorldHint:c().optional()}),bt=l({taskSupport:i([`required`,`optional`,`forbidden`]).optional()}),xt=l({...O.shape,...D.shape,description:t().optional(),inputSchema:l({type:s(`object`),properties:d(t(),p).optional(),required:a(t()).optional()}).catchall(n()),outputSchema:l({type:s(`object`),properties:d(t(),p).optional(),required:a(t()).optional()}).catchall(n()).optional(),annotations:yt.optional(),execution:bt.optional(),_meta:d(t(),n()).optional()}),St=M.extend({method:s(`tools/list`)}),Ct=N.extend({tools:a(xt)}),Z=b.extend({content:a(X).default([]),structuredContent:d(t(),n()).optional(),isError:c().optional()});Z.or(b.extend({toolResult:n()}));var wt=g.extend({name:t(),arguments:d(t(),n()).optional()}),Tt=_.extend({method:s(`tools/call`),params:wt}),Et=y.extend({method:s(`notifications/tools/list_changed`),params:v.optional()});l({autoRefresh:c().default(!0),debounceMs:r().int().nonnegative().default(300)});var Q=i([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Dt=h.extend({level:Q}),Ot=_.extend({method:s(`logging/setLevel`),params:Dt}),kt=v.extend({level:Q,logger:t().optional(),data:n()}),At=y.extend({method:s(`notifications/message`),params:kt}),jt=l({name:t().optional()}),Mt=l({hints:a(jt).optional(),costPriority:r().min(0).max(1).optional(),speedPriority:r().min(0).max(1).optional(),intelligencePriority:r().min(0).max(1).optional()}),Nt=l({mode:i([`auto`,`required`,`none`]).optional()}),Pt=l({type:s(`tool_result`),toolUseId:t().describe(`The unique identifier for the corresponding tool call.`),content:a(X).default([]),structuredContent:l({}).loose().optional(),isError:c().optional(),_meta:d(t(),n()).optional()}),Ft=te(`type`,[q,J,Y]),$=te(`type`,[q,J,Y,pt,Pt]),It=l({role:W,content:u([$,a($)]),_meta:d(t(),n()).optional()}),Lt=g.extend({messages:a(It),modelPreferences:Mt.optional(),systemPrompt:t().optional(),includeContext:i([`none`,`thisServer`,`allServers`]).optional(),temperature:r().optional(),maxTokens:r().int(),stopSequences:a(t()).optional(),metadata:p.optional(),tools:a(xt).optional(),toolChoice:Nt.optional()}),Rt=_.extend({method:s(`sampling/createMessage`),params:Lt}),zt=b.extend({model:t(),stopReason:f(i([`endTurn`,`stopSequence`,`maxTokens`]).or(t())),role:W,content:Ft}),Bt=b.extend({model:t(),stopReason:f(i([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(t())),role:W,content:u([$,a($)])}),Vt=l({type:s(`boolean`),title:t().optional(),description:t().optional(),default:c().optional()}),Ht=l({type:s(`string`),title:t().optional(),description:t().optional(),minLength:r().optional(),maxLength:r().optional(),format:i([`email`,`uri`,`date`,`date-time`]).optional(),default:t().optional()}),Ut=l({type:i([`number`,`integer`]),title:t().optional(),description:t().optional(),minimum:r().optional(),maximum:r().optional(),default:r().optional()}),Wt=l({type:s(`string`),title:t().optional(),description:t().optional(),enum:a(t()),default:t().optional()}),Gt=l({type:s(`string`),title:t().optional(),description:t().optional(),oneOf:a(l({const:t(),title:t()})),default:t().optional()}),Kt=l({type:s(`string`),title:t().optional(),description:t().optional(),enum:a(t()),enumNames:a(t()).optional(),default:t().optional()}),qt=u([Wt,Gt]),Jt=l({type:s(`array`),title:t().optional(),description:t().optional(),minItems:r().optional(),maxItems:r().optional(),items:l({type:s(`string`),enum:a(t())}),default:a(t()).optional()}),Yt=l({type:s(`array`),title:t().optional(),description:t().optional(),minItems:r().optional(),maxItems:r().optional(),items:l({anyOf:a(l({const:t(),title:t()}))}),default:a(t()).optional()}),Xt=u([Jt,Yt]),Zt=u([Kt,qt,Xt]),Qt=u([Zt,Vt,Ht,Ut]),$t=g.extend({mode:s(`form`).optional(),message:t(),requestedSchema:l({type:s(`object`),properties:d(t(),Qt),required:a(t()).optional()})}),en=g.extend({mode:s(`url`),message:t(),elicitationId:t(),url:t().url()}),tn=u([$t,en]),nn=_.extend({method:s(`elicitation/create`),params:tn}),rn=v.extend({elicitationId:t()}),an=y.extend({method:s(`notifications/elicitation/complete`),params:rn}),on=b.extend({action:i([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,d(t(),u([t(),r(),c(),a(t())])).optional())}),sn=l({type:s(`ref/resource`),uri:t()}),cn=l({type:s(`ref/prompt`),name:t()}),ln=h.extend({ref:u([cn,sn]),argument:l({name:t(),value:t()}),context:l({arguments:d(t(),t()).optional()}).optional()}),un=_.extend({method:s(`completion/complete`),params:ln});function dn(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function fn(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var pn=b.extend({completion:o({values:a(t()).max(100),total:f(r().int()),hasMore:f(c())})}),mn=l({uri:t().startsWith(`file://`),name:t().optional(),_meta:d(t(),n()).optional()}),hn=_.extend({method:s(`roots/list`),params:h.optional()}),gn=b.extend({roots:a(mn)}),_n=y.extend({method:s(`notifications/roots/list_changed`),params:v.optional()});u([A,k,un,Ot,ft,lt,qe,Ye,Qe,nt,it,Tt,St,L,z,B,H]),u([E,j,Fe,_n,I]),u([T,zt,Bt,on,gn,R,V,F]),u([A,Rt,nn,hn,L,z,B,H]),u([E,j,At,ot,et,Et,vt,I,an]),u([T,Pe,pn,_t,ut,Je,Xe,$e,Z,Ct,R,V,F]);var vn=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===C.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new yn(e.elicitations,n)}return new e(t,n,r)}},yn=class extends vn{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(C.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},bn=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function xn(e){return(await bn).getRandomValues(new Uint8Array(e))}async function Sn(e){let t=``;for(;t.length<e;){let n=await xn(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Cn(e){return await Sn(e)}async function wn(e){let t=await(await bn).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Tn(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Cn(e);return{code_verifier:t,code_challenge:await wn(t)}}export{Q as A,fn as B,lt as C,B as D,gn as E,Qe as F,be as G,xe as H,le as I,he as K,Ot as L,A as M,j as N,V as O,ue as P,I as R,se as S,qe as T,ye as U,Me as V,_e as W,L as _,Ve as a,Fe as b,zt as c,ce as d,on as f,z as g,ft as h,H as i,vn as j,St as k,Bt as l,C as m,Tt as n,E as o,T as p,oe as q,Z as r,un as s,Tn as t,F as u,R as v,Ye as w,Se as x,k as y,dn as z};
|
package/dist/chunks/{oauth-bearer-credential-D87-WID3.js → oauth-bearer-credential-BzAAtcOq.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as e,I as t,M as n,N as r,P as i,Q as a,X as o,f as s,h as c,i as l,it as u,o as d,z as f}from"./auth-
|
|
1
|
+
import{H as e,I as t,M as n,N as r,P as i,Q as a,X as o,f as s,h as c,i as l,it as u,o as d,z as f}from"./auth-C_jLPvth.js";import{C as p,a as m,c as ee,k as h,v as te}from"./person-owner-BqBLyw4S.js";import{execFile as ne}from"node:child_process";import{dirname as g,join as _}from"node:path";import{chmod as re,mkdir as v,readFile as y,rename as b,rm as x,stat as ie,writeFile as ae}from"node:fs/promises";import{AsyncLocalStorage as oe}from"node:async_hooks";import{randomUUID as S}from"node:crypto";import{homedir as se,platform as C}from"node:os";import{setTimeout as ce}from"node:timers/promises";function w(e,t=[]){let n=e instanceof Error?e.message:String(e);return c(n,t)}function le(e,t=[]){let n=c(e.title,t),r=c(e.detail?.trim()??``,t);return`${e.status} ${n}${r?` — ${r}`:``}`}function ue(){if(C()===`win32`){let e=process.env.APPDATA??_(se(),`AppData`,`Roaming`);return _(e,`aventure`,`config.json`)}let e=process.env.XDG_CONFIG_HOME??_(se(),`.config`);return _(e,`aventure`,`config.json`)}function de(){let e=process.env[a.authToken];return typeof e==`string`&&e.length>0?{present:!0,source:`env`}:{present:!1,source:null}}function T(e,t){return typeof e==`object`&&!!e&&`code`in e&&e.code===t}function E(e){let t=e.trim();if(t.length===0)throw Error(`API host must not be blank`);let n=new URL(me(t)?t:`${he(t)}://${t}`),r=D(n.hostname);if(n.protocol!==`https:`&&n.protocol!==`http:`||n.username.length>0||n.password.length>0||n.pathname!==`/`&&n.pathname!==``||n.search.length>0||n.hash.length>0)throw Error(`API host must contain only an HTTP(S) host and optional port`);if(n.protocol===`http:`&&!r)throw Error(`stored credentials require HTTPS except for loopback API hosts`);return{host:n.host.toLowerCase(),origin:n.origin,isLoopback:r}}function fe(e){return{...e,host:E(e.host).origin}}function pe(e){let t=E(e);if(t.isLoopback)return`http://localhost:3000`;if(t.host===`api.aventure.vc`)return`https://aventure.vc`;throw Error(`no first-party browser origin is configured for API host ${t.host}`)}function me(e){return/^[a-z][a-z\d+.-]*:\/\//iu.test(e)}function he(e){let t=e.split(`/`,1)[0]?.toLowerCase()??``;try{return D(new URL(`http://${t}`).hostname)?`http`:`https`}catch{return`https`}}function D(e){let t=e.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`0.0.0.0`||t===`[::1]`}var ge=2;function _e(e,t){return be(e,t).redactedUrl}async function ve(e,t,n){let r=be(e,t);return await ye(new URL(r.openerUrl),n)}async function ye(e,t){let n=t.environment??process.env,r=t.operatingSystem??C(),i=O(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=xe(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await Se(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function be(e,t){let{id:n,verificationUrl:r,pollSecret:i}=e,a,o;try{a=new URL(r),o=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(o.username.length>0||o.password.length>0||o.pathname!==`/`||o.search.length>0||o.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let s=D(o.hostname);if(o.protocol!==`https:`&&!(o.protocol===`http:`&&s))throw Error(`configured browser origin must use HTTPS except for loopback development`);let c=new URLSearchParams(a.hash.slice(1)),l=[...c.keys()],u=c.getAll(`cliAuthorizationId`),d=c.getAll(`browserSecret`),f=d[0]??``;if(a.origin!==o.origin||a.protocol!==o.protocol||a.username.length>0||a.password.length>0||a.pathname!==`/settings/developer`||a.search.length>0||l.length!==ge||u.length!==1||u[0]!==n||d.length!==1||f.length===0||i.length===0||f===i)throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let p;try{p=decodeURIComponent(r)}catch{throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`)}if(r.includes(i)||p.includes(i))throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let m=new URL(a);return m.hash=new URLSearchParams({cliAuthorizationId:n,browserSecret:`<redacted>`}).toString(),{openerUrl:r,redactedUrl:m.toString()}}function O(e,t,n){return e?`--no-browser was set`:n===`darwin`&&t.CODEX_SESSION_ID?`macOS Codex browser process boundary`:t.SSH_CONNECTION||t.SSH_CLIENT||t.SSH_TTY?`SSH/headless session detected`:(n===`linux`||n===`freebsd`)&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?`no graphical display detected`:null}function xe(e,t){return e===`darwin`?{command:`open`,arguments:[t]}:e===`win32`?{command:`rundll32.exe`,arguments:[`url.dll,FileProtocolHandler`,t]}:e===`linux`||e===`freebsd`?{command:`xdg-open`,arguments:[t]}:null}function Se(e,t){return new Promise((n,r)=>{ne(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var Ce=100,we=3e4,Te=6e4,k=new oe;function A(){return _(g(ue()),`credentials.json`)}function Ee(e){return`OS keyring is unusable (${e}); the credential will be stored in ${A()} (mode 0600).\n`}async function j(e,t){let n=(await P())[e]?.[t];if(n!==void 0)return{record:{provider:`file`,value:n}};try{let n=await(await N(e,t)).getPassword()??void 0;return n===void 0?{}:{record:{provider:`keyring`,value:n}}}catch(e){return{keyringFailure:M(e)}}}async function De(e,t,n){if((await P())[e]?.[t]!==void 0)return await Oe(e,t,n,`file store holds this account`);let r;try{let i=await N(e,t);if(await i.setPassword(n),await i.getPassword()===n)return await L(e,t,void 0),`keyring`;r=`Error: keyring readback did not match`}catch(e){r=M(e,[n])}return await Oe(e,t,n,r)}async function Oe(e,t,n,r){if(await L(e,t,n),(await P())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function ke(e,t){try{let n=await N(e,t),r;try{await n.deleteCredential()}catch(e){r=e}let i;try{i=await n.getPassword()??void 0}catch(e){throw Error(`OS keyring removal outcome is unknown (${M(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${M(r)})`,r===void 0?void 0:{cause:r})}finally{await L(e,t,void 0)}}async function Ae(e,t){let n=`${t}:probe:${S()}`,r=`aventure-cli-credential-probe:${S()}`,i;try{let t=await N(e,n);await t.setPassword(r);let a=await(await N(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await N(e,n)).getPassword()??void 0;if(a!==r)i=`Error: probe readback did not match`;else if(!o||s!==void 0)i=`Error: probe cleanup was not confirmed`;else return{provider:`keyring`}}catch(e){i=M(e,[r])}try{await I(async()=>{await L(e,n,r);let t=(await P())[e]?.[n];if(await L(e,n,void 0),t!==r)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${i}; file ${A()}: ${M(e,[r])})`,{cause:e})}return{provider:`file`,keyringFailure:i}}function M(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=w(e,t).trim().split(`
|
|
2
2
|
`,1);return r&&r!==n?`${n}: ${r}`:n}async function N(e,t){let n=C(),r=n===`linux`||n===`freebsd`?O(!1,process.env,n):null;if(r!==null)throw Error(`OS keyring unlock prompt is unreachable (${r})`);let{AsyncEntry:i}=await import(`@napi-rs/keyring`);return new i(e,t)}async function P(){let e=A(),t;try{t=await y(e,`utf8`)}catch(e){if(T(e,`ENOENT`))return{};throw e}let n;try{n=JSON.parse(t)}catch(t){return await F(e,t)}return Me(n)?n:await F(e,void 0)}async function F(t,n){let r=`${t}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await b(t,r)}catch(e){if(T(e,`ENOENT`))return{};throw Error(`${t} is not a valid credential file and could not be moved aside`,{cause:e})}return e({component:`aventure-cli`,event:`credential_file_quarantined`,message:`${t} is not a valid credential file; moved it to ${r} and continuing with an empty file store`,...n===void 0?{}:{error:n}}),{}}async function I(e){if(k.getStore()===!0)return await e();let t=`${A()}.lock`;await v(g(t),{recursive:!0,mode:448});let n=Date.now()+we,r=S();for(;;){try{await ae(t,r,{flag:`wx`,mode:384});break}catch(e){if(!T(e,`EEXIST`))throw e}if(await ie(t).then(e=>Date.now()-e.mtimeMs,()=>0)>Te)await x(t,{force:!0});else if(Date.now()>n)throw Error(`credential store is locked by another CLI process (${t})`);else await ce(Ce)}try{return await k.run(!0,e)}finally{await y(t,`utf8`).catch(()=>``)===r&&await x(t,{force:!0})}}async function L(e,t,n){await I(async()=>await je(e,t,n))}async function je(e,t,n){let r=A(),i=await P(),a={...i[e]};if(n===void 0?delete a[t]:a[t]=n,Object.keys(a).length===0?delete i[e]:i[e]=a,Object.keys(i).length===0){await x(r,{force:!0});return}await v(g(r),{recursive:!0,mode:448});let o=`${r}.${S()}.tmp`;await ae(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await re(o,384),await b(o,r)}function Me(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`))}var R=te({createdAt:h({offset:!0}),description:p().nullish(),expiresAt:h({offset:!0}).nullish(),id:p().regex(/^ak_[0-9A-Fa-f]{32}$/),lastUsedAt:h({offset:!0}).nullish(),name:p(),revocationReason:p().nullish(),scopes:ee(p()),status:m([`ACTIVE`,`REVOKED`,`EXPIRED`]),subject:p(),updatedAt:h({offset:!0})}),z=`vc.aventure.aventure-cli`,B=`aventure-cli-personal-v1`;async function Ne(e,t,n){let r=H(e),i=Le(t,n),a;try{a=await De(z,r,i)}catch(e){throw Error(`${w(e,[i,t.secret])}; broker acknowledgment was withheld. Re-run auth status before retrying.`,{cause:e})}return{host:r,provider:a,activation:n,credential:t}}async function V(e){let t=H(e),n;try{n=await j(z,t)}catch(e){return Ie(w(e))}let{record:r,keyringFailure:i}=n;return r===void 0?i===void 0?{state:`missing`}:{state:`missing`,keyringFailure:i}:{state:`found`,stored:{host:t,provider:r.provider,...Re(r.value)}}}async function Pe(e){let t=await V(e);if(t.state!==`missing`)return t;try{let{keyringFailure:t}=await Ae(z,H(e));return t===void 0?{state:`missing`}:{state:`missing`,keyringFailure:t}}catch(e){return Ie(w(e))}}async function Fe(e){await ke(z,H(e))}function H(e){return E(e).host}function Ie(e){return{state:`unavailable`,summary:e,cause:`storage`}}function Le(e,t){return`${B}:${t}\n${JSON.stringify(e.apiKey)}\n${e.secret}`}function Re(e){let t=e.indexOf(`
|
|
3
3
|
`),n=t<0?-1:e.indexOf(`
|
|
4
|
-
`,t+1),r=t<0?e:e.slice(0,t),i=r===`${B}:active`?`active`:`pending`;if(t<0||n<0||r!==`${B}:pending`&&r!==`${B}:active`)throw Error(`OS credential entry has an unsupported format`);let a=e.slice(n+1);if(a.length===0)throw Error(`OS credential entry has an empty secret`);let o;try{o=JSON.parse(e.slice(t+1,n))}catch(e){throw Error(`OS credential entry failed canonical schema validation`,{cause:e})}let s=R.safeParse(o);if(!s.success)throw Error(`OS credential entry failed canonical schema validation`,{cause:s.error});return{activation:i,credential:{apiKey:s.data,secret:a}}}async function ze(t){if(Be())return;let n=H(u().host);try{let e=await V(n);if(e.state===`unavailable`){f(Ve(`keyring`,Error(e.summary)));return}e.state===`found`&&e.stored.activation===`active`&&!Be()&&(process.env[a.authToken]=e.stored.credential.secret,t?.(`api-key`))}catch(t){e(Ve(`parse`,t))}}function Be(){return(process.env[a.authToken]?.trim().length??0)>0}function Ve(e,t){return{component:`aventure-cli`,event:`api_key_materialization_unavailable`,message:`saved API key could not be loaded; continuing with environment auth`,fields:{source:e},error:t}}var He=d.omit({mcpResource:!0}),U=`vc.aventure.aventure-cli.oauth`,Ue=`oauth:`,We=6e4;function Ge(e,t){let n=Z(t);return{client:e,expiresAt:ct(st(n)),tokens:n}}async function Ke(e,t){let n=q(e),r=nt(n,t),i;try{i=await De(U,X(n),r)}catch(e){throw Error(`OAuth credential could not be stored — ${w(e,[r,...Y(t.tokens)])}`,{cause:e})}return{host:n,provider:i,credential:rt(n,r)}}async function W(e){let t=q(e),n;try{n=await j(U,X(t))}catch(e){return{state:`unavailable`,summary:w(e)}}let{record:r,keyringFailure:i}=n;return r===void 0?i===void 0?{state:`missing`}:{state:`missing`,keyringFailure:i}:{state:`found`,stored:{host:t,provider:r.provider,credential:rt(t,r.value)}}}async function G(e){await ke(U,X(q(e)))}async function qe(e){try{return await W(e)}catch(e){return{state:`invalid`,summary:w(e)}}}async function Je(e){let t=await qe(e);if(t.state!==`missing`)return t;let n=await Ye(e);return n.state===`unavailable`?n:n.keyringFailure===void 0?{state:`missing`}:{state:`missing`,keyringFailure:n.keyringFailure}}async function Ye(e){let t=q(e);try{return{state:`available`,...await Ae(U,X(t))}}catch(e){return{state:`unavailable`,summary:w(e)}}}function Xe(e){return K(e.authorizationServer,`authorization server`)}function Ze(e){if(URL.canParse(e.resource)&&new URL(e.resource).protocol===`http:`){let t=E(e.resource);if(t.isLoopback)return new URL(t.origin)}return K(e.resource,`resource`)}function Qe(e){if(e.clientId.trim()!==e.clientId||e.clientId.length===0)throw Error(`OAuth client ID must not be blank`);return e.clientId}function $e(e){if(e.scope.length===0||e.scope.some(e=>e.trim()!==e||e.length===0)||new Set(e.scope).size!==e.scope.length)throw Error(`OAuth scope must contain unique non-blank values`);return e.scope}function K(e,t,n=!1){let r;try{r=new URL(e)}catch(e){throw Error(`OAuth ${t} is not a valid URL`,{cause:e})}if(r.protocol!==`https:`||r.username.length>0||r.password.length>0||!n&&r.search.length>0||r.hash.length>0)throw Error(`OAuth ${t} must be an HTTPS URL without credentials${n?``:`, query`} or fragment`);return r}function q(e){return E(e).host}function J(e){return new Date(e.expiresAt).getTime()-We<=Date.now()}function et(e){let t=tt(e.tokens.id_token)??tt(e.tokens.access_token),n=t?.email;return{subject:t?.sub??null,email:typeof n==`string`?n:null}}function tt(e){if(e!==void 0)try{return n(e)}catch{return}}function Y(e){return[e.access_token,e.refresh_token,e.id_token]}function X(e){return`${Ue}${e}`}function nt(e,t){return JSON.stringify({client:it(e,t.client),expiresAt:lt(t.expiresAt),tokens:Z(t.tokens)})}function rt(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`OS OAuth credential entry failed schema validation`,{cause:e})}if(!dt(n))throw Error(`OS OAuth credential entry failed schema validation`);return{client:it(e,at(n.client)),expiresAt:lt(n.expiresAt),tokens:Z(ot(n.tokens))}}function it(e,t){if(q(t.resource)!==e)throw Error(`OAuth client resource must match the credential API host`);return t}function at(e){let t=He.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed canonical client validation`,{cause:t.error});return t.data}function ot(e){let t=l.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed OAuth token validation`,{cause:t.error});return t.data}function Z(e){if(!ut(e.access_token)||e.token_type.trim().toLowerCase()!==`bearer`)throw Error(`OAuth token response must contain a bearer access token`);if(e.refresh_token!==void 0&&!ut(e.refresh_token))throw Error(`OAuth token response has an invalid refresh token`);return st(e),e}function st(e){let t=e.expires_in;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<=0)throw Error(`OAuth token response must contain a positive expires_in`);return t}function ct(e){let t=new Date(Date.now()+e*1e3);if(!Number.isFinite(t.getTime()))throw Error(`OAuth token response has an expiry outside the supported date range`);return t.toISOString()}function lt(e){if(typeof e!=`string`)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);return e}function ut(e){return e.trim()===e&&e.length>0}function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function ft(n,o){if($())return;let c=async(t,r,i,a=!1)=>{if(await ze(o),!$())throw a?r:mt(t,n,r,i);e({component:`aventure-cli`,event:`oauth_credential_bypassed`,message:`OAuth sign-in is unavailable (${t}); using the stored API key.`,...r===void 0?{}:{error:Error(w(r,Q(i)))}})},l=async(t,n,r)=>{let i=await W(t.host).catch(()=>void 0);if(i?.state===`found`&&i.stored.credential.tokens.access_token!==t.credential.tokens.access_token)return await d(i.stored,!1);try{await G(t.host)}catch(r){e({component:`aventure-cli`,event:`oauth_credential_retire_failed`,message:`the saved OAuth credential is dead (${n}) but could not be removed`,error:Error(w(r,Q(t)))})}await c(n,r,t)},d=async(e,n)=>{let u=(t,r)=>n?l(e,t,r):c(t,r,e),d=e.credential;if(J(d)){if(d.tokens.refresh_token===void 0)return await u(`the saved OAuth credential has expired`);try{d=await pt(e)}catch(n){return n instanceof i?await u(`aVenture sign-in rejected the saved refresh token`,n):await c(`the saved OAuth credential could not be renewed`,n,e,!(n instanceof t))}}let f;try{f=await s(d.tokens.access_token,new URL(d.client.resource))!==null}catch(t){return t instanceof r?await u(`the saved OAuth credential is malformed`,t):await c(`the saved OAuth credential could not be verified`,t,e,!0)}if(!f)return await u(`the saved OAuth credential was rejected`);$()||(process.env[a.authToken]=d.tokens.access_token,o?.(`oauth`))},f;try{f=q(u().host)}catch(e){throw mt(`the API host could not select its OAuth credential`,n,e)}let p;try{p=await W(f)}catch(e){return await c(`the saved OAuth credential is invalid or expired`,e)}if(p.state!==`missing`){if(p.state===`unavailable`)return await c(`the saved OAuth credential could not be read`,Error(p.summary));await d(p.stored,!0)}}async function pt(t){return await I(async()=>{let n=await W(t.host),r=n.state===`found`?n.stored:t;if(!J(r.credential))return r.credential;let{renewOAuthTokens:i}=await import(`./oauth-login-
|
|
4
|
+
`,t+1),r=t<0?e:e.slice(0,t),i=r===`${B}:active`?`active`:`pending`;if(t<0||n<0||r!==`${B}:pending`&&r!==`${B}:active`)throw Error(`OS credential entry has an unsupported format`);let a=e.slice(n+1);if(a.length===0)throw Error(`OS credential entry has an empty secret`);let o;try{o=JSON.parse(e.slice(t+1,n))}catch(e){throw Error(`OS credential entry failed canonical schema validation`,{cause:e})}let s=R.safeParse(o);if(!s.success)throw Error(`OS credential entry failed canonical schema validation`,{cause:s.error});return{activation:i,credential:{apiKey:s.data,secret:a}}}async function ze(t){if(Be())return;let n=H(u().host);try{let e=await V(n);if(e.state===`unavailable`){f(Ve(`keyring`,Error(e.summary)));return}e.state===`found`&&e.stored.activation===`active`&&!Be()&&(process.env[a.authToken]=e.stored.credential.secret,t?.(`api-key`))}catch(t){e(Ve(`parse`,t))}}function Be(){return(process.env[a.authToken]?.trim().length??0)>0}function Ve(e,t){return{component:`aventure-cli`,event:`api_key_materialization_unavailable`,message:`saved API key could not be loaded; continuing with environment auth`,fields:{source:e},error:t}}var He=d.omit({mcpResource:!0}),U=`vc.aventure.aventure-cli.oauth`,Ue=`oauth:`,We=6e4;function Ge(e,t){let n=Z(t);return{client:e,expiresAt:ct(st(n)),tokens:n}}async function Ke(e,t){let n=q(e),r=nt(n,t),i;try{i=await De(U,X(n),r)}catch(e){throw Error(`OAuth credential could not be stored — ${w(e,[r,...Y(t.tokens)])}`,{cause:e})}return{host:n,provider:i,credential:rt(n,r)}}async function W(e){let t=q(e),n;try{n=await j(U,X(t))}catch(e){return{state:`unavailable`,summary:w(e)}}let{record:r,keyringFailure:i}=n;return r===void 0?i===void 0?{state:`missing`}:{state:`missing`,keyringFailure:i}:{state:`found`,stored:{host:t,provider:r.provider,credential:rt(t,r.value)}}}async function G(e){await ke(U,X(q(e)))}async function qe(e){try{return await W(e)}catch(e){return{state:`invalid`,summary:w(e)}}}async function Je(e){let t=await qe(e);if(t.state!==`missing`)return t;let n=await Ye(e);return n.state===`unavailable`?n:n.keyringFailure===void 0?{state:`missing`}:{state:`missing`,keyringFailure:n.keyringFailure}}async function Ye(e){let t=q(e);try{return{state:`available`,...await Ae(U,X(t))}}catch(e){return{state:`unavailable`,summary:w(e)}}}function Xe(e){return K(e.authorizationServer,`authorization server`)}function Ze(e){if(URL.canParse(e.resource)&&new URL(e.resource).protocol===`http:`){let t=E(e.resource);if(t.isLoopback)return new URL(t.origin)}return K(e.resource,`resource`)}function Qe(e){if(e.clientId.trim()!==e.clientId||e.clientId.length===0)throw Error(`OAuth client ID must not be blank`);return e.clientId}function $e(e){if(e.scope.length===0||e.scope.some(e=>e.trim()!==e||e.length===0)||new Set(e.scope).size!==e.scope.length)throw Error(`OAuth scope must contain unique non-blank values`);return e.scope}function K(e,t,n=!1){let r;try{r=new URL(e)}catch(e){throw Error(`OAuth ${t} is not a valid URL`,{cause:e})}if(r.protocol!==`https:`||r.username.length>0||r.password.length>0||!n&&r.search.length>0||r.hash.length>0)throw Error(`OAuth ${t} must be an HTTPS URL without credentials${n?``:`, query`} or fragment`);return r}function q(e){return E(e).host}function J(e){return new Date(e.expiresAt).getTime()-We<=Date.now()}function et(e){let t=tt(e.tokens.id_token)??tt(e.tokens.access_token),n=t?.email;return{subject:t?.sub??null,email:typeof n==`string`?n:null}}function tt(e){if(e!==void 0)try{return n(e)}catch{return}}function Y(e){return[e.access_token,e.refresh_token,e.id_token]}function X(e){return`${Ue}${e}`}function nt(e,t){return JSON.stringify({client:it(e,t.client),expiresAt:lt(t.expiresAt),tokens:Z(t.tokens)})}function rt(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`OS OAuth credential entry failed schema validation`,{cause:e})}if(!dt(n))throw Error(`OS OAuth credential entry failed schema validation`);return{client:it(e,at(n.client)),expiresAt:lt(n.expiresAt),tokens:Z(ot(n.tokens))}}function it(e,t){if(q(t.resource)!==e)throw Error(`OAuth client resource must match the credential API host`);return t}function at(e){let t=He.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed canonical client validation`,{cause:t.error});return t.data}function ot(e){let t=l.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed OAuth token validation`,{cause:t.error});return t.data}function Z(e){if(!ut(e.access_token)||e.token_type.trim().toLowerCase()!==`bearer`)throw Error(`OAuth token response must contain a bearer access token`);if(e.refresh_token!==void 0&&!ut(e.refresh_token))throw Error(`OAuth token response has an invalid refresh token`);return st(e),e}function st(e){let t=e.expires_in;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<=0)throw Error(`OAuth token response must contain a positive expires_in`);return t}function ct(e){let t=new Date(Date.now()+e*1e3);if(!Number.isFinite(t.getTime()))throw Error(`OAuth token response has an expiry outside the supported date range`);return t.toISOString()}function lt(e){if(typeof e!=`string`)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw Error(`OS OAuth credential entry has an invalid absolute expiry`);return e}function ut(e){return e.trim()===e&&e.length>0}function dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function ft(n,o){if($())return;let c=async(t,r,i,a=!1)=>{if(await ze(o),!$())throw a?r:mt(t,n,r,i);e({component:`aventure-cli`,event:`oauth_credential_bypassed`,message:`OAuth sign-in is unavailable (${t}); using the stored API key.`,...r===void 0?{}:{error:Error(w(r,Q(i)))}})},l=async(t,n,r)=>{let i=await W(t.host).catch(()=>void 0);if(i?.state===`found`&&i.stored.credential.tokens.access_token!==t.credential.tokens.access_token)return await d(i.stored,!1);try{await G(t.host)}catch(r){e({component:`aventure-cli`,event:`oauth_credential_retire_failed`,message:`the saved OAuth credential is dead (${n}) but could not be removed`,error:Error(w(r,Q(t)))})}await c(n,r,t)},d=async(e,n)=>{let u=(t,r)=>n?l(e,t,r):c(t,r,e),d=e.credential;if(J(d)){if(d.tokens.refresh_token===void 0)return await u(`the saved OAuth credential has expired`);try{d=await pt(e)}catch(n){return n instanceof i?await u(`aVenture sign-in rejected the saved refresh token`,n):await c(`the saved OAuth credential could not be renewed`,n,e,!(n instanceof t))}}let f;try{f=await s(d.tokens.access_token,new URL(d.client.resource))!==null}catch(t){return t instanceof r?await u(`the saved OAuth credential is malformed`,t):await c(`the saved OAuth credential could not be verified`,t,e,!0)}if(!f)return await u(`the saved OAuth credential was rejected`);$()||(process.env[a.authToken]=d.tokens.access_token,o?.(`oauth`))},f;try{f=q(u().host)}catch(e){throw mt(`the API host could not select its OAuth credential`,n,e)}let p;try{p=await W(f)}catch(e){return await c(`the saved OAuth credential is invalid or expired`,e)}if(p.state!==`missing`){if(p.state===`unavailable`)return await c(`the saved OAuth credential could not be read`,Error(p.summary));await d(p.stored,!0)}}async function pt(t){return await I(async()=>{let n=await W(t.host),r=n.state===`found`?n.stored:t;if(!J(r.credential))return r.credential;let{renewOAuthTokens:i}=await import(`./oauth-login-BPal4uKl.js`),a=Ge(r.credential.client,await i(r));try{await Ke(t.host,a)}catch(t){e({component:`aventure-cli`,event:`oauth_credential_store_failed`,message:`renewed OAuth credential could not be stored; this command uses it and the next one falls back to the API key or sign-in`,error:Error(w(t,Y(a.tokens)))})}return a})}function Q(e){return e===void 0?[]:Y(e.credential.tokens)}function $(){return(process.env[a.authToken]?.trim().length??0)>0}function mt(e,t,n,r){let i=n===void 0?``:` — ${w(n,Q(r))}`,a=t??o().bin[0];return Error(`OAuth sign-in is required: ${e}. Run \`${a} auth login\` before retrying.${i}`)}export{fe as A,Ne as C,ve as D,ye as E,w as M,le as N,_e as O,V as S,Ee as T,Ke as _,G as a,Fe as b,J as c,et as d,Ze as f,K as g,Ye as h,Ge as i,de as j,pe as k,Xe as l,Y as m,pt as n,qe as o,$e as p,q as r,Je as s,ft as t,Qe as u,ze as v,R as w,Pe as x,H as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./oauth-login-DCwh-0eS.js";export{e as renewOAuthTokens};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as e,L as t,N as n,a as r,c as i,ct as a,f as o,i as s,it as c,m as l,n as u,r as ee,st as d,t as f}from"./auth-
|
|
1
|
+
import{F as e,L as t,N as n,a as r,c as i,ct as a,f as o,i as s,it as c,m as l,n as u,r as ee,st as d,t as f}from"./auth-C_jLPvth.js";import{A as p,E as m,M as h,N as te,T as ne,_ as re,c as ie,f as g,g as _,h as v,i as y,l as b,m as x,n as ae,o as oe,p as S,r as se,u as C}from"./oauth-bearer-credential-BzAAtcOq.js";import{S as ce,q as le,t as ue}from"./index.node-CWMdNV2l.js";import{once as de}from"node:events";import{stderr as w}from"node:process";import{createServer as fe}from"node:http";import{randomBytes as pe,timingSafeEqual as me}from"node:crypto";import{setTimeout as he}from"node:timers/promises";function ge(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var T=`code`,E=`S256`;function D(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&ge(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function O(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:k(i,a,n);return;case`client_secret_post`:A(i,a,r);return;case`none`:j(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function k(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function A(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function j(e,t){t.set(`client_id`,e)}async function M(n){let r=n instanceof Response?n.status:void 0,i=n instanceof Response?await n.text():n;try{let{error:n,error_description:r,error_uri:a}=u.parse(JSON.parse(i));return new(e[n]||t)(r||``,a)}catch(e){let n=`${r?`HTTP ${r}: `:``}Invalid OAuth error response: ${e}. Raw body: ${i}`;return new t(n)}}var N=s.omit({issuer:!0});f.omit({issuer:!0});async function P(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?P(e,void 0,n):void 0;throw r}}function F(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function I(e,{fetchFn:t=fetch,protocolVersion:n=ce}={}){let i={"MCP-Protocol-Version":n,Accept:`application/json`},a=F(e);for(let{url:e,type:n}of a){let a=await P(e,i,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw Error(`HTTP ${a.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?ee.parse(await a.json()):r.parse(await a.json())}}}function L(e){return typeof e==`string`?e:e.href}async function _e(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(T))throw Error(`Incompatible auth server: does not support response type ${T}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(E))throw Error(`Incompatible auth server: does not support code challenge method ${E}`)}else s=new URL(`/authorize`,e);let c=await ue(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,T),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,E),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,L(o)),{authorizationUrl:s,codeVerifier:l}}function ve(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function R(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,L(a)),i?await i(c,n,s,t):r&&O(D(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await M(l);return N.parse(await l.json())}async function ye(e,{metadata:t,clientInformation:n,authorizationCode:r,codeVerifier:i,redirectUri:a,resource:o,addClientAuthentication:s,fetchFn:c}){return R(e,{metadata:t,tokenRequestParams:ve(r,i,a),clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:c})}async function be(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await R(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}var xe=5e3,Se=500,z=`Approval poll was interrupted; retrying.
|
|
2
2
|
`,Ce=`urn:ietf:params:oauth:grant-type:device_code`;function B(e){let t=Reflect.get(e,`device_authorization_endpoint`);if(typeof t!=`string`)throw Error(`OAuth authorization-server metadata lacks device_authorization_endpoint`);return _(t,`device authorization endpoint`,!0)}async function we(e,t){let n=await fetch(B(t),{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:C(e),scope:S(e).join(` `),resource:g(e).toString()})});if(!n.ok)throw Error(`device authorization endpoint answered ${n.status}`);return Te(await V(n,`device authorization`),Date.now())}async function V(e,t){try{return await e.json()}catch(n){throw Error(`${t} endpoint answered ${e.status} without a JSON body`,{cause:n})}}function Te(e,t){if(typeof e!=`object`||!e)throw Error(`device authorization response is not an object`);let n=Reflect.get(e,`device_code`),r=Reflect.get(e,`user_code`),i=Reflect.get(e,`verification_uri_complete`),a=Reflect.get(e,`verification_uri`),o=Reflect.get(e,`expires_in`),s=Reflect.get(e,`interval`);if(typeof n!=`string`||typeof r!=`string`||n.length===0||r.length===0)throw Error(`device authorization response lacks device_code or user_code`);let c=typeof i==`string`&&i.length>0?i:a;if(typeof c!=`string`)throw Error(`device authorization response lacks a verification URI`);if(typeof o!=`number`||o<=0)throw Error(`device authorization response lacks a positive expires_in`);return{deviceCode:n,userCode:r,verificationUri:_(c,`verification URI`,!0),expiresAt:t+o*1e3,intervalMilliseconds:(typeof s==`number`&&s>=0?s:5)*1e3}}async function Ee(e,t,n){let r=_(t.token_endpoint,`token endpoint`,!0),i=n.intervalMilliseconds,a=null;for(;Date.now()<n.expiresAt;){await he(i);let t;try{t=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:C(e),grant_type:Ce,device_code:n.deviceCode})})}catch(e){a=`the token endpoint was unreachable — ${h(e)}`,w.write(z);continue}if(t.status>=Se){await t.body?.cancel(),a=`the token endpoint answered ${t.status}`,w.write(z);continue}a=null;let o=await V(t,`token`);if(t.ok){let e=s.safeParse(o);if(!e.success)throw Error(`token endpoint returned an invalid token response`);return e.data}let c=u.safeParse(o),l=c.success?c.data.error:`HTTP ${t.status}`;if(l!==`authorization_pending`){if(l===`slow_down`){i+=xe;continue}throw Error(l===`access_denied`?`the sign-in was denied in the browser`:l===`expired_token`?`the device code expired before approval`:`token endpoint answered ${l}`)}}throw Error(a===null?`the device code expired before approval`:`the device code expired before approval — last failure: ${a}`)}var De=3e5;function Oe(e){let t;try{t=new URL(e.redirectUri)}catch(e){throw Error(`OAuth callback configuration is not a valid URL`,{cause:e})}if(t.protocol!==`http:`||t.hostname!==`127.0.0.1`||t.port.length>0||t.pathname!==`/callback`||t.username.length>0||t.password.length>0||t.search.length>0||t.hash.length>0)throw Error(`OAuth callback configuration must be http://127.0.0.1/callback without a port, query, or fragment`);return t}async function ke(e,t){let n,r=new Promise(e=>{n=e}),i=fe((r,i)=>{i.setHeader(`Cache-Control`,`no-store`),i.setHeader(`Content-Type`,`text/plain; charset=utf-8`);let a=new URL(r.url??`/`,e);if(r.method!==`GET`||a.pathname!==e.pathname){i.statusCode=404,i.end(`OAuth callback not found.`);return}let o=a.searchParams.getAll(`state`),s=Buffer.from(o[0]??``),c=Buffer.from(t);if(o.length!==1||s.length!==c.length||!me(s,c)){i.statusCode=400,i.end(`OAuth callback state did not match. Return to the CLI and retry.`);return}if(a.searchParams.has(`error`)){i.statusCode=400,i.end(`OAuth authorization was not completed. Return to the CLI.`),n({state:`failed`,message:`OAuth authorization server returned an error`});return}let l=a.searchParams.getAll(`code`),u=l[0]?.trim();if(l.length!==1||u===void 0||u.length===0){i.statusCode=400,i.end(`OAuth callback did not include an authorization code.`);return}i.statusCode=200,i.end(`OAuth authorization completed. Return to the CLI.`),n({state:`code`,authorizationCode:u})});i.on(`error`,e=>n({state:`failed`,message:`OAuth callback listener failed: ${h(e)}`}));try{let t=de(i,`listening`);i.listen({host:`127.0.0.1`,port:0}),await t;let n=i.address();if(n===null||typeof n==`string`||n.port<=0)throw Error(`OAuth callback listener did not receive an ephemeral loopback port`);let a=new URL(e);return a.port=String(n.port),{redirectUri:a,waitForAuthorizationCode:async()=>{let e;return await Promise.race([r,new Promise(t=>{e=setTimeout(()=>t({state:`timed-out`}),De)})]).finally(()=>{e!==void 0&&clearTimeout(e)})},close:async()=>await H(i)}}catch(e){throw i.listening&&await H(i),e}}function H(e){return new Promise((t,n)=>{e.close(e=>e===void 0?t():n(e))})}var U=`the OAuth credential is valid, but the API refused this account (HTTP 403); signing in again will not change that`;async function W(e){let t;try{t=se(c().host)}catch(e){return d(`auth login: invalid API host — ${h(e)}`)}let r=await oe(t);if(r.state===`missing`)return G(t,e);if(r.state===`unavailable`)return d(`auth login: ${r.summary}`);if(r.state===`invalid`)return G(t,e,`Saved OAuth credential cannot be read — ${r.summary}`);let{stored:i}=r;if(ie(i.credential))return await Ae(i,e);let s;try{s=await o(i.credential.tokens.access_token,g(i.credential.client))}catch(r){return r instanceof n?G(t,e,`Saved OAuth credential was rejected`):d(`auth login: saved OAuth credential could not be verified — ${h(r,x(i.credential.tokens))}`)}return s===`forbidden`?d(`auth login: ${U}`):s===null?G(t,e,`Saved OAuth credential was rejected`):a(`OAuth CLI access token is already stored and verified.`,$(i))}async function Ae(e,t){let n=await v(e.host);if(n.state===`unavailable`)return d(`auth login: ${n.summary}`);let{tokens:r}=e.credential;if(r.refresh_token===void 0)return G(e.host,t,`Saved OAuth access token expired`,n);let i;try{i=await ae(e)}catch(i){return G(e.host,t,`Saved OAuth credential could not be renewed — ${h(i,x(r))}`,n)}J(n);let a=await Q(e.host,i,`OAuth CLI access token renewed and verified.`);if(!a.ok)return a;let o=await Z(i);return o.state===`failed`?d(`auth login: ${o.summary}`):o.state===`rejected`?G(e.host,t,`Renewed OAuth access token was rejected`,n):a}async function G(e,t,n,r){let i=r??await v(e);if(i.state===`unavailable`)return d(`auth login: ${i.summary}`);J(i),n!==void 0&&w.write(`${n}; continuing to browser sign-in.\n`);let a;try{let e=(await Y()).oauthClient;if(e==null)throw Error(`the API does not advertise an OAuth CLI client`);a=e}catch(e){return d(`auth login: OAuth configuration is unavailable — ${h(e)}`)}let o;try{o=await X(a)}catch(e){return d(`auth login: OAuth authorization-server discovery failed — ${h(e)}`)}if(t.noBrowser)return await K(e,a,o);let s=pe(32).toString(`base64url`),c;try{c=await ke(Oe(a),s);let t=await _e(b(a),{metadata:o,clientInformation:{client_id:C(a)},redirectUrl:c.redirectUri,resource:g(a),scope:S(a).join(` `),state:s}),n=await m(t.authorizationUrl,{noBrowser:!1});if(n.state!==`opened`)return await c.close(),c=void 0,w.write(`Browser not opened automatically (${n.reason}).\n`),await K(e,a,o);w.write(`Browser sign-in opened: choose the account, then approve. Waiting for the loopback callback...
|
|
3
3
|
`);let r=await c.waitForAuthorizationCode();if(r.state===`timed-out`)return await c.close(),c=void 0,w.write(`Browser sign-in was not completed; continuing with a device code.
|
|
4
4
|
`),await K(e,a,o);if(r.state===`failed`)return d(`auth login: ${r.message}`);let i;try{i=await ye(b(a),{metadata:o,clientInformation:{client_id:C(a)},authorizationCode:r.authorizationCode,codeVerifier:t.codeVerifier,redirectUri:c.redirectUri,resource:g(a)})}catch(e){return d(`auth login: OAuth token exchange failed — ${h(e,[r.authorizationCode,t.codeVerifier])}`)}return await q(e,a,i)}catch(e){return d(`auth login: OAuth browser authorization failed — ${h(e)}`)}finally{await c?.close()}}async function K(e,t,n){let r;try{r=await we(t,n)}catch(e){return d(`auth login: OAuth device authorization request failed — ${h(e)}`)}w.write([`Sign-in URL (works on any device): ${r.verificationUri.toString()}`,`Confirm that the page shows code ${r.userCode} before approving.`,"That page approves with the account already signed in there; to pick an account, run `auth login` on a machine with a browser.",`Waiting for approval...
|