@aventurevc/aventure-cli 0.8.239 → 0.8.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aventure-cli/index.js +1 -1
- package/dist/aventure-cli/unified-operations.json +1 -1
- package/dist/chunks/{api-key-credential-verification-DOgXhdps.js → api-key-credential-verification-mMekpho4.js} +1 -1
- package/dist/chunks/{api-key-credential-verification-Deh_cRmj.js → api-key-credential-verification-ojaiIf0j.js} +1 -1
- package/dist/chunks/{api-key-login-Bl3amXwl.js → api-key-login-rLWkAQ_k.js} +1 -1
- package/dist/chunks/{auth-status-render-C6azVpoO.js → auth-status-render-Bp_c2kF9.js} +1 -1
- package/dist/chunks/aventure-cli-D0NEdbFg.js +11 -0
- package/dist/chunks/{batch-io-Cmo0m4tu.js → batch-io-By9YEmZW.js} +1 -1
- package/dist/chunks/{builtin-auth-Bvqpuq_U.js → builtin-auth-DtXXrcex.js} +5 -5
- package/dist/chunks/{builtin-research-run-wait-DQvx_0vF.js → builtin-research-run-wait-CuL5YNzI.js} +1 -1
- package/dist/chunks/{builtin-update-CMBUyKFB.js → builtin-update-JNk2mnDh.js} +1 -1
- package/dist/chunks/{cli-help-policy-CEZPZEOQ.js → cli-help-policy-BSkCikW7.js} +1 -1
- package/dist/chunks/{completion-D-VlrtsO.js → completion-ChN2_goh.js} +1 -1
- package/dist/chunks/contract-BoQqQVwP.js +1 -0
- package/dist/chunks/{contract-parameter-zkhCaKUz.js → contract-parameter-DRNxhCKs.js} +1 -1
- package/dist/chunks/{generated-option-order-uCio4nh5.js → generated-option-order-DAzrGPOt.js} +1 -1
- package/dist/chunks/{help-catalog-TLFLfBit.js → help-catalog-tM-2mFr2.js} +1 -1
- package/dist/chunks/{help-intent-DYr9j6nC.js → help-intent-I9N7JRE7.js} +1 -1
- package/dist/chunks/logout-D-p586e2.js +1 -0
- package/dist/chunks/{logout-CI8ozZxe.js → logout-bAOnLVcZ.js} +1 -1
- package/dist/chunks/{mcp-generation-contract-Cjby_ahK.js → mcp-generation-contract-BAK1Yxiu.js} +1 -1
- package/dist/chunks/mcp-generation-contract-VVrtxE0D.js +1 -0
- package/dist/chunks/{oauth-bearer-credential-Cr1XEugX.js → oauth-bearer-credential-BFQz9k2h.js} +1 -1
- package/dist/chunks/oauth-bearer-credential-DattK6eD.js +1 -0
- package/dist/chunks/{oauth-login-CIfcnNC9.js → oauth-login-BhIOT6p8.js} +1 -1
- package/dist/chunks/{oauth-login-Cbmj4Qe-.js → oauth-login-CJVSyM5j.js} +1 -1
- package/dist/chunks/{openapi-call-C2AMq6_D.js → openapi-call-B3pG7Dqm.js} +1 -1
- package/dist/chunks/{openapi-call-N8RraQ85.js → openapi-call-o3oKcBXS.js} +1 -1
- package/dist/chunks/openapi-commands-CLn-TCPy.js +1 -0
- package/dist/chunks/{openapi-commands-CIDu8BhO.js → openapi-commands-Dsmc0xON.js} +1 -1
- package/dist/chunks/openapi-snapshot-xFGmCymw.js +1 -0
- package/dist/chunks/{operations-BxXr8p28.js → operations-B7FP0mq_.js} +2 -2
- package/dist/chunks/{operations-catalog-BJwcYGix.js → operations-catalog-B0p3zfxK.js} +1 -1
- package/dist/chunks/operations-catalog-Co81xH0y.js +1 -0
- package/dist/chunks/{operations-metadata-BGfKoI-w.js → operations-metadata-BfIKb5PX.js} +2 -2
- package/dist/chunks/{output-BeQggrS_.js → output-Bb8wDk_C.js} +1 -1
- package/dist/chunks/{output-DZlc6LsU.js → output-wvaTemP-.js} +1 -1
- package/dist/chunks/{parse-error-hint-0bjTd09N.js → parse-error-hint-B_kJpdDW.js} +1 -1
- package/dist/chunks/{startup-auth-CXP4epXY.js → startup-auth-D8UPQxT1.js} +1 -1
- package/dist/chunks/{startup-auth-BJVo0cfB.js → startup-auth-D_E4tTmq.js} +1 -1
- package/dist/chunks/{text-response-D0HLXEab.js → text-response-BI4rEuhL.js} +1 -1
- package/dist/chunks/tool-policy-NTXy68a8.js +1 -0
- package/package.json +3 -3
- package/dist/chunks/aventure-cli-DEyqcPrf.js +0 -11
- package/dist/chunks/contract-DuaB1_Ib.js +0 -1
- package/dist/chunks/logout-Bkpo1mb3.js +0 -1
- package/dist/chunks/mcp-generation-contract-DMZzSi2x.js +0 -1
- package/dist/chunks/oauth-bearer-credential-O1Lxte-R.js +0 -1
- package/dist/chunks/openapi-commands-D-i7WmxD.js +0 -1
- package/dist/chunks/openapi-snapshot-DbUsUieG.js +0 -1
- package/dist/chunks/operations-catalog-DrOjPTzc.js +0 -1
- package/dist/chunks/tool-policy-C37kGt8n.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{enableCompileCache as e}from"node:module";import{fileURLToPath as t}from"node:url";e();var{Command:n,CommanderError:r}=await import(`../chunks/commander-D8IVfzyC.js`),{readRuntimePackage:i}=await import(`../chunks/package-DxrXjUBK.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-COBUpkxY.js`),o=process.argv.slice(2);try{if(a(),o.length===1&&(o[0]===`--version`||o[0]===`-V`))await new n().exitOverride().version(i(t(import.meta.url)).version).parseAsync();else{let{logWarn:e,setStderrLogging:t}=await import(`../chunks/logging-CgYAFXRk.js`),{cliMachineOutputSelected:n}=await import(`../chunks/output-mode-Z-SqZGR4.js`),{commandAuthMaterializationMode:r,materializeCommandCredential:a}=await import(`../chunks/startup-auth-
|
|
2
|
+
import{enableCompileCache as e}from"node:module";import{fileURLToPath as t}from"node:url";e();var{Command:n,CommanderError:r}=await import(`../chunks/commander-D8IVfzyC.js`),{readRuntimePackage:i}=await import(`../chunks/package-DxrXjUBK.js`),{locateRuntimeManifest:a}=await import(`../chunks/runtime-identity-COBUpkxY.js`),o=process.argv.slice(2);try{if(a(),o.length===1&&(o[0]===`--version`||o[0]===`-V`))await new n().exitOverride().version(i(t(import.meta.url)).version).parseAsync();else{let{logWarn:e,setStderrLogging:t}=await import(`../chunks/logging-CgYAFXRk.js`),{cliMachineOutputSelected:n}=await import(`../chunks/output-mode-Z-SqZGR4.js`),{commandAuthMaterializationMode:r,materializeCommandCredential:a}=await import(`../chunks/startup-auth-D_E4tTmq.js`),{GENERATED_OPENAPI_COMMAND_SPECS:s}=await import(`../chunks/openapi-commands-Dsmc0xON.js`);if(n(o)&&t(!1),o.includes(`--all-fields`)){let{setTextAllFields:e}=await import(`../chunks/text-field-BDYE-wQt.js`);e(!0)}let c=r(o,s);if(c===`stored`||c===`optional`)try{await a(c)}catch(t){e({component:i().bin[0],event:`optional_auth_materialization_failed`,message:`saved credential unavailable; continuing with credential-optional command`,error:t})}await import(`../chunks/aventure-cli-D0NEdbFg.js`)}}catch(e){if(!(e instanceof r))throw e;e.code!==`commander.version`&&process.stderr.write(`${e.message}\n`),process.exitCode=e.exitCode}export{};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"generatedFrom": "MCP_GENERATION_CONTRACT",
|
|
4
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"generatedAt": "2026-10-24T09:19:05.424Z",
|
|
5
5
|
"totalOperations": 137,
|
|
6
6
|
"note": "Projection of MCP_GENERATION_CONTRACT - see mcp/scripts/build-unified-operations.ts header for SSOT rules.",
|
|
7
7
|
"operations": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e}from"./env-CpA6E7ay.js";import{c as t,r as n}from"./openapi-call-
|
|
1
|
+
import{f as e}from"./env-CpA6E7ay.js";import{c as t,r as n}from"./openapi-call-o3oKcBXS.js";import{n as r,s as i,t as a}from"./credential-redaction-Fd-q1M6s.js";import{a as o,i as s}from"./api-key-credential-CTYGmo4i.js";async function c(e){let t=await l(e.credential.secret);if(t.state!==`verified`||e.activation!==`active`)return{stored:e,verification:t};try{return{stored:await s(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`),verification:t}}catch(n){return{stored:e,verification:{state:`unavailable`,summary:`${t.summary}, but the cached metadata could not be updated — ${a(n,[e.credential.secret])}`}}}}async function l(s){let c=i(e()),l;try{l=await t(c,{method:`GET`,path:n(`getCurrentApiKey`,{}),headers:{Authorization:`Bearer ${s}`}},o)}catch(e){return{state:`unavailable`,summary:`identity verification failed before an HTTP response — ${a(e,[s])}`}}return l.ok&&l.redirect?{state:`unavailable`,summary:`identity verification returned unexpected redirect ${l.status}`}:l.ok?l.data.status===`ACTIVE`?{state:`verified`,summary:`API key verified by aVenture sign-in`,apiKey:l.data}:{state:`invalid`,summary:`API key is not active`}:{state:l.problem.status===401||l.problem.status===403?`invalid`:`unavailable`,summary:`identity verification: ${r(l.problem,[s])}`}}export{l as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as refreshStoredApiKeyCredential}from"./api-key-credential-verification-
|
|
1
|
+
export{t as refreshStoredApiKeyCredential}from"./api-key-credential-verification-mMekpho4.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./package-CZBWjlYb.js";import{A as t,E as n,S as r,_ as i,g as a,i as o,n as s}from"./iso-l1vOidnb.js";import{f as c}from"./env-CpA6E7ay.js";import{c as l,r as u}from"./result-envelope-DXFbrrkt.js";import{z as d}from"./tool-policy-C37kGt8n.js";import{c as f,u as p}from"./openapi-call-N8RraQ85.js";import{i as m}from"./response-problem-D7yaxq6L.js";import{a as h,n as g,r as _,s as v,t as y}from"./credential-redaction-Fd-q1M6s.js";import{i as b,n as x,t as ee}from"./api-key-credential-CTYGmo4i.js";import{c as te,l as ne,n as S}from"./credential-store-DLz1bMPQ.js";import{n as C}from"./api-key-credential-verification-DOgXhdps.js";import{n as w}from"./contract-DuaB1_Ib.js";import{t as T}from"./openapi-composites-B9JPhVYN.js";import{n as re}from"./logout-CI8ozZxe.js";import{stderr as E,stdin as ie}from"node:process";import{TextDecoder as ae,inspect as oe}from"node:util";import{hostname as se,platform as ce}from"node:os";import{setTimeout as le}from"node:timers/promises";import{webcrypto as D}from"node:crypto";var O=o([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),k=o([`RSA_OAEP_256_A256_GCM_V1`]),A=i({clientLabel:r().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:O.nullish(),encryptionAlgorithm:k.nullish(),encryptionPublicKey:r().min(344).max(12e3).nullish()}),j=32;async function ue(){let e=await D.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await D.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function de(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=M(n,`wrapped key`,128,1024),s=M(r,`nonce`,12,12),c=M(i,`ciphertext`,1,65536),l=M(a,`authentication tag`,16,16),u;try{u=await D.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==j)throw Error(`broker credential used an invalid AES-256 key`);let e=await D.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await D.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new ae(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function M(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var N=o([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),P=o([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),F=i({approvedAt:s({offset:!0}).nullish(),clientLabel:r(),clientPlatform:O,comparisonCode:r(),consumedAt:s({offset:!0}).nullish(),createdAt:s({offset:!0}),expiresAt:s({offset:!0}),id:n(),intervalSeconds:a().int().min(1),keyReadyAt:s({offset:!0}).nullish(),status:N,terminalAt:s({offset:!0}).nullish(),terminalReason:P.nullish(),updatedAt:s({offset:!0})}),I=i({algorithm:k,authenticationTag:r(),ciphertext:r(),nonce:r(),wrappedKey:r()}),L=i({delivery:I.nullish(),expiresAt:s({offset:!0}),status:N,terminalReason:P.nullish()}),R=i({comparisonCode:r(),expiresAt:s({offset:!0}),id:n(),intervalSeconds:a().int().min(1),pollSecret:r(),verificationUrl:r()}),z=w(T,`start`),B=w(T,`poll`),V=w(T,`acknowledge`),H=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${g(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=he(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},U=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${y(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function fe(e){let t=await f(v(c()),{method:z.method,path:d(z.path,{},z.operationId),headers:{},contentType:`application/json`,body:e},R);if(t.ok&&t.redirect)throw new H(`start`,G(t.status));if(!t.ok)throw new H(`start`,t.problem);return ge(t.data)}async function W(e,t){let n=p(B.operationId),r=await f(v(c()),{method:B.method,path:d(B.path,{cliAuthorizationId:e},B.operationId),headers:{[n]:t}},L);if(r.ok&&r.redirect)throw new H(`poll`,G(r.status),[t]);if(!r.ok)throw new H(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:me(r.headers[`retry-after`])}}async function pe(e,t){let n=p(V.operationId),r;try{r=await f(v(c()),{method:V.method,path:d(V.path,{cliAuthorizationId:e},V.operationId),headers:{[n]:t}},F)}catch(e){throw new U(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new H(`acknowledge`,G(r.status),[t]);if(!r.ok)throw new H(`acknowledge`,r.problem,[t]);return r.data}function me(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function he(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function G(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function ge(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[oe.custom]:{enumerable:!1,value:a}})}var K=`RSA_OAEP_256_A256_GCM_V1`,_e=1,ve=30,q=e().bin[0],J=`The local record remains pending and unavailable to ordinary commands. Re-run \`${q} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function ye(e){if(!ie.isTTY)return u(`${q} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let n,r;try{let e=c().host;n=h(e),r=_(e)}catch(e){return u(`auth login --key: invalid environment configuration — ${y(e)}`)}for(;;){let e;try{e=await x(n)}catch(e){return u(`auth login --key: credential storage could not be inspected — ${y(e)}`)}if(e.state===`unavailable`)return u(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&E.write(S(e.keyringFailure));break}let t=await be(e.stored);if(t!==null)return t}let i;try{i=await ue()}catch(e){return u(`auth login --key: ephemeral encryption key could not be created — ${y(e)}`)}let a=A.safeParse({clientLabel:e.clientLabel?.trim()||(se().trim()||q).slice(0,120),clientPlatform:we(),encryptionAlgorithm:K,encryptionPublicKey:i.publicKey});if(!a.success)return u(`auth login --key: ${t(a.error)}`);let o;try{o=await fe(a.data)}catch(e){return u(`auth login --key: could not start browser authorization — ${y(e)}`)}let s;try{s=ne(o,r)}catch(e){return u(`auth login --key: unsafe browser authorization URL rejected — ${y(e)}`)}if(!Ce(await te(o,r,{noBrowser:e.noBrowser}),o,s))return u(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[s]});let d;try{d=await Se(o)}catch(e){return u(`auth login --key: authorization did not complete — ${y(e)}`,[],{references:[s]})}if(d.algorithm!==K)return u(`auth login --key: broker selected an unsupported encryption algorithm`);let f;try{f=await de(i.privateKey,d)}catch(e){return u(`auth login --key: encrypted credential could not be opened — ${y(e)}`)}let p=await C(f);if(p.state!==`verified`)return u(`auth login --key: decrypted credential was neither stored nor acknowledged — ${p.summary}`);let m;try{m=await b(n,{apiKey:p.apiKey,secret:f},`pending`)}catch(e){return u(`auth login --key: credential could not be durably stored — ${y(e)}`)}let g;try{g=await xe(o)}catch(e){return Q(m,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${y(e,[o.pollSecret])}`,J)}if(g.status!==`CONSUMED`)return Q(m,!0,`auth login --key: broker returned ${g.status} after acknowledgment`,J);let v=await C(f);if(v.state!==`verified`||!$(v.apiKey,m.credential.apiKey))return Q(m,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${v.summary}`,J);try{let e=await b(n,{apiKey:v.apiKey,secret:f},`active`);return l(`API key stored; authenticated identity and broker acknowledgment verified.`,Z(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return Q(m,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${y(e)}`,J)}}async function be(e){let t=await C(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?l(`API key is already stored and its authenticated identity was verified.`,Z(e,!0),{ids:[e.credential.apiKey.id]}):Q(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${q} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&$(t.apiKey,e.credential.apiKey))try{let n=await b(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return l(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,Z(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return Q(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${y(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${q} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return Q(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${q} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await re(e);if(n.outcome===`unconfirmed`)return Q(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await ee(e.host)}catch(t){return Q(e,!1,`auth login --key: stale pending credential could not be removed — ${y(t,[e.credential.secret])}`)}return E.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
1
|
+
import{a as e}from"./package-CZBWjlYb.js";import{A as t,E as n,S as r,_ as i,g as a,i as o,n as s}from"./iso-l1vOidnb.js";import{f as c}from"./env-CpA6E7ay.js";import{c as l,r as u}from"./result-envelope-DXFbrrkt.js";import{z as d}from"./tool-policy-NTXy68a8.js";import{c as f,u as p}from"./openapi-call-o3oKcBXS.js";import{i as m}from"./response-problem-D7yaxq6L.js";import{a as h,n as g,r as _,s as v,t as y}from"./credential-redaction-Fd-q1M6s.js";import{i as b,n as x,t as ee}from"./api-key-credential-CTYGmo4i.js";import{c as te,l as ne,n as S}from"./credential-store-DLz1bMPQ.js";import{n as C}from"./api-key-credential-verification-mMekpho4.js";import{n as w}from"./contract-BoQqQVwP.js";import{t as T}from"./openapi-composites-B9JPhVYN.js";import{n as re}from"./logout-bAOnLVcZ.js";import{stderr as E,stdin as ie}from"node:process";import{TextDecoder as ae,inspect as oe}from"node:util";import{hostname as se,platform as ce}from"node:os";import{setTimeout as le}from"node:timers/promises";import{webcrypto as D}from"node:crypto";var O=o([`MACOS`,`LINUX`,`WINDOWS`,`OTHER`]),k=o([`RSA_OAEP_256_A256_GCM_V1`]),A=i({clientLabel:r().regex(/.*\S.*/).min(1).max(120).nullish(),clientPlatform:O.nullish(),encryptionAlgorithm:k.nullish(),encryptionPublicKey:r().min(344).max(12e3).nullish()}),j=32;async function ue(){let e=await D.subtle.generateKey({name:`RSA-OAEP`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:`SHA-256`},!0,[`encrypt`,`decrypt`]),t=await D.subtle.exportKey(`spki`,e.publicKey);return{publicKey:Buffer.from(t).toString(`base64`),privateKey:e.privateKey}}async function de(e,t){let{wrappedKey:n,nonce:r,ciphertext:i,authenticationTag:a}=t,o=M(n,`wrapped key`,128,1024),s=M(r,`nonce`,12,12),c=M(i,`ciphertext`,1,65536),l=M(a,`authentication tag`,16,16),u;try{u=await D.subtle.decrypt({name:`RSA-OAEP`},e,o)}catch{throw Error(`broker credential key could not be decrypted`)}let d=new Uint8Array(u);try{if(d.byteLength!==j)throw Error(`broker credential used an invalid AES-256 key`);let e=await D.subtle.importKey(`raw`,d,{name:`AES-GCM`},!1,[`decrypt`]),t=new Uint8Array(c.byteLength+l.byteLength);t.set(c),t.set(l,c.byteLength);let n;try{n=await D.subtle.decrypt({name:`AES-GCM`,iv:s,tagLength:128},e,t)}catch{throw Error(`broker credential payload failed authentication`)}let r=new ae(`utf-8`,{fatal:!0}).decode(n);if(r.trim().length===0)throw Error(`broker returned a blank credential`);return r}finally{d.fill(0)}}function M(e,t,n,r){let i=e.replace(/=+$/u,``),a=Uint8Array.from(Buffer.from(e,`base64`)),o=Buffer.from(a).toString(`base64`).replace(/=+$/u,``);if(i.length===0||o!==i||a.byteLength<n||a.byteLength>r)throw Error(`broker returned an invalid ${t}`);return a}var N=o([`PENDING`,`ISSUING`,`KEY_READY`,`REVOKING`,`CONSUMED`,`REVOKED`,`DENIED`,`EXPIRED`,`FAILED`]),P=o([`Denied by user`,`Authorization request expired`,`CLI authorization expired before acknowledgement`,`Credential issuance recovery revoked an unrecoverable key`,`Revoked by user`,`Clerk create response validation failed`,`Credential issuance failed`,`Credential issuance could not be recovered`,`API-key quota reached`,`Credential issuance lost its database claim`,`Credential delivery encryption failed`,`Credential issuance finalization was lost`]),F=i({approvedAt:s({offset:!0}).nullish(),clientLabel:r(),clientPlatform:O,comparisonCode:r(),consumedAt:s({offset:!0}).nullish(),createdAt:s({offset:!0}),expiresAt:s({offset:!0}),id:n(),intervalSeconds:a().int().min(1),keyReadyAt:s({offset:!0}).nullish(),status:N,terminalAt:s({offset:!0}).nullish(),terminalReason:P.nullish(),updatedAt:s({offset:!0})}),I=i({algorithm:k,authenticationTag:r(),ciphertext:r(),nonce:r(),wrappedKey:r()}),L=i({delivery:I.nullish(),expiresAt:s({offset:!0}),status:N,terminalReason:P.nullish()}),R=i({comparisonCode:r(),expiresAt:s({offset:!0}),id:n(),intervalSeconds:a().int().min(1),pollSecret:r(),verificationUrl:r()}),z=w(T,`start`),B=w(T,`poll`),V=w(T,`acknowledge`),H=class extends Error{httpStatus;retryAfterSeconds;retryable;constructor(e,t,n=[]){super(`CLI authorization ${e} failed: ${g(t,n)}`),this.name=`CliAuthorizationRequestError`,this.httpStatus=t.status,this.retryAfterSeconds=he(t.retryAfterSeconds),this.retryable=t.status>=500||t.status===429}},U=class extends Error{constructor(e,t,n=[]){super(`CLI authorization ${e} transport failed: ${y(t,n)}`,{cause:t}),this.name=`CliAuthorizationTransportError`}};async function fe(e){let t=await f(v(c()),{method:z.method,path:d(z.path,{},z.operationId),headers:{},contentType:`application/json`,body:e},R);if(t.ok&&t.redirect)throw new H(`start`,G(t.status));if(!t.ok)throw new H(`start`,t.problem);return ge(t.data)}async function W(e,t){let n=p(B.operationId),r=await f(v(c()),{method:B.method,path:d(B.path,{cliAuthorizationId:e},B.operationId),headers:{[n]:t}},L);if(r.ok&&r.redirect)throw new H(`poll`,G(r.status),[t]);if(!r.ok)throw new H(`poll`,r.problem,[t]);return{authorization:r.data,retryAfterSeconds:me(r.headers[`retry-after`])}}async function pe(e,t){let n=p(V.operationId),r;try{r=await f(v(c()),{method:V.method,path:d(V.path,{cliAuthorizationId:e},V.operationId),headers:{[n]:t}},F)}catch(e){throw new U(`acknowledge`,e,[t])}if(r.ok&&r.redirect)throw new H(`acknowledge`,G(r.status),[t]);if(!r.ok)throw new H(`acknowledge`,r.problem,[t]);return r.data}function me(e){if(e===void 0)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null}function he(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:null}function G(e){return{status:e,title:`Unexpected redirect`,type:`about:blank`,code:void 0,detail:`CLI authorization endpoint returned an unexpected redirect`}}function ge(e){let{verificationUrl:t,pollSecret:n,...r}=e,i={...e},a=()=>({...r,verificationUrl:`<redacted>`,pollSecret:`<redacted>`});return Object.defineProperties(i,{verificationUrl:{enumerable:!1,get:()=>t},pollSecret:{enumerable:!1,get:()=>n},toJSON:{enumerable:!1,value:a},toString:{enumerable:!1,value:()=>`CliAuthorizationStart(${JSON.stringify(a())})`},[oe.custom]:{enumerable:!1,value:a}})}var K=`RSA_OAEP_256_A256_GCM_V1`,_e=1,ve=30,q=e().bin[0],J=`The local record remains pending and unavailable to ordinary commands. Re-run \`${q} auth login --key\`; it recovers the credential when the broker acknowledged it, and otherwise clears the stale record.`;async function ye(e){if(!ie.isTTY)return u(`${q} auth login --key requires an interactive TTY on stdin`,[`For non-interactive automation, inject AUTH_TOKEN through the environment.`]);let n,r;try{let e=c().host;n=h(e),r=_(e)}catch(e){return u(`auth login --key: invalid environment configuration — ${y(e)}`)}for(;;){let e;try{e=await x(n)}catch(e){return u(`auth login --key: credential storage could not be inspected — ${y(e)}`)}if(e.state===`unavailable`)return u(`auth login --key: ${e.summary}`,[`Make the OS keyring or the CLI config directory writable, or use AUTH_TOKEN from the environment.`]);if(e.state===`missing`){e.keyringFailure!==void 0&&E.write(S(e.keyringFailure));break}let t=await be(e.stored);if(t!==null)return t}let i;try{i=await ue()}catch(e){return u(`auth login --key: ephemeral encryption key could not be created — ${y(e)}`)}let a=A.safeParse({clientLabel:e.clientLabel?.trim()||(se().trim()||q).slice(0,120),clientPlatform:we(),encryptionAlgorithm:K,encryptionPublicKey:i.publicKey});if(!a.success)return u(`auth login --key: ${t(a.error)}`);let o;try{o=await fe(a.data)}catch(e){return u(`auth login --key: could not start browser authorization — ${y(e)}`)}let s;try{s=ne(o,r)}catch(e){return u(`auth login --key: unsafe browser authorization URL rejected — ${y(e)}`)}if(!Ce(await te(o,r,{noBrowser:e.noBrowser}),o,s))return u(`auth login --key: browser authorization requires an interactive terminal for manual handoff`,[`Automatic browser opening did not complete, and the approval URL was withheld because stderr is not an interactive terminal. Retry from an interactive terminal.`],{references:[s]});let d;try{d=await Se(o)}catch(e){return u(`auth login --key: authorization did not complete — ${y(e)}`,[],{references:[s]})}if(d.algorithm!==K)return u(`auth login --key: broker selected an unsupported encryption algorithm`);let f;try{f=await de(i.privateKey,d)}catch(e){return u(`auth login --key: encrypted credential could not be opened — ${y(e)}`)}let p=await C(f);if(p.state!==`verified`)return u(`auth login --key: decrypted credential was neither stored nor acknowledged — ${p.summary}`);let m;try{m=await b(n,{apiKey:p.apiKey,secret:f},`pending`)}catch(e){return u(`auth login --key: credential could not be durably stored — ${y(e)}`)}let g;try{g=await xe(o)}catch(e){return Q(m,!0,`auth login --key: credential was stored and verified, but broker acknowledgment was not confirmed — ${y(e,[o.pollSecret])}`,J)}if(g.status!==`CONSUMED`)return Q(m,!0,`auth login --key: broker returned ${g.status} after acknowledgment`,J);let v=await C(f);if(v.state!==`verified`||!$(v.apiKey,m.credential.apiKey))return Q(m,!0,`auth login --key: broker acknowledgment succeeded, but refreshed credential metadata could not prove the granted lifetime — ${v.summary}`,J);try{let e=await b(n,{apiKey:v.apiKey,secret:f},`active`);return l(`API key stored; authenticated identity and broker acknowledgment verified.`,Z(e,!0),{ids:[e.credential.apiKey.id]})}catch(e){return Q(m,!0,`auth login --key: remote acknowledgment succeeded, but local activation could not be confirmed — ${y(e)}`,J)}}async function be(e){let t=await C(e.credential.secret);if(e.activation!==`pending`)return t.state===`verified`?l(`API key is already stored and its authenticated identity was verified.`,Z(e,!0),{ids:[e.credential.apiKey.id]}):Q(e,!1,`auth login --key: stored credential ${t.state} — ${t.summary}`,`Run \`${q} auth logout\` to revoke/remove it before authorizing a replacement.`);if(t.state===`verified`&&$(t.apiKey,e.credential.apiKey))try{let n=await b(e.host,{apiKey:t.apiKey,secret:e.credential.secret},`active`);return l(`Recovered pending CLI credential: broker acknowledgment had succeeded.`,Z(n,!0),{ids:[n.credential.apiKey.id]})}catch(t){return Q(e,!0,`auth login --key: credential is valid but could not be promoted locally — ${y(t,[e.credential.secret])}`,`The remote key remains valid. Re-run \`${q} auth login --key\` to retry local activation; it will recover the pending credential automatically.`)}if(t.state===`unavailable`||t.state===`verified`&&!e.credential.apiKey.expiresAt)return Q(e,t.state===`verified`,`auth login --key: the stored pending credential acknowledgment could not be verified — ${t.summary}`,t.state===`verified`?`The stored expiry is missing. Both records were preserved; inspect the existing key in your account before deciding how to recover it.`:`The stored record and the remote key were both preserved. Re-run \`${q} auth login --key\` when the API is reachable; it recovers an acknowledged credential and clears an unacknowledged one.`);let n=await re(e);if(n.outcome===`unconfirmed`)return Q(e,!1,`auth login --key: a prior credential is durably stored but broker acknowledgment was not confirmed`,`Remote revocation of the stale pending key was not confirmed — ${n.summary}. Retry when the API is reachable.`);try{await ee(e.host)}catch(t){return Q(e,!1,`auth login --key: stale pending credential could not be removed — ${y(t,[e.credential.secret])}`)}return E.write(n.outcome===`revoked`?`Revoked and cleared a stale pending CLI credential; starting a fresh browser authorization.
|
|
2
2
|
`:`Cleared a stale pending CLI credential whose remote key can no longer authenticate; starting a fresh browser authorization.
|
|
3
3
|
`),null}async function xe(e){let t=new Date(e.expiresAt).getTime(),n=Y(e.intervalSeconds);for(;;)try{return await pe(e.id,e.pollSecret)}catch(e){if(e instanceof H){if(!e.retryable)throw e;n=Y(e.retryAfterSeconds??n)}else if(!(e instanceof U))throw e;if(Date.now()>=t)throw e;E.write(`Broker acknowledgment was interrupted; retrying.
|
|
4
4
|
`),await X(n,t)}}async function Se(e){let t=new Date(e.expiresAt).getTime(),n=Y(e.intervalSeconds),r;for(E.write(`Waiting for browser approval...
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./private-live-identity-AuYLZJvL.js";import{f as t,t as n}from"./env-CpA6E7ay.js";import{r}from"./auth-resolver-JikQ_vOz.js";import{a as i,l as a}from"./openapi-call-
|
|
1
|
+
import{t as e}from"./private-live-identity-AuYLZJvL.js";import{f as t,t as n}from"./env-CpA6E7ay.js";import{r}from"./auth-resolver-JikQ_vOz.js";import{a as i,l as a}from"./openapi-call-o3oKcBXS.js";import{a as o,i as s}from"./response-problem-D7yaxq6L.js";import{t as c}from"./credential-redaction-Fd-q1M6s.js";import{t as l}from"./api-key-bearer-credential-DDrDgtmD.js";import{a as u,f as d,l as f,s as p}from"./oauth-credential-CsMU443S.js";import{t as m}from"./oauth-bearer-credential-BFQz9k2h.js";async function h(e){let t=null,n=e=>{t=e};try{await m(e,n),await l(n)}catch(e){return{materialized:t,failure:c(e)}}return{materialized:t,failure:null}}async function g(t,n,r,a){if(a.failure!==null)return{scope:t,selected:null,identity:null,authorization:null,error:a.failure};let o=null,s=null,l,u=e=>{l=e,s=_(e.credential,a.materialized)};try{let n=await i({method:`POST`,path:`/v1/auth/me/permissions`,body:{operation:[]},auth:t,requesterScope:t,responseFormat:`json`,onAuthPrepared:u});if(!n.ok)throw Error(v(n));if(s===null)throw Error(`Live permission probe did not prepare a credential`);if(o=S(n.data),t===`read`)return{scope:t,selected:s,identity:null,authorization:o,error:null};if(l===void 0)throw Error(`Live permission probe did not retain its prepared credential`);let r=await e(t,l);return{scope:t,selected:s,identity:r,authorization:o,error:null}}catch(e){return{scope:t,selected:s,identity:null,authorization:o,error:c(e,y(n,r,l))}}}function _(e,t){if(e===null)return null;let n=t??r().source;if(n===null)throw Error(`Prepared credential has no local provenance`);return{credential:e,source:n}}function v(e){return[e.summary,...e.warnings].join(` — `)}function y(e,n,r){return[t().userBearerToken,...o(r?.headers??{}),...e.state===`found`?d(e.stored.credential.tokens):[],n.state===`found`?n.stored.credential.secret:void 0]}function b(e,t,n=null){let r=t.state===`found`?t.stored:void 0,i=r?.credential.apiKey.expiresAt??null;return{host:e,present:r!==void 0,provider:r?.provider??null,activation:r?.activation??null,apiKeyId:r?.credential.apiKey.id??null,subject:r?.credential.apiKey.subject??null,scope:r?.credential.apiKey.scopes??[],name:r===void 0?null:s(r.credential.apiKey.name,[r.credential.secret]),status:r?.credential.apiKey.status??null,expiresAt:i,metadataSource:r===void 0?null:n?.state===`verified`?`clerk`:`store-cache`,live:n===null?null:{state:n.state,summary:n.summary},expiresInDay:T(i),storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function x(e,t){let n=t.state===`found`?t.stored:void 0;return{host:e,present:n!==void 0,provider:n?.provider??null,expiresAt:n?.credential.expiresAt??null,expired:n===void 0?null:u(n.credential),renewable:n===void 0?null:n.credential.tokens.refresh_token!==void 0,identity:n===void 0?null:f(n.credential),client:n?.credential.client??null,storageFailure:t.state===`unavailable`?t.summary:null,keyringFailure:t.state===`missing`?t.keyringFailure??null:null,error:t.state===`invalid`?t.summary:null}}function S(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)throw Error(`permission probe returned no JSON response`);let t=a.safeParse(e.response);if(!t.success)throw t.error;return t.data}function C(e,t){let{expiresAt:n,expiresInDay:r}=b(e,t);return n!==null&&r!==null&&new Date(n).getTime()<=Date.now()?` (cached expiry passed ${Math.abs(r)}d ago; \`auth status\` re-checks it with aVenture sign-in)`:``}var w=864e5;function T(e){if(e===null)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:Math.round((t-Date.now())/w)}var E=7;function D(e){return e===null?`none`:e.length<=11?e:`${e.slice(0,E)}\u2026${e.slice(-4)}`}var O=13,k=14;function A(e){return[``,`${e.cliName} ${e.cliVersion} \u2192 ${e.apiKey.host}`+(e.apiVersion===null?` (api build unavailable)`:` (api ${e.apiVersion})`),``,...P(e.oauth,e.cliName,e.refresh),...I(e.apiKey,e.oauth,e.cliName),``,M(`Providers`,z(e.providers)),M(`Environment`,B(e.resolved)),M(`Selected`,V(e.resolved,e.refresh,e.cliName)),...j(e.live)].join(`
|
|
2
2
|
`)}function j(e){if(e===null)return[];let t=N(`local credential provenance was captured before verification`);if(e.error!==null)return[``,M(`Live probe`,`${e.scope} permission probe failed`),t,N(e.error)];if(e.authorization===null)return[];let n=e.authorization.permissionGrant,r=e.identity;return[``,M(`Live probe`,`${e.scope} permission probe succeeded`),t,N(`operation access ${e.authorization.operationAccess}; ${n.role.length} role; ${n.permission.length} permission`),...r===null?[N(e.scope===`read`?`identity not requested for a read-scope credential`:`identity unavailable in this build`)]:[M(`Live account`,r.nameFull??r.email??r.clerkUserId??r.id)],N(`no API operation was executed or individually authorized`)]}function M(e,t){return` ${e.padEnd(O)}${t}`}function N(e){return` ${``.padEnd(O)}${e}`}function P(e,t,n){switch(e.state){case`found`:{let{credential:r,provider:i}=e.stored,a=f(r);return[M(`OAuth`,`${a.email??a.subject??`unknown identity`} via ${i}`),N(F(r,t,n))]}case`missing`:return[M(`OAuth`,`none stored`),...e.keyringFailure===void 0?[]:[N(`OS keyring unusable — login stores to file: ${e.keyringFailure}`)]];case`unavailable`:return[M(`OAuth`,`storage unavailable: ${e.summary}`)];case`invalid`:return[M(`OAuth`,`stored credential invalid: ${e.summary}`)];default:throw Error(`Unsupported OAuth credential state`)}}function F(e,t,n){return u(e)?e.tokens.refresh_token===void 0?`access token expired — run \`${t} auth login\``:n.failure===null?n.materialized===`api-key`?`access token expired and renewal failed; the API key is in use — \`${t} auth login\` renews OAuth`:`access token expired — not renewed while AUTH_TOKEN is set in the environment`:`access token expired — ${n.failure}`:`access token valid until ${e.expiresAt}`}function I(e,t,n){if(!e.present){if(t.state===`found`)return[];let r=e.storageFailure??(t.state===`unavailable`?t.summary:null);return r===null?[M(`Signed in`,`no \u2014 run \`${n} auth login\``),...e.error===null?[]:[N(`stored credential invalid: ${e.error}`)]]:[M(`Signed in`,`credential storage unavailable`),N(r)]}return[M(t.state===`found`?`API key`:`Signed in`,e.subject??`unknown subject`),N(`via ${e.provider??`unknown store`}`),M(`Key`,`${e.name??`unnamed`} ${D(e.apiKeyId)}`),...L(e,n),M(`Scopes`,e.scope.length===0?`none`:e.scope.join(`, `))]}function L(e,t){let n=e.live,r=e.expiresInDay,i=e.expiresAt;if(n?.state===`invalid`)return[M(`Key state`,`rejected by aVenture sign-in \u2014 ${n.summary}`),N(`run \`${t} auth logout\`, then \`${t} auth login --key\``)];let a=n?.state===`verified`;return[M(`Key state`,a?`${e.status??`unknown`}, verified by aVenture sign-in now`:`${e.status??`unknown`} when stored`),...i===null||r===null?[N(`no expiry recorded`)]:[N(R(i,r,a?`expires`:`cached expiry`))],...a?[]:[N(n===null?"aVenture sign-in owns the live verdict — `auth status` re-checks it":`aVenture sign-in could not be reached \u2014 ${n.summary}`)]]}function R(e,t,n){let r=e.slice(0,10);return new Date(e).getTime()<=Date.now()?`${n} ${r} passed ${Math.abs(t)}d ago`:t<=k?`${n} ${r}, ${t}d away`:`${n} ${r}`}function z(e){if(e.state===`unavailable`)return`unavailable: ${e.summary}`;let t=e.catalog.oauthClient;return[e.catalog.clerkPublishableKey?`browser sign-in`:`no browser sign-in`,t?`oauth ${p(t).host} client ${t.clientId}`:`no OAuth CLI client`].join(`; `)}function B(e){return`${n.authToken}=${e.present?e.source??`resolved`:`unset`}`}function V(e,t,r){return e.present||t.materialized===`env`?`${n.authToken} from the environment`:t.materialized===`oauth`?`saved OAuth access token`:t.materialized===`api-key`?`saved API key`:`none \u2014 sign in with \`${r} auth login\``}export{b as apiKeyCredentialDiagnostics,C as apiKeyExpiryQualifier,g as inspectLiveAuth,x as oauthCredentialDiagnostics,h as refreshCliCredentials,A as renderAuthStatus,B as summarizeCredential};
|
|
@@ -0,0 +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-CZBWjlYb.js";import{a as o,c as s,l as c,r as l}from"./env-CpA6E7ay.js";import{c as u,f as d,r as f}from"./result-envelope-DXFbrrkt.js";import{L as p,R as m,a as h,c as g,t as _,y as v}from"./tool-policy-NTXy68a8.js";import{i as y}from"./logging-BHp-5JwI.js";import{i as ee,n as te,t as ne}from"./cli-help-policy-BSkCikW7.js";import{a as re,c as ie,d as ae,f as oe,l as se,n as ce,o as b,r as le,s as ue,t as de,u as fe}from"./startup-auth-D8UPQxT1.js";import{_ as pe,h as me}from"./help-catalog-tM-2mFr2.js";import{n as he,t as ge}from"./operations-metadata-BfIKb5PX.js";import{t as x}from"./openapi-commands-CLn-TCPy.js";import{i as S,r as C,t as w}from"./output-mode-COLMloqB.js";import{S as _e,_ as T,a as ve,b as E,c as ye,d as be,f as xe,g as D,h as Se,i as Ce,l as we,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as je,u as Me,v as O,x as Ne,y as Pe}from"./generated-option-order-DAzrGPOt.js";import{a as Fe,i as Ie,n as Le,r as Re}from"./payload-operand-guard-B5t_1_uQ.js";import{fileURLToPath as ze}from"node:url";import{readFile as Be}from"node:fs/promises";async function Ve(e){let t;try{t=e===`-`?await He():await Be(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 He(){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 k=`--content-type`;function Ue(e,n,r){let i=e=>!r?.has(e)&&(r?.add(e),!0),a=n.requestBody??[];if(a.length>1&&i(k)){let n=a.map(({contentType:e})=>e);e.addOption(new t(`${k} <media-type>`,`Select the request body encoding, never an uploaded file's media type; omit for ${n[0]}.`).choices(n).argParser(Ge(a)))}if(F(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>`,ve(r,r.requiredPath)).argParser(A(`--from-file`)))}let o=De(a).filter(e=>i(M(e.variant[0].parameter)));for(let n of o.toSorted((e,t)=>Ee(e.variant[0].parameter,t.variant[0].parameter))){let{descriptor:r,parameter:i}=n.variant[0],o=new t(Ce(n),a.length>1?ke(n):ye(r,i));a.length===1&&i.envName!==void 0&&o.env(i.envName);let s=a.length===1?Ae(r,i.optionKey):[];s.length>0&&o.conflicts(s),a.length>1?o.argParser(We):T(i.name)||i.schemaType===`array`?o.argParser(Ke):o.argParser(A(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`)})}it(e,n,o)}function We(e,t){return t===void 0?e:typeof t==`string`?[t,e]:[...t,e]}function Ge(e){return(t,r)=>{if(r!==void 0)throw new n(`${k} was already given; pass it once.`);let i=v(e,t);if(!i.ok)throw new n(i.summary);return t}}function Ke(e,t){return[...t??[],e]}function A(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 j(e,t){let n=ue(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=qe(e,i,t);if(a!==null)return f(a);let o=xe(e.operationId,i,t);if(!o.ok)return f(o.summary,o.warnings);t=o.data;let s=Je(i,t);if(s!==null)return f(s);let c=await Qe(t);if(!c.ok)return f(c.summary,c.warnings);let l=Te(e.requestBody??[],i,c.data);if(l!==null)return f(l);let d=Ze(e.operationId,i,c.data);if(!d.ok)return d;let p=Se(e.operationId,i,c.data);if(p!==null)return f(p);let m=$e(e.operationId,i,t);if(!m.ok)return m;if(c.data===void 0&&m.data===void 0)return i.required?f(rt(e.operationId,i)):u(`No body`,void 0);let h=tt(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&&!O(h.data)){let t=i.kind===`multipart`?` keyed by multipart part name`:` body`;return f(`${e.operationId} requires a JSON object${t}.`)}let g=Xe(i,h.data);if(g.length>0)return f(`${e.operationId} requires body option(s): ${g.join(`, `)}`);let _=h.data,y=O(_)?E(i).filter(e=>!D(_,e)):[];return y.length>0?f(Ye(e.operationId,i,y)):h}function qe(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`${M(t)} requires ${k} ${i.join(` or `)}.`}return null}function Je(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 Ye(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 Xe(e,t){return O(t)?e.parameter.filter(e=>e.required&&!D(t,e.name)).map(M):[]}function Ze(e,t,n){let r=_e(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 Ve(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 $e(e,t,n){let r={},i=!1;for(let e of t.parameter){let a=Ne(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=et(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=we(e,t,n,r);return a===null?u(`Direct body options parsed`,r):a}function et(e,t,n,r,i){let a=Pe(r,i);if(a===null){let e=nt(r,i);return e.ok?Me(n,r.name,e.data,r.schemaType===`array`):f(e.summary,e.warnings)}if(a.plain.length>0)return f(`${M(r)} mixes row-form values with plain value(s): ${a.plain.join(`, `)} — prefix every value with its 0-based ${a.container}[] row index, as 0:value.`);let o=Oe(e,t,a.container);for(let e of a.rows.keys())if(!(e<o))return f(`${M(r)} names ${a.container}[] row ${e}, but these options build at most ${o} ${a.container}[] row(s) — number rows from 0, and name the row of a value that itself starts with digits and a colon, as 0:0:00 for the value 0:00.`);for(let[e,t]of a.rows){let i=[];for(let e of t){let t=P(r.name,r.itemSchemaType,e);if(!t.ok)return f(t.summary,t.warnings);i.push(t.data)}let a=be(n,r.name,e,i);if(!a.ok)return a}return u(`Body value assigned`,null)}var M=e=>e.flag.split(` `)[0]??e.name;function tt(e,t,n,r){if(n===void 0)return u(`Direct body parsed`,r);if(r===void 0)return u(`Input parsed`,n);if(O(n)&&O(r))try{return u(`Input parsed`,N(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 N(e,t,n,r=``){let i={...t};for(let[t,a]of Object.entries(n)){let n=i[t],o=`${r}${t}`;if(O(n)&&O(a))i[t]=N(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`:me.test(o)?`; keep multi-line text in the --from-file body`:``}.`)}return i}function nt(e,t){if(typeof t==`boolean`)return u(`Body value parsed`,t);if(t===void 0||typeof t==`string`)return P(e.name,e.schemaType,t??``);let n=[],r=T(e.name)&&e.schemaType!==`array`?e.schemaType:e.itemSchemaType;for(let i of t){let t=P(e.name,r,i);if(!t.ok)return t;n.push(t.data)}return u(`Body value parsed`,n)}function P(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 rt(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(M).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(M).join(`, `);return i.length===0?`${e} requires --from-file`:`${e} requires --from-file or body option(s): ${i}`}function it(e,t,n){let r=[...t.parameters,...n.map(({variant:e})=>e[0].parameter)];(t.requestBody?.length??0)>1&&r.push({optionKey:`contentType`,flag:k,location:`body`}),F(t)&&r.push({optionKey:`fromFile`,flag:`--from-file`,location:`body`}),je(e.options,r)}function F(e){return(e.requestBody??[]).some(e=>e.kind!==`multipart`||e.parameter.some(e=>e.schemaFormat!==`binary`))}function at(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, 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 ask <question>` or `help --ask <question>` answers a platform question.").argument(`[command...]`,"command path, operationId, or METHOD and path, e.g. `help entities get`"),r.addOption(new ot(r)),r.hook(`preSubcommand`,e=>{e.opts().help&&e.help()});let i=lt(t);i!==void 0&&r.option(`--ask <question>`,i.summary),w(r),r.action(async function(r){let{emit:a}=await import(`./output-wvaTemP-.js`),o=this.optsWithGlobals();if(o.help&&r.length===0){this.outputHelp();return}if(!o.help&&i!==void 0&&o.ask!==void 0){let e=S(o);if(r.length>0){a({mode:e},f(`Use either a command path or --ask, not both.`));return}a({mode:e},await dt(i,o.ask,o.environment,e));return}let s=V(e,r),c=t.find(t=>s!==void 0&&V(e,t.cliPath)===s);if(o.help||s!==void 0&&c===void 0){s===void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),s.outputHelp();return}let l=c===void 0?await ut(r,t):u(`Resolved by command path`,{operationId:c.operationId});if(l.ok&&l.data?.command!==void 0&&this.error(`unknown command '${r.join(` `)}' (run \`${n} --help\` for the command tree)`),!l.ok||l.data===null){a({mode:S(o)},l);return}let{writeShowResult:d}=await import(`./operations-catalog-Co81xH0y.js`);d({...o,...l.data},t,S(o,`text`),n)}),ct(e,t,n)}var ot=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))}},I=2,L=6,st={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=>!te.has(e.name())):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(I)}${e}\n${R(n,a,i)}`}};function R(e,t,n){return n.boxWrap(e,t-L).replace(/^/gmu,` `.repeat(L))}function ct(e,t,n){for(let r of t){let i=V(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=pe(r.operationId,t,n),c=z(he(r.header),o,e),l=z(ge(r.errorResponse),o,e);return`\n${[...s,...c,...l].join(`
|
|
2
|
+
`)}\n`})}}function z(e,t,n){let[r,...i]=e;return r===void 0?[]:[``,r,...i.map(e=>R(e.trimStart(),t,n).replace(/^ +/u,` `.repeat(I)))]}function lt(e){let[t,...n]=e.filter(e=>{let[t,n,...r]=e.cliPath;return t===`help`&&n!==void 0&&r.length===0&&H(e)!==void 0});return n.length===0?t:void 0}var B='Accepted selectors: `<METHOD> <route template or concrete path>`, an operationId, or a CLI command path such as "entities get".';async function ut(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}\`.`,[B]);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-B3pG7Dqm.js`),h=d({method:s,path:c});return!h.ok||h.data===null?f(h.summary,[...h.warnings,B]):u(`Resolved by method and path`,{operationId:h.data.operation.operationId})}function V(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}async function dt(e,t,n,r){let{buildOpenApiPath:i,runOpenApiCall:a}=await import(`./openapi-call-B3pG7Dqm.js`),o=H(e);if(o===void 0)return f(`The \`${e.cliPath.join(` `)}\` operation no longer takes a single required text body; run it directly instead of \`help --ask\`.`);n!==void 0&&(process.env.API_ENV=n);let s=await j(e,{[o.optionKey]:t});return s.ok?await a({method:e.method,path:i(e.operationId,{}),searchParams:{},body:s.data,auth:e.auth,responseFormat:C(r)?`json`:`auto`}):s}function H(e){if(e.requestBody?.length!==1||e.parameters.some(e=>e.required))return;let t=(e.requestBody[0]?.parameter??[]).filter(e=>e.required);return t.length===1&&t[0]?.schemaType===`string`?t[0]:void 0}function ft(e,t,n){if(e.cliPath[0]!==`lookup`||!pt(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 pt(e){return e.ok?Array.isArray(e.data)&&e.data.length===0:e.httpStatus===404}function mt(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 ht(t,n,r,i){let a=gt(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-DtXXrcex.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-JNk2mnDh.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-runs`,register:async()=>{let{registerBuiltinResearchRunWaitCommand:e}=await import(`./builtin-research-run-wait-CuL5YNzI.js`);e(n)}},{selected:s===`completion`,register:async()=>{let{registerCompletionCommand:e}=await import(`./completion-ChN2_goh.js`);e(n,r,c)}},{selected:s===`command-catalog`,register:async()=>{let{registerOperationsCommand:e}=await import(`./operations-B7FP0mq_.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,registerBuiltin:h,async completeTree(e){e(n,r.filter(e=>!p.includes(e))),await h(!0)}}}function gt(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 _t=new Set(x.map(e=>e.cliPath.join(` `)));function U(e,t){e.showHelpAfterError(!1).exitOverride(t(e)),e.commands.length===0?e.hook(`preAction`,Le):e.registeredArguments.length===0&&!_t.has(Fe(e).join(` `))&&e.addHelpOption(new Ie(e));for(let n of e.commands)U(n,t)}var W=a(ze(import.meta.url)),G=W.bin[0];async function K(e,t){let{BearerVerificationUnavailableError:n}=await import(`./openapi-call-B3pG7Dqm.js`),{emitJson:r}=await import(`./output-wvaTemP-.js`),i=e instanceof Error?e:Error(String(e));y({component:G,event:`fatal`,message:i.message,error:i}),process.stderr.write(`${G} fatal (${t}): ${i.stack??i.message}\n`);let a=i instanceof n?{httpStatus:i.problem.status,problem:i.problem}:{};r({...f(`${G} ${t}: ${i.message}`,[i.name||`Error`],a),counts:{exitCode:1}}),process.exit(1)}function q(e){return ne[ee(e,b)??`cli`]}function J(e,t){let n=t.map(e=>{let t=e.cliPath[0]??``;return{spec:e,top:t,rank:q(t).rank}}).toSorted((e,t)=>e.rank-t.rank||e.top.localeCompare(t.top)).map(e=>e.spec),r=new Set(n.filter(e=>de(e.cliPath[0])).map(e=>e.cliPath[0]??``)),i=new Set,a=new Set;for(let{cliPath:e,deprecated:t}of n)for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(` `);i.add(r),t!==!0&&a.add(r)}for(let t of n)vt(e,t,r,a,i.has(t.cliPath.join(` `)))}function vt(e,t,n,r,i){let a=t.cliPath,o=e,s=``,c=!n.has(a[0]??``);for(let e of a.slice(0,-1)){s=s===``?e:`${s} ${e}`;let t=c&&s===e||!r.has(s);o=yt(o,e,s,t)}let l=a.at(-1)??t.operationId,u=o.commands.find(e=>e.name()===l)??o.command(l,t.deprecated===!0?{hidden:!0}:{}),d=t.requestBody?.flatMap(({parameter:e})=>e)??[];u.summary(t.summary||t.operationId).description([`${t.method} ${t.path}.`,t.summary||t.description,`Full documentation: ${G} help ${t.cliPath.join(` `)}`,t.requestBody?.[0]?.kind===`json`||[...t.parameters,...d].some(e=>h(e.schemaType,e.itemSchemaType))?_:``].filter(Boolean).join(`
|
|
3
|
+
`));let p=ae(t);for(let e of t.parameters)bt(u,e,i||e===p);Ue(u,t),g(t.intent)&&!u.options.some(e=>e.long===`--execute`)&&u.option(`--execute`,`Deprecated; accepted and ignored. This command executes by its verb.`,!1),w(u),u.hook(`preAction`,e=>fe(e,t)),t.explain===!0&&u.option(`--explain`,`Print the search strategy and parsed constraints before the results`),p!==void 0&&u.argument(`[text...]`,p.description||`Same as ${ie(p.flag)}.`),u.action(async function(){let{emit:e,emitSearchExplanation:n}=await import(`./output-wvaTemP-.js`),r=this.optsWithGlobals(),i=S(r),a=r;if(p!==void 0){let t=oe(p,this.args,r);if(!t.ok||t.data===null)return e({mode:i},t);a=t.data}let o=se(t,a);if(o.length>0)return e({mode:i},f(`missing required options: ${o.join(`, `)}`));let s=await xt(t,a,i),c=ft(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?process.stdout.write(s.data):e({mode:i},s)})}function yt(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 bt(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 xt(e,t,n){let{buildOpenApiPath:r,runOpenApiCall:i}=await import(`./openapi-call-B3pG7Dqm.js`),{pendingResult:a}=await import(`./output-wvaTemP-.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 j(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 mt(e,await i({method:e.method,path:r(e.operationId,l),searchParams:u,headers:d,body:o.data,contentType:ue(e,t),auth:e.auth,responseFormat:C(n)?`json`:`auto`,responseBytes:e.binaryResponse===!0,pendingResult:a}))}var St=e=>{if(e.code!==`EPIPE`)throw e;process.exit(0)};for(let e of[process.stdout,process.stderr])e.on(`error`,St);process.on(`uncaughtException`,e=>K(e,`uncaughtException`)),process.on(`unhandledRejection`,e=>K(e,`unhandledRejection`));var Y=ce(process.argv.slice(2),x),X=Y===`required`?x:re(x),Z=new Re;Z.name(G).usage(`<command> [subcommand] [options]`).configureHelp(st).version(W.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
|
+
people, and news — carry everything else: funding, publications, and tags.
|
|
5
|
+
|
|
6
|
+
Mutations execute directly; --execute is a deprecated no-op.
|
|
7
|
+
The aVenture MCP server tools execute through this same CLI.`).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 \`${G} --help\` for usage)`);var Q=ht(process.argv.slice(2),Z,X,W);J(Z,Q.generated),await Q.registerBuiltin(),at(Z,X,G);for(let e of Z.commands)e.helpGroup()||e.helpGroup(q(e.name()).heading);var $;if(U(Z,e=>t=>{throw $=(async()=>{!Q.fullTree&&![`commander.helpDisplayed`,`commander.version`].includes(t.code)&&await Q.completeTree(J);let{commandExitHandler:n}=await import(`./parse-error-hint-B_kJpdDW.js`);try{n(e)(t)}catch(e){if(e!==t)throw e}})(),t}),Y===`required`){let e=[Z];for(;e.length>0;){let t=e.pop();t!==void 0&&(e.push(...t.commands),t.hook(`preAction`,async(e,t)=>{e===t&&await le(`required`)}))}}var Ct=new Set(Z.commands.filter(e=>[`entities`,`people`,`news`].includes(e.name())).flatMap(e=>e.commands.map(e=>e.name())));Z.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])=>Ct.has(e)?[t]:[]),``,`Authentication (every command that calls aVenture needs a credential):`,` Create one at ${o}/sign-up, then run: ${G} auth login`,` AUTH_TOKEN aVenture API key, for CI and other non-interactive shells`,` Check what this shell holds with: ${G} auth status\n`,`Output modes (per command):`,` --text compact lines, the terminal default; --json the full envelope`,` --data response data as JSON, the default when piped or non-TTY`,` --data-full uncapped, for bounded programs, never LLM agents`,` --all-fields --text plus the detail fields it hides by default
|
|
8
|
+
`,`Exit codes:`,` 0 envelope.ok === true
|
|
9
|
+
1 envelope.ok === false
|
|
10
|
+
`,`Examples:`,` $ ${G} auth login`,` $ ${G} lookup --name Stripe --url https://stripe.com`,` $ ${G} search "fintech companies in Austin"\n`,`Run \`${G} <command> --help\` for its subcommands and options,`,`or \`${G} help <command>\` for its full documentation.`].join(`
|
|
11
|
+
`));try{await Z.parseAsync()}catch(t){await $,t instanceof e?process.exitCode=t.exitCode:await K(t,`parseAsync`)}export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./package-CZBWjlYb.js";import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import"./operations-metadata-
|
|
1
|
+
import"./package-CZBWjlYb.js";import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import"./operations-metadata-BfIKb5PX.js";import"node:path";import"node:fs";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-CZBWjlYb.js";import{a as n,f as r,t as i}from"./env-CpA6E7ay.js";import{c as a,r as o}from"./result-envelope-DXFbrrkt.js";import{r as s}from"./auth-resolver-JikQ_vOz.js";import{a as c,t as l}from"./credential-redaction-Fd-q1M6s.js";import{n as u}from"./contract-
|
|
2
|
-
`))).action(async function(e){let{emit:t}=await import(`./output-
|
|
3
|
-
`);return u.ok?a(d,u,{counts:c}):{...o(d,l,{counts:c}),data:u}}function b(e,t){return e.filter(e=>e.status===t).length}function x(e,t,n){return{name:e,status:t,message:n}}function S(){return p.find(e=>e.intent===`status`&&e.resource===`status`)}async function C(e){let{runUpdate:n}=await import(`./builtin-update-
|
|
1
|
+
import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-CZBWjlYb.js";import{a as n,f as r,t as i}from"./env-CpA6E7ay.js";import{c as a,r as o}from"./result-envelope-DXFbrrkt.js";import{r as s}from"./auth-resolver-JikQ_vOz.js";import{a as c,t as l}from"./credential-redaction-Fd-q1M6s.js";import{n as u}from"./contract-BoQqQVwP.js";import{t as d}from"./openapi-composites-B9JPhVYN.js";import{n as f,t as p}from"./openapi-commands-CLn-TCPy.js";import{t as m}from"./output-Bb8wDk_C.js";import{i as h,t as g}from"./output-mode-COLMloqB.js";var _=[{name:`cli-version`,purpose:`running CLI against the latest published release`},{name:`api-schemas`,purpose:`the installed @aventurevc/api-schemas contracts resolve`},{name:`api-host`,purpose:`the selected API host answers`},{name:`auth`,purpose:`which credential signs in, as which account and role, never secrets`},{name:`catalog`,purpose:`this CLI knows every operation the API serves`}];function v(e,n=t().bin[0]){g(e.command(`doctor`).summary(`One-call selftest: CLI version, schemas, API host, auth scope, command catalog`).description(["Run every environment check in one call and report `{ ok, check: [...] }`:",..._.map(e=>` - ${e.name}: ${e.purpose}`),``,`Exit code is 0 only when no check failed; a skipped check (no registry reachable) or a`,`warned one (the account read failed) does not fail the run. Each failing message names the command that fixes it.`,"--json always carries the report at `.data`; --data prints the report directly when",`every check passes and the result envelope when one fails, like every other command.`].join(`
|
|
2
|
+
`))).action(async function(e){let{emit:t}=await import(`./output-wvaTemP-.js`),r=this.optsWithGlobals();r.environment!==void 0&&(process.env.API_ENV=r.environment),t({mode:h(e)},await y(n))})}async function y(e){let t=S(),n=await C(e),[r,i]=await Promise.all([w(e),T(t,e)]),s=[n.check,r,i.check,await D(e),P(t,i.servedFingerprint,n.upgradeAvailable,e)],c={pass:b(s,`pass`),warn:b(s,`warn`),fail:b(s,`fail`),skip:b(s,`skip`)},l=s.filter(e=>e.status===`fail`).map(e=>e.message),u={ok:l.length===0,check:s},d=[`doctor: ${c.pass} pass, ${c.warn} warn, ${c.fail} fail, ${c.skip} skip`,...s.map(e=>` ${e.name} ${e.status} — ${e.message}`)].join(`
|
|
3
|
+
`);return u.ok?a(d,u,{counts:c}):{...o(d,l,{counts:c}),data:u}}function b(e,t){return e.filter(e=>e.status===t).length}function x(e,t,n){return{name:e,status:t,message:n}}function S(){return p.find(e=>e.intent===`status`&&e.resource===`status`)}async function C(e){let{runUpdate:n}=await import(`./builtin-update-JNk2mnDh.js`),r=t(),i=n(r,`check`);if(!i.ok||i.data===null)return{check:x(`cli-version`,`skip`,`Could not compare ${r.version} against the registry (${i.summary}); rerun \`${e} update\` with registry access.`),upgradeAvailable:null};let{targetPackage:a,currentVersion:o,latestVersion:s,upgradeAvailable:c}=i.data;return{check:c?x(`cli-version`,`fail`,`Upgrade ${a} from ${o} to ${s}: run \`${e} update\`.`):x(`cli-version`,`pass`,`${a} ${o} matches the latest published release.`),upgradeAvailable:c}}async function w(e){try{let{EntityDetailSchema:e}=await import(`./detail-BBMLykCm.js`);if(typeof e.safeParse!=`function`)throw Error(`EntityDetailSchema does not expose a Zod parser`);return x(`api-schemas`,`pass`,`Installed @aventurevc/api-schemas contracts resolve beyond the CLI startup path.`)}catch(t){return x(`api-schemas`,`fail`,`Reinstall the CLI: run \`${e} update\` — ${l(t)}.`)}}async function T(e,t){let{runOpenApiCall:n}=await import(`./openapi-call-B3pG7Dqm.js`),i=e??{method:`GET`,path:`/info`,auth:`none`},a;try{a=r().host}catch(e){return{check:x(`api-host`,`fail`,`Correct API_ENV or pass \`--environment <name>\` — ${l(e)}.`),servedFingerprint:null}}let s=await n({method:i.method,path:i.path,auth:i.auth,responseFormat:`json`}).catch(e=>o(l(e)));return s.ok?{check:x(`api-host`,`pass`,`${i.method} ${i.path} answered at ${a}.`),servedFingerprint:e===void 0?null:E(s.data)}:{check:x(`api-host`,`fail`,s.httpStatus===401?`Replace or unset the credential ${a} rejected, or run \`${t} auth login\`, then rerun \`${t} auth doctor\` — ${i.method} ${i.path} returned ${s.summary}.`:`Point the CLI at a reachable API host with \`--environment <name>\` or API_URL, then rerun \`${t} auth doctor\` — ${i.method} ${i.path} at ${a} returned ${s.summary}.`),servedFingerprint:null}}function E(e){if(typeof e!=`object`||!e||e instanceof Uint8Array)return null;let{response:t}=e;if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t.operationFingerprint;return typeof n==`string`&&n.length>0?n:null}async function D(e){let{isOAuthCredentialExpired:t}=await import(`./oauth-credential-DgtNj00w.js`),n=s(),[r,a]=await Promise.all([k(),A()]);if(a.state===`unavailable`&&a.cause===`environment`)return x(`auth`,`fail`,`Fix the environment configuration first — ${a.summary}.`);let o=n.present,c=a.state===`found`&&a.stored.activation===`active`;if(!o&&r.state===`invalid`)return x(`auth`,`fail`,`Saved OAuth credential is invalid; run \`${e} auth login\` to sign in again after verification — ${r.summary}.`);if(!o&&r.state===`found`&&t(r.stored.credential)&&r.stored.credential.tokens.refresh_token===void 0)return x(`auth`,`fail`,`Saved OAuth access token is expired without a refresh token; run \`${e} auth login\` to sign in again.`);if(!o&&!c&&r.state===`unavailable`)return x(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login\`, or inject ${i.authToken} through the environment — ${r.summary}.`);if(o||r.state===`found`||c){let t=await O(e,n);return x(`auth`,t.status,`Credential source available: ${await j(n,r,a)}; ${t.text}.`)}return a.state===`unavailable`?x(`auth`,`fail`,`Make the OS keyring or the CLI config directory usable before \`${e} auth login --key\`, or inject ${i.authToken} through the environment — ${a.summary}.`):x(`auth`,`fail`,`Run \`${e} auth login\` for OAuth or \`${e} auth login --key\` for an API key. For non-interactive use, set ${i.authToken} in the environment.`)}async function O(e,t){let{refreshCliCredentials:n}=await import(`./auth-status-render-Bp_c2kF9.js`),{inspectPrivateLiveIdentity:i}=await import(`./private-live-identity-w8v84cKs.js`),a=c(r().host),o=await n(e),s=`credential=${t.present?t.source??`env`:o.materialized??`none`}`;try{if(o.failure!==null)throw Error(o.failure);let e=await i(`write`);if(e===null)return{status:`pass`,text:`${s} host=${a}`};let t=e.rbacRole.length===0?`none`:e.rbacRole.join(`,`);return{status:`pass`,text:`${s} account=${e.email??e.id} role=${t} host=${a}`}}catch(t){return{status:`warn`,text:`${s} account=unread host=${a} — GET /v1/auth/me returned ${l(t,[r().userBearerToken])}; run \`${e} auth status --verify write\``}}}async function k(){let{inspectOAuthCredentialStorage:e}=await import(`./oauth-credential-DgtNj00w.js`),t;try{t=c(r().host)}catch(e){return{state:`unavailable`,summary:l(e)}}return await e(t)}async function A(){let{inspectApiKeyCredentialStorage:e}=await import(`./api-key-credential-DqWZhM1S.js`),t;try{t=c(r().host)}catch(e){return{state:`unavailable`,summary:l(e),cause:`environment`}}try{return await e(t)}catch(e){return{state:`unavailable`,summary:l(e),cause:`storage`}}}async function j(e,t,n){let{summarizeCredential:r}=await import(`./auth-status-render-Bp_c2kF9.js`);return[r(e),`oauth=${await N(t)}`,`api-key=${await M(n)}`].join(` `)}async function M(e){let{apiKeyExpiryQualifier:t}=await import(`./auth-status-render-Bp_c2kF9.js`);if(e.state!==`found`)return e.state===`missing`?`unset`:`unavailable`;let n=c(r().host);return`${e.stored.activation}${t(n,e)}`}async function N(e){let{isOAuthCredentialExpired:t}=await import(`./oauth-credential-DgtNj00w.js`);switch(e.state){case`found`:return t(e.stored.credential)?`expired`:`stored`;case`missing`:return`unset`;case`invalid`:return`invalid`;case`unavailable`:return`unavailable`;default:throw Error(`Unsupported OAuth credential state`)}}function P(e,t,n,r){let i=p.length;if(e===void 0)return x(`catalog`,`skip`,`The public catalog omits deployment-status metadata and holds ${i} operations.`);if(t===null)return x(`catalog`,`skip`,`Could not read the served operation fingerprint, so drift is unproven; this catalog holds ${i} operations at ${f}.`);if(t===`3594d6ba35a2f865`)return x(`catalog`,`pass`,`${i} generated operations match the set the API serves (${f}).`);let a=`This catalog describes a different operation set than the API serves (${f} vs ${t})`;return n===!0?x(`catalog`,`fail`,`${a}: run \`${r} update\`.`):x(`catalog`,`skip`,n===!1?`${a}, and this CLI is already the latest published release: either the deployed API is older than this CLI, or a newer CLI has not been published yet.`:`${a}, and the registry did not answer, so it is unknown whether a newer release describes it: rerun \`${r} update\` with registry access.`)}var F=u(d,`oauth`),I=[u(d,`start`),u(d,`poll`),u(d,`acknowledge`)],L=u(d,`revoke`);function R(n,r=t().bin[0]){let a=H(n);v(a,r);let s=[`${F.description} Default method: OAuth in your browser.`,`With --key: ${I.map(({description:e})=>e).join(` `)}`].join(`
|
|
4
4
|
`);g(V(a,[F,...I],s)).action(z),g(V(a,[L],L.description)).action(B),g(a.command(`status`).summary(`Keep saved credentials current and report them`).description(`Runs the same credential materialization every command runs, then reports:
|
|
5
5
|
- auth: whether AUTH_TOKEN was already set in this shell's environment
|
|
6
6
|
- oauth: the saved OAuth identity and access-token expiry for the selected API host;
|
|
@@ -13,5 +13,5 @@ import{n as e}from"./commander-DEj7N1b9.js";import{a as t}from"./package-CZBWjlY
|
|
|
13
13
|
Saved credentials are sent only to the selected API host and aVenture sign-in, never printed.
|
|
14
14
|
--verify read|write additionally runs a live permission probe for that scope; it does not
|
|
15
15
|
execute or authorize an arbitrary API operation.`).addOption(new e(`--verify <scope>`,`verify one permission-probe scope`).choices([`read`,`write`]))).action(async function(e){U(this),m({mode:h(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(`
|
|
16
|
-
`)).action(async function(){let{refreshCliCredentials:e}=await import(`./auth-status-render-
|
|
17
|
-
`))}function U(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function W(e,n){let{resolveAuthStatus:s}=await import(`./auth-resolver-p3AsKEaj.js`),{inspectOAuthCredentialStorage:u}=await import(`./oauth-credential-DgtNj00w.js`),{apiKeyCredentialDiagnostics:d,inspectLiveAuth:f,oauthCredentialDiagnostics:p,refreshCliCredentials:m,renderAuthStatus:h}=await import(`./auth-status-render-
|
|
16
|
+
`)).action(async function(){let{refreshCliCredentials:e}=await import(`./auth-status-render-Bp_c2kF9.js`);U(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`):m({mode:`text`},t.failure===null?Q(`auth token: no credentials resolved`,null,r,{oauth:!0,apiKey:!0}):o(`auth token: ${t.failure}`))})}async function z(e){U(this);let t=h(e);if(e.providers===!0){m({mode:t},await K());return}let n=e.key===!0?await(await import(`./api-key-login-rLWkAQ_k.js`)).loginApiKeyCredential({noBrowser:!e.browser,clientLabel:e.clientLabel}):await(await import(`./oauth-login-CJVSyM5j.js`)).loginOAuthCredential({noBrowser:!e.browser});m({mode:t},n)}async function B(e){let{logoutCliCredentials:t}=await import(`./logout-D-p586e2.js`);U(this),m({mode:h(e)},await t({forgetLocal:e.forgetLocal===!0}))}function V(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 H(e){return(e.commands.find(e=>e.name()===`auth`)??e.command(`auth`)).summary(`Sign in, sign out, and check credentials`).description([`\`${F.command}\`: ${F.summary}; \`--key\` ${I[0].summary.toLowerCase()}.`,`\`${L.command}\`: ${L.summary}.`,"`auth status` reports local credential provenance, sign-in providers, and CLI/API build metadata.","`auth doctor` runs the one-call selftest and prints `{ ok, check: [...] }`.","`auth token` prints the bearer token the next command sends."].join(`
|
|
17
|
+
`))}function U(e){let t=e.optsWithGlobals();t.environment!==void 0&&(process.env.API_ENV=t.environment)}async function W(e,n){let{resolveAuthStatus:s}=await import(`./auth-resolver-p3AsKEaj.js`),{inspectOAuthCredentialStorage:u}=await import(`./oauth-credential-DgtNj00w.js`),{apiKeyCredentialDiagnostics:d,inspectLiveAuth:f,oauthCredentialDiagnostics:p,refreshCliCredentials:m,renderAuthStatus:h}=await import(`./auth-status-render-Bp_c2kF9.js`),g;try{g=c(r().host)}catch(e){return o(`auth status: invalid API host — ${l(e)}`)}let _=s(),v=m(e),[y,b]=await Promise.all([Z(`/info`,`GET /info`),q()]),x=await v,[S,C]=await Promise.all([u(g),G(g)]),w=n===void 0?null:await f(n,S,C.inspection,x),T=t().version,E=d(g,C.inspection,C.verification),D=h({cliName:e,cliVersion:T,apiVersion:y.ok?await Y(y.data):null,oauth:S,apiKey:E,providers:b,resolved:_,refresh:x,live:w}),O={cli:{version:T},api:y.ok?y.data??null:null,auth:{[i.authToken]:_},selected:x.materialized,oauth:p(g,S),apiKey:E,providers:b,live:w,...y.ok?{}:{apiError:y.summary}};return x.failure===null?!y.ok&&y.httpStatus===401?{...o(`auth status: the API rejected the selected credential (401) | ${D}`,[`Replace or unset ${i.authToken}, or run \`${e} auth login\`.`]),data:O}:w!==null&&w.error!==null?{...o(`auth status: ${w.scope} permission probe failed — ${w.error}`,[w.error]),data:O}:w!==null||_.present||S.state===`found`||C.inspection.state===`found`?a(D,O):Q(`auth status: no credentials resolved | ${D}`,O,e,{oauth:S.state===`missing`,apiKey:C.inspection.state===`missing`}):{...o(`auth status: ${x.failure} | ${D}`,[x.failure]),data:O}}async function G(e){let{refreshStoredApiKeyCredential:t}=await import(`./api-key-credential-verification-ojaiIf0j.js`),n=await J(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 K(){let e=await q();return e.state===`found`?a(`Sign-in providers for the selected API host`,e.catalog):o(`auth login --providers: ${e.summary}`)}async function q(){try{let{fetchAuthProviderCatalog:e}=await import(`./oauth-login-CJVSyM5j.js`);return{state:`found`,catalog:await e()}}catch(e){return{state:`unavailable`,summary:l(e)}}}async function J(e){try{let{inspectApiKeyCredentialStorage:t}=await import(`./api-key-credential-DqWZhM1S.js`);return await t(e)}catch(e){return{state:`invalid`,summary:l(e)}}}async function Y(e){let{SystemBuildSchema:t}=await import(`./system-build-z_cn0X5C.js`);if(!X(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 X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Z(e,t){let{runOpenApiCall:n}=await import(`./openapi-call-B3pG7Dqm.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 Q(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{R as registerBuiltinAuthCommands};
|
package/dist/chunks/{builtin-research-run-wait-DQvx_0vF.js → builtin-research-run-wait-CuL5YNzI.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import{t as n}from"./output-
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import{t as n}from"./output-Bb8wDk_C.js";import{i as r,t as i}from"./output-mode-COLMloqB.js";var a=5e3,o=6e4,s=3e4,c=86400;function l(e){let t=e.commands.find(e=>e.name()===`research-runs`);if(t===void 0)return;let a=t.command(`wait`).summary(`Wait for one research run to finish, then report its outcome`).description("Polls `research-runs get` with backoff until the run is completed, failed, or stopped, then prints its status, error, failure class, spend, and last event time; 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.").requiredOption(`--run-id <uuid>`,`Research run id`).option(`--timeout <seconds>`,`Total seconds to wait`,`1800`);i(a),a.action(async function(){let e=this.optsWithGlobals();n({mode:r(e)},await u(e))})}async function u(e){let{setTimeout:n}=await import(`node:timers/promises`),{buildOpenApiPath:r}=await import(`./openapi-call-B3pG7Dqm.js`),{parseBoundedInt:i}=await import(`./batch-io-By9YEmZW.js`),s=i(`--timeout`,e.timeout,1,c);if(!s.ok||s.data===null)return t(s.summary);let l=Date.now()+s.data*1e3,u=r(`getResearchRun`,{runId:e.runId}),p=a,m=`not read yet`,h=(n=`after ${s.data}s`)=>t(`Run ${e.runId} is still ${m} ${n}`,[`Wait longer with --timeout, or read it with \`research-runs get --run-id ${e.runId}\`.`]);for(;;){if(l-Date.now()<=0)return h();let e=0,t=await f(u,l);if(t.kind===`deadline`)return h();if(t.kind===`refused`)return t.envelope;if(t.kind===`detail`){let{run:e}=t.detail;if(e.status===`completed`||e.status===`failed`||e.status===`stopped`)return await d(t.detail,l);m=`${e.status}, last event ${t.detail.lastEventAt??`none`}`}else m=`unread (${t.reason})`,e=(t.retryAfterSeconds??0)*1e3;let r=l-Date.now();if(r<=0||e>=r)return h(r<=0?`after ${s.data}s`:`and the API asks for ${e/1e3}s, past the ${s.data}s --timeout`);let i=Math.max(e,a+Math.random()*(p-a));await n(Math.min(i,r)),p=Math.min(p*2,o)}}async function d(t,n){let{readResearchRunSpend:r}=await import(`./research-run-spend-D9aXcq6b.js`),{run:i}=t,a=await r({runId:i.id,deadline:n}),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 f(e,n){let{HarnessRunDetailSchema:r}=await import(`./run-detail-TzF_MGxB.js`),{runOpenApiCall:i}=await import(`./openapi-call-B3pG7Dqm.js`),{isTransientRefusal:a,isTransportFailure:o}=await import(`./request-replay-BNREbhMp.js`),{retrySeconds:c}=await import(`./response-problem-C1c4ogJm.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{l as registerBuiltinResearchRunWaitCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,n as t,r as n,t as r}from"./package-CZBWjlYb.js";import{c as i,r as a}from"./result-envelope-DXFbrrkt.js";import{t as o}from"./output-
|
|
1
|
+
import{a as e,n as t,r as n,t as r}from"./package-CZBWjlYb.js";import{c as i,r as a}from"./result-envelope-DXFbrrkt.js";import{t as o}from"./output-Bb8wDk_C.js";import{i as s,t as c}from"./output-mode-COLMloqB.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=[...e,`--@aventurevc:registry=${t.registry}`],s=u(`npm`,o,{env:r,encoding:`utf8`,...n});if(s.error)return s.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: ${s.error.message}`,[`spawn_error`]);if(s.status!==0){let t=(s.stderr??``).trim().split(`
|
|
3
3
|
`).slice(-3).join(` | `);return a(`npm ${e.join(` `)} exited ${s.status}`,[t||`no stderr`])}return i(`npm ok`,s.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{d as e}from"./tool-policy-
|
|
1
|
+
import{d as e}from"./tool-policy-NTXy68a8.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={app:`account`,auth:`account`,entities:`researchData`,people:`researchData`,enrichments:`researchData`,news:`researchData`,search:`researchData`,directory:`researchData`,resolve:`researchData`,lookup:`researchData`,"lookup-jobs":`researchData`,"lookup-mentions":`researchData`,"research-runs":`researchData`,provenance:`administration`,billing:`account`,harness:`administration`,jobs:`administration`,operations:`administration`,metrics:`cli`,inference:`administration`,web:`researchData`,contacts:`administration`,"url-types":`researchData`,"unique-ids":`researchData`,research:`administration`,status:`cli`,agents:`cli`,help:`cli`},f=new Set([`metrics`]);export{n as a,a as c,u as i,s as l,f as n,t as o,l as r,i as s,c as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./package-CZBWjlYb.js";import{t}from"./openapi-commands-
|
|
1
|
+
import{a as e}from"./package-CZBWjlYb.js";import{t}from"./openapi-commands-CLn-TCPy.js";import{n,r}from"./completion-setup-CwJt88xW.js";import{o as i}from"./generated-option-order-DAzrGPOt.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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./commander-DEj7N1b9.js";import{o as t}from"./tool-policy-NTXy68a8.js";import{a as n,o as r}from"./cli-help-policy-BSkCikW7.js";import{n as i,t as a}from"./contract-parameter-DRNxhCKs.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 t=e.parameter.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})})}),n=e.requestBody?.map(n=>{let r=l(e,t,n),i=c(n.cliConflicts,r),a=i.length===0?{}:{cliConflicts:i};return Object.assign({},n,{parameter:r},a)}),r=e.response.find(({status:e})=>e.startsWith(`2`)),a=r?.schemaName?.replace(/Schema$/,``);return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,cliPath:e.projection.cliPath,summary:e.summary,description:e.description,binaryResponse:e.binaryResponse?!0:void 0,explain:e.explain?!0:void 0,deprecated:e.deprecated?!0:void 0,requestBody:n,mutationReadback:e.mutationReadback,scope:e.projection.scope,auth:e.projection.auth,visibility:e.projection.visibility,mutates:e.projection.mutates,errorResponse:e.errorResponse,successResponse:a,detailField:r?.detailField,header:r?.header,parameters:t}})}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=r(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:n(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-NTXy68a8.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};
|
package/dist/chunks/{generated-option-order-uCio4nh5.js → generated-option-order-DAzrGPOt.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import{t as n}from"./private-readback-DX42Bf2b.js";import{a as r,c as i,l as a,s as o}from"./cli-help-policy-
|
|
1
|
+
import{c as e,r as t}from"./result-envelope-DXFbrrkt.js";import{t as n}from"./private-readback-DX42Bf2b.js";import{a as r,c as i,l as a,s as o}from"./cli-help-policy-BSkCikW7.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(!D(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||!S(n,r.name))continue;let a=x(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||!T(n)||!Array.isArray(r))return O(t,n,r);for(let[e,i]of r.entries()){let r=O(t,n,i,e);if(!r.ok)return r}return e(`Body value assigned`,null)}function d(e,t,n,r){return O(e,t,r,n)}function f(e){let t=[];for(let n of e.split(`.`)){let e=A(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=b(e,n.split(`.`));return Array.isArray(r)?{path:n,rowCount:r.length,firstHole:y(r)}:null}function m(n,r){if(T(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){let n=f(e.name);if(e.schemaType!==`array`||n===null||t===void 0||typeof t==`boolean`)return null;let r=new Map,i=[];for(let e of typeof t==`string`?[t]:t){let t=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 _(e,t,n){let r=0;for(let i of e.parameter){let e=t[i.optionKey];e!==void 0&&typeof e!=`boolean`&&f(i.name)===n&&(r=Math.max(r,typeof e==`string`?1:e.length))}return r}function v(e,n,r,i){for(let a of n.parameter){let n=r[a.optionKey];if(n===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(a,n)!==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 y(e){for(let t=0;t<e.length;t+=1)if(e[t]===void 0)return t;return null}function b(e,t){let n=e;for(let e of t){if(!D(n))return;n=n[e]??null}return n}function x(e,t){if(!T(t))return b(e,t.split(`.`))}function S(e,t){return w(e,t.split(`.`))}function C(e,t,n){if(!D(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)&&S(n,e.name))return`${e.name} in --from-file requires --content-type ${i.contentType}.`}return null}function w(e,t){let[n,...r]=t;if(n===void 0)return!0;let i=A(n);if(!D(e)||!Object.hasOwn(e,i.key))return!1;let a=e[i.key]??null;return i.isArray?Array.isArray(a)&&a.every(e=>w(e,r)):w(a,r)}function T(e){return e.split(`.`).some(e=>A(e).isArray)}function E(e,t){return e.parameter.length===0||!D(t)?null:M(t,[],j(e.parameter))}function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(n,r,i,a=0){let o=r.split(`.`),s=n;for(let[n,c]of o.entries()){let l=A(c),u=n===o.length-1,d=k(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 k(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 D(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 D(l)?e(`Body path stepped`,l):c()}function A(e){let t=e.endsWith(`[]`);return{key:t?e.slice(0,-2):e,isArray:t}}function j(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 M(e,t,n){if(Array.isArray(e)){if(e.length===0)return null;for(let r of e){let e=M(r,t,n);if(e!==null)return e}return null}if(!D(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&&N(`${a}[]`,n))continue;if(!N(a,n)){if(!P(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=I(e,r);return{path:a,message:`unknown JSON path ${a}. ${o===void 0?`Admitted keys: ${i.join(`, `)||`(none)`}.`:`Use ${o}.`}`}}let o=M(i,e,n);if(o!==null)return o}return null}function N(e,t){return t.prefix.has(e)||t.leaf.has(e)}function P(e){return e.slice(0,-1).some(e=>e.endsWith(`[]`))}var F=4;function I(e,t){let n=e.at(-1)?.replace(/\[\]$/u,``).toLowerCase()??``,r=t.map(e=>({path:e,score:L(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 L(e,t){let n=t.replace(/\[\]$/u,``).toLowerCase();if(n===e)return 0;if(Math.min(e.length,n.length)<F)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 R=e=>Array.isArray(e)&&!Object.isFrozen(e);function z(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(i(e)),t.description=n(t.description,{...e,hasParseDefault:t.defaultValue!==void 0}))}if(!R(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?q(n,i):n===void 0?i===void 0?0:1:-1})}function B(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 V(e){let{flag:t}=e.variant[0].parameter;return e.variant.every(({parameter:e})=>e.flag===t)?t:`${t.split(` `)[0]??t} <value>`}function H(e){let t=e.variant.map(({descriptor:e,parameter:t})=>({contentType:e.contentType,text:G(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 U(e,t){return[...new Set((e.cliConflicts??[]).filter(e=>e.includes(t)).flatMap(e=>e.filter(e=>e!==t)))]}function W(e,t){let n=e.kind===`multipart`?`Read a JSON object keyed by multipart part name from a file, or use - for stdin`:`Read the JSON request body from a file, or use - for stdin`,r=t.filter(e=>!t.some(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[].`)));return r.length===0?a(n):`${a(n)} Required JSON paths: ${r.join(`, `)}.`}function G(e,t){let n=r(t.description,void 0),i=e.kind!==`multipart`&&T(t.name),a=e.kind!==`multipart`&&t.optionKey!==t.name&&/^\w+$/u.test(t.name);return`${n}${i?` Repeat to add another value.`:``}${a?` --from-file JSON key: ${t.name}.`:``}${K(e,t)}`}function K(e,t){if(e.kind===`multipart`||t.schemaType!==`array`)return``;let n=f(t.name);return n===null?``:` Prefix each value with its 0-based ${n}[] row index, as 0:value, to fill more than one ${n}[] row. A leading digits-and-colon is always read as that index, so name the row of a value that starts the same way, as 0:0:00 for the value 0:00.`}function q(e,t){return o(e)-o(t)||Number(e.required!==!0)-Number(t.required!==!0)}export{E as S,T as _,W as a,l as b,G as c,d,s as f,S as g,c as h,V as i,v as l,C as m,q as n,B as o,_ as p,H as r,U as s,z as t,u,D as v,m as x,g as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./package-CZBWjlYb.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,f as u,l as d,o as ee,s as te,u as ne}from"./tool-policy-
|
|
1
|
+
import{a as e}from"./package-CZBWjlYb.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,f as u,l as d,o as ee,s as te,u as ne}from"./tool-policy-NTXy68a8.js";import{i as re,t as f}from"./human-text-cap-BcNmIPQA.js";import{n as ie,t as ae}from"./contract-parameter-DRNxhCKs.js";var p=2,oe=new Set(`a.an.the.and.or.for.to.of.in.on.at.by.with.from.into.is.are.be.do.does.how.what.which.that.this.these.those.i.me.my.we.our.you.your.it.its.please.want.need.can.could.should.would`.split(`.`));function m(e,t){let n=v(t);n.length!==0&&(e.add(n),(n===`individual`||n===`individuals`)&&m(e,`person`),h(e,se(n),n),h(e,ce(n),n))}function se(e){if(e===`people`)return`person`;let t=e.endsWith(`ies`)?e.slice(0,-3):``;if(t.length>=p&&!t.endsWith(`v`)&&/[^aeiou]$/u.test(t))return`${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 ce(e){if(e===`person`)return`people`;if(e!==`new`&&e!==`news`&&e!==`status`&&e!==`us`){if(e.length>=p&&e.endsWith(`y`)&&/[^aeiou]y$/u.test(e))return`${e.slice(0,-1)}ies`;if(!(e.length>=p&&e.endsWith(`es`)))return e.length>=p&&/(?:s|ss|sh|ch|x|z)$/u.test(e)?`${e}es`:e.endsWith(`s`)?void 0:`${e}s`}}function h(e,t,n){t!==void 0&&t!==n&&t.length>=p&&/^[a-z]+$/u.test(t)&&e.add(t)}function g(e){let t=new Set(_(e)),n=Array.from(t);for(let e of n)m(t,e);return t}function le(e){return _(e).map(g)}function ue(e,t){if(e.length===0)return!1;let n=g(t.join(` `));return e.every(e=>[...e].some(e=>n.has(e)))}function _(e){return v(e).split(/[^a-z0-9]+/u).filter(e=>e.length>0&&!oe.has(e))}function v(e){return e.trim().replace(/([a-z0-9])([A-Z])/gu,`$1 $2`).replace(/[_-]/gu,` `).replace(/\s+/gu,` `).toLowerCase().replace(/\blook up\b/gu,`lookup`)}function y(e,t){return e.map(e=>{let n=e.requestBody??[],r=[...e.parameters.map(e=>b(e)),...n.flatMap(e=>e.parameter.map(t=>b(t,n.length>1?e.contentType:void 0))),...de(n)],i=[t,...e.cliPath].join(` `),a=e.mutates===!0||l(e.intent),o=u(e),s=n[0];return{operationId:e.operationId,method:e.method,path:e.path,resource:e.resource,intent:e.intent,scope:e.scope,mutates:a,destructive:te(e.method,e.intent),auth:e.auth,cli:{command:i,path:e.cliPath},mcpTool:e.binaryResponse||!ne(e.path)||o===null?null:d(o),body:{hasBody:s!==void 0,kind:s?.kind??null,...s!==void 0&&n.length>1?{contentType:s.contentType}:{},required:s?.required??!1,description:s?.description??``,requiredPath:s?.requiredPath??[]},flags:r,errorResponse:e.errorResponse,...e.successResponse===void 0?{}:{successResponse:e.successResponse},...e.header===void 0||e.header.length===0?{}:{header:e.header},summary:e.summary,description:e.description,...e.deprecated===void 0?{}:{deprecated:e.deprecated}}})}function b(e,t){let n=e.flag.split(/\s+/u);return{name:n[0]??e.flag,optionKey:e.optionKey,wireName:e.name,location:e.location,required:e.required,placeholder:n.length<=1?null:n.slice(1).join(` `),description:e.description,choices:e.choices??[],...t===void 0?{}:{contentType:t}}}function de(e){if((e?.length??0)<=1)return[];let t=e?.map(({contentType:e})=>e)??[];return[{name:`--content-type`,optionKey:`contentType`,wireName:`Content-Type`,location:`body`,required:!1,placeholder:`<media-type>`,description:`Select the request body encoding, never an uploaded file's media type; omit for ${t[0]}.`,choices:t}]}function x(e){return e.flags.filter(({contentType:t})=>t===void 0||t===e.body.contentType)}var fe=[`-id`,`-slug`,`-url`],pe=[`--id`,`--slug`,`--url`],me=`/v1/lookup`,he=`--from-file "<path>"`;function ge(t,n,r=e().bin[0]){let i=y(n,r),a=i.find(e=>e.operationId===t);return a===void 0?[]:w(a,i)}function S(t,n,r=e().bin[0]){let i=n.find(e=>e.operationId===t),[a]=i===void 0?[]:y([i],r);return a&&C(a,E(a,!1))}function _e(t,n,r,i=e().bin[0]){let a=e=>{let t=e.findIndex((e,t)=>r[t]!==e);return t===-1?e.length:t},o=`${r[0]} get`,[s,c]=n.filter(({method:e,path:n,parameters:r,cliPath:i})=>{let s=r.filter(({location:e})=>e===`path`),[c]=s;return e===`GET`&&s.length===1&&c?.flag.split(/\s+/u)[0]===t&&n.endsWith(`/{${c.name}}`)&&(a(i)>1||i.join(` `)===o)}).toSorted((e,t)=>a(t.cliPath)-a(e.cliPath));if(s!==void 0&&(c===void 0||a(c.cliPath)!==a(s.cliPath)))return S(s.operationId,n,i)}function C(e,t){return[e.cli.command,...t,`--data`].join(` `)}function w(e,t){return[`example: ${C(e,E(e))}`,...ve(e,t)]}function ve(e,t){return x(e).flatMap(e=>{if(!e.required||!e.optionKey.endsWith(`Id`))return[];let n=`${e.optionKey.slice(0,-2)}Slug`,r=t.find(e=>e.method===`GET`&&/\/lookup(?:-exact)?$/u.test(e.path)&&e.flags.some(e=>e.optionKey===n)),i=r?.flags.find(e=>e.optionKey===n);if(r===void 0||i===void 0)return[];let a=`${r.cli.command} ${D(i)} --data`,o=t.find(e=>e.method===`POST`&&e.path===me),s=o?.flags.find(e=>e.optionKey===`name`),c=o?.flags.find(e=>e.optionKey===`kind`),l=c?.choices.find(t=>e.optionKey.toUpperCase().startsWith(t)),u=`lookup: ${e.name} from a slug: ${a}`;return o===void 0||s===void 0||c===void 0||l===void 0?[u]:[u,`lookup: ${e.name} from a name or URL: ${o.cli.command} ${c.name} ${l} ${D(s)} --data, then match.owner.${e.optionKey} when status is MATCHED`]})}var T=/(?:^|\.)text$/u;function E(e,t=!0){let n=x(e),r=n.filter(e=>e.required),i=e.body.kind===`json`&&n.some(e=>e.location===`body`&&T.test(e.wireName)&&(e.required||!e.wireName.includes(`.`))),a=i?r.filter(e=>e.location!==`body`):r,o=(r.length>0||!t?a:ye(e)).map(D);return i||(e.body.required||e.body.requiredPath.length>0)&&!a.some(e=>e.location===`body`)?[...o,he]:o}function ye(e){let t=new Set;m(t,e.resource);for(let n of fe)for(let r of t){let t=e.flags.find(e=>e.name===`--${r}${n}`);if(t!==void 0)return[t]}for(let t of pe){let n=e.flags.find(e=>e.name===t);if(n!==void 0)return[n]}return[]}function D(e){return e.placeholder===null?e.name:`${e.name} "${e.placeholder}"`}var O=s([`HIGH`,`MEDIUM`,`LOW`]),be=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:be.nullish(),excerpt:n(),sourceId:n(),sourceType:A,sourceVersion:n().nullish()}),xe=r({instruction:n(),operationId:n(),planTaskKey:c(n()).optional(),stepKey:n().optional()}),M=r({body:n(),expectation:n(),method:c(n()),override:n(),reject:c(n()),typeCatalog:n()}),Se=r({cliCommand:n(),mcpTool:n().nullish(),step:xe,writeGuidance:M.nullish()}),N=s([`ENTITY`,`TEXT`,`WRITER_BRIEF`]),Ce=Object.assign(t([N,n()]),{enum:N.enum}),we=r({allowedValue:n().nullish(),description:n(),key:n(),required:i().default(!0).optional(),type:Ce}),P=r({catalogRevision:a().optional(),gateId:c(n()).optional(),input:c(we),step:c(Se),taskKey:n().optional()}),F=s([`TASK_PLAN`,`OPERATION_ADVICE`,`CLARIFY`,`ABSTAIN`]),Te=r({candidate:c(j),operationId:n().nullish(),outcome:F,probability:o().nullish(),taskKey:n().nullish(),taskPlan:P.nullish()}),Ee=r({answer:n(),citation:c(j),confidence:O,resolution:Te.nullish()});function I(e){let t=e.requestBody?.[0],n=e.parameter.map(t=>L(t,ie(e,t))),r=(t?.parameter??[]).map(t=>L(t,ae(e,t)));return{selector:n.filter(e=>e.location===`path`||R(e)),pagination:n.filter(z),filter:[...n.filter(B),...r.filter(B)],body:r.filter(e=>!B(e))}}function L(e,t){let{in:n,inputName:r,...i}=e;return{...i,flag:ee(t),location:n,description:e.description||`${e.name} ${e.in} parameter`}}function R(e){return/(^|[A-Z])(id|slug)$/u.test(e.name)}function z(e){return[`page`,`size`,`sort`,`cursor`,`mode`,`projection`].includes(e.name)}function B(e){return e.location!==`path`&&!R(e)&&!z(e)}function V(e){return{operationId:e.operationId,method:e.method,path:e.path,summary:e.summary,cli:e.projection.cliPath.join(` `),intent:e.intent,scope:e.projection.scope,requiredInput:U(e),responseContentType:[...new Set(e.response.filter(({status:e})=>e.startsWith(`2`)).flatMap(({contentType:e})=>e??[]))]}}function H(e,t){let n=e.requestBody?.[0],r=V(e),i=W(e);return t?{...r,...i===void 0?{}:{paidPlan:i},resource:e.resource,bodyKind:n?.kind??null,bodyRequired:n?.required??!1,requiredBodyPath:n?.requiredPath??[],argument:I(e)}:{...r,optionalInput:ke(e),arrayInput:Ae(e),...i===void 0?{}:{paidPlan:i}}}function De(e){let t=I(e),n=e=>e.filter(e=>e.required);return{...H(e,!1),optionalDetailOmitted:!0,argument:{selector:n(t.selector),pagination:n(t.pagination),filter:n(t.filter),body:n(t.body)}}}function Oe(e){let{cli:t,scope:n,...r}=V(e),i=W(e);return{...r,...i===void 0?{}:{paidPlan:i},optionalDetailOmitted:!0}}function U(e){return[...e.parameter.filter(({required:e})=>e).map(({name:e})=>e),...e.requestBody?.[0]?.requiredPath??[]]}function ke(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 Ae(e){return[...e.parameter,...e.requestBody?.[0]?.parameter??[]].filter(({schemaType:e})=>e===`array`).map(({name:e})=>e)}var G=160,K=`Operation catalog matches`,je=[`whole`,`described`,`requiredDescribed`,`optionalNamed`,`optionalGrouped`],q=e=>`${[K,...e].join(`
|
|
2
2
|
`)}\n`;function Me(e,t=[]){if(!Array.isArray(e)||e.length===0||!e.every(Fe))return null;let n=e,r=e=>re([K,...e,...t]);for(let e of je){let t=[...n.flatMap(t=>X(t,e)),...Y(n,e)];if(r(t))return q(t)}let i=e=>[...n.slice(0,e).flatMap(e=>X(e,`optionalGrouped`)),...Y(n.slice(0,e),`optionalGrouped`),...e>=n.length?[]:[`... ${n.length-e} more operations omitted to fit ${f} UTF-8 bytes: ${n.slice(e).map(({operationId:e})=>e).join(`, `)}; call aventure_help with q=<operationId> and limit=1 to read one.`]];return q(i([...n.keys()].findLast(e=>e>0&&r(i(e)))??1))}var J=`call aventure_help with q=<operationId> and limit=1; inspect structuredContent.data argument and optionalInput for the retained inputs`;function Y(e,t){let n=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[...Ne(e,t),...n]}function Ne(e,t){let n=e.flatMap(e=>`argument`in e?Object.values(e.argument).flat():[]),r=t===`whole`?0:n.filter(e=>e.description.length>G&&(t===`described`||e.required)).length,i=r===0?[]:[`... ${r} argument descriptions shortened; inspect structuredContent.data[].argument for full descriptions.`];if(e.some(e=>`optionalDetailOmitted`in e))return[...i,e.some(e=>`argument`in e)?`... optional argument details omitted: the full list exceeds the result cap; ${J}.`:`... 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 i;let a=t===`requiredDescribed`?`optional argument descriptions`:`optional argument details`,o=n.filter(({required:e})=>!e).length;return[...i,`... ${o} ${a} omitted to fit ${f} UTF-8 bytes; structuredContent carries them, and ${J}.`]}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} (aventure_${e.intent})`,` ${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=>Pe(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 Pe(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 Fe(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.intent),arguments:{operationId:e.operationId,...n===void 0?{}:{pathParams:n},...r===void 0?{}:{query:r},...e.requestBody===void 0?{}:{body:Le(e)}}}}var Ie=4;function Le(e){let t=e.requestBody?.[0];if(t===void 0)return{};if(t.requiredPath.length>0||e.intent!==`lookup`||t.schemaType===`array`)return Re(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>Ie?[]:[[t,`<${i.join(`|`)}>`]]}))}function Re(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(ze,t);r[n.at(-1)??e]=`<${e}>`}return t}function ze(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 Be(e){let t=W(e);return{mcpCall:Q(e),...t===void 0?{}:{paidPlan:t}}}function Ve(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{ue as C,le as D,v as E,m as S,_ as T,ge as _,Me as a,y as b,Oe as c,F as d,P as f,x as g,T as h,Be as i,De as l,O as m,$ as n,Q as o,A as p,Ve as r,H as s,K as t,Ee as u,_e 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-DXFbrrkt.js";import{V as r,c as i,m as a,n as o}from"./tool-policy-
|
|
1
|
+
import{c as e,i as t,r as n}from"./result-envelope-DXFbrrkt.js";import{V as r,c as i,m as a,n as o}from"./tool-policy-NTXy68a8.js";import{t as s}from"./openapi-snapshot-xFGmCymw.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-tM-2mFr2.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(),i=r(n.paths,e),o=i===null?new Map:a(n,i.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},a){let o=oe(a),s=ie(a),l=0;o.some(t=>t===e)&&(l+=100),o.some(t=>t.includes(e))&&(l+=40),l+=ae(e,o);let p=new Set(o.flatMap(f)),m=new Set(s.flatMap(f));for(let e of t)o.some(t=>t===e)?l+=20:m.has(e)?l+=8:p.has(e)&&(l+=K);for(let e of a.cliPath){let n=new Set;d(n,e),[...n].some(e=>t.has(e))&&(l+=W)}c(n,s)&&(l+=200),n.length>1&&s.some(t=>t.includes(e))&&(l+=ee),a.parameterName.some(t=>u(t)===e)&&(l+=G);let h=new Set(a.parameterDescription.flatMap(f));for(let e of t)h.has(e)&&(l+=K);return l+=ce(t,a.enumParameter),[`list`,`search`,`find`,`browse`].some(e=>t.has(e))&&/^(?:list|search)[A-Z]/u.test(a.operationId)&&(l+=30),l+=B(n,r,a.responseFieldLevel),l-=se(e,t,a.description),i(a.intent)&&!re(r)?l*q:l}var te=`edit change set fix rename link unlink mark publish correct`.split(` `),ne=new Set([...Object.entries(o).filter(([,e])=>i(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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as logoutCliCredentials}from"./logout-bAOnLVcZ.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e}from"./env-CpA6E7ay.js";import{c as t,r as n}from"./result-envelope-DXFbrrkt.js";import{z as r}from"./tool-policy-
|
|
1
|
+
import{f as e}from"./env-CpA6E7ay.js";import{c as t,r as n}from"./result-envelope-DXFbrrkt.js";import{z as r}from"./tool-policy-NTXy68a8.js";import{c as i}from"./openapi-call-o3oKcBXS.js";import{a,n as o,s,t as c}from"./credential-redaction-Fd-q1M6s.js";import{a as l,r as u,t as d}from"./api-key-credential-CTYGmo4i.js";import{n as f}from"./contract-BoQqQVwP.js";import{t as p}from"./openapi-composites-B9JPhVYN.js";import{c as m,f as h,m as g,n as _,r as v}from"./oauth-credential-CsMU443S.js";import{t as y}from"./oauth-login-BhIOT6p8.js";var b=f(p,`revoke`);async function x(r){let i;try{i=a(e().host)}catch(e){return n(`auth logout: invalid API host — ${c(e)}`)}let o=await S(i),s=await T(i,r),l=o.state===`failed`?[`OAuth credential could not be removed — ${o.summary}`]:o.state===`forgotten`&&!o.revoked?[`OAuth refresh token was not revoked remotely — ${o.summary??`no revocation endpoint`}`]:[],u={host:i,revoked:!1,forgotten:!1,oauth:o};return s===null?o.state===`missing`?t(`No CLI credential is stored for this API host.`,u):o.state===`failed`?{...n(`auth logout: ${l[0]}`),data:u}:t(o.revoked?`OAuth credential revoked remotely and removed locally.`:`OAuth credential removed locally.`,u,{warnings:l}):{...s,data:{...s.data??u,oauth:o},warnings:[...s.warnings,...l]}}async function S(e){let t=await v(e);if(t.state===`missing`)return{state:`missing`};let n=t.state===`found`?await w(t.stored):{revoked:!1};try{await _(e)}catch(e){return{state:`failed`,summary:c(e)}}return{state:`forgotten`,...n}}async function C(e){let t=Reflect.get(await y(e),`revocation_endpoint`);return typeof t==`string`?g(t,`revocation endpoint`,!0):void 0}async function w(e){let{client:t,tokens:n}=e.credential,r=n.refresh_token??n.access_token;try{let e=await C(t);if(e===void 0)return{revoked:!1};let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:r,client_id:m(t)})});return n.ok?{revoked:!0}:{revoked:!1,summary:`revocation endpoint answered ${n.status}`}}catch(e){return{revoked:!1,summary:c(e,h(n))}}}async function T(e,r){let i;try{i=await u(e)}catch(e){return n(`auth logout: stored credential could not be read — ${c(e)}`)}if(i.state===`unavailable`)return{...n(`auth logout: ${i.summary}`),data:{host:e,revoked:!1,forgotten:!1}};if(i.state===`missing`)return null;let a=i.stored,o=await E(a),s=o.outcome===`revoked`,l=a.activation===`pending`&&o.outcome===`rejected`;if(!s&&!l&&!r.forgetLocal)return{...n(`auth logout: remote revocation was not confirmed; local credential preserved — ${o.summary}`,[`Retry when the API is available. If an earlier response was lost after revocation, the retry can be unauthorized because revoked keys cannot authenticate.`,"Use `--forget-local` only to remove local bytes while accepting that the remote key may remain active."]),data:D(a,!1,!1)};try{await d(a.host)}catch(e){return{...n(`auth logout: local credential removal failed — ${c(e,[a.credential.secret])}`,[s?"The remote key is revoked. Re-run with `--forget-local` to retry local cleanup.":`Remote revocation was not confirmed; inspect auth status before retrying.`]),data:D(a,s,!1)}}return t(s?`API key revoked remotely and removed locally.`:l?`Stale pending CLI credential removed; its remote key can no longer authenticate and unacknowledged keys expire at the authorization deadline.`:`API key removed locally without confirmed remote revocation.`,D(a,s,!0),{ids:[a.credential.apiKey.id],warnings:s||l?[]:[`Remote revocation was not confirmed; the API key may remain active.`]})}async function E(t){let n=s(e());try{let e=await i(n,{method:b.method,path:r(b.path,{},b.operationId),headers:{Authorization:`Bearer ${t.credential.secret}`}},l);return e.ok&&e.redirect?{outcome:`unconfirmed`,summary:`remote key revocation returned unexpected redirect ${e.status}`}:e.ok?e.data.id!==t.credential.apiKey.id||e.data.subject!==t.credential.apiKey.subject?{outcome:`unconfirmed`,summary:`remote response did not match the stored API key identity`}:e.data.status===`REVOKED`?{outcome:`revoked`,summary:`remote key revocation confirmed`}:{outcome:`unconfirmed`,summary:`remote response did not confirm REVOKED status`}:{outcome:e.problem.status===401&&e.problem.type!==`about:blank`?`rejected`:`unconfirmed`,summary:o(e.problem,[t.credential.secret])}}catch(e){return{outcome:`unconfirmed`,summary:c(e,[t.credential.secret])}}}function D(e,t,n){return{host:e.host,apiKeyId:e.credential.apiKey.id,activation:e.activation,revoked:t,forgotten:n}}export{E as n,x as t};
|