@aventurevc/aventure-cli 0.8.290 → 0.8.292
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 +49 -49
- package/dist/chunks/{api-key-bearer-credential-BMluEr_f.js → api-key-bearer-credential-B3se_F1i.js} +1 -1
- package/dist/chunks/{api-key-bearer-credential-DZF0_Kfc.js → api-key-bearer-credential-BaoRcNkq.js} +1 -1
- package/dist/chunks/{api-key-credential-ChxzjOuF.js → api-key-credential-CinaNDln.js} +1 -1
- package/dist/chunks/{api-key-credential-BegTzVQm.js → api-key-credential-D4bb8GPN.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-UYqfiy0G.js → api-key-credential-verification-Dym59aOM.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-BX5JmE_O.js → api-key-credential-verification-JBxAP14v.js} +1 -1
- package/dist/chunks/{api-key-login-C1IYHo4P.js → api-key-login-CRlD8Hdw.js} +1 -1
- package/dist/chunks/auth-resolver-BXhNcSxB.js +1 -0
- package/dist/chunks/{auth-resolver-Dr6cdiZa.js → auth-resolver-BtalY5VS.js} +1 -1
- package/dist/chunks/{auth-status-check-fG-9iO2K.js → auth-status-check-0ePRcfng.js} +1 -1
- package/dist/chunks/{auth-status-check-D0txAx9a.js → auth-status-check-L5XKjyEd.js} +1 -1
- package/dist/chunks/{auth-status-render-C_3x5fkF.js → auth-status-render-T4-yV9fp.js} +1 -1
- package/dist/chunks/{aventure-cli-DLIb_6o0.js → aventure-cli-CGapiYCc.js} +5 -5
- package/dist/chunks/{batch-io-BkB1uCIG.js → batch-io-DvVHFAm1.js} +1 -1
- package/dist/chunks/{builtin-auth-BW6XQnyE.js → builtin-auth-BPepC3qA.js} +4 -4
- package/dist/chunks/builtin-run-wait-BhrC4p34.js +1 -0
- package/dist/chunks/{builtin-update-BUYGTZn6.js → builtin-update-ClVqHjfb.js} +1 -1
- package/dist/chunks/{cli-help-policy-BB_tvwV5.js → cli-help-policy-EqwYSBOi.js} +1 -1
- package/dist/chunks/{completion-B6OstKEu.js → completion-CrxyFr6i.js} +1 -1
- package/dist/chunks/{contract-BIbN8zfH.js → contract-B6QqVAgo.js} +1 -1
- package/dist/chunks/{contract-parameter-vSu_ZE57.js → contract-parameter-DZFV8Cs1.js} +1 -1
- package/dist/chunks/{credential-redaction-1KvG1I2A.js → credential-redaction-C08ZVt7t.js} +1 -1
- package/dist/chunks/{credential-store-iLl096PD.js → credential-store-DhTI6Vkx.js} +1 -1
- package/dist/chunks/{env-D4lMZw-8.js → env-B0nFdXns.js} +1 -1
- package/dist/chunks/{generated-option-order-BkjcNcaN.js → generated-option-order-CG9WMlq9.js} +1 -1
- package/dist/chunks/{help-catalog-CvfEYwPL.js → help-catalog-B8JUR6zB.js} +1 -1
- package/dist/chunks/{help-intent-i4bvvWxC.js → help-intent-CGB8sWuW.js} +1 -1
- package/dist/chunks/{logging-BFASdeBx.js → logging-BLz3ITZ8.js} +1 -1
- package/dist/chunks/{logging-CD850a3X.js → logging-D5jL7iVk.js} +1 -1
- package/dist/chunks/{logout-DQGjvSlu.js → logout-7Kj-lSJ8.js} +1 -1
- package/dist/chunks/logout-CwWDCvm9.js +1 -0
- package/dist/chunks/mcp-generation-contract-C1XGcFYq.js +1 -0
- package/dist/chunks/{mcp-generation-contract-DKKLGq3j.js → mcp-generation-contract-JICRiDpb.js} +1 -1
- package/dist/chunks/oauth-bearer-credential-B90_0m1y.js +1 -0
- package/dist/chunks/{oauth-bearer-credential-CTk3JD-X.js → oauth-bearer-credential-Bo4Batar.js} +1 -1
- package/dist/chunks/{oauth-credential-DNPeHTcs.js → oauth-credential-B-ClOD2R.js} +1 -1
- package/dist/chunks/{oauth-credential-GVGWH-DR.js → oauth-credential-sVZgsb1B.js} +1 -1
- package/dist/chunks/{oauth-login-5xpFwoR0.js → oauth-login-DATtqIu1.js} +1 -1
- package/dist/chunks/{oauth-login-DKYtuGmh.js → oauth-login-DpYCqeAI.js} +1 -1
- package/dist/chunks/{openapi-call-wnUkIXxc.js → openapi-call-Cexzbbt7.js} +1 -1
- package/dist/chunks/{openapi-call-CpON5wqD.js → openapi-call-Ch3_9dpf.js} +1 -1
- package/dist/chunks/openapi-commands-C5nlH1da.js +1 -0
- package/dist/chunks/{openapi-commands-Cx-K_lwh.js → openapi-commands-CECTft6K.js} +1 -1
- package/dist/chunks/openapi-snapshot.json +1 -1
- package/dist/chunks/{operations-Cen6uwSM.js → operations-U1u_HvKU.js} +2 -2
- package/dist/chunks/operations-catalog-CVHLwnGb.js +1 -0
- package/dist/chunks/{operations-catalog-xz1ttxg5.js → operations-catalog-E_BgS29v.js} +1 -1
- package/dist/chunks/{operations-metadata-DsfG8AY3.js → operations-metadata-CQE-KJJ2.js} +1 -1
- package/dist/chunks/{output-5g86W1kU.js → output-B4vFYIk5.js} +1 -1
- package/dist/chunks/{output-BlymsqT4.js → output-DnYn9JLl.js} +1 -1
- package/dist/chunks/{output-mode-BxLHyuo2.js → output-mode-DA6P7QJC.js} +1 -1
- package/dist/chunks/output-mode-DzK-KTAx.js +1 -0
- package/dist/chunks/{output-spill-D9G-tWU9.js → output-spill-CuQ24_Xn.js} +1 -1
- package/dist/chunks/{parse-error-hint-Ow2TdC4V.js → parse-error-hint-BbTb0kHW.js} +1 -1
- package/dist/chunks/{payload-operand-guard-B9PZN96c.js → payload-operand-guard-BPI5mc9F.js} +1 -1
- package/dist/chunks/private-run-read-DM_02z6l.js +1 -0
- package/dist/chunks/{request-replay-B6JNLRrJ.js → request-replay-zMBhTFrR.js} +1 -1
- package/dist/chunks/{request-replay-CxaD7_FL.js → request-replay-zWu_6Sak.js} +1 -1
- package/dist/chunks/response-problem-B3Q-8otA.js +1 -0
- package/dist/chunks/{response-problem-TCwoXCAT.js → response-problem-B6bUo9co.js} +1 -1
- package/dist/chunks/result-envelope-5DwGbGQt.js +1 -0
- package/dist/chunks/{startup-auth-y9T33mGF.js → startup-auth-8hH2Q16F.js} +1 -1
- package/dist/chunks/{startup-auth-ynvjKOGF.js → startup-auth-BeHVkU9g.js} +1 -1
- package/dist/chunks/{text-response-D_S0HvLU.js → text-response-P41LwuTT.js} +1 -1
- package/dist/chunks/{tool-policy-WURn1WGx.js → tool-policy-BnoDi0Yk.js} +1 -1
- package/package.json +3 -3
- package/dist/chunks/auth-resolver-D3JQo0Sd.js +0 -1
- package/dist/chunks/builtin-research-run-wait-DiP_YACC.js +0 -1
- package/dist/chunks/logout-CrtcVV2r.js +0 -1
- package/dist/chunks/mcp-generation-contract-g09ghcqd.js +0 -1
- package/dist/chunks/oauth-bearer-credential-q-6Fh37V.js +0 -1
- package/dist/chunks/openapi-commands-CHtb4AKj.js +0 -1
- package/dist/chunks/operations-catalog-CiUxguPl.js +0 -1
- package/dist/chunks/output-mode-D0olAapl.js +0 -1
- package/dist/chunks/research-run-spend-D9aXcq6b.js +0 -1
- package/dist/chunks/response-problem-C_lGuxhw.js +0 -1
- package/dist/chunks/result-envelope-Dy-nSLrT.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as e,n as t,o as n,r,t as i}from"./commander-DEj7N1b9.js";import{a}from"./package-DEeHDoOT.js";import{a as o,c as s,l as c,r as l}from"./env-D4lMZw-8.js";import{c as u,p as d,r as f}from"./result-envelope-Dy-nSLrT.js";import{L as p,R as m,o as h,t as g,u as _,y as v}from"./tool-policy-WURn1WGx.js";import{i as y}from"./logging-BFASdeBx.js";import{r as ee,t as te}from"./cli-help-policy-BB_tvwV5.js";import{a as ne,c as re,d as ie,f as ae,l as oe,n as se,o as b,r as ce,s as x,t as le,u as ue}from"./startup-auth-ynvjKOGF.js";import{t as S}from"./openapi-commands-CHtb4AKj.js";import{_ as de,h as fe}from"./help-catalog-CvfEYwPL.js";import{n as pe,t as me}from"./operations-metadata-DsfG8AY3.js";import{a as C,i as he,t as w}from"./output-mode-BxLHyuo2.js";import{S as ge,_ as T,a as _e,b as E,c as ve,d as ye,f as be,g as xe,h as Se,i as D,l as O,m as k,n as A,o as j,p as Ce,r as we,s as Te,t as Ee,u as De,v as M,x as Oe,y as N}from"./generated-option-order-BkjcNcaN.js";import{a as ke,i as Ae,n as je,r as Me}from"./payload-operand-guard-B9PZN96c.js";import{fileURLToPath as Ne}from"node:url";import{readFile as Pe}from"node:fs/promises";async function Fe(e){let t;try{t=e===`-`?await Ie():await Pe(e,`utf8`)}catch(t){return f(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return u(`No input provided`,null);let e=JSON.parse(t);return u(`Input parsed`,e)}catch(e){return f(`Input is not valid JSON: ${e.message}`)}}async function Ie(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var P=`--content-type`;function Le(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(P)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${P} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(ze(a)))}if(z(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,_e(r,r.requiredPath)).argParser(F(`--from-file`)))}let o=j(a).filter(e=>i(I(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>A(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(D(n),a.length>1?we(n):ve(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Te(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Re):M(i.name)||i.schemaType===`array`?o.argParser(Be):o.argParser(F(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}$e(e,n,o)}function Re(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function ze(e){return(t,r)=>{if(r!==void 0)throw new n(`${P} was already given; pass it once.`);let i=v(e,t);if(!i.ok)throw new n(i.summary);return t}}function Be(e,t){return[...t??[],e]}function F(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Ve(e,t){let n=x(e,t),r=v(e.requestBody??[],n);if(!r.ok||r.data===null)return f(r.summary,r.warnings);let i=r.data;if(i===void 0)return u(`No body`,void 0);let a=He(e,i,t);if(a!==null)return f(a);let o=k(e.operationId,i,t);if(!o.ok)return f(o.summary,o.warnings);t=o.data;let s=Ue(i,t);if(s!==null)return f(s);let c=await qe(t);if(!c.ok)return f(c.summary,c.warnings);let l=Se(e.requestBody??[],i,c.data);if(l!==null)return f(l);let d=Ke(e.operationId,i,c.data);if(!d.ok)return d;let p=xe(e.operationId,i,c.data);if(p!==null)return f(p);let m=Je(e.operationId,i,t);if(!m.ok)return m;if(c.data===void 0&&m.data===void 0)return i.required?f(Qe(e.operationId,i)):u(`No body`,void 0);let h=Xe(e.operationId,i,c.data,m.data);if(!h.ok||h.data===void 0)return h;if(i.schemaType===`array`&&!Array.isArray(h.data))return f(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!N(h.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return f(`${e.operationId} requires a JSON object${t}.`)}let g=Ge(i,h.data);if(g.length>0)return f(`${e.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,y=N(_)?E(i).filter(e=>!T(_,e)):[];return y.length>0?f(We(e.operationId,i,y)):h}function He(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${I(t)} requires ${P} ${i.join(` or `)}.`}return null}function Ue(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 We(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 Ge(e,t){return N(t)?e.parameter.filter(e=>e.required&&!T(t,e.name)).map(I):[]}function Ke(e,t,n){let r=ge(t,n);return r===null?u(`Body file paths validated`,null):f(`${e} --from-file contains ${r.message}`)}async function qe(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return u(`No body file`,void 0);let n=await Fe(t);if(!n.ok)return f(n.summary,n.warnings);let r=d.safeParse(n.data);return r.success?u(`Input parsed`,r.data):f(`Input is not valid JSON value: ${r.error.message}`)}function Je(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Oe(e,n[e.optionKey]);if(!a.ok||a.data===null)return f(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Ye(t,n,r,e,o);if(!s.ok)return f(s.summary,s.warnings);i=!0}if(!i)return u(`No direct body options`,void 0);let a=ye(e,t,n,r);return a===null?u(`Direct body options parsed`,r):a}function Ye(e,t,n,r,i){let a=O(e,t,r);if(a===null){let e=Ze(r,i);return e.ok?be(n,r.name,e.data,r.schemaType===`array`):f(e.summary,e.warnings)}let o=De(e,t,r,a);if(o!==null)return f(o);let s=r.schemaType===`array`,c=s?r.itemSchemaType:r.schemaType;for(let[e,t]of a.rows){let i=[];for(let e of t){let t=R(r.name,c,e);if(!t.ok)return f(t.summary,t.warnings);i.push(t.data)}for(let t of s?[i]:i){let i=Ce(n,r.name,e,t);if(!i.ok)return i}}return u(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function Xe(e,t,n,r){if(n===void 0)return u(`Direct body parsed`,r);if(r===void 0)return u(`Input parsed`,n);if(N(n)&&N(r))try{return u(`Input parsed`,L(t,n,r))}catch(t){return f(`${e} ${t instanceof Error?t.message:String(t)}`)}return f(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function L(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(N(n)&&N(a))i[t]=L(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:fe.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function Ze(e,t){if(typeof t==`boolean`)return u(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return R(e.name,e.schemaType,t??``);let n=[],r=M(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=R(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return u(`Body value parsed`,n)}function R(e,t,n){if(t===`boolean`)return n===`true`?u(`Body value parsed`,!0):n===`false`?u(`Body value parsed`,!1):f(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?f(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?f(`${e} must be an integer.`):u(`Body value parsed`,i)}return u(`Body value parsed`,n)}function Qe(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=E(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 $e(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:P,location:`body`}),z(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Ee(e.options,r)}function z(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function et(e,t,n=a().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show full documentation for a command, search the catalog, or ask a question`).description("Show a command's full documentation offline. Select it by command path,\noperationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.\n`help catalog [query...]` searches or lists every operation;\n`help ask <question>` answers a platform question.").argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new tt(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()}),w(r),r.action(async function(r){let{emit:i}=await import(`./output-5g86W1kU.js`),a=this.optsWithGlobals();if(a.help&&r.length===0){this.outputHelp();return}let o=G(e,r),s=t.find(t=>o!==void 0&&G(e,t.cliPath)===o);if(a.help||o!==void 0&&s===void 0){o===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),o.outputHelp();return}let c=s===void 0?await it(r,t):u(`Resolved by command path`,{operationId:s.operationId});if(c.ok&&c.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!c.ok||c.data===null){i({mode:C(a)},c);return}let{writeShowResult:l}=await import(`./operations-catalog-CiUxguPl.js`);l({...a,...c.data},t,C(a,`text`),n)}),rt(e,t,n)}var tt=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},B=2,V=6,nt={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>b[e.name()]?.listed!==!1):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(B)}${e}\n${H(n,a,i)}`}};function H(e,t,n){return n.boxWrap(e,t-V).replace(/^/gmu,` `.repeat(V))}function rt(e,t,n){for(let r of t){let i=G(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=de(r.operationId,t,n),c=U(pe(r.header),o,e),l=U(me(r.errorResponse),o,e);return`\n${[...s,...c,...l].join(`
|
|
2
|
-
`)}\n`})}}function U(e,t,n){let[r,...i]=e;return r===void 0?[]:[``,r,...i.map(e=>H(e.trimStart(),t,n).replace(/^ +/u,` `.repeat(B)))]}var W='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';async function it(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?u(`Resolved by route`,{operationId:i.operationId}):f(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[W]);let o=p.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return u(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=m(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return u(`Resolved by route template`,{operationId:l.operationId});let{resolveOpenApiOperationSelector:d}=await import(`./openapi-call-
|
|
3
|
-
`)),!o)return;let y=ie(t);for(let e of t.parameters)ft(m,e,i||e===y);Le(m,t),_(t.intent)&&!m.options.some(e=>e.long===`--execute`)&&m.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),w(m),m.hook(`preAction`,e=>ue(e,t)),t.explain===!0&&m.option(`--explain`,`Print the search strategy and parsed constraints before the results`),y!==void 0&&m.argument(`[text...]`,y.description||`Same as ${re(y.flag)}.`),m.action(async function(){let{emit:e,emitSearchExplanation:n}=await import(`./output-
|
|
1
|
+
import{a as e,n as t,o as n,r,t as i}from"./commander-DEj7N1b9.js";import{a}from"./package-DEeHDoOT.js";import{a as o,c as s,l as c,r as l}from"./env-B0nFdXns.js";import{c as u,p as d,r as f}from"./result-envelope-5DwGbGQt.js";import{L as p,R as m,o as h,t as g,u as _,y as v}from"./tool-policy-BnoDi0Yk.js";import{i as y}from"./logging-BLz3ITZ8.js";import{r as ee,t as te}from"./cli-help-policy-EqwYSBOi.js";import{a as ne,c as re,d as ie,f as ae,l as oe,n as se,o as b,r as ce,s as x,t as le,u as ue}from"./startup-auth-BeHVkU9g.js";import{t as S}from"./openapi-commands-C5nlH1da.js";import{_ as de,h as fe}from"./help-catalog-B8JUR6zB.js";import{n as pe,t as me}from"./operations-metadata-CQE-KJJ2.js";import{a as C,i as he,t as w}from"./output-mode-DA6P7QJC.js";import{S as ge,_ as T,a as _e,b as E,c as ve,d as ye,f as be,g as xe,h as Se,i as D,l as O,m as k,n as A,o as j,p as Ce,r as we,s as Te,t as Ee,u as De,v as M,x as Oe,y as N}from"./generated-option-order-CG9WMlq9.js";import{a as ke,i as Ae,n as je,r as Me}from"./payload-operand-guard-BPI5mc9F.js";import{fileURLToPath as Ne}from"node:url";import{readFile as Pe}from"node:fs/promises";async function Fe(e){let t;try{t=e===`-`?await Ie():await Pe(e,`utf8`)}catch(t){return f(`Could not read input: ${t.message}`,[`path=${e}`])}try{if(t.trim().length===0)return u(`No input provided`,null);let e=JSON.parse(t);return u(`Input parsed`,e)}catch(e){return f(`Input is not valid JSON: ${e.message}`)}}async function Ie(){if(process.stdin.isTTY)throw Error(`--from-file - requires JSON on stdin, but stdin is a TTY`);process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}var P=`--content-type`;function Le(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(P)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${P} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(ze(a)))}if(z(n)&&i(`--from-file`)){let r=a[0];if(r===void 0)throw Error(`${n.operationId} has no request body`);e.addOption(new t(`--from-file <path>`,_e(r,r.requiredPath)).argParser(F(`--from-file`)))}let o=j(a).filter(e=>i(I(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>A(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(D(n),a.length>1?we(n):ve(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Te(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(Re):M(i.name)||i.schemaType===`array`?o.argParser(Be):o.argParser(F(i.flag)),e.addOption(o),o.envVar!==void 0&&e.on(`optionEnv:${o.name()}`,()=>{let t=e.opts()[i.optionKey];typeof t==`string`&&t.trim()&&e.setOptionValueWithSource(i.optionKey,t.trim(),`env`)})}$e(e,n,o)}function Re(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function ze(e){return(t,r)=>{if(r!==void 0)throw new n(`${P} was already given; pass it once.`);let i=v(e,t);if(!i.ok)throw new n(i.summary);return t}}function Be(e,t){return[...t??[],e]}function F(e){let t=e.split(/\s+/u)[0]??e;return(e,r)=>{if(r!==void 0)throw new n(`${t} was already given; pass it once.`);return e}}async function Ve(e,t){let n=x(e,t),r=v(e.requestBody??[],n);if(!r.ok||r.data===null)return f(r.summary,r.warnings);let i=r.data;if(i===void 0)return u(`No body`,void 0);let a=He(e,i,t);if(a!==null)return f(a);let o=k(e.operationId,i,t);if(!o.ok)return f(o.summary,o.warnings);t=o.data;let s=Ue(i,t);if(s!==null)return f(s);let c=await qe(t);if(!c.ok)return f(c.summary,c.warnings);let l=Se(e.requestBody??[],i,c.data);if(l!==null)return f(l);let d=Ke(e.operationId,i,c.data);if(!d.ok)return d;let p=xe(e.operationId,i,c.data);if(p!==null)return f(p);let m=Je(e.operationId,i,t);if(!m.ok)return m;if(c.data===void 0&&m.data===void 0)return i.required?f(Qe(e.operationId,i)):u(`No body`,void 0);let h=Xe(e.operationId,i,c.data,m.data);if(!h.ok||h.data===void 0)return h;if(i.schemaType===`array`&&!Array.isArray(h.data))return f(`${e.operationId} requires a JSON array body.`);if(i.parameter.length>0&&!N(h.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return f(`${e.operationId} requires a JSON object${t}.`)}let g=Ge(i,h.data);if(g.length>0)return f(`${e.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,y=N(_)?E(i).filter(e=>!T(_,e)):[];return y.length>0?f(We(e.operationId,i,y)):h}function He(e,t,n){let r=new Set(t.parameter.map(({optionKey:e})=>e));for(let i of e.requestBody??[])if(i!==t)for(let t of i.parameter){if(r.has(t.optionKey)||n[t.optionKey]===void 0)continue;let i=(e.requestBody??[]).filter(e=>e.parameter.some(({optionKey:e})=>e===t.optionKey)).map(({contentType:e})=>e);return`${I(t)} requires ${P} ${i.join(` or `)}.`}return null}function Ue(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 We(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 Ge(e,t){return N(t)?e.parameter.filter(e=>e.required&&!T(t,e.name)).map(I):[]}function Ke(e,t,n){let r=ge(t,n);return r===null?u(`Body file paths validated`,null):f(`${e} --from-file contains ${r.message}`)}async function qe(e){let t=typeof e.fromFile==`string`?e.fromFile:void 0;if(t===void 0)return u(`No body file`,void 0);let n=await Fe(t);if(!n.ok)return f(n.summary,n.warnings);let r=d.safeParse(n.data);return r.success?u(`Input parsed`,r.data):f(`Input is not valid JSON value: ${r.error.message}`)}function Je(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Oe(e,n[e.optionKey]);if(!a.ok||a.data===null)return f(a.summary,a.warnings);let o=a.data;if(o===void 0)continue;let s=Ye(t,n,r,e,o);if(!s.ok)return f(s.summary,s.warnings);i=!0}if(!i)return u(`No direct body options`,void 0);let a=ye(e,t,n,r);return a===null?u(`Direct body options parsed`,r):a}function Ye(e,t,n,r,i){let a=O(e,t,r);if(a===null){let e=Ze(r,i);return e.ok?be(n,r.name,e.data,r.schemaType===`array`):f(e.summary,e.warnings)}let o=De(e,t,r,a);if(o!==null)return f(o);let s=r.schemaType===`array`,c=s?r.itemSchemaType:r.schemaType;for(let[e,t]of a.rows){let i=[];for(let e of t){let t=R(r.name,c,e);if(!t.ok)return f(t.summary,t.warnings);i.push(t.data)}for(let t of s?[i]:i){let i=Ce(n,r.name,e,t);if(!i.ok)return i}}return u(`Body value assigned`,null)}var I=e=>e.flag.split(` `)[0]??e.name;function Xe(e,t,n,r){if(n===void 0)return u(`Direct body parsed`,r);if(r===void 0)return u(`Input parsed`,n);if(N(n)&&N(r))try{return u(`Input parsed`,L(t,n,r))}catch(t){return f(`${e} ${t instanceof Error?t.message:String(t)}`)}return f(`${e} cannot combine --from-file with direct body options unless the file body is an object.`)}function L(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(N(n)&&N(a))i[t]=L(e,n,a,`${o}.`);else if(n===void 0||n===a)i[t]=a;else throw Error(`sets JSON key '${o}' both in --from-file and with ${e.parameter.find(({name:e})=>e===o)?.flag.split(` `)[0]??`body options`} — set it in one place${Array.isArray(n)?`: move the per-item fields inside the matching '${o}[]' object(s) in the file body`:fe.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function Ze(e,t){if(typeof t==`boolean`)return u(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return R(e.name,e.schemaType,t??``);let n=[],r=M(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=R(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return u(`Body value parsed`,n)}function R(e,t,n){if(t===`boolean`)return n===`true`?u(`Body value parsed`,!0):n===`false`?u(`Body value parsed`,!1):f(`${e} must be true or false.`);if(t===`number`||t===`integer`){let r=n.trim(),i=Number(r);return r===``||!Number.isFinite(i)?f(`${e} must be a finite ${t}.`):t===`integer`&&!Number.isInteger(i)?f(`${e} must be an integer.`):u(`Body value parsed`,i)}return u(`Body value parsed`,n)}function Qe(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=E(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 $e(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:P,location:`body`}),z(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),Ee(e.options,r)}function z(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function et(e,t,n=a().bin[0]){e.helpCommand(!1);let r=e.commands.find(e=>e.name()===`help`)??e.command(`help`);r.summary(`Show full documentation for a command, search the catalog, or ask a question`).description("Show a command's full documentation offline. Select it by command path,\noperationId, or `<METHOD> <path>`; `<command> --help` prints only its usage.\n`help catalog [query...]` searches or lists every operation;\n`help ask <question>` answers a platform question.").argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new tt(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()}),w(r),r.action(async function(r){let{emit:i}=await import(`./output-B4vFYIk5.js`),a=this.optsWithGlobals();if(a.help&&r.length===0){this.outputHelp();return}let o=G(e,r),s=t.find(t=>o!==void 0&&G(e,t.cliPath)===o);if(a.help||o!==void 0&&s===void 0){o===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),o.outputHelp();return}let c=s===void 0?await it(r,t):u(`Resolved by command path`,{operationId:s.operationId});if(c.ok&&c.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!c.ok||c.data===null){i({mode:C(a)},c);return}let{writeShowResult:l}=await import(`./operations-catalog-CVHLwnGb.js`);l({...a,...c.data},t,C(a,`text`),n)}),rt(e,t,n)}var tt=class extends t{helpCommand;constructor(e){super(`-h, --help`,`display help for command`),this.helpCommand=e}is(e){if(e!==this.short&&e!==this.long)return!1;let t=this.helpCommand.parent?.args??[],n=t.findIndex(e=>e===this.helpCommand.name()||this.helpCommand.aliases().includes(e)),r=n<0?void 0:t[n+1];return r===void 0||r.startsWith(`-`)?!0:!this.helpCommand.commands.some(e=>e.name()===r||e.aliases().includes(r))}},B=2,V=6,nt={formatHelp(e,t){let n=n=>r.prototype.formatHelp.call(this,e,Object.assign(Object.create(t),n));if(t.visibleCommands(e).length===0)return n({});let i=t.padWidth(e,t),a={padWidth:()=>i,visibleOptions:()=>[],showGlobalOptions:!1},o=n({...a,visibleCommands:()=>[]}),s=n({padWidth:()=>i,visibleCommands:()=>[]}).slice(o.length);return n(a)+s},visibleCommands(e){let t=r.prototype.visibleCommands.call(this,e);return e.parent===null?t.filter(e=>b[e.name()]?.listed!==!1):t},subcommandTerm(e){let t=r.prototype.subcommandTerm.call(this,e);return e.commands.length>0&&e.registeredArguments.length===0?`${t} <command>`:t},formatItem(e,t,n,i){let a=i.helpWidth??80,o=a-t-4;return n===``||o>=i.minWidthToWrap?r.prototype.formatItem.call(i,e,t,n,i):`${` `.repeat(B)}${e}\n${H(n,a,i)}`}};function H(e,t,n){return n.boxWrap(e,t-V).replace(/^/gmu,` `.repeat(V))}function rt(e,t,n){for(let r of t){let i=G(e,r.cliPath);i!==void 0&&i.addHelpText(`after`,()=>{let e=i.createHelp(),a=i.configureOutput().getOutHelpWidth?.();e.prepareContext(a===void 0?{}:{helpWidth:a});let o=e.helpWidth??80,s=de(r.operationId,t,n),c=U(pe(r.header),o,e),l=U(me(r.errorResponse),o,e);return`\n${[...s,...c,...l].join(`
|
|
2
|
+
`)}\n`})}}function U(e,t,n){let[r,...i]=e;return r===void 0?[]:[``,r,...i.map(e=>H(e.trimStart(),t,n).replace(/^ +/u,` `.repeat(B)))]}var W='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';async function it(e,t){let[n=``,...r]=e.join(` `).trim().split(/\s+/u),[i,...a]=t.filter(e=>e.path===n);if(r.length===0&&i!==void 0)return a.length===0?u(`Resolved by route`,{operationId:i.operationId}):f(`${n} is served by ${[i,...a].map(({method:e})=>e).join(`, `)}; name the method, as in \`help ${i.method} ${n}\`.`,[W]);let o=p.find(e=>e===n.toLowerCase());if(o===void 0||r.length===0){let n=e.join(` `).trim();return u(`Resolved by name`,t.some(e=>e.operationId===n)?{operationId:n}:{command:n})}let s=m(o),c=r.join(``),l=t.find(e=>e.method===s&&e.path===c);if(l!==void 0)return u(`Resolved by route template`,{operationId:l.operationId});let{resolveOpenApiOperationSelector:d}=await import(`./openapi-call-Cexzbbt7.js`),h=d({method:s,path:c});return!h.ok||h.data===null?f(h.summary,[...h.warnings,W]):u(`Resolved by method and path`,{operationId:h.data.operation.operationId})}function G(e,t){let n=e;for(let e of t){let t=n.commands.find(t=>t.name()===e||t.aliases().includes(e));if(t===void 0)return;n=t}return n}function at(e,t,n){if(e.cliPath[0]!==`lookup`||!ot(n))return null;let r=e.parameters.filter(e=>t[e.optionKey]!==void 0).map(e=>`${e.name}=${String(t[e.optionKey])}`),i=`no record for ${r.length===0?`the given input`:r.join(`, `)}`;return n.ok?f(i):f(i,[],{httpStatus:n.httpStatus,problem:n.problem})}function ot(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function st(e,t){if(e.deprecated!==!0)return t;let n=e.description.match(/^Deprecated:[^.]*\./u)?.[0]??`Deprecated; run \`help ${e.cliPath.join(` `)}\` for its replacement.`;return{...t,warnings:[n,...t.warnings]}}function ct(t,n,r,i){let a=K(t),o=a instanceof e?[]:a,s=o[0],c=i.bin[0],l=[{selected:s===`auth`,register:async()=>{let{registerBuiltinAuthCommands:e}=await import(`./builtin-auth-BPepC3qA.js`);e(n,c)}},{selected:s===`agents`,register:async()=>{let{registerBuiltinAgentSetupCommand:e}=await import(`./builtin-agent-setup-B2Xvqera.js`);e(n,c)}},{selected:s===`update`,register:async()=>{let{registerBuiltinUpdateCommand:e}=await import(`./builtin-update-ClVqHjfb.js`);e(n,i)}},{selected:s===`batch`,register:async()=>{let{registerBuiltinBatchCommand:e}=await import(`./builtin-batch-DdGyCjlR.js`);e(n,r,c)}},{selected:s===`research`||s===`research-runs`||s===`data-engineering`,register:async()=>{let{registerBuiltinRunWaitCommand:e}=await import(`./builtin-run-wait-BhrC4p34.js`);await e(n)}},{selected:s===`completion`,register:async()=>{let{registerCompletionCommand:e}=await import(`./completion-CrxyFr6i.js`);e(n,r,c)}},{selected:s===`help`,register:async()=>{let{registerHelpCatalogCommand:e}=await import(`./operations-U1u_HvKU.js`);e(n,r,c)}},{selected:s===`command-catalog`,register:async()=>{let{registerRetiredCommandCatalog:e}=await import(`./operations-U1u_HvKU.js`);e(n,r,c)}}],u=s===void 0||s===`help`||s===`completion`||s===`command-catalog`||!l.some(e=>e.selected)&&!r.some(e=>e.cliPath[0]===s),d=1;for(;d<o.length&&r.some(e=>o.slice(0,d+1).every((t,n)=>e.cliPath[n]===t));)d++;let f=o.slice(0,d),p=u?r:r.filter(e=>f.slice(0,e.cliPath.length).every((t,n)=>e.cliPath[n]===t)),m=new Set,h=async(e=!1)=>{for(let t of l)(e||u||t.selected)&&!m.has(t)&&(await t.register(),m.add(t))};return{generated:p,fullTree:u,rootHelp:t.length>0&&t.every(e=>e===`--help`||e===`-h`),registerBuiltin:h,async completeTree(e){e(n,r.filter(e=>!p.includes(e))),await h(!0)}}}function K(n){try{return new i().exitOverride().configureOutput({writeErr:()=>void 0}).addOption(new t(`--environment <environment>`)).parseOptions([...n]).operands}catch(t){if(!(t instanceof e))throw t;return t}}var lt=new Set(S.map(e=>e.cliPath.join(` `)));function q(e,t){e.showHelpAfterError(!1).exitOverride(t(e)),e.commands.length===0?e.hook(`preAction`,je):e.registeredArguments.length===0&&!lt.has(ke(e).join(` `))&&e.addHelpOption(new Ae(e));for(let n of e.commands)q(n,t)}function J(e){return te[ee(e,b)??`cli`]}function Y(e,t,n,{rootHelp:r=!1}={}){let i=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:J(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),a=new Set(i.filter(e=>le(e.cliPath[0])).map(e=>e.cliPath[0]??``)),o=new Set,s=new Set;for(let{cliPath:e,deprecated:t}of i)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);o.add(r),t!==!0&&s.add(r)}for(let t of i)ut(e,t,a,s,o.has(t.cliPath.join(` `)),n,!r||t.cliPath.length===1)}function ut(e,t,n,r,i,a,o){let s=t.cliPath,c=e,l=``,u=!n.has(s[0]??``);for(let e of s.slice(0,-1)){l=l===``?e:`${l} ${e}`;let t=u&&l===e||!r.has(l);c=dt(c,e,l,t)}let d=s.at(-1)??t.operationId,p=t.deprecated===!0&&r.has(s.join(` `)),m=c.commands.find(e=>e.name()===d)??c.command(d,t.deprecated===!0&&!p?{hidden:!0}:{}),v=t.requestBody?.flatMap(({parameter:e})=>e)??[];if(m.summary((p?b[s.join(` `)]?.summary:void 0)??(t.summary||t.operationId)).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${a} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...v].some(e=>h(e.schemaType,e.itemSchemaType))?g:``].filter(Boolean).join(`
|
|
3
|
+
`)),!o)return;let y=ie(t);for(let e of t.parameters)ft(m,e,i||e===y);Le(m,t),_(t.intent)&&!m.options.some(e=>e.long===`--execute`)&&m.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),w(m),m.hook(`preAction`,e=>ue(e,t)),t.explain===!0&&m.option(`--explain`,`Print the search strategy and parsed constraints before the results`),y!==void 0&&m.argument(`[text...]`,y.description||`Same as ${re(y.flag)}.`),m.action(async function(){let{emit:e,emitSearchExplanation:n}=await import(`./output-B4vFYIk5.js`),r=this.optsWithGlobals(),i=C(r),a=r;if(y!==void 0){let t=ae(y,this.args,r);if(!t.ok||t.data===null)return e({mode:i},t);a=t.data}let o=oe(t,a);if(o.length>0)return e({mode:i},f(`missing required options: ${o.join(`, `)}`));let s=await pt(t,a,i),c=at(t,a,s);if(c!==null)return e({mode:i},c);r.explain===!0&&s.ok&&n(i,s.data),s.ok&&s.data instanceof Uint8Array&&i!==`csv`&&i!==`xlsx`?process.stdout.write(s.data):e({mode:i},s)})}function dt(e,t,n,r){let i=e.commands.find(e=>e.name()===t);if(i!==void 0)return i;let a=b[n],o=e.command(t,r?{hidden:!0}:{}).helpCommand(!1);return a!==void 0&&o.summary(a.summary).description(a.summary),o}function ft(e,n,r=!1){let i=n.description||`${n.name} ${n.location} parameter`,a=n.defaultValue===void 0?void 0:typeof n.defaultValue==`string`||typeof n.defaultValue==`boolean`?n.defaultValue:[...n.defaultValue];if(n.legacyFlag!==void 0){let o=new t(n.flag,i);a!==void 0&&o.default(a);let s=new t(n.legacyFlag,i).conflicts(n.optionKey);e.addOption(o).addOption(s),e.hook(`preAction`,e=>{let t=e.opts(),i=t[n.optionKey],a=t[s.attributeName()];a===void 0?!r&&n.required&&i===void 0&&e.error(`error: required option '${o.flags}' not specified`,{code:`commander.missingMandatoryOptionValue`}):(i===void 0||e.getOptionValueSource(n.optionKey)==="default")&&e.setOptionValueWithSource(n.optionKey,a,`cli`)})}else a===void 0?n.required&&!r?e.requiredOption(n.flag,i):e.option(n.flag,i):e.option(n.flag,i,a)}async function pt(e,t,n){let{buildOpenApiPath:r,runOpenApiCall:i}=await import(`./openapi-call-Cexzbbt7.js`),{pendingResult:a}=await import(`./output-B4vFYIk5.js`);if(t.environment!==void 0){let e=c(t.environment);if(e===null)return f(`Unknown aVenture environment '${t.environment}'`,[`Use one of: ${s().join(`, `)}`]);process.env.API_ENV=e}let o=await Ve(e,t);if(!o.ok)return o;let l=Object.fromEntries(e.parameters.filter(e=>e.location===`path`).map(e=>{let n=t[e.optionKey];if(Array.isArray(n))return[e.name,n.at(0)??``];if(n===void 0)throw Error(`Missing required option ${e.optionKey}`);return[e.name,String(n)]})),u=Object.fromEntries(e.parameters.filter(e=>e.location===`query`).flatMap(e=>{let n=t[e.optionKey];if(n===void 0||Array.isArray(n)&&n.length===0)return[];let r=Array.isArray(n)||typeof n==`boolean`?n:String(n);return[[e.name,r]]})),d=Object.fromEntries(e.parameters.filter(e=>e.location===`header`).flatMap(e=>{let n=t[e.optionKey];return n===void 0||Array.isArray(n)&&n.length===0?[]:[[e.name,Array.isArray(n)?n.join(`,`):String(n)]]}));return st(e,await i({method:e.method,path:r(e.operationId,l),searchParams:u,headers:d,body:o.data,contentType:x(e,t),auth:e.auth,responseFormat:he(n),responseBytes:e.binaryResponse===!0,pendingResult:a}))}async function mt(e,n){let r=n.bin[0],i=se(e,S),a=i===`required`?S:ne(S),c=new Me;c.name(r).usage(`<command> [subcommand] [options]`).configureHelp(nt).version(n.version).summary(`CLI for the aVenture API: companies, people, and news, with the funding, publications, and classifications attached to them`).description(`The aVenture research API from your terminal. Three records — companies,
|
|
4
4
|
people, and news — carry everything else: funding, publications, and tags.
|
|
5
5
|
|
|
6
6
|
Mutations execute directly; --execute is a deprecated no-op.
|
|
7
|
-
The aVenture MCP server runs these same operations through the same API client.`).addOption(new t(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${l})`).choices([...s()])).showHelpAfterError(`(run \`${r} --help\` for usage)`);let u=ct(e,c,a,n);Y(c,u.generated,r,{rootHelp:u.rootHelp}),await u.registerBuiltin(),et(c,a,r);for(let e of c.commands)e.helpGroup()||e.helpGroup(J(e.name()).heading);let d;if(q(c,e=>t=>{throw d=(async()=>{!u.fullTree&&![`commander.helpDisplayed`,`commander.version`].includes(t.code)&&await u.completeTree((e,t)=>Y(e,t,r));let{commandExitHandler:n}=await import(`./parse-error-hint-
|
|
7
|
+
The aVenture MCP server runs these same operations through the same API client.`).addOption(new t(`--environment <environment>`,`route all API calls to a mapped API environment (default: API_URL host, else API_ENV, else ${l})`).choices([...s()])).showHelpAfterError(`(run \`${r} --help\` for usage)`);let u=ct(e,c,a,n);Y(c,u.generated,r,{rootHelp:u.rootHelp}),await u.registerBuiltin(),et(c,a,r);for(let e of c.commands)e.helpGroup()||e.helpGroup(J(e.name()).heading);let d;if(q(c,e=>t=>{throw d=(async()=>{!u.fullTree&&![`commander.helpDisplayed`,`commander.version`].includes(t.code)&&await u.completeTree((e,t)=>Y(e,t,r));let{commandExitHandler:n}=await import(`./parse-error-hint-BbTb0kHW.js`);try{n(e)(t)}catch(e){if(e!==t)throw e}})(),t}),i===`required`){let e=[c];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&await ce(`required`)}))}}let f=new Set(c.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));return c.addHelpText(`after`,[``,`Record subcommands under entities, people, and news:`,...[[`search`,` search Find many of that record from a plain-English query or a filter`],[`lookup`,` lookup Find one news article; companies and people use the root lookup`],[`get`,` get Read one record`],[`list`,` list Read many records`],[`create`,` create, update, delete Write; each needs a credential that permits it`]].flatMap(([e,t])=>f.has(e)?[t]:[]),``,`Authentication (every command that calls aVenture needs a credential):`,` Create one at ${o}/sign-up, then run: ${r} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Check what this shell holds with: ${r} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --csv Print CSV rows or preserve server CSV bytes.`,` --xlsx Write server XLSX bytes with --to-file; use --csv otherwise.`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
|
|
8
8
|
`,`Exit codes:`,` 0 envelope.ok === true
|
|
9
9
|
1 envelope.ok === false
|
|
10
10
|
`,`Examples:`,` $ ${r} auth login`,` $ ${r} lookup-from-file --name Stripe --url https://stripe.com`,` $ ${r} search "fintech companies in Austin"\n`,`Run \`${r} <command> --help\` for its subcommands and options,`,`or \`${r} help <command>\` for its full documentation.`].join(`
|
|
11
|
-
`)),{program:c,exitPreparation:()=>d}}var X=a(Ne(import.meta.url)),Z=X.bin[0];async function Q(e,t){let{BearerVerificationUnavailableError:n}=await import(`./openapi-call-
|
|
11
|
+
`)),{program:c,exitPreparation:()=>d}}var X=a(Ne(import.meta.url)),Z=X.bin[0];async function Q(e,t){let{BearerVerificationUnavailableError:n}=await import(`./openapi-call-Cexzbbt7.js`),{emitJson:r}=await import(`./output-B4vFYIk5.js`),i=e instanceof Error?e:Error(String(e));y({component:Z,event:`fatal`,message:i.message,error:i}),process.stderr.write(`${Z} fatal (${t}): ${i.stack??i.message}\n`);let a=i instanceof n?{httpStatus:i.problem.status,problem:i.problem}:{};r({...f(`${Z} ${t}: ${i.message}`,[i.name||`Error`],a),counts:{exitCode:1}}),process.exit(1)}var ht=e=>{if(e.code!==`EPIPE`)throw e;process.exit(0)};for(let e of[process.stdout,process.stderr])e.on(`error`,ht);process.on(`uncaughtException`,e=>Q(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>Q(e,`unhandledRejection`));var $=await mt(process.argv.slice(2),X);try{await $.program.parseAsync()}catch(t){await $.exitPreparation(),t instanceof e?process.exitCode=t.exitCode:await Q(t,`parseAsync`)}export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./package-DEeHDoOT.js";import{c as e,r as t}from"./result-envelope-
|
|
1
|
+
import"./package-DEeHDoOT.js";import{c as e,r as t}from"./result-envelope-5DwGbGQt.js";import"./operations-metadata-CQE-KJJ2.js";import"node:path";import"node:fs";import"node:os";import"node:fs/promises";import"node:crypto";function n(n,r,i,a){let o=Number(r);return!Number.isInteger(o)||o<i||o>a?t(`${n} must be an integer between ${i} and ${a}, got "${r}"`):e(`${n} parsed`,o)}export{n as parseBoundedInt};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-DEeHDoOT.js";import{a as n,f as r,t as i}from"./env-
|
|
1
|
+
import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-DEeHDoOT.js";import{a as n,f as r,t as i}from"./env-B0nFdXns.js";import{c as a,r as o}from"./result-envelope-5DwGbGQt.js";import{r as s}from"./api-target-vxev2RKl.js";import{t as c}from"./credential-redaction-C08ZVt7t.js";import{n as l}from"./contract-B6QqVAgo.js";import{t as u}from"./openapi-composites-CO9Q6ihp.js";import{t as d}from"./auth-status-check-0ePRcfng.js";import{t as f}from"./output-DnYn9JLl.js";import{a as p,t as m}from"./output-mode-DA6P7QJC.js";var h=l(u,`oauth`),g=[l(u,`start`),l(u,`poll`),l(u,`acknowledge`)],_=l(u,`revoke`);function v(n,r=t().bin[0]){let a=S(n),s=[`${h.description} Default method: OAuth in your browser.`,`With --key: ${g.map(({description:e})=>e).join(` `)}`].join(`
|
|
2
2
|
`);m(x(a,[h,...g],s)).action(y),m(x(a,[_],_.description)).action(b),m(a.command(`status`).summary(`Keep saved credentials current and report them`).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`," - check: `{ name, status, message }` for each environment check:",...d.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.`,`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(`
|
|
3
3
|
`)).addOption(new e(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){C(this),f({mode:p(e)},await w(r,e.verify))}),a.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: ${i.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(`
|
|
4
|
-
`)).action(async function(){let{refreshCliCredentials:e}=await import(`./auth-status-render-
|
|
5
|
-
`))}function C(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function w(e,n){let{resolveAuthStatus:l}=await import(`./auth-resolver-
|
|
6
|
-
`)}async function E(e){let{refreshStoredApiKeyCredential:t}=await import(`./api-key-credential-verification-
|
|
4
|
+
`)).action(async function(){let{refreshCliCredentials:e}=await import(`./auth-status-render-T4-yV9fp.js`);C(this);let t=await e(r),n=process.env[i.authToken]?.trim();t.failure===null&&n!==void 0&&n.length>0?process.stdout.write(`${n}\n`):f({mode:`text`},t.failure===null?M(`auth token: no credentials resolved`,null,r,{oauth:!0,apiKey:!0}):o(`auth token: ${t.failure}`))})}async function y(e){C(this);let t=p(e),n=e.key===!0?await(await import(`./api-key-login-CRlD8Hdw.js`)).loginApiKeyCredential({noBrowser:!e.browser,clientLabel:e.clientLabel}):await(await import(`./oauth-login-DpYCqeAI.js`)).loginOAuthCredential({noBrowser:!e.browser});f({mode:t},n)}async function b(e){let{logoutCliCredentials:t}=await import(`./logout-CwWDCvm9.js`);C(this),f({mode:p(e)},await t({forgetLocal:e.forgetLocal===!0}))}function x(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 S(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${h.command}\`: ${h.summary}; \`--key\` ${g[0].summary.toLowerCase()}.`,`\`${_.command}\`: ${_.summary}.`,"`auth status` reports credential provenance, sign-in providers, CLI/API build metadata, and environment checks.","`auth token` prints the bearer token the next command sends."].join(`
|
|
5
|
+
`))}function C(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function w(e,n){let{resolveAuthStatus:l}=await import(`./auth-resolver-BXhNcSxB.js`),{apiHostCheck:u,authStatusReport:d,checkResult:f,environmentChecks:p}=await import(`./auth-status-check-L5XKjyEd.js`),{inspectOAuthCredentialStorage:m}=await import(`./oauth-credential-B-ClOD2R.js`),{apiKeyCredentialDiagnostics:h,inspectLiveAuth:g,oauthCredentialDiagnostics:_,refreshCliCredentials:v,renderAuthStatus:y}=await import(`./auth-status-render-T4-yV9fp.js`),b;try{b=s(r().host)}catch(e){return o(`auth status: invalid API host — ${c(e)}`)}let x=l(),S=v(e),[C,w,O]=await Promise.all([j(`/info`,`GET /info`),D(),p(e)]),A=await S,[N,P]=await Promise.all([m(b),E(b)]),F=n===void 0?null:await g(n,N,P.inspection,A),I=t().version,L=h(b,P.inspection,P.verification),R=F!==null||x.present||N.state===`found`||P.inspection.state===`found`,z=A.failure??F?.error??(R?null:`no credentials resolved`),B=d(O,u(C,b,e),z===null?f(`auth`,`pass`,`credential=${A.materialized??x.source??`none`}`):f(`auth`,`fail`,z)),V=`${y({cliName:e,cliVersion:I,apiVersion:C.ok?await k(C.data):null,oauth:N,apiKey:L,providers:w,resolved:x,refresh:A,live:F})}\n${T(B.check)}`,H={cli:{version:I},api:C.ok?C.data??null:null,auth:{[i.authToken]:x},selected:A.materialized,oauth:_(b,N),apiKey:L,providers:w,live:F,check:B.check,...C.ok?{}:{apiError:C.summary}};if(A.failure!==null)return{...o(`auth status: ${A.failure} | ${V}`,[A.failure]),data:H};if(!C.ok&&C.httpStatus===401)return{...o(`auth status: the API rejected the selected credential (401) | ${V}`,[`Replace or unset ${i.authToken}, or run \`${e} auth login\`.`]),data:H};if(F!==null&&F.error!==null)return{...o(`auth status: ${F.scope} permission probe failed — ${F.error}`,[F.error]),data:H};if(!R)return M(`auth status: no credentials resolved | ${V}`,H,e,{oauth:N.state===`missing`,apiKey:P.inspection.state===`missing`});let U=B.check.filter(e=>e.status===`fail`);return U.length===0?a(V,H):{...o(`auth status: ${U.map(e=>e.name).join(`, `)} failed | ${V}`,U.map(e=>e.message)),data:H}}function T(e){return[`Checks`,...e.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
6
|
+
`)}async function E(e){let{refreshStoredApiKeyCredential:t}=await import(`./api-key-credential-verification-Dym59aOM.js`),n=await O(e);if(n.state!==`found`)return{inspection:n,verification:null};let{stored:r,verification:i}=await t(n.stored);return{inspection:{state:`found`,stored:r},verification:i}}async function D(){try{let{fetchAuthProviderCatalog:e}=await import(`./oauth-login-DpYCqeAI.js`);return{state:`found`,catalog:await e()}}catch(e){return{state:`unavailable`,summary:c(e)}}}async function O(e){try{let{inspectApiKeyCredentialStorage:t}=await import(`./api-key-credential-D4bb8GPN.js`);return await t(e)}catch(e){return{state:`invalid`,summary:c(e)}}}async function k(e){let{SystemBuildSchema:t}=await import(`./system-build-z_cn0X5C.js`);if(!A(e))return null;let n=t.safeParse(Reflect.get(e,`response`));if(!n.success)return null;let r=n.data.build.version?.trim();return r&&r.length>0?r:null}function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function j(e,t){let{runOpenApiCall:n}=await import(`./openapi-call-Cexzbbt7.js`);return await n({method:`GET`,path:e,auth:`none`,responseFormat:`json`}).catch(e=>o(`${t} failed: ${e instanceof Error?e.message:String(e)}`))}function M(e,t,r,a){return{...o(e,[...a.apiKey?[`For an API key (works over SSH), run \`${r} auth login --key\`.`]:[],...a.oauth?[`For OAuth, run \`${r} auth login\`; without a browser it prints a device code.`]:[],`For non-interactive use, set ${i.authToken} to an aVenture API key (create one at ${n}/settings/api-keys).`]),data:t}}export{v as registerBuiltinAuthCommands};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-5DwGbGQt.js";import{t as n}from"./output-DnYn9JLl.js";import{a as r,t as i}from"./output-mode-DA6P7QJC.js";var a=5e3,o=6e4,s=3e4,c=86400,l={noun:`research runs`,summary:`Wait for research runs to finish, then report each outcome`,description:"Polls `research runs get` with backoff until the run is completed, failed, or stopped, then prints its status, error, failure class, and last event time, plus spend when available in this distribution; a timeout reports the last event time so a stalled run shows. Exits nonzero when the run failed or stopped, or when --timeout passes first.",getOperationId:`getResearchRun`,defaultTimeoutSeconds:1800,schema:async()=>(await import(`./run-detail-x7MeXtlD.js`)).HarnessRunDetailSchema,progress:({run:e,lastEventAt:t})=>e.status===`completed`||e.status===`failed`||e.status===`stopped`?void 0:`${e.status}, last event ${t??`none`}`,outcome:m};async function u(e){let t=t=>e.commands.find(e=>e.name()===t),n=e=>t(e)?.commands.find(e=>e.name()===`runs`),r=n(`research`);r!==void 0&&d(r,l);let i=t(`research-runs`);i!==void 0&&d(i,l,`Deprecated: use research runs wait.`);let a=n(`data-engineering`);if(a!==void 0){let{dataEngineeringRuns:e}=await import(`./private-run-read-DM_02z6l.js`);e!==void 0&&d(a,e)}}function d(e,t,a){let o=e.command(`wait`,{hidden:a!==void 0}).summary(t.summary).description(`${t.description} Several --run-id values wait for every run in one process; data then lists each outcome in order, and the exit is nonzero unless every run succeeded.`).requiredOption(`--run-id <uuid...>`,`Run id; repeat or list several to wait for all`).option(`--timeout <seconds>`,`Total seconds to wait; a run still in flight then exits nonzero as still running`,String(t.defaultTimeoutSeconds));i(o),o.action(async function(){let e=this.optsWithGlobals(),i=await Promise.all(e.runId.map(n=>p(t,{runId:n,timeout:e.timeout}))),o=i.length===1&&i[0]!==void 0?i[0]:f(i);n({mode:r(e)},a===void 0?o:{...o,warnings:[a,...o.warnings]})})}function f(t){let n=t.filter(e=>e.ok).length;return{...e(`${n} of ${t.length} runs succeeded: ${t.map(e=>e.summary).join(`; `)}`,t.map(e=>e.data),{warnings:t.flatMap(e=>e.warnings)}),ok:n===t.length}}async function p(e,n){let{setTimeout:r}=await import(`node:timers/promises`),{buildOpenApiPath:i}=await import(`./openapi-call-Cexzbbt7.js`),{parseBoundedInt:s}=await import(`./batch-io-DvVHFAm1.js`),l=s(`--timeout`,n.timeout,1,c);if(!l.ok||l.data===null)return t(l.summary);let u=Date.now()+l.data*1e3,d=i(e.getOperationId,{runId:n.runId}),f=a,p=`not read yet`,m=(r=`after ${l.data}s`)=>t(`Run ${n.runId} is still ${p} ${r}`,[`Wait longer with --timeout, or read it with \`${e.noun} get --run-id ${n.runId}\`.`]);for(;;){if(u-Date.now()<=0)return m();let t=0,n=await h(d,u,await e.schema());if(n.kind===`deadline`)return m();if(n.kind===`refused`)return n.envelope;if(n.kind===`detail`){let t=e.progress(n.detail);if(t===void 0)return await e.outcome(n.detail,u);p=t}else p=`unread (${n.reason})`,t=(n.retryAfterSeconds??0)*1e3;let i=u-Date.now();if(i<=0||t>=i)return m(i<=0?`after ${l.data}s`:`and the API asks for ${t/1e3}s, past the ${l.data}s --timeout`);let s=Math.max(t,a+Math.random()*(f-a)),c=Math.min(u,Date.now()+s),g=c-Date.now();for(;g>0;)await r(g),g=c-Date.now();f=Math.min(f*2,o)}}async function m(t,n){let{readResearchRunSpend:r}=await import(`./private-run-read-DM_02z6l.js`),{run:i}=t,a=await r?.({runId:i.id,deadline:n})??{costUsd:null},o={runId:i.id,status:i.status,error:i.error??null,failureClass:i.failureClass??null,publicUrl:t.publicUrl??null,finishedAt:i.finishedAt??null,lastEventAt:t.lastEventAt??null,...a.costUsd===null?{}:{costUsd:a.costUsd}},s={warnings:a.warning===void 0?[]:[a.warning]},c=a.costUsd===null?``:`; spend $${a.costUsd.toFixed(4)}`;if(i.status===`completed`)return e(`Run ${i.id} completed${c}`,o,s);let l=i.failureClass?` (${i.failureClass})`:``,u=i.error?`: ${i.error}`:``;return{...e(`Run ${i.id} ${i.status}${l}${c}${u}`,o,s),ok:!1}}async function h(e,n,r){let{runOpenApiCall:i}=await import(`./openapi-call-Cexzbbt7.js`),{isTransientRefusal:a,isTransportFailure:o}=await import(`./request-replay-zMBhTFrR.js`),{retrySeconds:c}=await import(`./response-problem-B3Q-8otA.js`),l=n-Date.now();if(l<=0)return{kind:`deadline`};let u=AbortSignal.timeout(Math.min(s,l)),d;try{d=await i({method:`GET`,path:e,auth:`auto`,responseFormat:`json`,signal:u})}catch(e){if(o(e)||u.aborted&&e instanceof Error&&e.cause instanceof Error&&e.cause.name===`AbortError`&&e.cause.cause===u.reason)return{kind:`transient`,reason:String(e)};throw e}if(!d.ok){let{problem:n}=d;if(n!==void 0&&a(n.status,n)){let e=c(n.retryAfterSeconds);return{kind:`transient`,reason:d.summary,...e===void 0?{}:{retryAfterSeconds:e}}}return{kind:`refused`,envelope:t(`GET ${e} failed: ${d.summary}`,d.warnings,{problem:n})}}let f=d.data,p=r.safeParse(typeof f==`object`&&f&&`response`in f?f.response:void 0);return p.success?{kind:`detail`,detail:p.data}:{kind:`refused`,envelope:t(`${e} returned an unexpected body: ${p.error.message}`)}}export{u as registerBuiltinRunWaitCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,n as t,r as n,t as r}from"./package-DEeHDoOT.js";import{c as i,r as a}from"./result-envelope-
|
|
1
|
+
import{a as e,n as t,r as n,t as r}from"./package-DEeHDoOT.js";import{c as i,r as a}from"./result-envelope-5DwGbGQt.js";import{t as o}from"./output-DnYn9JLl.js";import{a as s,t as c}from"./output-mode-DA6P7QJC.js";import{t as l}from"./completion-setup-CwJt88xW.js";import{spawnSync as u}from"node:child_process";import{basename as d,dirname as f,relative as p,resolve as m,sep as h}from"node:path";import{existsSync as g,lstatSync as _,mkdirSync as v,mkdtempSync as y,readdirSync as b,readlinkSync as x,realpathSync as S,renameSync as C,symlinkSync as w}from"node:fs";import{randomUUID as T}from"node:crypto";var E=new Intl.Collator(void 0,{numeric:!0}),D=2e4,O=[`lib`,`aventurevc-releases`];function k(t,n=e()){let r=n.registry===``?`Requires npm authentication for @aventurevc packages.`:`Installs from npm.`;c(t.command(`update`).summary(`Check for or install the latest release`).description([`Compare the running CLI version against the latest published`,`release and install it into the active published bin prefix.`,``,`Refuses to install when the running binary is the working-tree build`,`(rebuild that checkout instead). ${r}`,`--execute is deprecated, accepted, and ignored; update executes by its verb.`].join(`
|
|
2
2
|
`)).option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1).option(`--release <version>`,`Install and activate exactly this version, not the latest.`)).action(e=>o({mode:s(e)},A(void 0,`apply`,e.release)))}function A(r,o=`apply`,s){let c=r;try{c??=e(process.argv[1])}catch(e){return a(e instanceof Error?e.message:String(e),[`invalid_package_metadata`])}let l=c.name,u=c.version,f=c.registry===``?``:t,p=c.registry===``&&l===`@aventurevc/aventure-cli`,h=s;if(h===void 0){let e=j([`view`,f,`version`,`--silent`,`--global`],c,{timeout:D});if(!e.ok)return{...e,data:null};if(h=(e.data??``).trim(),h===``)return a(`npm view ${f} returned empty version`,[`empty_stdout`])}let _=s!==void 0||p||E.compare(u,h)<0,x={targetPackage:f,runningPackage:l,currentVersion:u,latestVersion:h,upgradeAvailable:_,upgradeInstalled:!1};if(o===`check`)return i(`${l}@${u} → ${f}@${h} (${_?`available`:`up to date`})`,x);if(c.workingTreeRoot!==null)return a(`Refusing to install over the working-tree build at ${c.workingTreeRoot}; rebuild via make instead`,["running CLI is npm-linked from the back-end checkout — `update` is for published bins"]);try{let e=P(c),t=m(e,...O),r=d(f),a=m(t,`${r}-current`),o=f===``?[f,``]:[f,n],l=F(e,c),p=s??[h,l?.version??u].reduce((e,t)=>E.compare(e,t)<0?t:e,u);v(t,{recursive:!0});let _=[N(c),...g(a)?[S(a)]:[],...b(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>m(t,e.name))],C,w=null,T=!1;for(let t of new Set(_.filter(t=>t!==e))){let e=M(t,o,p,c.registry);if(e.ok&&e.data!==null){C=t,w=e.data;break}}if(C===void 0){C=y(m(t,`${r}-${encodeURIComponent(p)}-`));let e=j([`install`,`-g`,`--prefix`,C,...o.map(e=>`${e}@${p}`)],c,{stdio:[`ignore`,`inherit`,`inherit`]});if(!e.ok)return{...e,data:null};T=!0;let n=M(C,o,p,c.registry);if(!n.ok)return{...n,data:null};w=n.data}if(w===null)throw Error(`release verification produced no package`);let D=I(C,e,a,w,s),k=R();return i(`${f} active at ${D}`,{...x,upgradeInstalled:T||s!==void 0||l?.version!==D,installPrefix:e,verifiedVersion:D,completionRefreshed:k.refreshed,completionRefreshMessage:k.message})}catch(e){return a(`${f} update failed: ${L(e)}`,[`existing releases were preserved`])}}function j(e,t,n={}){let r={...process.env};t.registry===``?r.NODE_AUTH_TOKEN??=r.GH_PACKAGES_TOKEN:delete r.GH_PACKAGES_TOKEN;let o=t.registry;if(t.registry===``){let e=u(`npm`,[`config`,`get`,`@aventurevc:registry`,`--global`],{env:r,encoding:`utf8`});if(e.error||e.status!==0){let t=e.error?.message??(e.stderr??``).trim();return a(`npm config get @aventurevc:registry exited ${e.status}`,[t||`no stderr`])}let t=e.stdout.trim().replace(/\/?$/,`/`);t.startsWith(`https://`)&&t!==`https://registry.npmjs.org/`&&(o=t)}let s=[...e,`--@aventurevc:registry=${o}`],c=u(`npm`,s,{env:r,encoding:`utf8`,...n});if(c.error)return c.signal===`SIGTERM`&&n.timeout!==void 0?a(`npm ${e[0]??``} did not answer within ${n.timeout}ms`,[`timeout`]):a(`npm ${e[0]??``} failed to start: ${c.error.message}`,[`spawn_error`]);if(c.status!==0){let t=(c.stderr??``).trim().split(`
|
|
3
3
|
`).slice(-3).join(` | `);return a(`npm ${e.join(` `)} exited ${c.status}`,[t||`no stderr`])}return i(`npm ok`,c.stdout??``)}function M(t,n,r,o){try{let a=n.map(n=>{let i=e(m(t,`lib`,`node_modules`,...n.split(`/`),`package.json`));if(i.name!==n||i.version!==r||i.registry!==o)throw Error(`${n} does not match ${r} from ${o}`);for(let e of i.bin)if(!S(m(t,`bin`,e)).startsWith(`${i.packageRoot}${h}`))throw Error(`${e} escapes ${i.packageRoot}`);return i});for(let e of a){let n=m(t,`bin`,e.bin[0]),i=u(process.execPath,[n,`--version`],{encoding:`utf8`,timeout:D});if(i.error)throw Error(`${e.name} verification failed: ${i.error.message}`);let a=(i.stdout??``).trim();if(i.status!==0||a!==r)throw Error(`${e.name} expected ${r} but reported ${a||`empty output`}`)}return i(`CLI and MCP release verified`,a)}catch(e){return a(`release verification failed: ${L(e)}`,[`release prefix: ${t}`])}}function N(e){let t=f(e.packageRoot),n=f(t),r=f(n);if(d(t)!==e.name.split(`/`)[0]||d(n)!==`node_modules`||d(r)!==`lib`)throw Error(`the running package is not in a verifiable global npm prefix; npm install was not run`);if(!e.entryPath.startsWith(`${e.packageRoot}${h}`))throw Error(`the running entry escapes its package root`);return f(r)}function P(e){let t=N(e),n=`${h}${O.join(h)}${h}`,r=t.lastIndexOf(n);return r<0?t:t.slice(0,r)}function F(t,n){let i=n.registry===``?d(``):r,a=m(t,`bin`,i);if(!g(a))return null;let o=e(a);if(o.registry!==n.registry)throw Error(`${a} belongs to another product`);return o}function I(t,n,r,i,a){let o=i[0];if(o===void 0)throw Error(`release contains no CLI`);let s=m(n,`bin`);v(s,{recursive:!0});let c=i.flatMap(t=>t.bin.filter((t,n)=>{let r=m(s,t);if(!g(r)||e(r).registry===o.registry)return!0;if(o.registry!==``&&n>0)return!1;throw Error(`${r} belongs to another product`)}));if(!g(r)){let e=y(m(f(r),`${d(r)}-seed-`));v(m(e,`bin`));for(let n of c){let r=m(s,n);w(S(g(r)?r:m(t,`bin`,n)),m(e,`bin`,n))}try{w(p(f(r),e),r)}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`EEXIST`))throw e}}if(!_(r).isSymbolicLink())throw Error(`${r} is not a release symlink`);for(let e of c){let t=p(s,m(r,`bin`,e)),n=m(s,`.${e}-${T()}`);w(t,n),C(n,m(s,e))}for(let e of c){let t=m(s,e);if(!_(t).isSymbolicLink()||m(s,x(t))!==m(r,`bin`,e))throw Error(`${t} does not follow the product current pointer`)}let l=F(n,o);if(a===void 0&&l!==null&&E.compare(l.version,o.version)>0)return l.version;let u=`${r}-${T()}`;return w(p(f(r),t),u),C(u,r),o.version}function L(e){return e instanceof Error?e.message:String(e)}function R(){try{return l()}catch(e){return{refreshed:!1,message:e instanceof Error?e.message:String(e)}}}export{k as registerBuiltinUpdateCommand,A as runUpdate};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e}from"./tool-policy-
|
|
1
|
+
import{f as e}from"./tool-policy-BnoDi0Yk.js";function t(t,n,r,i){let a=t===`array`?n:t,o=t===`array`?`...`:``;return r===`uuid`||r===`date-time`||r===`date`?`${r}${o}`:a===`boolean`?`true|false${o}`:a===`integer`||a===`number`?`${a}${o}`:`${e(i)}${o}`}function n(e,t){let n=s(e);if(t===void 0||t.length===0)return n;let r=`Allowed values: ${t.join(`, `)}`;return n===``?`${r}.`:`${n} ${r}.`}var r={path:{heading:`Path parameters:`,rank:0},header:{heading:`Request headers:`,rank:1},input:{heading:`Input:`,rank:2},body:{heading:`Body fields:`,rank:3},option:{heading:`Options:`,rank:1/0}};function i(e){return o(e).rank}function a(e){return o(e).heading}function o(e){return e.location===`path`?r.path:e.location===`header`?r.header:e.inputType===`file`||e.schemaFormat===`binary`?r.input:e.location===`body`?r.body:r.option}var s=e=>e===``||/[.!?]$/u.test(e)?e:`${e}.`,c={researchData:{heading:`Research data commands:`,rank:0},account:{heading:`Account commands:`,rank:1},administration:{heading:`Administration commands:`,rank:2},cli:{heading:`CLI commands:`,rank:3}};function l(e,t){return e!==void 0&&u(e,t)===`administration`}function u(e,t){return t?.[e]?.section??d[e]}var d={auth:`account`,entities:`researchData`,people:`researchData`,search:`researchData`,lookup:`researchData`,"lookup-from-file":`researchData`,web:`researchData`,research:`administration`};export{t as a,s as c,n as i,l as n,i as o,u as r,a as s,c as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./package-DEeHDoOT.js";import{t}from"./openapi-commands-
|
|
1
|
+
import{a as e}from"./package-DEeHDoOT.js";import{t}from"./openapi-commands-C5nlH1da.js";import{n,r}from"./completion-setup-CwJt88xW.js";import{o as i}from"./generated-option-order-CG9WMlq9.js";import a from"node:process";function o(i,o=t,s=e().bin[0]){let l=i.command(`completion`).summary(`Generate shell completion scripts`).description(`Generate shell completion scripts for the aVenture CLI.`);for(let e of[`bash`,`fish`,`zsh`])l.command(e).summary(`Print ${e} shell completions`).description(`Print ${e} completion definitions for ${s}.`).action(()=>{a.stdout.write(c(i,e,o))});n(l,s),r(l,s)}function s(){return e().bin}function c(e,n,r=t,i=s()){let a=_(r);return n===`fish`?[`# fish completions for ${i.join(`, `)}`,...u(e),...i.map(e=>`complete -c ${N(e)} -e`),`${A(i)} -f`,...d(e,i),...f(e,a,i),``].join(`
|
|
2
2
|
`):l(e,n,a,i)}function l(e,t,n,r){let i=t===`zsh`?`typeset -ga `:``,a=`complete -F _aventure_cli ${r.map(e=>e.replaceAll(`'`,`'\\''`)).join(` `)}`,[o,s,c]=b(e,n);return[...t===`zsh`?[`#compdef ${r.join(` `)}`]:[],`# ${t} completions for ${r.join(`, `)}`,`${i}_aventure_cli_commands=(`,...o.map(e=>` ${e}`),`)`,`${i}_aventure_cli_options=(`,...s.map(e=>` ${e}`),`)`,`${i}_aventure_cli_values=(`,...c.map(e=>` ${e}`),`)`,``,...C(t),...t===`bash`?[a,``]:[``]].join(`
|
|
3
3
|
`)}function u(e){return[`function __aventure_cli_command_path\n set -l global_value_options ${p(e).filter(e=>e.required||e.optional).flatMap(e=>E(e)??[]).map(N).join(` `)}\n set -l tokens (commandline -xpc)\n if test (count $tokens) -gt 0\n set -e tokens[1]\n end\n set -l path\n set -l skip_next 0\n for token in $tokens\n if test $skip_next -eq 1\n set skip_next 0\n continue\n end\n if string match -q -- '--*=*' $token\n set -l name (string replace -r '^--([^=]+)=.*$' '$1' -- $token)\n contains -- $name $global_value_options; and continue\n end\n if string match -q -- '--*' $token\n set -l name (string replace -r '^--' '' -- $token)\n if contains -- $name $global_value_options\n set skip_next 1\n continue\n end\n break\n end\n if string match -q -- '-*' $token\n break\n end\n set -a path $token\n end\n printf '%s\\n' $path\nend\n`,`function __aventure_cli_path_is
|
|
4
4
|
set -l expected $argv
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./commander-DEj7N1b9.js";import{c as t}from"./tool-policy-
|
|
1
|
+
import{n as e}from"./commander-DEj7N1b9.js";import{c as t}from"./tool-policy-BnoDi0Yk.js";import{a as n,i as r}from"./cli-help-policy-EqwYSBOi.js";import{n as i,t as a}from"./contract-parameter-DZFV8Cs1.js";function o(e){return e.toSorted((e,t)=>e.projection.cliPath.length-t.projection.cliPath.length||e.projection.cliPath.join(` `).localeCompare(t.projection.cliPath.join(` `))||e.operationId.localeCompare(t.operationId)).map(e=>{let{security:t,parameter:n,projection:r,response:a,...o}=e,s=n.flatMap(t=>{if(t.in!==`path`&&t.in!==`query`&&t.in!==`header`)return[];let n=t.in;return(t.in===`query`&&t.itemProperty!==void 0?t.itemProperty:[t]).map(t=>{let r=d(t,i(e,t),n);if(t.legacyName===void 0)return r;let a=d(t,i(e,t,t.legacyName),n).flag;return a===r.flag?r:Object.assign(r,{legacyFlag:a})})}),u=e.requestBody?.map(t=>{let n=l(e,s,t),r=c(t.cliConflicts,n),i=r.length===0?{}:{cliConflicts:r};return Object.assign({},t,{parameter:n},i)}),f=a.find(({status:e})=>e.startsWith(`2`)),p=f?.schemaName?.replace(/Schema$/,``);return Object.assign(o,{cliPath:r.cliPath,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:u,scope:r.scope,auth:r.auth,visibility:r.visibility,mutates:r.mutates,selfCredential:r.selfCredential,successResponse:p,detailField:f?.detailField,header:f?.header,parameters:s})})}function s(e,t){let[n,r]=e.filter(e=>e.role===t);if(n===void 0||r!==void 0)throw Error(`Generated composite CLI role '${t}' is incomplete`);return n}function c(e,t){let n=new Map(t.map(({name:e,optionKey:t})=>[e,t]));return(e??[]).map(e=>e.map(e=>{let t=n.get(e);if(t===void 0)throw Error(`x-aventure-cli-conflicts field '${e}' was removed from the generated CLI projection`);return t}))}function l(e,t,n){let r=new Set(t.map(e=>e.optionKey));(e.requestBody?.length??0)>1&&r.add(`contentType`);let i=new Set(t.filter(e=>e.location===`path`).map(e=>e.name));return n.parameter.toSorted((e,t)=>u(e.name)-u(t.name)).flatMap(t=>{if(!t.required&&(r.has(t.inputName)||i.has(t.name)))return[];let n=a(e,t,r);return r.add(n),[d(t,n,`body`)]})}function u(e){let t=e.split(`.`).at(-1);return t===`min`?0:t===`max`?1:2}function d(i,a,o){let s=i.itemSchemaEnum??i.schemaEnum,c=n(i.schemaType,i.itemSchemaType,i.schemaFormat,a),l=`${t(a)} ${i.schemaType===`boolean`?`[${c}]`:`<${c}>`}`;return{name:i.name,optionKey:new e(l).attributeName(),flag:l,required:i.required&&i.schemaDefault===void 0,description:r(i.description,s),schemaType:i.schemaType,schemaFormat:i.schemaFormat,itemSchemaType:i.itemSchemaType,defaultValue:f(i.schemaDefault),choices:s,...i.envName===void 0?{}:{envName:i.envName},...i.visibility&&{visibility:i.visibility},location:o}}var f=e=>Array.isArray(e)?e.map(String):typeof e==`number`?String(e):e;export{s as n,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./tool-policy-
|
|
1
|
+
import"./tool-policy-BnoDi0Yk.js";function e(e,t,n=t.inputName){if(t.in===`body`)return n;let r=f.find(t=>n===t.name&&e.path.includes(t.path));return r===void 0?d(c(n!==`id`&&n!==`slug`?n:`${i(e.path)}${s(n)}`),t):r.inputName}function t(e,t,r=o(e)){return n(a(e,t),new Set(r))}function n(e,t){if(!t.has(e))return e;let n=`body${s(e)}`,r=n;for(let e=2;t.has(r);e+=1)r=`${n}${e}`;return r}function r(e,t,n){return`${e}[${t}].${n}`}function i(e){return p.find(([,t])=>t.test(e))?.[0]??`record`}function a(e,t){if(t.name===`id`&&e.path===`/v1/app/url-slug-redirects`)return`recordId`;let n=l(t);return d(e.intent===`search`&&(t.name.startsWith(`filter.`)||t.name.startsWith(`search.`))?c(n.replace(/^(?:filter|search)/u,``).replace(/^./u,e=>e.toLowerCase())):n,t)}function o(t){return new Set(t.parameter.filter(e=>e.in===`path`||e.in===`query`||e.in===`header`).map(n=>e(t,n)))}function s(e){return e.replace(/^./u,e=>e.toUpperCase())}function c(e){return e.replace(/^addressAddress/u,`address`).replace(/^arrayFilterAmountInvestedRange/u,`fundraiseAmountInvestedRange`).replace(/^arrayFilterAmountRaisedRange/u,`fundraiseAmountRaisedRange`).replace(/^arrayFilterEntityName$/u,`entityName`).replace(/^arrayFilterInvestedCompany$/u,`fundraiseInvestedCompanyName`).replace(/^arrayFilterPersonTitle$/u,`personTitle`).replace(/^arrayFilterRound$/u,`fundraiseRound`).replace(/^arrayFilterTotalInvestmentCount/u,`totalInvestmentCount`).replace(/^arrayFilterTypeRecord$/u,`typeRecord`).replace(/^createEntity/u,`entity`).replace(/^createUrlLink/u,`urlLink`).replace(/^fundraiseActivity/u,`fundraise`).replace(/FundraiseActivity/gu,`Fundraise`).replace(/^logoOption/u,`logo`).replace(/LogoOption/gu,`Logo`).replace(/^researchDetailTypeResearchDetail$/u,`researchDetailType`).replace(/^researchDetailValueResearchDetail$/u,`researchDetailValue`).replace(/^textText$/u,`text`).replace(/^textTextName$/u,`textName`).replace(/^textTextType$/u,`textType`)}function l(e){let t=c(e.inputName);return/(?:^|\.)nameAlias\[\]\./u.test(e.name)?t.replace(/^entityNameAlias/u,`alias`):/(?:^|\.)urlLink\[\]\./u.test(e.name)?u(t):/(?:^|\.)manualLogo\./u.test(e.name)?t.replace(/^manualLogo/u,`logo`):t}function u(e){return e===`urlLinkUrl`?`url`:e===`urlLinkUrlType`?`urlType`:e.replace(/^urlLink/u,`url`)}function d(e,t){return e===`text`?/(?:^|\.)text(?:\[\])?\.text$/u.test(t.name)?`textBody`:`inputText`:e}var f=[{name:`detailId`,path:`/research-details/{detailId}`,inputName:`researchDetailId`},{name:`version`,path:`/instructions/`,inputName:`instructionVersion`},{name:`detailId`,path:`/financial/valuation/{detailId}`,inputName:`valuationDetailId`},{name:`joinId`,path:`/fundraise-investor-joins`,inputName:`fundraiseInvestorJoinId`}],p=[[`entity`,/^\/v1\/entities(?:$|\/detail|\/lookup|\/summary|\/duplicate-check)/u],[`person`,/^\/v1\/people(?:\/detail|\/lookup|\/duplicate-check|\/\{slug\})/u],[`news`,/^\/v1\/(?:news\/|jobs\/news\/)/u],[`screenshot`,/^\/v1\/media\/screenshots\//u],[`media`,/^\/v1\/media/u],[`article`,/^\/v1\/app\/blog\/articles/u],[`page`,/^\/v1\/app\/pages/u],[`contact`,/^\/v1\/contacts\//u],[`provenance`,/^\/v1\/provenance\//u],[`location`,/^\/v1\/addresses\/locations\//u]];export{e as n,r,t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./response-problem-
|
|
1
|
+
import{i as e}from"./response-problem-B6bUo9co.js";function t(t,n=[]){let r=t instanceof Error?t.message:String(t);return e(r,n)}function n(t,n=[]){let r=e(t.title,n),i=e(t.detail?.trim()??``,n);return`${t.status} ${r}${i?` — ${i}`:``}`}export{n,t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./package-DEeHDoOT.js";import{n as t,t as n}from"./auth-resolver-
|
|
1
|
+
import{a as e}from"./package-DEeHDoOT.js";import{n as t,t as n}from"./auth-resolver-BtalY5VS.js";import{o as r}from"./logging-BLz3ITZ8.js";import{i}from"./api-target-vxev2RKl.js";import{t as a}from"./credential-redaction-C08ZVt7t.js";import{execFile as o}from"node:child_process";import{dirname as s,join as c}from"node:path";import{platform as l}from"node:os";import{chmod as u,mkdir as d,readFile as f,rename as p,rm as m,stat as h,writeFile as g}from"node:fs/promises";import{AsyncLocalStorage as _}from"node:async_hooks";import{setTimeout as v}from"node:timers/promises";import{randomUUID as y}from"node:crypto";var b=2;function x(e,t){return w(e,t).redactedUrl}async function S(e,t,n){let r=w(e,t);return await C(new URL(r.openerUrl),n)}async function C(e,t){let n=t.environment??process.env,r=t.operatingSystem??l(),i=T(t.noBrowser,n,r);if(i!==null)return{state:`skipped`,reason:i};let a=E(r,e.toString());if(a===null)return{state:`failed`,reason:`unsupported browser-opening platform: ${r}`};try{return await D(a.command,a.arguments),{state:`opened`,reason:null}}catch{return{state:`failed`,reason:`browser opener failed`}}}function w(e,t){let{id:n,verificationUrl:r,pollSecret:a}=e,o,s;try{o=new URL(r),s=new URL(t)}catch{throw Error(`broker returned an invalid browser verification URL`)}if(s.username.length>0||s.password.length>0||s.pathname!==`/`||s.search.length>0||s.hash.length>0)throw Error(`configured browser origin must contain only an origin`);let c=i(s.hostname);if(s.protocol!==`https:`&&!(s.protocol===`http:`&&c))throw Error(`configured browser origin must use HTTPS except for loopback development`);let l=new URLSearchParams(o.hash.slice(1)),u=[...l.keys()],d=l.getAll(`cliAuthorizationId`),f=l.getAll(`browserSecret`),p=f[0]??``;if(o.origin!==s.origin||o.protocol!==s.protocol||o.username.length>0||o.password.length>0||o.pathname!==`/settings/developer`||o.search.length>0||u.length!==b||d.length!==1||d[0]!==n||f.length!==1||p.length===0||a.length===0||p===a)throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let m;try{m=decodeURIComponent(r)}catch{throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`)}if(r.includes(a)||m.includes(a))throw Error(`broker returned a browser verification URL outside the configured first-party approval flow`);let h=new URL(o);return h.hash=new URLSearchParams({cliAuthorizationId:n,browserSecret:`<redacted>`}).toString(),{openerUrl:r,redactedUrl:h.toString()}}function T(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 E(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 D(e,t){return new Promise((n,r)=>{o(e,[...t],{timeout:5e3,windowsHide:!0},e=>e?r(e):n())})}var O=100,k=3e4,A=6e4,j=new _;function M(){return c(s(n()),`credentials.json`)}function N(){let e=l();return e===`linux`||e===`freebsd`?T(!1,process.env,e):null}function P(e){let t=`${M()} (mode 0600)`;if(e!==void 0)return`OS keyring is unusable (${e}); the credential will be stored in ${t}.\n`;let n=N();return n===null?null:`${n}: the credential will be stored in ${t}; no OS keyring is needed.\n`}async function F(e,t){let n=(await U())[e]?.[t];if(n!==void 0)return{record:{provider:`file`,value:n}};if(N()!==null)return{};try{let n=await(await H(e,t)).getPassword()??void 0;return n===void 0?{}:{record:{provider:`keyring`,value:n}}}catch(e){return{keyringFailure:V(e)}}}async function I(e,t,n){if((await U())[e]?.[t]!==void 0)return await L(e,t,n,`file store holds this account`);let r=N();if(r!==null)return await L(e,t,n,`not used (${r})`);let i;try{let r=await H(e,t);if(await r.setPassword(n),await r.getPassword()===n)return await K(e,t,void 0),`keyring`;i=`Error: keyring readback did not match`}catch(e){i=V(e,[n])}return await L(e,t,n,i)}async function L(e,t,n,r){if(await K(e,t,n),(await U())[e]?.[t]!==n)throw Error(`credential storage did not confirm a durable write (keyring: ${r}; file: readback did not match)`);return`file`}async function R(e,t){if(N()!==null)await K(e,t,void 0);else try{let n=await H(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 (${V(r??e)})`,{cause:e})}if(i!==void 0)throw Error(`OS keyring did not confirm removal (${V(r)})`,r===void 0?void 0:{cause:r})}finally{await K(e,t,void 0)}}async function z(e,t){let n=`${t}:probe:${y()}`,r=`aventure-cli-credential-probe:${y()}`,i=N();if(i!==null)return await B(e,n,r,`not used (${i})`),{provider:`file`};let a;try{let t=await H(e,n);await t.setPassword(r);let i=await(await H(e,n)).getPassword(),o=await t.deleteCredential(),s=await(await H(e,n)).getPassword()??void 0;if(i!==r)a=`Error: probe readback did not match`;else if(!o||s!==void 0)a=`Error: probe cleanup was not confirmed`;else return{provider:`keyring`}}catch(e){a=V(e,[r])}return await B(e,n,r,a),{provider:`file`,keyringFailure:a}}async function B(e,t,n,r){try{await G(async()=>{await K(e,t,n);let r=(await U())[e]?.[t];if(await K(e,t,void 0),r!==n)throw Error(`probe readback did not match`)})}catch(e){throw Error(`credential storage is unavailable (keyring: ${r}; file ${M()}: ${V(e,[n])})`,{cause:e})}}function V(e,t=[]){if(!(e instanceof Error))return`Error`;let n=e.name||`Error`,[r=``]=a(e,t).trim().split(`
|
|
2
2
|
`,1);return r&&r!==n?`${n}: ${r}`:n}async function H(e,t){let{AsyncEntry:n}=await import(`@napi-rs/keyring`);return new n(e,t)}async function U(){let e=M(),n;try{n=await f(e,`utf8`)}catch(e){if(t(e,`ENOENT`))return{};throw e}let r;try{r=JSON.parse(n)}catch(t){return await W(e,t)}return J(r)?r:await W(e,void 0)}async function W(n,i){let a=`${n}.corrupt-${new Date().toISOString().replace(/[:.]/gu,`-`)}`;try{await p(n,a)}catch(e){if(t(e,`ENOENT`))return{};throw Error(`${n} is not a valid credential file and could not be moved aside`,{cause:e})}return r({component:e().bin[0],event:`credential_file_quarantined`,message:`${n} is not a valid credential file; moved it to ${a} and continuing with an empty file store`,...i===void 0?{}:{error:i}}),{}}async function G(e){if(j.getStore()===!0)return await e();let n=`${M()}.lock`;await d(s(n),{recursive:!0,mode:448});let r=Date.now()+k,i=y();for(;;){try{await g(n,i,{flag:`wx`,mode:384});break}catch(e){if(!t(e,`EEXIST`))throw e}if(await h(n).then(e=>Date.now()-e.mtimeMs,()=>0)>A)await m(n,{force:!0});else if(Date.now()>r)throw Error(`credential store is locked by another CLI process (${n})`);else await v(O)}try{return await j.run(!0,e)}finally{await f(n,`utf8`).catch(()=>``)===i&&await m(n,{force:!0})}}async function K(e,t,n){await G(async()=>await q(e,t,n))}async function q(e,t,n){let r=M(),i=await U(),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 m(r,{force:!0});return}await d(s(r),{recursive:!0,mode:448});let o=`${r}.${y()}.tmp`;await g(o,`${JSON.stringify(i,null,2)}\n`,{mode:384}),await u(o,384),await p(o,r)}function J(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`))}export{G as a,S as c,F as i,x as l,P as n,I as o,z as r,C as s,R as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./result-envelope-
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-5DwGbGQt.js";var n=[`localhost`,`127.0.0.1`,`0.0.0.0`,`[::1]`];function r(e){let t=e.trim().toLowerCase().replace(/^https?:\/\//,``).split(`/`)[0]??``;return n.some(e=>t===e||t.startsWith(`${e}:`))}var i={authToken:`AUTH_TOKEN`},a=[i.authToken],o=`production`,s={production:{host:`api.aventure.vc`},local:{host:`localhost:8080`}},c=`https://${s.production.host}`,l=`https://aventure.vc`;function u(){return{host:v(process.env.API_URL)??g(process.env.API_ENV)?.host??f(),userBearerToken:process.env[i.authToken]}}function d(){let e=u().host,t=r(e)?null:h(process.env.API_ENV);return(t===null?void 0:s[t]?.host)??e}function f(){let e=s[o]?.host;if(e===void 0)throw Error(`Default API environment is unavailable`);return e}function p(e){if(!e.userBearerToken)throw Error(`Sign in with \`auth login\`, or set ${i.authToken} to an aVenture API key from ${l}/settings/api-keys`);return{Authorization:`Bearer ${e.userBearerToken}`}}function m(){return Object.keys(s)}function h(e){let t=e?.trim().toLowerCase();if(!t)return null;switch(t){case`stage`:case`staging`:return`staging`;case`prod`:case`production`:return`production`;case`dev`:case`development`:case`localhost`:case`local`:return`local`;default:return null}}function g(e){let t=h(e);if(t===null){if(!e?.trim())return null;throw Error(`Unknown aVenture environment '${e}'. Use one of: ${m().join(`, `)}`)}let n=s[t];if(n===void 0)throw Error(`Environment '${t}' is unavailable in this distribution`);return n}function _(n){try{let t=u();return e(`env ready`,n===`none`?{env:t,headers:{},credential:null}:{env:t,headers:p(t),credential:i.authToken})}catch(e){return t(e.message)}}function v(...e){return e.find(e=>e!==void 0&&e.trim().length>0)}export{l as a,m as c,d,u as f,c as i,h as l,a as n,p as o,r as p,o as r,f as s,i as t,_ as u};
|
package/dist/chunks/{generated-option-order-BkjcNcaN.js → generated-option-order-CG9WMlq9.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./result-envelope-
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-5DwGbGQt.js";import{t as n}from"./private-readback-DX42Bf2b.js";import{c as r,i,o as a,s as o}from"./cli-help-policy-EqwYSBOi.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-l1vOidnb.js";import{c as l,d as u,l as ee,s as d,u as te}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-l1vOidnb.js";import{c as l,d as u,l as ee,s as d,u as te}from"./tool-policy-BnoDi0Yk.js";import{i as ne,t as f}from"./human-text-cap-dR2SJQJC.js";import{n as re,t as ie}from"./contract-parameter-DZFV8Cs1.js";var p=2,ae=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);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&m(e,`person`),h(e,oe(n),n),h(e,se(n),n))}function oe(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`${e.slice(0,-3)}y`;let n=e.endsWith(`es`)?e.slice(0,-2):``;if(n.length>=p&&n!==`us`&&/(?:s|ss|sh|ch|x|z)$/u.test(n))return n;if(e.length>p&&e.endsWith(`s`)&&!e.endsWith(`ss`)&&!e.endsWith(`us`)&&e!==`news`)return e.slice(0,-1)}function se(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 ce(e){return _(e).map(g)}function le(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&&!ae.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))),...ue(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||te(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:ee(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse?null:u(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 ue(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 de=[`-id`,`-slug`,`-url`],fe=[`--id`,`--slug`,`--url`],pe=`/v1/lookup`,me=`--from-file "<path>"`;function he(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 ge(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))}`,..._e(e,t)]}function _e(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===pe),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:ve(e)).map(D);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,me]:o}function ve(e){let t=new Set;m(t,e.resource);for(let n of de)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 fe){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 O=s([`HIGH`,`MEDIUM`,`LOW`]),ye=s([`PAID_PLAN`,`DAILY_ALLOWANCE`]),k=s([`OPERATION`,`SKILL`,`PROMPT`,`COMPLETION_GATE`,`RESEARCH_DETAIL_TYPE`,`RESEARCH_SNIPPET_TYPE`,`TEXT_TYPE`]),A=Object.assign(t([k,n()]),{enum:k.enum}),j=r({billingAccess:ye.nullish(),excerpt:n(),sourceId:n(),sourceType:A,sourceVersion:n().nullish()}),be=r({instruction:n(),operationId:n(),planTaskKey:c(n()).optional(),stepKey:n().optional(),title:n().nullish()}),xe=r({body:n(),expectation:n(),method:c(n()),override:n(),reject:c(n()),typeCatalog:n()}),M=r({cliCommand:n(),mcpTool:n().nullish(),step:be,title:n().nullish(),writeGuidance:xe.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`]),I=r({candidate:c(j),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),we=r({answer:n(),citation:c(j),confidence:O,resolution:I.nullish()});function L(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>R(t,re(e,t))),r=(t?.parameter??[]).map(t=>R(t,ie(e,t)));return{selector:n.filter(e=>e.location===`path`||z(e)),pagination:n.filter(B),filter:[...n.filter(V),...r.filter(V)],body:r.filter(e=>!V(e))}}function R(e,t){let{in:n,inputName:r,...i}=e;return{...i,flag:l(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function z(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function B(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function V(e){return e.location!==`path`&&!z(e)&&!B(e)}function H(e){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:De(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]}}function U(e,t){let n=e.requestBody?.[0],r=H(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:L(e)}:{...r,optionalInput:Oe(e),arrayInput:ke(e),...i===void 0?{}:{paidPlan:i}}}function Te(e){let t=L(e),n=e=>e.filter(e=>e.required);return{...U(e,!1),optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function Ee(e){let{cli:t,scope:n,...r}=H(e),i=W(e);return{...r,...i===void 0?{}:{paidPlan:i},optionalDetailOmitted:!0}}function De(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function Oe(e){let t=e.requestBody?.[0],n=new Set(t?.requiredPath??[]);return{query:e.parameter.filter(e=>e.in===`query`&&!e.required).map(({name:e})=>e),body:(t?.parameter??[]).filter(({name:e})=>!n.has(e)).map(({name:e})=>e)}}function W(e){return e.response.find(({status:e})=>e===`402`)?.description}function ke(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var G=160,K=`Operation catalog matches`,Ae=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],q=e=>`${[K,...e].join(`
|
|
2
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=>ne([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>0?[` 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{le as C,ce as D,v as E,m as S,_ as T,he as _,je as a,y as b,Ee as c,F as d,P as f,x as g,T as h,ze as i,Te as l,O as m,$ as n,Q as o,A as p,Be as r,U as s,K as t,we as u,ge as v,g as w,S as x,w as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./result-envelope-
|
|
1
|
+
import{c as e,i as t,r as n}from"./result-envelope-5DwGbGQt.js";import{V as r,m as i,n as a,u as o}from"./tool-policy-BnoDi0Yk.js";import{t as s}from"./openapi-snapshot-C3NgiUZo.js";import{C as c,D as l,E as u,S as d,T as f,c as p,i as m,l as h,n as g,o as _,r as v,s as y,t as b,u as x,w as S}from"./help-catalog-B8JUR6zB.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 k(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 A(e,t,n){return e===`uuid`?/(?:^id|Id)$/u.test(t)&&n.includes(`{${t}}`):t===e}function j(e,t){let n=new Set;for(let r of e){let e=new Set;d(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 M(e,t,n){if(n.intent!==`read`&&n.intent!==`lookup`)return 0;let r=new Set(f(n.summary)),i=0;for(let t of e.kind)n.directParameterName.some(e=>A(t,e,n.path))&&(i+=E,r.has(t)&&(i+=D));if(i===0)return 0;let a=new Set(f(`${n.summary} ${n.description}`));return(t.size>0?t.has(n.resource):e.urlPathWord.some(e=>{let t=new Set;return d(t,e),[...t].some(e=>a.has(e))}))&&(i+=O),i}var N=40,P=4,F=3,I=1,L=new Map,R=new WeakMap;function z(e){let t=L.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,F);return L.set(e,o),o}function B(e,t,n){let r=0,i=V(n);for(let[e,i]of n)t.has(e.toLowerCase())&&(r+=N*(4-i)/4);for(let t of e){let e=Math.min(...[...t].map(e=>i.get(e)??1/0));e<=I&&(r+=P*(2-e))}return r}function V(e){let t=R.get(e);if(t!==void 0)return t;let n=new Map;for(let[t,r]of e){if(r>I)continue;let e=new Set;for(let n of f(t))d(e,n);for(let t of e)n.set(t,Math.min(n.get(t)??r,r))}return R.set(e,n),n}var H=5,U=.5,W=15,G=30,K=2,ee=100,q=.5;function J(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=k(e,new Set(r.flatMap(({fields:e})=>e.cliPath))),a=j(i.urlPathWord,r.map(({fields:e})=>e)),o=u(i.text);if(o.length===0&&i.kind.size===0)return t.map(e=>({item:e,score:1}));let s=S(o),c=l(o),d=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:$({normalizedQuery:o,tokens:s,termForm:c,queryWord:d},t))+M(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 Y=new WeakMap;function X(e){let t=Y.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:z(e.operationId)};return Y.set(e,i),i}function Z(n,r){let i=n.q?.trim()??``,a=J(i,r.filter(e=>Q(n,e)&&(i.length>0||e.deprecated!==!0)),X),o=(a[0]?.score??0)*U,s=a.filter(({score:e})=>e>=o),c=n.limit===void 0||!Number.isFinite(n.limit)?H: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},f=u.length===1,m=u.map(e=>y(e,f)),g=e(b,m,{counts:d}),_=t(g),v=f?u.map(h):u.map(p);return{summary:b,data:_?m:v,counts:d}}function Q(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 $({normalizedQuery:e,tokens:t,termForm:n,queryWord:r},i){let a=oe(i),s=ie(i),l=0;a.some(t=>t===e)&&(l+=100),a.some(t=>t.includes(e))&&(l+=40),l+=ae(e,a);let p=new Set(a.flatMap(f)),m=new Set(s.flatMap(f));for(let e of t)a.some(t=>t===e)?l+=20:m.has(e)?l+=8:p.has(e)&&(l+=K);for(let e of i.cliPath){let n=new Set;for(let t of e.split(`-`))d(n,t);[...n].some(e=>t.has(e))&&(l+=W)}c(n,s)&&(l+=200),n.length>1&&s.some(t=>t.includes(e))&&(l+=ee),i.parameterName.some(t=>u(t)===e)&&(l+=G);let h=new Set(i.parameterDescription.flatMap(f));for(let e of t)h.has(e)&&(l+=K);return l+=ce(t,i.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(i.operationId)&&(l+=30),l+=B(n,r,i.responseFieldLevel),l-=se(e,t,i.description),o(i.intent)&&!re(r)?l*q:l}var te=`edit change set fix rename link unlink mark publish correct`.split(` `),ne=new Set([...Object.entries(a).filter(([,e])=>o(e)).map(([e])=>e),...te]);function re(e){return[...e].some(e=>ne.has(e))}function ie(e){return[e.operationId,e.cliPath.join(` `),e.summary].map(u).filter(e=>e.length>0)}function ae(e,t){let n=f(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,(g(e.description).useFor||e.description).slice(0,240)].map(u).filter(e=>e.length>0))]}function se(e,t,n){let r=u(g(n).notFor);if(r.length===0)return 0;let i=r.includes(e)?40:0,a=new Set(f(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=f(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=x.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),p=f(d.operationId),h=d.taskPlan??void 0,g=(h?.step??[]).map(({step:e})=>({step:e,contract:f(e.operationId)})),y=[...new Set([...d.operationId!=null&&p===void 0?[d.operationId]:[],...g.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},m(t))}),...p===void 0?{}:{operation:{operationId:p.operationId,apiRoute:`${p.method} ${p.path}`,...v(p),...m(p)}},...(d.taskKey,{}),...h===void 0?{}:{taskPlan:{input:h.input,step:g.map(({contract:e,step:{stepKey:t,instruction:n,operationId:r}})=>e===void 0?{instruction:n,operationId:r}:{instruction:n,mcpCall:_(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{z as a,de as i,J as n,Z as r,X as t};
|