@aventurevc/aventure-cli 0.8.402 → 0.8.403
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/{api-key-bearer-credential-Clf7XM4J.js → api-key-bearer-credential-Bs5UJ_f_.js} +1 -1
- package/dist/chunks/{api-key-bearer-credential-DQ29gpEv.js → api-key-bearer-credential-CRQwcNzZ.js} +1 -1
- package/dist/chunks/{api-key-credential-BBW2h2jz.js → api-key-credential-C6-Wy4uY.js} +1 -1
- package/dist/chunks/{api-key-credential-CuZLESs6.js → api-key-credential-CVGrdGnM.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-CkTXsFhd.js → api-key-credential-verification-B3kg-JHp.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-Bez178d4.js → api-key-credential-verification-BCr_-xlm.js} +1 -1
- package/dist/chunks/{api-key-login-RyuDyFHo.js → api-key-login-D5pQPrYy.js} +1 -1
- package/dist/chunks/{auth-status-check-CY623YaF.js → auth-status-check-CdaCRMML.js} +1 -1
- package/dist/chunks/{auth-status-check-C8nC6C0m.js → auth-status-check-tHbOMxdD.js} +1 -1
- package/dist/chunks/{auth-status-render-CYZvF1Hr.js → auth-status-render-DcuH_ciE.js} +1 -1
- package/dist/chunks/{aventure-cli-BeA2mLEM.js → aventure-cli-tyxkHVmB.js} +5 -5
- package/dist/chunks/{batch-io-B8Ouc6E1.js → batch-io-C14QM53J.js} +1 -1
- package/dist/chunks/{builtin-auth-BngRgFO-.js → builtin-auth-BYek40aT.js} +4 -4
- package/dist/chunks/{builtin-run-wait-wwxiOsS7.js → builtin-run-wait-7-lmVXly.js} +1 -1
- package/dist/chunks/{builtin-update-m4cnfanV.js → builtin-update-Cp5u2_Qq.js} +1 -1
- package/dist/chunks/{cli-help-policy-DKvhxVzj.js → cli-help-policy-DTjRjUH-.js} +1 -1
- package/dist/chunks/{completion-XOY7OKoj.js → completion-ow7Rt7uR.js} +1 -1
- package/dist/chunks/{contract-snPxQZji.js → contract-Brqijd_7.js} +1 -1
- package/dist/chunks/{contract-parameter-Cs9iqQzY.js → contract-parameter-CKdYGNoF.js} +1 -1
- package/dist/chunks/{credential-redaction-Cf-Mw3qP.js → credential-redaction-D7QNuGn5.js} +1 -1
- package/dist/chunks/{credential-store-BhTLplzD.js → credential-store-ib9XXesn.js} +1 -1
- package/dist/chunks/{generated-option-order-CBag8Kti.js → generated-option-order-B6BD1JlQ.js} +1 -1
- package/dist/chunks/{help-catalog-MO3v3A36.js → help-catalog-DdME0yOc.js} +1 -1
- package/dist/chunks/{help-intent-B0yMjuhN.js → help-intent-DuNcxASG.js} +1 -1
- package/dist/chunks/logout-BRKdA64O.js +1 -0
- package/dist/chunks/{logout-DbDQsCy6.js → logout-iY7gv6qw.js} +1 -1
- package/dist/chunks/{oauth-bearer-credential-IrH08eoo.js → oauth-bearer-credential-CzNA_9Nb.js} +1 -1
- package/dist/chunks/oauth-bearer-credential-qT4uFGK1.js +1 -0
- package/dist/chunks/{oauth-credential-CnGHoZKw.js → oauth-credential-DnT4FZzP.js} +1 -1
- package/dist/chunks/{oauth-credential-uP3vPzHP.js → oauth-credential-jMJ5WAXa.js} +1 -1
- package/dist/chunks/{oauth-login-DLWO7fMK.js → oauth-login-BGsNjuan.js} +1 -1
- package/dist/chunks/{oauth-login-CIhSeCDd.js → oauth-login-DbXC53-c.js} +1 -1
- package/dist/chunks/openapi-call-B9w-JMXr.js +102 -0
- package/dist/chunks/{openapi-call-B70VNbgP.js → openapi-call-CjvpSA-q.js} +1 -1
- package/dist/chunks/{operations-DVjipKiQ.js → operations-0RvjDluM.js} +1 -1
- package/dist/chunks/operations-catalog-CU79rFv1.js +1 -0
- package/dist/chunks/{operations-catalog-YYdl3dh5.js → operations-catalog-DklhT_Ek.js} +1 -1
- package/dist/chunks/{operations-metadata-DeN8IIh3.js → operations-metadata-D5VMUeN1.js} +1 -1
- package/dist/chunks/output-CLdHpE5W.js +4 -0
- package/dist/chunks/{output-CeghHATQ.js → output-TuxU_L46.js} +1 -1
- package/dist/chunks/{parse-error-hint-4aq-ExnF.js → parse-error-hint-BNq0_6Ov.js} +1 -1
- package/dist/chunks/{request-replay-Bh80ekjX.js → request-replay-Bbm4MRY4.js} +1 -1
- package/dist/chunks/{request-replay-0Qg7ktZO.js → request-replay-IoqFKMcS.js} +1 -1
- package/dist/chunks/response-problem-B14G_XCk.js +1 -0
- package/dist/chunks/{response-problem-DzOWyTv1.js → response-problem-CMoiDmUe.js} +1 -1
- package/dist/chunks/{startup-auth-DnfpEkUh.js → startup-auth-CG8r6QVQ.js} +1 -1
- package/dist/chunks/{startup-auth-CMHcAEzF.js → startup-auth-DagOUn3u.js} +1 -1
- package/dist/chunks/text-response--x47lzpP.js +18 -0
- package/dist/chunks/tool-policy-C0CH_dBK.js +1 -0
- package/package.json +3 -3
- package/dist/chunks/logout-DSYCnsbA.js +0 -1
- package/dist/chunks/oauth-bearer-credential-ZjxBi4CF.js +0 -1
- package/dist/chunks/openapi-call-C_hosXIF.js +0 -102
- package/dist/chunks/operations-catalog-BxeLs1Pk.js +0 -1
- package/dist/chunks/output-Dwj3iHV1.js +0 -4
- package/dist/chunks/response-problem-C3P97Css.js +0 -1
- package/dist/chunks/text-response-C40khd3L.js +0 -17
- package/dist/chunks/tool-policy-B9_QnvtY.js +0 -1
package/dist/chunks/{generated-option-order-CBag8Kti.js → generated-option-order-B6BD1JlQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./result-envelope-BvVnhP83.js";import{t as n}from"./private-readback-ZiavCvq2.js";import{c as r,i,o as a,s as o}from"./cli-help-policy-
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-BvVnhP83.js";import{t as n}from"./private-readback-ZiavCvq2.js";import{c as r,i,o as a,s as o}from"./cli-help-policy-DTjRjUH-.js";function s(n,r,i){let a={...i};for(let e of r.parameter){let r=e.envName;if(r===void 0)continue;let i=process.env[r]?.trim();if(i===void 0||i.length===0)continue;let o=a[e.optionKey];if(o!==void 0&&(typeof o!=`string`||o!==i))return{...t(`${n} ${e.flag.split(` `)[0]??e.name} conflicts with ${r}; omit the flag or use ${i}.`),data:a};o===void 0&&(a[e.optionKey]=i)}return e(`Environment-bound options applied`,a)}function c(e,t,n){if(!k(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||!w(n,r.name))continue;let a=C(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 l(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 u(t,n,r,i=!1){if(i||!D(n)||!Array.isArray(r))return A(t,n,r);for(let[e,i]of r.entries()){let r=A(t,n,i,e);if(!r.ok)return r}return e(`Body value assigned`,null)}function d(e,t,n,r){return A(e,t,r,n)}function f(e){let t=[];for(let n of e.split(`.`)){let e=M(n);if(t.push(e.key),e.isArray)return t.join(`.`)}return null}function p(e,t){let n=f(t);if(n===null)return null;let r=S(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:x(r)}:null}function m(n,r){if(D(n.name)||n.schemaType===`array`)return e(`Repeated body option selected`,typeof r==`string`?[r]:r);if(!Array.isArray(r))return e(`Scalar body option selected`,r);let i=n.flag.split(` `)[0]??n.name;return r.length===1?e(`Scalar body option selected`,r[0]):t(`${i} was already given; pass it once.`)}var h=/^(?<row>\d+):(?<item>.*)$/su;function g(e,t,n){let r=_(n,t[n.optionKey]);return r===null||n.schemaType===`array`||e.parameter.filter(e=>e.schemaType!==`array`&&f(e.name)===r.container&&_(e,t[e.optionKey])?.plain.length===0).length>1?r:null}function _(e,t){let n=f(e.name);if(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=h.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 v(e,t,n,{container:r,rows:i,plain:a}){let o=n.flag.split(` `)[0]??n.name;if(a.length>0)return`${o} mixes row-form values with plain value(s): ${a.join(`, `)} — prefix every value with its 0-based ${r}[] row index, as 0:value.`;let s=y(e,t,r);for(let[e,t]of i){if(e>=s)return`${o} names ${r}[] row ${e}, but these options build at most ${s} ${r}[] 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.`;if(n.schemaType!==`array`&&t.length>1)return`${o} names ${r}[] row ${e} ${t.length} times — give each ${r}[] row one value.`}return null}function y(e,t,n){let r=0,i=0;for(let a of e.parameter){let o=t[a.optionKey];if(o===void 0||typeof o==`boolean`||f(a.name)!==n)continue;let s=typeof o==`string`?1:o.length;r=Math.max(r,s),a.schemaType!==`array`&&g(e,t,a)!==null&&(i+=s)}return Math.max(r,i)}function b(e,n,r,i){for(let a of n.parameter){if(r[a.optionKey]===void 0)continue;let o=p(i,a.name);if(o===null)continue;if(o.firstHole!==null)return t(`${e} has no ${o.path}[] row ${o.firstHole} — number ${o.path}[] rows from 0 with no gaps.`);if(a.schemaType!==`array`||o.rowCount<=1||g(n,r,a)!==null)continue;let s=a.flag.split(` `)[0]??a.name;return t(`${s} fills one ${o.path}[] row's list, so ${e} cannot also build ${o.rowCount} ${o.path}[] rows from direct options — prefix each value with its 0-based ${o.path}[] row index, as 0:value, or pass the rows with --from-file.`)}return null}function x(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function S(e,t){let n=e;for(let e of t){if(!k(n))return;n=n[e]??null}return n}function C(e,t){if(!D(t))return S(e,t.split(`.`))}function w(e,t){return E(e,t.split(`.`))}function T(e,t,n){if(!k(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)&&w(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function E(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=M(n);if(!k(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>E(e,r)):E(a,r)}function D(e){return e.split(`.`).some(e=>M(e).isArray)}function O(e,t){return e.parameter.length===0||!k(t)?null:P(t,[],N(e.parameter))}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(n,r,i,a=0){let o=r.split(`.`),s=n;for(let[n,c]of o.entries()){let l=M(c),u=n===o.length-1,d=j(s,l,r,u,i,a);if(!d.ok||d.data===null)return t(d.summary,d.warnings);if(u)return e(`Body value assigned`,null);s=d.data}return t(`${r} is not a valid body option path.`)}function j(n,r,i,a,o,s){let c=()=>t(`${i} cannot be combined with another body option at ${r.key}.`),l=n[r.key];if(r.isArray){if(l!==void 0&&!Array.isArray(l))return c();let t=l??[];if(l===void 0&&(n[r.key]=t),a)return t[s]===void 0?(t[s]=o,e(`Body value assigned`,n)):c();let i=t[s];if(i===void 0){let n={};return t[s]=n,e(`Body path created`,n)}return k(i)?e(`Body path stepped`,i):c()}if(a)return l===void 0?(n[r.key]=o,e(`Body value assigned`,n)):c();if(l===void 0){let t={};return n[r.key]=t,e(`Body path created`,t)}return k(l)?e(`Body path stepped`,l):c()}function M(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function N(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 P(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=P(r,t,n);if(e!==null)return e}return null}if(!k(e))return null;for(let[r,i]of Object.entries(e)){let e=[...t,Array.isArray(i)?`${r}[]`:r],a=e.join(`.`);if(i===null&&F(`${a}[]`,n))continue;if(!F(a,n)){if(!I(e))continue;let r=[...new Set([...n.leaf,...n.prefix])].filter(e=>e.split(`.`).slice(0,-1).join(`.`)===t.join(`.`)),i=r.map(e=>e.split(`.`).at(-1)??``),o=R(e,r);return{path:a,message:`unknown JSON path ${a}. ${o===void 0?`Admitted keys: ${i.join(`, `)||`(none)`}.`:`Use ${o}.`}`}}let o=P(i,e,n);if(o!==null)return o}return null}function F(e,t){return t.prefix.has(e)||t.leaf.has(e)}function I(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}var L=4;function R(e,t){let n=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``,r=t.map(e=>({path:e,score:z(n,e.split(`.`).at(-1)??``)})).filter(({score:e})=>e<1/0).toSorted((e,t)=>e.score-t.score||e.path.localeCompare(t.path));return r[0]?.score===r[1]?.score?void 0:r[0]?.path}function z(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();if(n===e)return 0;if(Math.min(e.length,n.length)<L)return 1/0;let r=e.length<=n.length?e:n,i=e.length<=n.length?n:e;if(i.length-r.length>1)return 1/0;let a=0;for(;a<r.length&&r[a]===i[a];)a+=1;return r.slice(a+ +(r.length===i.length))===i.slice(a+1)?1:1/0}var B=e=>Array.isArray(e)&&!Object.isFrozen(e);function V(e,t){let r=new Map;for(let e of t){let t=e.flag?.split(` `)[0];t!==void 0&&r.set(t,t===`--from-file`?{...e,inputType:`file`}:e)}for(let t of e){let e=t.long===void 0?void 0:r.get(t.long);e!==void 0&&(t.helpGroup(o(e)),t.description=n(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!B(e))throw Error(`Commander option list is frozen; generated option help cannot be ordered.`);e.sort((e,t)=>{let n=e.long===void 0?void 0:r.get(e.long),i=t.long===void 0?void 0:r.get(t.long);return n!==void 0&&i!==void 0?Y(n,i):n===void 0?i===void 0?0:1:-1})}function H(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 U(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function W(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:q(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 G(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function K(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`,i=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return i.length===0?r(n):`${r(n)} Required JSON paths: ${i.join(`, `)}.`}function q(e,t){let n=i(t.description,void 0),r=e.kind!==`multipart`&&D(t.name),a=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${r?` Repeat to add another value.`:``}${a?` --from-file JSON key: ${t.name}.`:``}${J(e,t)}`}function J(e,t){if(e.kind===`multipart`)return``;let n=f(t.name);if(n===null)return``;let[r,i]=t.schemaType===`array`?[``,``]:[` on two or more ${n}[] flags`,` then`];return` Prefix each value with its 0-based ${n}[] row index, as 0:value${r}, to fill more than one ${n}[] row. A leading digits-and-colon is${i} 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 Y(e,t){return a(e)-a(t)||Number(e.required!==!0)-Number(t.required!==!0)}export{O as S,w as _,K as a,l as b,q as c,b as d,u as f,c as g,T as h,U as i,g as l,s as m,Y as n,H as o,d as p,W as r,G as s,V as t,v as u,D as v,m as x,k as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./package-DEeHDoOT.js";import{C as t,S as n,_ as r,c as i,d as a,g as o,i as s,s as c}from"./iso-DzqMxtky.js";import{t as l}from"./confidence-CjeYTBnf.js";import{c as u,d as ee,l as te,s as d,u as ne}from"./tool-policy-
|
|
1
|
+
import{a as e}from"./package-DEeHDoOT.js";import{C as t,S as n,_ as r,c as i,d as a,g as o,i as s,s as c}from"./iso-DzqMxtky.js";import{t as l}from"./confidence-CjeYTBnf.js";import{c as u,d as ee,l as te,s as d,u as ne}from"./tool-policy-C0CH_dBK.js";import{i as re,t as f}from"./human-text-cap-dR2SJQJC.js";import{n as ie,t as ae}from"./contract-parameter-CKdYGNoF.js";var p=2,oe=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`));function m(e,t){let n=v(t);if(n.length!==0){e.add(n),(n===`individual`||n===`individuals`)&&m(e,`person`);for(let t of se(n))h(e,t,n);h(e,ce(n),n)}}function se(e){if(e===`people`)return[`person`];let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=p&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return[`${t}y`];let n=e.endsWith(`es`)?e.slice(0,-2):``;return n.length>=p&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n)?[n,`${n}e`]:e.length>p&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`?[e.slice(0,-1)]:[]}function ce(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=p&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=p&&e.endsWith(`es`)))return e.length>=p&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function h(e,t,n){t!==void 0&&t!==n&&t.length>=p&&/^[a-z]+$/u.test(t)&&e.add(t)}function g(e){let t=new Set(_(e)),n=Array.from(t);for(let e of n)m(t,e);return t}function le(e){return _(e).map(g)}function ue(e,t){if(e.length===0)return!1;let n=g(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function _(e){return v(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!oe.has(e))}function v(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}function y(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>b(e)),...n.flatMap(e=>e.parameter.map(t=>b(t,n.length>1?e.contentType:void 0))),...de(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||ne(e.intent),o=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:te(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse?null:ee(e,`public`),body:{hasBody:o!==void 0,kind:o?.kind??null,...o!==void 0&&n.length>1?{contentType:o.contentType}:{},required:o?.required??!1,description:o?.description??``,requiredPath:o?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},...e.header===void 0||e.header.length===0?{}:{header:e.header},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function b(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 de(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request body encoding, never an uploaded file's media type; omit for ${t[0]}.`,choices:t}]}function x(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var fe=[`-id`,`-slug`,`-url`],pe=[`--id`,`--slug`,`--url`],me=`/v1/lookup`,he=`--from-file "<path>"`;function ge(t,n,r=e().bin[0]){let i=y(n,r),a=i.find(e=>e.operationId===t);return a===void 0?[]:w(a,i)}function S(t,n,r=e().bin[0]){let i=n.find(e=>e.operationId===t),[a]=i===void 0?[]:y([i],r);return a&&C(a,E(a,!1))}function _e(t,n,r,i=e().bin[0]){let a=e=>{let t=e.findIndex((e,t)=>r[t]!==e);return t===-1?e.length:t},o=`${r[0]} get`,[s,c]=n.filter(({method:e,path:n,parameters:r,cliPath:i})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return e===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===t&&n.endsWith(`/{${c.name}}`)&&(a(i)>1||i.join(` `)===o)}).toSorted((e,t)=>a(t.cliPath)-a(e.cliPath));if(s!==void 0&&(c===void 0||a(c.cliPath)!==a(s.cliPath)))return S(s.operationId,n,i)}function C(e,t){return[e.cli.command,...t,`--data`].join(` `)}function w(e,t){return[`example: ${C(e,E(e))}`,...ve(e,t)]}function ve(e,t){return x(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} ${D(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===me),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${D(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var T=/(?:^|\.)text$/u;function E(e,t=!0){let n=x(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&T.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:ye(e)).map(D);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,he]:o}function ye(e){let t=new Set;m(t,e.resource);for(let n of fe)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 pe){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function D(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var be=s([`PAID_PLAN`,`DAILY_ALLOWANCE`]),O=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),k=Object.assign(t([O,n()]),{enum:O.enum}),A=r({billingAccess:be.nullish(),excerpt:n(),sourceId:n(),sourceType:k,sourceVersion:n().nullish()}),xe=r({instruction:n(),operationId:n(),planTaskKey:c(n()).optional(),publishesAnalysis:i().optional(),stepKey:n().optional(),title:n().nullish()}),j=r({body:n(),expectation:n(),method:c(n()),override:n(),reject:c(n()),typeCatalog:n()}),M=r({cliCommand:n(),mcpTool:n().nullish(),step:xe,title:n().nullish(),writeGuidance:j.nullish()}),N=s([`ENTITY`,`NEWS`,`TEXT`,`FACT`,`WRITER_BRIEF`]),Se=Object.assign(t([N,n()]),{enum:N.enum}),Ce=r({allowedValue:n().nullish(),description:n(),key:n(),required:i().default(!0).optional(),type:Se}),P=r({catalogRevision:a().optional(),gateId:c(n()).optional(),input:c(Ce),step:c(M),taskKey:n().optional()}),F=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),we=r({candidate:c(A),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),Te=r({answer:n(),citation:c(A),confidence:l,resolution:we.nullish()});function I(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>L(t,ie(e,t))),r=(t?.parameter??[]).map(t=>L(t,ae(e,t)));return{selector:n.filter(e=>e.location===`path`||R(e)),pagination:n.filter(z),filter:[...n.filter(B),...r.filter(B)],body:r.filter(e=>!B(e))}}function L(e,t){let{in:n,inputName:r,nullable:i,...a}=e;return{...a,flag:u(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function R(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function z(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function B(e){return e.location!==`path`&&!R(e)&&!z(e)}function V(e){return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,tool:d(e),scope:e.projection.scope,requiredInput:U(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]}}function H(e,t){let n=e.requestBody?.[0],r=V(e),i=W(e);return t?{...r,...i===void 0?{}:{paidPlan:i},resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:I(e)}:{...r,optionalInput:Oe(e),arrayInput:ke(e),...i===void 0?{}:{paidPlan:i}}}function Ee(e){let t=I(e),n=e=>e.filter(e=>e.required);return{...H(e,!1),arrayInput:void 0,optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function De(e){let{cli:t,scope:n,...r}=V(e),i=W(e);return{...r,...i===void 0?{}:{paidPlan:i},optionalDetailOmitted:!0}}function U(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Oe(e){let t=e.requestBody?.[0],n=new Set(t?.requiredPath??[]);return{query:e.parameter.filter(e=>e.in===`query`&&!e.required).map(({name:e})=>e),body:(t?.parameter??[]).filter(({name:e})=>!n.has(e)).map(({name:e})=>e)}}function W(e){return e.response.find(({status:e})=>e===`402`)?.description}function ke(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var G=160,K=`Operation catalog matches`,Ae=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],q=e=>`${[K,...e].join(`
|
|
2
2
|
`)}\n`;function je(e,t=[],n=`mcp`){if(!Array.isArray(e)||e.length===0||!e.every(Pe))return null;let r=e,i=n===`mcp`?`structuredContent.data`:`the --data --to-file <path> output`,a=e=>re([K,...e,...t]);for(let e of Ae){let t=[...r.flatMap(t=>X(t,e)),...Y(r,e,i)];if(a(t))return q(t)}let o=(e,t=r.length-e)=>{let n=r.slice(e),a=n.length-t;return[...r.slice(0,e).flatMap(e=>X(e,`optionalGrouped`)),...Y(r.slice(0,e),`optionalGrouped`,i),...n.length===0?[]:[`... ${n.length} more operations omitted to fit ${f} UTF-8 bytes: ${[...n.slice(0,t).map(({operationId:e})=>e),...a>0?[`and ${a} more in ${i}`]:[]].join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`]]},s=[...r.keys()].findLast(e=>a(o(e)));return q(s===void 0?o(0,[...r.keys()].findLast(e=>a(o(0,e)))??0):o(s))}var J=e=>`call aventure_help with q=<operationId> and limit=1; inspect argument and optionalInput in ${e} for the retained inputs`;function Y(e,t,n){let r=t===`optionalGrouped`&&e.some(e=>X(e,t).some(e=>e.includes(`.{`)))?[`... optional input names sharing a prefix are grouped: a.{b, c} names a.b and a.c.`]:[];return[...Me(e,t,n),...r]}function Me(e,t,n){let r=e.flatMap(e=>`argument`in e?Object.values(e.argument).flat():[]),i=t===`whole`?0:r.filter(e=>e.description.length>G&&(t===`described`||e.required)).length,a=i===0?[]:[`... ${i} argument descriptions shortened; inspect each row's argument in ${n} for full descriptions.`];if(e.some(e=>`optionalDetailOmitted`in e))return[...a,e.some(e=>`argument`in e)?`... optional argument details omitted: the full list exceeds the result cap; ${J(n)}.`:`... optional inputs omitted: the full list exceeds the result cap; call aventure_help with q=<operationId> and limit=1 to read one operation's inputs.`];if(t===`whole`||!e.some(e=>`argument`in e))return[];if(t===`described`)return a;let o=t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`,s=r.filter(({required:e})=>!e).length;return[...a,`... ${s} ${o} omitted to fit ${f} UTF-8 bytes; ${n} carries them, and ${J(n)}.`]}function X(e,t){let n=`argument`in e?Object.values(e.argument).flat():[],r=n.filter(({required:e})=>!e).map(({name:e})=>e);return[`${e.operationId} ${e.method} ${e.path} (${e.tool})`,` ${e.summary}`,` required: ${e.requiredInput.length===0?`none`:e.requiredInput.join(`, `)}`,` responseContentType: ${e.responseContentType.length===0?`none`:e.responseContentType.join(`, `)}`,...`optionalInput`in e?Object.entries(e.optionalInput).filter(([,e])=>e.length>0).map(([e,n])=>` optional ${e}: ${Z(n,t)}`):[],...`arrayInput`in e&&e.arrayInput?.length?[` JSON array inputs: ${e.arrayInput.join(`, `)}`]:[],...`paidPlan`in e&&e.paidPlan!==void 0?[` paid plan: ${e.paidPlan}`]:[],...n.filter(({required:e})=>e||t!==`optionalNamed`&&t!==`optionalGrouped`).map(e=>Ne(e,e.required||t!==`requiredDescribed`,t)),...(t===`optionalNamed`||t===`optionalGrouped`)&&r.length>0?[` optional inputs: ${Z(r,t)}`]:[]]}function Z(e,t){if(t!==`optionalGrouped`)return e.join(`, `);let n=new Map;for(let t of e){let e=n,r=t.split(`.`);r.forEach((t,n)=>{let i=e.get(t)??{end:!1,child:new Map};e.set(t,i),n===r.length-1&&(i.end=!0),e=i.child})}let r=(e,t)=>{let n=[...t.child].flatMap(([n,i])=>t.child.size===1?r(`${e}.${n}`,i):r(n,i));return[...t.end?[e]:[],...t.child.size>1?[`${e}.{${n.join(`, `)}}`]:n]};return[...n].flatMap(([e,t])=>r(e,t)).join(`, `)}function Ne(e,t,n){let r=[e.location,e.required?`required`:void 0,e.schemaType,e.schemaFormat,e.schemaEnum===void 0?void 0:`choices: ${e.schemaEnum.join(`, `)}`,e.itemSchemaEnum===void 0?void 0:`item choices: ${e.itemSchemaEnum.join(`, `)}`,e.schemaDefault===void 0?void 0:`default: ${JSON.stringify(e.schemaDefault)}`,e.itemSchemaType===void 0?void 0:`items: ${e.itemSchemaType}${e.itemSchemaFormat===void 0?``:` (${e.itemSchemaFormat})`}`].filter(e=>e!==void 0).join(`, `),i=` ${e.name} (${r})`;return t?`${i}: ${n===`whole`||e.description.length<=G?e.description:`${e.description.slice(0,157)}...`}`:i}function Pe(e){return typeof e==`object`&&!!e&&`operationId`in e&&typeof e.operationId==`string`&&`requiredInput`in e&&Array.isArray(e.requiredInput)&&`intent`in e&&`summary`in e}function Q(e){let t=t=>{let n=(`parameter`in e?e.parameter:e.parameters.map(e=>({...e,in:e.location,schemaDefault:e.defaultValue}))).filter(e=>e.in===t&&e.required&&e.schemaDefault===void 0).map(({name:e})=>[e,`<${e}>`]);return n.length===0?void 0:Object.fromEntries(n)},n=t(`path`),r=t(`query`);return{tool:d(e),arguments:{operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Ie(e)}}}}var Fe=4;function Ie(e){let t=e.requestBody?.[0];if(t===void 0)return{};if(t.requiredPath.length>0||e.intent!==`lookup`||t.schemaType===`array`)return Le(t.requiredPath);let n=t.parameter;return Object.fromEntries(n.flatMap(e=>{let{name:t,schemaType:n,schemaFormat:r}=e,i=`optionKey`in e?e.choices:e.schemaEnum;return t.includes(`.`)||n!==`string`||r!==void 0?[]:i===void 0?[[t,`<${t}>`]]:i.length>Fe?[]:[[t,`<${i.join(`|`)}>`]]}))}function Le(e){let t={},n=e.filter(t=>!e.some(e=>e.startsWith(`${t}.`)||e.startsWith(`${t}[]`)));for(let e of n){let n=e.split(`.`),r=n.slice(0,-1).reduce(Re,t);r[n.at(-1)??e]=`<${e}>`}return t}function Re(e,t){let n=t.replace(/\[\]$/u,``),r=e[n],i=Array.isArray(r)?r[0]:r;if(typeof i==`object`&&i&&!Array.isArray(i))return i;let a={};return e[n]=t.endsWith(`[]`)?[a]:a,a}function ze(e){let t=W(e);return{mcpCall:Q(e),...t===void 0?{}:{paidPlan:t}}}function Be(e){let t=$(e.description);return{useFor:t.useFor||e.summary||e.description||`${e.method} ${e.path}`,notFor:t.notFor}}function $(e){let t=e.match(/USE FOR:\s*([\s\S]*?)(?:NOT FOR:|$)/iu),n=e.match(/NOT FOR:\s*([\s\S]*?)$/iu);return{useFor:t?.[1]?.trim()??``,notFor:n?.[1]?.trim()??``}}export{g as C,le as E,ue as S,v as T,_e as _,je as a,S as b,De as c,F as d,P as f,ge as g,x as h,ze as i,Ee as l,T as m,$ as n,Q as o,k as p,Be as r,H as s,K as t,Te as u,w as v,_ as w,m as x,y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./result-envelope-BvVnhP83.js";import{
|
|
1
|
+
import{c as e,i as t,r as n}from"./result-envelope-BvVnhP83.js";import{U as r,m as i,n as a,u as o}from"./tool-policy-C0CH_dBK.js";import{t as s}from"./openapi-snapshot-C3NgiUZo.js";import{C as c,E as l,S as u,T as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y,u as b,w as x,x as S}from"./help-catalog-DdME0yOc.js";var C=/\b(?:https?:\/\/)?(?:[a-z0-9-]+\.)+[a-z]{2,}(?::\d+)?(?:\/\S*)?/giu,w=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu,T=/^[a-z0-9]+(?:-[a-z0-9]+)+$/u,E=250,D=40,O=100;function ee(e,t){let n=new Set,r=[],i=/\bslugs?\b/iu.test(e);return{text:e.replace(w,()=>(n.add(`uuid`),` `)).replace(C,e=>{n.add(`url`);let t=e.replace(/^(?:https?:\/\/)?[^/]+/iu,``).replace(/[?#].*$/su,``).split(`/`).filter(e=>e.length>0).map(e=>e.toLowerCase()),i=t.at(-1);return i!==void 0&&T.test(i)&&(n.add(`slug`),t.pop()),r.push(...t.flatMap(e=>e.split(/[^a-z0-9]+/u))),` `}).split(/\s+/u).filter(e=>{let r=e.replace(/^[^a-z0-9]+|[^a-z0-9]+$/giu,``).toLowerCase(),a=T.test(r)&&!t.has(r)&&(i||/\d/u.test(r));return a&&n.add(`slug`),!a}).join(` `).trim(),kind:n,urlPathWord:r.filter(e=>e.length>0)}}function k(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function A(e,t){let n=new Set;for(let r of e){let e=new Set;S(e,r);let i=t.filter(({cliPath:t})=>e.has(t[0]??``)),a=i.length>0?i:t.filter(({cliPath:t})=>t.some(t=>e.has(t)));for(let{resource:e}of a)n.add(e)}return n}function te(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(x(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>k(t,e,n.path))&&(i+=E,r.has(t)&&(i+=D));if(i===0)return 0;let a=new Set(x(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return S(t,e),[...t].some(e=>a.has(e))}))&&(i+=O),i}var j=40,M=4,N=3,P=1,F=new Map,I=new WeakMap;function L(e){let t=F.get(e);if(t!==void 0)return t;let n=s(),a=r(n.paths,e),o=a===null?new Map:i(n,a.operation.responses,N);return F.set(e,o),o}function R(e,t,n){let r=0,i=z(n);for(let[e,i]of n)t.has(e.toLowerCase())&&(r+=j*(4-i)/4);for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=P&&(r+=M*(2-e))}return r}function z(e){let t=I.get(e);if(t!==void 0)return t;let n=new Map;for(let[t,r]of e){if(r>P)continue;let e=new Set;for(let n of x(t))S(e,n);for(let t of e)n.set(t,Math.min(n.get(t)??r,r))}return I.set(e,n),n}var B=5,V=.5,H=15,U=30,W=2,G=100,K=.5;function q(e,t,n){if(e.trim().length===0)return t.map(e=>({item:e,score:1}));let r=t.map(e=>({item:e,fields:n(e)})),i=ee(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=A(i.urlPathWord,r.map(({fields:e})=>e)),o=d(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=c(o),u=l(o),f=new Set(i.text.toLowerCase().split(/[^a-z0-9]+/u));return r.map(({item:e,fields:t})=>({item:e,fields:t,score:(o.length===0?0:Q({normalizedQuery:o,tokens:s,termForm:u,queryWord:f},t))+te(i,a,t)})).filter(({score:e})=>e>0).toSorted((e,t)=>Number(e.fields.deprecated===!0)-Number(t.fields.deprecated===!0)||t.score-e.score||e.fields.cliPath.length-t.fields.cliPath.length||e.fields.cliPath.join(` `).localeCompare(t.fields.cliPath.join(` `))||e.fields.operationId.localeCompare(t.fields.operationId)).map(({item:e,score:t})=>({item:e,score:t}))}var J=new WeakMap;function Y(e){let t=J.get(e);if(t!==void 0)return t;let n=e.requestBody??[],r=[...e.parameter,...n.flatMap(e=>e.parameter)],i={...e,cliPath:e.projection.cliPath,enumParameter:r.map(e=>({values:e.itemSchemaEnum??e.schemaEnum??[],direct:e.name===e.inputName})),parameterName:r.flatMap(e=>[e.name,e.inputName]),directParameterName:e.parameter.map(e=>e.name),parameterDescription:[...r,...n].map(({description:e})=>e),responseFieldLevel:L(e.operationId)};return J.set(e,i),i}function X(n,r){let i=n.q?.trim()??``,a=q(i,r.filter(e=>Z(n,e)&&(i.length>0||e.deprecated!==!0)),Y),o=(a[0]?.score??0)*V,s=a.filter(({score:e})=>e>=o),c=n.limit===void 0||!Number.isFinite(n.limit)?B:n.limit,l=Math.min(s.length,Math.max(0,Math.trunc(c))),u=s.slice(0,l).map(({item:e})=>e),d={totalOperations:r.length,matched:s.length,returned:u.length},p=u.length===1,h=u.map(e=>v(e,p)),g=e(y,h,{counts:d}),_=t(g),b=p?u.map(m):u.map(f);return{summary:y,data:_?h:b,counts:d}}function Z(e,t){let{root:n}=e;return!(e.method!==void 0&&t.method!==e.method||e.scope!==void 0&&t.projection.scope!==e.scope||n&&t.resource!==n&&t.projection.cliPath[0]!==n)}function Q({normalizedQuery:e,tokens:t,termForm:n,queryWord:r},i){let a=oe(i),s=ie(i),c=0;a.some(t=>t===e)&&(c+=100),a.some(t=>t.includes(e))&&(c+=40),c+=ae(e,a);let l=new Set(a.flatMap(x)),f=new Set(s.flatMap(x));for(let e of t)a.some(t=>t===e)?c+=20:f.has(e)?c+=8:l.has(e)&&(c+=W);for(let e of i.cliPath){let n=new Set;for(let t of e.split(`-`))S(n,t);[...n].some(e=>t.has(e))&&(c+=H)}u(n,s)&&(c+=200),n.length>1&&s.some(t=>t.includes(e))&&(c+=G),i.parameterName.some(t=>d(t)===e)&&(c+=U);let p=new Set(i.parameterDescription.flatMap(x));for(let e of t)p.has(e)&&(c+=W);return c+=ce(t,i.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(i.operationId)&&(c+=30),c+=R(n,r,i.responseFieldLevel),c-=se(e,t,i.description),o(i.intent)&&!re(r)?c*K:c}var ne=`edit change set fix rename link unlink mark publish correct`.split(` `),$=new Set([...Object.entries(a).filter(([,e])=>o(e)).map(([e])=>e),...ne]);function re(e){return[...e].some(e=>$.has(e))}function ie(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(d).filter(e=>e.length>0)}function ae(e,t){let n=x(e),r=0;for(let e=0;e<n.length-1;e+=1){let i=n.slice(e,e+2).join(` `);t.some(e=>e.includes(i))&&(r+=24)}return r}function oe(e){return[...new Set([e.operationId,e.method,e.path,e.resource,e.intent,e.cliPath.join(` `),e.summary,(h(e.description).useFor||e.description).slice(0,240)].map(d).filter(e=>e.length>0))]}function se(e,t,n){let r=d(h(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(x(r));for(let e of t)r===e?i+=20:a.has(e)&&(i+=8);return i}function ce(e,t){let n=0;for(let{values:r,direct:i}of t)r.some(t=>le(e,t))&&(n+=i?40:10);return n}function le(e,t){let n=x(t);return n.length>0&&n.every(t=>e.has(t))}function ue(e){return typeof e.data==`object`&&e.data!==null&&`response`in e.data?e.data.response:void 0}async function de(t,r,i,a){let o=t.q?.trim()??``;if(o.length===0)return n(`Provide q to resolve a request to one operation.`);let s=i.find(({resource:e,intent:t,deprecated:n})=>e===`help`&&t===`search`&&n!==!0);if(s===void 0)return n(`This build ships no help resolve operation.`);let c=await a(s,{body:{question:o,resolve:!0,...t.scope===void 0?{}:{scope:t.scope===`read`?`READ`:`WRITE`}}});if(!c.ok)return{...c,data:null};let l=b.safeParse(ue(c));if(!l.success||l.data.resolution==null)return n(`The help resolve operation returned no resolution.`,c.warnings,{httpStatus:c.httpStatus});let{answer:u,resolution:d}=l.data,f=e=>r.find(t=>t.operationId===e),m=f(d.operationId),h=d.taskPlan??void 0,v=(h?.step??[]).map(({step:e})=>({step:e,contract:f(e.operationId)})),y=[...new Set([...d.operationId!=null&&m===void 0?[d.operationId]:[],...v.filter(({contract:e})=>e===void 0).map(({step:e})=>e.operationId)])];return y.some(e=>!i.some(t=>t.operationId===e))?n(`No operation on this connection answers that request.`):e(y.length===0?`Help resolution`:`Help resolution this connection cannot finish: it cannot run ${y.join(`, `)}.`,{outcome:d.outcome,probability:d.probability,answer:u,candidate:d.candidate.filter(({sourceId:e})=>i.some(({operationId:t})=>t===e)).map(({sourceId:e})=>{let t=f(e);return t===void 0?{sourceId:e}:Object.assign({sourceId:e},p(t))}),...m===void 0?{}:{operation:{operationId:m.operationId,apiRoute:`${m.method} ${m.path}`,..._(m),...p(m)}},...(d.taskKey,{}),...h===void 0?{}:{taskPlan:{input:h.input,step:v.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:g(e)})}}},{warnings:y.map(e=>i.some(t=>t.operationId===e)?`Operation ${e} is in this server's catalog, but your grant does not allow it.`:`Operation ${e} is outside this server's catalog, so no credential runs it here.`)})}export{L as a,de as i,q as n,X as r,Y as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as logoutCliCredentials}from"./logout-iY7gv6qw.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,p as t,t as n}from"./env-IK6ic2dV.js";import{c as r,r as i}from"./result-envelope-BvVnhP83.js";import{
|
|
1
|
+
import{o as e,p as t,t as n}from"./env-IK6ic2dV.js";import{c as r,r as i}from"./result-envelope-BvVnhP83.js";import{V as a}from"./tool-policy-C0CH_dBK.js";import{s as o}from"./openapi-call-B9w-JMXr.js";import{a as s,r as c}from"./api-target-vxev2RKl.js";import{i as l,n as u,s as d,t as f}from"./api-key-credential-C6-Wy4uY.js";import{n as p,t as m}from"./credential-redaction-D7QNuGn5.js";import{n as h}from"./contract-Brqijd_7.js";import{t as g}from"./openapi-composites-IdxI7cAF.js";import{c as _,f as v,m as y,n as b,r as x}from"./oauth-credential-DnT4FZzP.js";import{t as S}from"./oauth-login-BGsNjuan.js";var C=h(g,`revoke`);async function w(r){let a;try{a=c(t().host)}catch(e){return i(`auth logout: invalid API host — ${m(e)}`)}let o=await j(a),s=await E(a),l=await k(a,r),u=T(a,s,l);if(o===void 0)return u;let d={...u.data??{host:a,revoked:!1,forgotten:!1},presented:o};switch(o.state){case`revoked`:return{...u,summary:`${u.summary} The API key in ${n.authToken} is revoked; unset it in this shell.`,data:d,ids:[...u.ids,o.apiKeyId]};case`unconfirmed`:return{...i(`auth logout: revocation of the API key in ${n.authToken} was not confirmed — ${o.summary}`,[`Retry when the API is available, or revoke the key at ${e}/settings/api-keys.`]),data:d};case`notApiKey`:case`rejected`:return{...u,data:d,warnings:[...u.warnings,`${n.authToken} was not revoked — ${o.summary}; unset it in this shell.`]};default:throw Error(`Unsupported AUTH_TOKEN logout state`)}}function T(e,t,n){let a=t.state===`failed`?[`OAuth credential could not be removed — ${t.summary}`]:t.state===`forgotten`&&!t.revoked?[`OAuth refresh token was not revoked remotely — ${t.summary??`no revocation endpoint`}`]:[],o={host:e,revoked:!1,forgotten:!1,oauth:t};return n===null?t.state===`missing`?r(`No CLI credential is stored for this API host.`,o):t.state===`failed`?{...i(`auth logout: ${a[0]}`),data:o}:r(t.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,o,{warnings:a}):{...n,data:{...n.data??o,oauth:t},warnings:[...n.warnings,...a]}}async function E(e){let t=await x(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await O(t.stored):{revoked:!1};try{await b(e)}catch(e){return{state:`failed`,summary:m(e)}}return{state:`forgotten`,...n}}async function D(e){let t=Reflect.get(await S(e),`revocation_endpoint`);return typeof t==`string`?y(t,`revocation endpoint`,!0):void 0}async function O(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await D(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:_(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:m(e,v(n))}}}async function k(e,t){let n;try{n=await l(e)}catch(e){return i(`auth logout: stored credential could not be read — ${m(e)}`)}if(n.state===`unavailable`)return{...i(`auth logout: ${n.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(n.state===`missing`)return null;let a=n.stored,o=await A(a),s=o.outcome===`revoked`,c=a.activation!==`active`&&o.outcome===`rejected`;if(!s&&!c&&!t.forgetLocal)return{...i(`auth logout: remote revocation was not confirmed; local credential preserved — ${o.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:N(a,!1,!1)};try{if((await u(a)).state===`changed`)return{...i(`auth logout: local credential changed during logout; current credential preserved, logout incomplete`,[o.summary]),data:N(a,s,!1)}}catch(e){return{...i(`auth logout: local credential removal failed — ${m(e,[a.credential.secret])}`,[s?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:N(a,s,!1)}}return r(s?`API key revoked remotely and removed locally.`:c?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,N(a,s,!0),{ids:[a.credential.apiKey.id],warnings:s||c?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function A(e){let t=await M(e.credential.secret);return t.apiKey===null?t:t.apiKey.id!==e.credential.apiKey.id||t.apiKey.subject!==e.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored API key identity`}:t}async function j(e){let n=t().userBearerToken?.trim();if(n===void 0||n.length===0)return;let r=await l(e);if(r.state===`found`&&r.stored.credential.secret===n)return;let i=await M(n);return i.outcome===`revoked`&&i.apiKey!==null?{state:`revoked`,apiKeyId:i.apiKey.id}:i.refused?{state:`notApiKey`,summary:i.summary}:{state:i.outcome===`rejected`?`rejected`:`unconfirmed`,summary:i.summary}}async function M(e){let n={apiKey:null,refused:!1},r=s(t());try{let t=await o(r,{method:C.method,path:a(C.path,{},C.operationId),headers:{Authorization:`Bearer ${e}`}},d);if(t.ok&&t.redirect)return{...n,outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${t.status}`};if(!t.ok){let r=t.problem.type!==`about:blank`,i=r&&t.problem.status===401;return{...n,outcome:i?`rejected`:`unconfirmed`,refused:r&&t.problem.status===403,summary:p(t.problem,[e])}}let i={id:t.data.id,subject:t.data.subject};return t.data.status===`REVOKED`?{apiKey:i,refused:!1,outcome:`revoked`,summary:`remote key revocation confirmed`}:{apiKey:i,refused:!1,outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}}catch(t){return{...n,outcome:`unconfirmed`,summary:m(t,[e])}}}function N(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:f(e.activation),revoked:t,forgotten:n}}export{A as n,w as t};
|
package/dist/chunks/{oauth-bearer-credential-IrH08eoo.js → oauth-bearer-credential-CzNA_9Nb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./package-DEeHDoOT.js";import{p as t,t as n}from"./env-IK6ic2dV.js";import{r}from"./auth-resolver-1fMlkB1Y.js";import{o as i}from"./logging-Cv27m9ID.js";import{r as a}from"./api-target-vxev2RKl.js";import{i as o}from"./api-key-credential-
|
|
1
|
+
import{a as e}from"./package-DEeHDoOT.js";import{p as t,t as n}from"./env-IK6ic2dV.js";import{r}from"./auth-resolver-1fMlkB1Y.js";import{o as i}from"./logging-Cv27m9ID.js";import{r as a}from"./api-target-vxev2RKl.js";import{i as o}from"./api-key-credential-C6-Wy4uY.js";import{t as s}from"./credential-redaction-D7QNuGn5.js";import{a as c}from"./credential-store-ib9XXesn.js";import{t as l}from"./api-key-bearer-credential-CRQwcNzZ.js";import{a as u,f as d,h as f,n as p,o as m,t as h}from"./oauth-credential-DnT4FZzP.js";import"./http-credentials-BUPEQD7v.js";async function g(){let e=await o(a(t().host)).catch(()=>null);return e===null||e.state===`unavailable`||e.state===`found`&&e.stored.activation===`active`}async function _(n,r){if(O())return;let o=async(t,a,o,c=!1)=>{if(await l(r),!O())throw c?a:A(t,n,a,o);i({component:n??e().bin[0],event:`oauth_credential_bypassed`,message:`OAuth sign-in is unavailable (${t}); using the stored API key.`,...a===void 0?{}:{error:Error(s(a,D(o)))}})},c=async(t,r,a,c)=>{if(c){let e=await m(t.host).catch(()=>void 0);if(e?.state===`found`&&e.stored.credential.tokens.access_token!==t.credential.tokens.access_token)return await d(e.stored,!1)}try{await p(t.host)}catch(a){i({component:n??e().bin[0],event:`oauth_credential_retire_failed`,message:`the saved OAuth credential is dead (${r}) but could not be removed`,error:Error(s(a,D(t)))})}await o(r,a,t)},d=async(e,t)=>{let r=(n,r)=>c(e,n,r,t),i=e.credential;if(u(i)){if(i.tokens.refresh_token===void 0)return await r(`the saved OAuth credential has expired`);try{i=await x(e)}catch(t){return await w(t)?await r(`aVenture sign-in rejected the saved refresh token`,t):await o(`the saved OAuth credential could not be renewed`,t,e,!await C(t))}}if(t&&i===e.credential&&(T(i)||!await g()))return f(e,i);let a;try{let{verifyUserBearerToken:e}=await import(`./openapi-call-CjvpSA-q.js`);a=await e(i.tokens.access_token,new URL(i.client.resource))!==null}catch(t){let{errors:n}=await import(`./webapi-WYeLOETY.js`);return t instanceof n.JWTInvalid?await r(`the saved OAuth credential is malformed`,t):await o(`the saved OAuth credential could not be verified`,t,e,!0)}if(!a)return await r(`the saved OAuth credential was rejected`);await E(e.host,i,n),f(e,i)},f=(e,t)=>{O()||(S({...e,credential:t}),r?.(`oauth`))},h;try{h=a(t().host)}catch(e){throw A(`the API host could not select its OAuth credential`,n,e)}let _;try{_=await m(h)}catch(e){return await o(`the saved OAuth credential is invalid or expired`,e)}if(_.state!==`missing`){if(_.state===`unavailable`)return await o(`the saved OAuth credential could not be read`,Error(_.summary));await d(_.stored,!0)}}async function v(){if(O())return;let e=await m(a(t().host));e.state===`found`&&(process.env[n.authToken]=e.stored.credential.tokens.access_token)}var y;function b(){return y!==void 0}async function x(t){return await c(async()=>{let n=await m(t.host),r=n.state===`found`?n.stored:t,a=y?.stored.host===r.host&&y.replaced===r.credential.tokens.access_token?y.stored:r;if(!u(a.credential))return a.credential;let{renewOAuthTokens:o}=await import(`./oauth-login-DbXC53-c.js`),c=h(a.credential.client,await o(a));try{await f(t.host,c),y=void 0}catch(t){y={replaced:r.credential.tokens.access_token,stored:{...a,credential:c}},i({component:e().bin[0],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(s(t,d(c.tokens)))})}return c})}function S(e){let t=e.credential.tokens.access_token,i,a;r(t,async()=>a===void 0?i!==void 0||process.env[n.authToken]!==t||!u(e.credential)?i:(a=o().finally(()=>{a=void 0}),await a):await a);async function o(){delete process.env[n.authToken];let r=A(`no saved credential could serve this command`,void 0);try{let{materializeCommandCredential:e}=await import(`./startup-auth-DagOUn3u.js`);if(await e(`required`),O())return}catch(e){r=e}process.env[n.authToken]=t;let{BearerVerificationUnavailableError:a}=await import(`./openapi-call-CjvpSA-q.js`);if(r instanceof a)return r.problem;let o=!(r instanceof k),c={status:o?503:401,title:`the saved OAuth sign-in expired during this command and could not be renewed`,type:`about:blank`,detail:s(r,D(e))};return o||(i=c),c}}async function C(e){let{OAuthError:t,OAuthErrorCode:n}=await import(`./dist-DGMIRNW7.js`),r=[n.ServerError,n.TemporarilyUnavailable];return e instanceof t&&!r.includes(e.code)}async function w(e){let{OAuthError:t,OAuthErrorCode:n}=await import(`./dist-DGMIRNW7.js`),r=n.InvalidGrant;return e instanceof t&&e.code===r}function T(e){if(e.verifiedAt===void 0)return!1;let t=Date.now()-new Date(e.verifiedAt).getTime();return t>=0&&t<9e5}async function E(t,n,r){let a=new Date().toISOString();try{await c(async()=>{let e=await m(t);e.state===`found`&&e.stored.credential.tokens.access_token===n.tokens.access_token&&await f(t,{...e.stored.credential,verifiedAt:a})})}catch(t){i({component:r??e().bin[0],event:`oauth_credential_verification_unrecorded`,message:`the saved OAuth credential was verified but the verification could not be stored`,error:Error(s(t,d(n.tokens)))})}}function D(e){return e===void 0?[]:d(e.credential.tokens)}function O(){return(process.env[n.authToken]?.trim().length??0)>0}var k=class extends Error{};function A(t,n,r,i){let a=r===void 0?``:` — ${s(r,D(i))}`;return new k(`OAuth sign-in is required: ${t}. Run \`${n??e().bin[0]} auth login\` before retrying.${a}`)}export{x as i,_ as n,v as r,b as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{n as materializeCliOAuthBearerCredential,r as materializeSavedCliOAuthBearerCredential}from"./oauth-bearer-credential-CzNA_9Nb.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Yt as e}from"./auth-BNDyLTqp-z6VNZXaE.js";import{m as t}from"./env-IK6ic2dV.js";import{i as n}from"./webapi-B2JTupyg.js";import{n as r,r as i}from"./api-target-vxev2RKl.js";import{t as a}from"./credential-redaction-
|
|
1
|
+
import{Yt as e}from"./auth-BNDyLTqp-z6VNZXaE.js";import{m as t}from"./env-IK6ic2dV.js";import{i as n}from"./webapi-B2JTupyg.js";import{n as r,r as i}from"./api-target-vxev2RKl.js";import{t as a}from"./credential-redaction-D7QNuGn5.js";import{a as o,i as s,o as c,r as l,t as u}from"./credential-store-ib9XXesn.js";import{t as d}from"./client-C-w059lW.js";import"./dist-oUS6BQ43.js";var f=d.omit({mcpResource:!0}),p=`vc.aventure.aventure-cli.oauth`,m=`oauth:`,h=6e4;function g(e,t){let n=R(t);return{client:e,expiresAt:B(z(n)),tokens:n}}async function _(e,t){let n=i(e),r=N(n,t),s;try{s=await o(async()=>await c(p,M(n),r))}catch(e){throw Error(`OAuth credential could not be stored — ${a(e,[r,...j(t.tokens)])}`,{cause:e})}return{host:n,provider:s,credential:P(n,r)}}async function v(e){let t=i(e),n;try{n=await s(p,M(t))}catch(e){return{state:`unavailable`,summary:a(e)}}let{record:r,keyringFailure:o}=n;return r===void 0?o===void 0?{state:`missing`}:{state:`missing`,keyringFailure:o}:{state:`found`,stored:{host:t,provider:r.provider,credential:P(t,r.value)}}}async function y(e){let t=i(e);await o(async()=>await u(p,M(t)))}async function b(e){try{return await v(e)}catch(e){return{state:`invalid`,summary:a(e)}}}async function x(e){let t=await b(e);if(t.state!==`missing`)return t;let n=await S(e);return n.state===`unavailable`?n:n.keyringFailure===void 0?{state:`missing`}:{state:`missing`,keyringFailure:n.keyringFailure}}async function S(e){let t=i(e);try{return{state:`available`,...await l(p,M(t))}}catch(e){return{state:`unavailable`,summary:a(e)}}}function C(e){return D(e.authorizationServer,`authorization server`)}function w(e){if(URL.canParse(e.resource)&&new URL(e.resource).protocol===`http:`){let t=r(e.resource);if(t.isLoopback)return new URL(t.origin)}return D(e.resource,`resource`)}function T(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 D(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 O(e){let n=Date.now()+t();return new Date(e.expiresAt).getTime()-h<=n}function k(e){let t=A(e.tokens.id_token)??A(e.tokens.access_token),n=t?.email;return{subject:t?.sub??null,email:typeof n==`string`?n:null}}function A(e){if(e!==void 0)try{return n(e)}catch{return}}function j(e){return[e.access_token,e.refresh_token,e.id_token]}function M(e){return`${m}${e}`}function N(e,t){return JSON.stringify({client:F(e,t.client),expiresAt:V(t.expiresAt,`absolute expiry`),tokens:R(t.tokens),...t.verifiedAt===void 0?{}:{verifiedAt:V(t.verifiedAt,`verification time`)}})}function P(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`OS OAuth credential entry failed schema validation`,{cause:e})}if(!U(n))throw Error(`OS OAuth credential entry failed schema validation`);return{client:F(e,I(n.client)),expiresAt:V(n.expiresAt,`absolute expiry`),tokens:R(L(n.tokens)),...n.verifiedAt===void 0?{}:{verifiedAt:V(n.verifiedAt,`verification time`)}}}function F(e,t){let n=r(t.resource);if(n.host!==e&&!(n.isLoopback&&r(e).isLoopback))throw Error(`OAuth client resource must match the credential API host`);return t}function I(e){let t=f.safeParse(e);if(!t.success)throw Error(`OS OAuth credential entry failed canonical client validation`,{cause:t.error});return t.data}function L(t){let n=e.safeParse(t);if(!n.success)throw Error(`OS OAuth credential entry failed OAuth token validation`,{cause:n.error});return n.data}function R(e){if(!H(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&&!H(e.refresh_token))throw Error(`OAuth token response has an invalid refresh token`);return z(e),e}function z(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 B(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 V(e,t){if(typeof e!=`string`)throw Error(`OS OAuth credential entry has an invalid ${t}`);let n=new Date(e);if(!Number.isFinite(n.getTime())||n.toISOString()!==e)throw Error(`OS OAuth credential entry has an invalid ${t}`);return e}function H(e){return e.trim()===e&&e.length>0}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{O as a,T as c,E as d,j as f,_ as h,x as i,k as l,D as m,y as n,v as o,S as p,b as r,C as s,g as t,w as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{i as inspectOAuthCredentialStorage}from"./oauth-credential-
|
|
1
|
+
export{i as inspectOAuthCredentialStorage}from"./oauth-credential-DnT4FZzP.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Gt as e,Yt as t}from"./auth-BNDyLTqp-z6VNZXaE.js";import{p as n}from"./env-IK6ic2dV.js";import{c as r,r as i}from"./result-envelope-BvVnhP83.js";import{a,n as o,s}from"./openapi-call-
|
|
1
|
+
import{Gt as e,Yt as t}from"./auth-BNDyLTqp-z6VNZXaE.js";import{p as n}from"./env-IK6ic2dV.js";import{c as r,r as i}from"./result-envelope-BvVnhP83.js";import{a,n as o,s}from"./openapi-call-B9w-JMXr.js";import{R as c}from"./webapi-B2JTupyg.js";import{a as l,r as u}from"./api-target-vxev2RKl.js";import{n as d,t as f}from"./credential-redaction-D7QNuGn5.js";import{n as p,s as ee}from"./credential-store-ib9XXesn.js";import"./dist-oUS6BQ43.js";import{a as te,c as m,d as h,f as g,h as ne,m as _,p as v,r as y,s as b,t as x,u as S}from"./oauth-credential-DnT4FZzP.js";import{t as C}from"./provider-catalog-CT1LnhCO.js";import{f as w,o as T,s as E,u as re}from"./dist-Dt0qAmdj.js";import{i as ie}from"./oauth-bearer-credential-CzNA_9Nb.js";import{once as ae}from"node:events";import{stderr as D}from"node:process";import{setTimeout as oe}from"node:timers/promises";import{createServer as se}from"node:http";import{randomBytes as ce,timingSafeEqual as O}from"node:crypto";var k=5e3,A=500,j=`Approval poll was interrupted; retrying.
|
|
2
2
|
`,M=`urn:ietf:params:oauth:grant-type:device_code`;function N(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 P(e,t){if(t.grant_types_supported?.includes(M)!==!0)throw Error(`OAuth authorization-server metadata must advertise the device authorization grant`);let n=await fetch(N(t),{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:m(e),scope:h(e).join(` `),resource:S(e).toString()})});if(!n.ok)throw Error(`device authorization endpoint answered ${n.status}`);return I(await F(n,`device authorization`),Date.now())}async function F(e,t){try{return await e.json()}catch(n){throw Error(`${t} endpoint answered ${e.status} without a JSON body`,{cause:n})}}function I(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 L(n,r,i){let a=_(r.token_endpoint,`token endpoint`,!0),o=i.intervalMilliseconds,s=null;for(;Date.now()<i.expiresAt;){await oe(o);let r;try{r=await fetch(a,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:m(n),grant_type:M,device_code:i.deviceCode})})}catch(e){s=`the token endpoint was unreachable — ${f(e)}`,D.write(j);continue}if(r.status>=A){await r.body?.cancel(),s=`the token endpoint answered ${r.status}`,D.write(j);continue}s=null;let c=await F(r,`token`);if(r.ok){let e=t.safeParse(c);if(!e.success)throw Error(`token endpoint returned an invalid token response`);return e.data}let l=e.safeParse(c),u=l.success?l.data.error:`HTTP ${r.status}`;if(u!==`authorization_pending`){if(u===`slow_down`)o+=k;else throw Error(u===`access_denied`?`the sign-in was denied in the browser`:u===`expired_token`?`the device code expired before approval`:`token endpoint answered ${u}`)}}throw Error(s===null?`the device code expired before approval`:`the device code expired before approval — last failure: ${s}`)}var R=3e5;function z(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 B(e,t){let n,r=new Promise(e=>{n=e}),i=se((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||!O(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}let d=a.searchParams.getAll(`iss`);d.length>1?(i.statusCode=400,i.end(`OAuth callback named more than one issuer.`)):(i.statusCode=200,i.end(`OAuth authorization completed. Return to the CLI.`),n({state:`code`,authorizationCode:u,iss:d[0]}))});i.on(`error`,e=>n({state:`failed`,message:`OAuth callback listener failed: ${f(e)}`}));try{let t=ae(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`}),R)})]).finally(()=>{e!==void 0&&clearTimeout(e)})},close:async()=>await V(i)}}catch(e){throw i.listening&&await V(i),e}}function V(e){return new Promise((t,n)=>{e.close(e=>e===void 0?t():n(e))})}var H=`the OAuth credential is valid, but the API refused this account (HTTP 403); signing in again will not change that`;async function U(e){let t;try{t=u(n().host)}catch(e){return i(`auth login: invalid API host — ${f(e)}`)}let o=await y(t);if(o.state===`missing`)return G(t,e);if(o.state===`unavailable`)return i(`auth login: ${o.summary}`);if(o.state===`invalid`)return G(t,e,`Saved OAuth credential cannot be read — ${o.summary}`);let{stored:s}=o;if(te(s.credential))return await W(s,e);let l;try{l=await a(s.credential.tokens.access_token,S(s.credential.client))}catch(n){return n instanceof c?G(t,e,`Saved OAuth credential was rejected`):i(`auth login: saved OAuth credential could not be verified — ${f(n,g(s.credential.tokens))}`)}return l===`forbidden`?i(`auth login: ${H}`):l===null?G(t,e,`Saved OAuth credential was rejected`):r(`OAuth CLI access token is already stored and verified.`,$(s))}async function W(e,t){let n=await v(e.host);if(n.state===`unavailable`)return i(`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 a;try{a=await ie(e)}catch(i){return G(e.host,t,`Saved OAuth credential could not be renewed — ${f(i,g(r))}`,n)}J(n);let o=await Q(e.host,a,`OAuth CLI access token renewed and verified.`);if(!o.ok)return o;let s=await Z(a);return s.state===`failed`?i(`auth login: ${s.summary}`):s.state===`rejected`?G(e.host,t,`Renewed OAuth access token was rejected`,n):o}async function G(e,t,n,r){let a=r??await v(e);if(a.state===`unavailable`)return i(`auth login: ${a.summary}`);J(a),n!==void 0&&D.write(`${n}; continuing to browser sign-in.\n`);let o;try{let e=(await Y()).oauthClient;if(e==null)throw Error(`the API does not advertise an OAuth CLI client`);o=e}catch(e){return i(`auth login: OAuth configuration is unavailable — ${f(e)}`)}let s;try{s=await X(o)}catch(e){return i(`auth login: OAuth authorization-server discovery failed — ${f(e)}`)}if(t.noBrowser)return await K(e,o,s);let c=ce(32).toString(`base64url`),l;try{l=await B(z(o),c);let t=await w(b(o),{metadata:s,clientInformation:{client_id:m(o)},redirectUrl:l.redirectUri,resource:S(o),scope:h(o).join(` `),state:c});t.authorizationUrl.searchParams.delete(`prompt`);let n=await ee(t.authorizationUrl,{noBrowser:!1});n.state===`opened`?D.write(`Browser sign-in opened: choose the account, then approve. Waiting for the loopback callback...
|
|
3
3
|
`):D.write(`Browser not opened automatically (${n.reason}).\nOpen this private sign-in URL in a browser that can reach this machine's loopback callback:
|
|
4
4
|
${t.authorizationUrl.toString()}\nWaiting for the loopback callback...\n`);let r=await l.waitForAuthorizationCode();if(r.state===`timed-out`)return await l.close(),l=void 0,D.write(`Browser sign-in was not completed; continuing with a device code.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as fetchAuthProviderCatalog,r as loginOAuthCredential,i as renewOAuthTokens}from"./oauth-login-
|
|
1
|
+
export{n as fetchAuthProviderCatalog,r as loginOAuthCredential,i as renewOAuthTokens}from"./oauth-login-BGsNjuan.js";
|