@prooflane/inspector-beta 0.1.0-beta.12 → 0.1.0-beta.13
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/server.mjs
CHANGED
|
@@ -16201,6 +16201,7 @@ function buildApp() {
|
|
|
16201
16201
|
if (capabilities)
|
|
16202
16202
|
return proxyControlPlane(req, reply, `${hostedSammyPath}/generations/${encodeURIComponent(req.params.id)}/approve`, { ...selectedBody(req.body, ["gateId", "name", "policyVersion", "expectedRevisionNumber"]), capabilities });
|
|
16203
16203
|
}), app.post("/api/intelligence/generations/:id/compile-suite", async (req, reply) => proxyControlPlane(req, reply, `${hostedSammyPath}/generations/${encodeURIComponent(req.params.id)}/compile-suite`, {})), app.get("/api/intelligence/usage", async (req, reply) => proxyControlPlane(req, reply, `${hostedSammyPath}/usage`, void 0, "GET")), app.get("/api/intelligence/datasets", async (req, reply) => proxyControlPlane(req, reply, `${hostedSammyPath}/datasets`, void 0, "GET")), app.post("/api/intelligence/datasets", async (req, reply) => proxyControlPlane(req, reply, `${hostedSammyPath}/datasets`, selectedBody(req.body, ["name", "format", "content"]))), app.get("/api/intelligence/native-artifacts", async (req, reply) => {
|
|
16204
|
+
reply.header("cache-control", "no-store");
|
|
16204
16205
|
let capabilities = hostedCapabilities(reply);
|
|
16205
16206
|
if (!capabilities)
|
|
16206
16207
|
return;
|
|
@@ -43,7 +43,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
43
43
|
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
44
44
|
`)})(),this.lockManager=(Pm||(Pm=hA()),Pm),t.cache&&t.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),t.cache)a=t.cache;else{if(n=t.cacheLocation||Ib,!Gb(n))throw new Error('Invalid cache location "'.concat(n,'"'));a=Gb(n)()}var r;this.httpTimeoutMs=t.httpTimeoutInSeconds?1e3*t.httpTimeoutInSeconds:Jg,this.cookieStorage=t.legacySameSiteCookie===!1?xo:AA,this.orgHintCookieName=(r=this.options.clientId,"auth0.".concat(r,".organization_hint")),this.isAuthenticatedCookieName=(d=>"auth0.".concat(d,".is.authenticated"))(this.options.clientId),this.sessionCheckExpiryDays=t.sessionCheckExpiryDays||1;const i=t.useCookiesForTransactions?this.cookieStorage:PA;let o="";var l;this.onlineAccess?o=i1:this.options.useRefreshTokens&&(o="offline_access"),this.scope=function(d,h){for(var g=arguments.length,v=new Array(g>2?g-2:0),f=2;f<g;f++)v[f-2]=arguments[f];if(typeof d!="object")return{[bs]:ch(h,d,...v)};let y={[bs]:ch(h,...v)};return Object.keys(d).forEach(b=>{const m=d[b];y[b]=ch(h,m,...v)}),y}(this.options.authorizationParams.scope,"openid",o),this.transactionManager=new EA(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||o1,this.cacheManager=new kA(a,a.allKeys?void 0:new LA(a,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new UA(this.options.clientId):void 0,this.domainUrl=(l=this.options.domain,/^https?:\/\//.test(l)?l:"https://".concat(l)),this.tokenIssuer=((d,h)=>d?d.startsWith("https://")?d:"https://".concat(d,"/"):"".concat(h,"/"))(this.options.issuer,this.domainUrl);const c="".concat(this.domainUrl,"/me/"),u=this.createFetcher(Object.assign(Object.assign({},this.options.useDpop&&{dpopNonceId:"__auth0_my_account_api__"}),{getAccessToken:d=>{var h;return this.getTokenSilently({authorizationParams:{scope:(h=d==null?void 0:d.scope)===null||h===void 0?void 0:h.join(" "),audience:c},detailedResponse:!0})}}));this.myAccount=new GA(u,c),this.authJsClient=new d2({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new g2(this.authJsClient.mfa,this),this.passkey=new v2(this.authJsClient.passkey,this),typeof window<"u"&&window.Worker&&this.options.useRefreshTokens&&n===Ib&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new OA,this.worker.postMessage({type:"init",allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(t){const n=this.options.auth0Client||Yg,a=Qg(n,!0),r=encodeURIComponent(btoa(JSON.stringify(a)));return"".concat(this.domainUrl).concat(t,"&auth0Client=").concat(r)}_authorizeUrl(t){return this._url("/authorize?".concat(yc(t)))}async _verifyIdToken(t,n,a){const r=await this.nowProvider();return CA({iss:this.tokenIssuer,aud:this.options.clientId,id_token:t,nonce:n,organization:a,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i!="string"?i:parseInt(i,10)||void 0),now:r});var i}_processOrgHint(t){t?this.cookieStorage.save(this.orgHintCookieName,t,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(t){return new URLSearchParams(window.location.search).get(t)||void 0}_clearSessionTransferTokenFromUrl(t){try{const n=new URL(window.location.href);n.searchParams.has(t)&&(n.searchParams.delete(t),window.history.replaceState({},"",n.toString()))}catch{}}_applySessionTransferToken(t){const n=this.options.sessionTransferTokenQueryParamName;if(!n||t.session_transfer_token)return t;const a=this._extractSessionTransferToken(n);return a?(this._clearSessionTransferTokenFromUrl(n),Object.assign(Object.assign({},t),{session_transfer_token:a})):t}async _prepareAuthorizeUrl(t,n,a){var r;const i=Tm(Ul()),o=Tm(Ul()),l=Ul(),c=await Pb(l),u=Ob(c),d=await((r=this.dpop)===null||r===void 0?void 0:r.calculateThumbprint()),h=((v,f,y,b,m,x,j,S,w)=>Object.assign(Object.assign(Object.assign({client_id:v.clientId},v.authorizationParams),y),{scope:Gl(f,y.scope,y.audience),response_type:"code",response_mode:S||"query",state:b,nonce:m,redirect_uri:j||v.authorizationParams.redirect_uri,code_challenge:x,code_challenge_method:"S256",dpop_jkt:w}))(this.options,this.scope,t,i,o,u,t.redirect_uri||this.options.authorizationParams.redirect_uri||a,n==null?void 0:n.response_mode,d),g=this._authorizeUrl(h);return{nonce:o,code_verifier:l,scope:h.scope,audience:h.audience||bs,redirect_uri:h.redirect_uri,state:i,url:g}}async loginWithPopup(t,n){var a;if(t=t||{},!(n=n||{}).popup&&(n.popup=(c=>{const u=window.screenX+(window.innerWidth-400)/2,d=window.screenY+(window.innerHeight-600)/2;return window.open(c,"auth0:authorize:popup","left=".concat(u,",top=").concat(d,",width=").concat(400,",height=").concat(600,",resizable,scrollbars=yes,status=1"))})(""),!n.popup))throw new aA;const r=this._applySessionTransferToken(t.authorizationParams||{}),i=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin);n.popup.location.href=i.url;const o=await((c,u)=>new Promise((d,h)=>{let g;const v=setInterval(()=>{c.popup&&c.popup.closed&&(clearInterval(v),clearTimeout(f),window.removeEventListener("message",g,!1),h(new nA(c.popup)))},1e3),f=setTimeout(()=>{clearInterval(v),h(new sA(c.popup)),window.removeEventListener("message",g,!1)},1e3*(c.timeoutInSeconds||60));g=function(y){if(y.origin===u&&y.data&&y.data.type==="authorization_response"){if(clearTimeout(f),clearInterval(v),window.removeEventListener("message",g,!1),c.closePopup!==!1&&c.popup.close(),y.data.response.error)return h(Ct.fromPayload(y.data.response));d(y.data.response)}},window.addEventListener("message",g)}))(Object.assign(Object.assign({},n),{timeoutInSeconds:n.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(i.url).origin);if(i.state!==o.state)throw new Ct("state_mismatch","Invalid state");const l=((a=t.authorizationParams)===null||a===void 0?void 0:a.organization)||this.options.authorizationParams.organization;await this._requestToken({audience:i.audience,scope:i.scope,code_verifier:i.code_verifier,grant_type:"authorization_code",code:o.code,redirect_uri:i.redirect_uri},{nonceIn:i.nonce,organization:l})}async getUser(){var t;if(await this._isSessionCeilingReached())return;const n=await this._getIdTokenFromCache();return(t=n==null?void 0:n.decodedToken)===null||t===void 0?void 0:t.user}async getIdTokenClaims(){var t;if(await this._isSessionCeilingReached())return;const n=await this._getIdTokenFromCache();return(t=n==null?void 0:n.decodedToken)===null||t===void 0?void 0:t.claims}async loginWithRedirect(){var t;const n=Wb(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),a=n.openUrl,r=n.fragment,i=n.appState,o=Qs(n,["openUrl","fragment","appState"]),l=((t=o.authorizationParams)===null||t===void 0?void 0:t.organization)||this.options.authorizationParams.organization,c=this._applySessionTransferToken(o.authorizationParams||{}),u=await this._prepareAuthorizeUrl(c),d=u.url,h=Qs(u,["url"]);this.transactionManager.create(Object.assign(Object.assign(Object.assign({},h),{appState:i,response_type:_i.Code}),l&&{organization:l}));const g=r?"".concat(d,"#").concat(r):d;a?await a(g):window.location.assign(g)}async handleRedirectCallback(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split("?").slice(1);if(t.length===0)throw new Error("There are no query params available for parsing.");const n=this.transactionManager.get();if(!n)throw new Ct("missing_transaction","Invalid state");this.transactionManager.remove();const a=(r=>{r.indexOf("#")>-1&&(r=r.substring(0,r.indexOf("#")));const i=new URLSearchParams(r);return{state:i.get("state"),code:i.get("code")||void 0,connect_code:i.get("connect_code")||void 0,error:i.get("error")||void 0,error_description:i.get("error_description")||void 0}})(t.join(""));return n.response_type===_i.ConnectCode?this._handleConnectAccountRedirectCallback(a,n):this._handleLoginRedirectCallback(a,n)}async _handleLoginRedirectCallback(t,n){const a=t.code,r=t.state,i=t.error,o=t.error_description;if(i)throw new eA(i,o||i,r,n.appState);if(!n.code_verifier||n.state&&n.state!==r)throw new Ct("state_mismatch","Invalid state");const l=n.organization,c=n.nonce,u=n.redirect_uri;return await this._requestToken(Object.assign({audience:n.audience,scope:n.scope,code_verifier:n.code_verifier,grant_type:"authorization_code",code:a},u?{redirect_uri:u}:{}),{nonceIn:c,organization:l}),{appState:n.appState,response_type:_i.Code}}async _handleConnectAccountRedirectCallback(t,n){const a=t.connect_code,r=t.state,i=t.error,o=t.error_description;if(i)throw new tA(i,o||i,n.connection,r,n.appState);if(!a)throw new Ct("missing_connect_code","Missing connect code");if(!(n.code_verifier&&n.state&&n.auth_session&&n.redirect_uri&&n.state===r))throw new Ct("state_mismatch","Invalid state");const l=await this.myAccount.completeAccount({auth_session:n.auth_session,connect_code:a,redirect_uri:n.redirect_uri,code_verifier:n.code_verifier});return Object.assign(Object.assign({},l),{appState:n.appState,response_type:_i.ConnectCode})}async checkSession(t){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(Fb))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(Fb)}try{await this.getTokenSilently(t)}catch{}}async getTokenSilently(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};var n,a;const r=Object.assign(Object.assign({cacheMode:"on"},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Gl(this.scope,(n=t.authorizationParams)===null||n===void 0?void 0:n.scope,((a=t.authorizationParams)===null||a===void 0?void 0:a.audience)||this.options.authorizationParams.audience)})}),i=await((o,l)=>{let c=Lm[l];return c||(c=o().finally(()=>{delete Lm[l],c=null}),Lm[l]=c),c})(()=>this._getTokenSilently(r),"".concat(this.options.clientId,"::").concat(r.authorizationParams.audience,"::").concat(r.authorizationParams.scope));return t.detailedResponse?i:i==null?void 0:i.access_token}async _getTokenSilently(t){const n=t.cacheMode,a=Qs(t,["cacheMode"]);if(await this._isSessionCeilingReached())return;if(n!=="off"){const l=await this._getEntryFromCache({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||bs,clientId:this.options.clientId,cacheMode:n});if(l)return l}if(n==="cache-only")return;const r=(i=this.options.clientId,o=a.authorizationParams.audience||"default","".concat("auth0.lock.getTokenSilently",".").concat(i,".").concat(o));var i,o;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(n!=="off"){const v=await this._getEntryFromCache({scope:a.authorizationParams.scope,audience:a.authorizationParams.audience||bs,clientId:this.options.clientId});if(v)return v}const l=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(a):await this._getTokenFromIFrame(a),c=l.id_token,u=l.token_type,d=l.access_token,h=l.oauthTokenScope,g=l.expires_in;return Object.assign(Object.assign({id_token:c,token_type:u,access_token:d},h?{scope:h}:null),{expires_in:g})})}catch(l){if(this._isInteractiveError(l)&&this.options.interactiveErrorHandler==="popup")return await this._handleInteractiveErrorWithPopup(a);throw l}}_isInteractiveError(t){return t instanceof Xg||t instanceof Ct&&this._isIframeMfaError(t)}_isIframeMfaError(t){return t.error==="login_required"&&t.error_description==="Multifactor authentication required"}async _handleInteractiveErrorWithPopup(t){try{await this.loginWithPopup({authorizationParams:t.authorizationParams});const n=await this._getEntryFromCache({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||bs,clientId:this.options.clientId});if(!n)throw new Ct("interactive_handler_cache_miss","Token not found in cache after interactive authentication");return n}catch(n){throw n}}async getTokenWithPopup(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var a,r;const i=Object.assign(Object.assign({},t),{authorizationParams:Object.assign(Object.assign(Object.assign({},this.options.authorizationParams),t.authorizationParams),{scope:Gl(this.scope,(a=t.authorizationParams)===null||a===void 0?void 0:a.scope,((r=t.authorizationParams)===null||r===void 0?void 0:r.audience)||this.options.authorizationParams.audience)})});return n=Object.assign(Object.assign({},QI),n),await this.loginWithPopup(i,n),(await this.cacheManager.get(new mn({scope:i.authorizationParams.scope,audience:i.authorizationParams.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(t){t.clientId!==null?t.clientId=t.clientId||this.options.clientId:delete t.clientId;const n=t.logoutParams||{},a=n.federated,r=Qs(n,["federated"]),i=a?"&federated":"";return this._url("/v2/logout?".concat(yc(Object.assign({clientId:t.clientId},r))))+i}async revokeRefreshToken(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.options.useRefreshTokens)return;const n=t.audience||this.options.authorizationParams.audience||bs,a=await this.cacheManager.getRefreshTokensByAudience(n,this.options.clientId);await async function(r,i){let o=r.baseUrl,l=r.timeout,c=r.auth0Client,u=r.useFormData,d=r.refreshTokens,h=r.audience,g=r.client_id,v=r.onRefreshTokenRevoked;const f=l||Jg,y="refresh_token",b="".concat(o,"/oauth/revoke"),m={"Content-Type":u?"application/x-www-form-urlencoded":"application/json","Auth0-Client":btoa(JSON.stringify(Qg(c||Yg)))};if(i){const j={client_id:g,token_type_hint:y},S=u?yc(j):JSON.stringify(j);try{return await tv({type:"revoke",timeout:f,fetchUrl:b,fetchOptions:{method:"POST",body:S,headers:m},useFormData:u,auth:{audience:h??bs}},i)}catch(w){throw new Ct("revoke_error",w.message)}}for(const j of d){const S={client_id:g,token_type_hint:y,token:j},w=u?yc(S):JSON.stringify(S),C=await E1(b,{method:"POST",body:w,headers:m},f);if(!C.ok){let _,N;try{var x=JSON.parse(await C.text());_=x.error,N=x.error_description}catch{}throw new Ct(_||"revoke_error",N||"HTTP error ".concat(C.status))}await(v==null?void 0:v(j))}}({baseUrl:this.domainUrl,timeout:this.httpTimeoutMs,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,client_id:this.options.clientId,refreshTokens:a,audience:n,onRefreshTokenRevoked:r=>this.cacheManager.stripRefreshToken(r)},this.worker),this.onlineAccess&&await this._clearLocalSession()}async logout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=Wb(t),a=n.openUrl,r=Qs(n,["openUrl"]);await this._clearLocalSession(t.clientId);const i=this._buildLogoutUrl(r);a?await a(i):a!==!1&&window.location.assign(i)}async _getTokenFromIFrame(t){const n=(a=this.options.clientId,"".concat("auth0.lock.getTokenFromIFrame",".").concat(a));var a;try{return await this.lockManager.runWithLock(n,5e3,async()=>{const r=Object.assign(Object.assign({},t.authorizationParams),{prompt:"none"}),i=this.cookieStorage.get(this.orgHintCookieName);i&&!r.organization&&(r.organization=i);const o=await this._prepareAuthorizeUrl(r,{response_mode:"web_message"},window.location.origin),l=o.url,c=o.state,u=o.nonce,d=o.code_verifier,h=o.redirect_uri,g=o.scope,v=o.audience;if(window.crossOriginIsolated)throw new Ct("login_required","The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");const f=t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds;let y;try{y=new URL(this.domainUrl).origin}catch{y=this.domainUrl}const b=await function(x,j){let S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((w,C)=>{const _=window.document.createElement("iframe");_.setAttribute("width","0"),_.setAttribute("height","0"),_.style.display="none";const N=()=>{window.document.body.contains(_)&&(window.document.body.removeChild(_),window.removeEventListener("message",$,!1))};let $;const E=setTimeout(()=>{C(new Up),N()},1e3*S);$=function(k){if(k.origin!=j||!k.data||k.data.type!=="authorization_response")return;const T=k.source;T&&T.close(),k.data.response.error?C(Ct.fromPayload(k.data.response)):w(k.data.response),clearTimeout(E),window.removeEventListener("message",$,!1),setTimeout(N,2e3)},window.addEventListener("message",$,!1),window.document.body.appendChild(_),_.setAttribute("src",x)})}(l,y,f);if(c!==b.state)throw new Ct("state_mismatch","Invalid state");const m=await this._requestToken(Object.assign(Object.assign({},t.authorizationParams),{code_verifier:d,code:b.code,grant_type:"authorization_code",redirect_uri:h,timeout:t.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:u,organization:r.organization});return Object.assign(Object.assign({},m),{scope:g,oauthTokenScope:m.scope,audience:v})})}catch(r){throw r.error==="login_required"&&(r instanceof Ct&&this._isIframeMfaError(r)&&this.options.interactiveErrorHandler==="popup"||this.logout({openUrl:!1})),r}}async _getTokenUsingRefreshToken(t){const n=await this.cacheManager.get(new mn({scope:t.authorizationParams.scope,audience:t.authorizationParams.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(n&&n.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw new g1(t.authorizationParams.audience||bs,t.authorizationParams.scope)}const a=t.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof t.timeoutInSeconds=="number"?1e3*t.timeoutInSeconds:null,i=((d,h,g,v)=>{var f;if(d&&g&&v){if(h.audience!==g)return h.scope;const y=v.split(" "),b=((f=h.scope)===null||f===void 0?void 0:f.split(" "))||[],m=b.every(x=>y.includes(x));return y.length>=b.length&&m?v:h.scope}return h.scope})(this.options.useMrrt,t.authorizationParams,n==null?void 0:n.audience,n==null?void 0:n.scope);try{const d=await this._requestToken(Object.assign(Object.assign(Object.assign({},t.authorizationParams),{grant_type:"refresh_token",refresh_token:n&&n.refresh_token,redirect_uri:a}),r&&{timeout:r}),{scopesToRequest:i});if(!this.onlineAccess&&d.refresh_token&&(n!=null&&n.refresh_token)&&await this.cacheManager.updateEntry(n.refresh_token,d.refresh_token),this.options.useMrrt&&(o=n==null?void 0:n.audience,l=n==null?void 0:n.scope,c=t.authorizationParams.audience,u=t.authorizationParams.scope,o!==c||!((h,g)=>{const v=(g==null?void 0:g.split(" "))||[];return((h==null?void 0:h.split(" "))||[]).every(f=>v.includes(f))})(u,l))){const h=DA(i,d.scope,this.onlineAccess);if(h){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t);throw await this.cacheManager.remove(this.options.clientId,t.authorizationParams.audience,t.authorizationParams.scope),new rA(t.authorizationParams.audience||"default",h)}}return Object.assign(Object.assign({},d),{scope:t.authorizationParams.scope,oauthTokenScope:d.scope,audience:t.authorizationParams.audience||bs})}catch(d){if(d.message){if(d.message.includes("user is blocked"))throw await this.logout({openUrl:!1}),d;if((d.message.includes("Missing Refresh Token")||d.message.includes("invalid refresh token"))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(t)}throw d}var o,l,c,u}async _saveEntryInCache(t){const n=t.decodedToken.claims,a=n.session_expiry,r=n.iat;if(a!==void 0){if(typeof a!="number")throw new Ct("invalid_token","Invalid session_expiry: value must be a number.");if(a>=1e10)throw new Ct("invalid_token","Invalid session_expiry: value appears to be in milliseconds; expected a Unix timestamp in seconds.");if(r===void 0||a<=r)throw new Ct("invalid_token","Invalid session_expiry: session ceiling is before or at the token issue time.")}const i=t.id_token,o=t.decodedToken,l=Qs(t,["id_token","decodedToken"]);this.userCache.set(xi,{id_token:i,decodedToken:o}),await this.cacheManager.setIdToken(this.options.clientId,t.id_token,t.decodedToken),await this.cacheManager.set(l)}async _clearLocalSession(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.clientId;var n;t===null?await this.cacheManager.clear():await this.cacheManager.clear(t),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(xi);try{await((n=this.dpop)===null||n===void 0?void 0:n.clear())}catch{}if(this.worker)try{await tv({type:"clear"},this.worker)}catch{}}async _isSessionCeilingReached(){var t,n;const a=this.userCache.get(xi),r=a??await this.cacheManager.getIdToken(new mn({clientId:this.options.clientId})),i=(n=(t=r==null?void 0:r.decodedToken)===null||t===void 0?void 0:t.claims)===null||n===void 0?void 0:n.session_expiry;if(i===void 0)return!1;const o=await this.nowProvider();return Math.floor(o/1e3)>=i-30&&(await this._clearLocalSession(),!0)}async _getIdTokenFromCache(){const t=this.options.authorizationParams.audience||bs,n=this.scope[t],a=await this.cacheManager.getIdToken(new mn({clientId:this.options.clientId,audience:t,scope:n})),r=this.userCache.get(xi);return a&&a.id_token===(r==null?void 0:r.id_token)?r:(this.userCache.set(xi,a),a)}async _getEntryFromCache(t){let n=t.scope,a=t.audience,r=t.clientId,i=t.cacheMode;const o=await this.cacheManager.get(new mn({scope:n,audience:a,clientId:r}),60,this.options.useMrrt,i);if(o&&o.access_token){const l=o.token_type,c=o.access_token,u=o.oauthTokenScope,d=o.expires_in,h=await this._getIdTokenFromCache();return h&&Object.assign(Object.assign({id_token:h.id_token,token_type:l||"Bearer",access_token:c},u?{scope:u}:null),{expires_in:d})}}_storeMfaContext(t,n,a){t instanceof Xg&&this.mfa.setMFAAuthDetails(t.mfa_token,n,a,t.mfa_requirements)}async _requestToken(t,n){var a,r,i,o,l,c;const u=n||{},d=u.nonceIn,h=u.organization,g=u.scopesToRequest;try{const v=await Mb(Object.assign(Object.assign({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop,preserveRefreshToken:this.onlineAccess},t),{scope:g||t.scope}),this.worker);let f=await this._verifyIdToken(v.id_token,d,h);if(t.grant_type==="authorization_code"){const y=await this._getIdTokenFromCache();!((r=(a=y==null?void 0:y.decodedToken)===null||a===void 0?void 0:a.claims)===null||r===void 0)&&r.sub&&y.decodedToken.claims.sub!==f.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(xi))}if(t.grant_type!=="authorization_code"){const y=await this._getIdTokenFromCache(),b=(o=(i=y==null?void 0:y.decodedToken)===null||i===void 0?void 0:i.claims)===null||o===void 0?void 0:o.session_expiry;b!==void 0&&(f=Object.assign(Object.assign({},f),{claims:Object.assign(Object.assign({},f.claims),{session_expiry:b})}))}return!v.refresh_token&&this.onlineAccess&&(v.refresh_token=(l=t.refresh_token)!==null&&l!==void 0?l:(c=await this.cacheManager.get(new mn({scope:g||t.scope,audience:t.audience||bs,clientId:this.options.clientId}),void 0,this.options.useMrrt))===null||c===void 0?void 0:c.refresh_token),await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({},v),{decodedToken:f,scope:t.scope,audience:t.audience||bs}),v.scope?{oauthTokenScope:v.scope}:null),{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(h||f.claims.org_id),Object.assign(Object.assign({},v),{decodedToken:f})}catch(v){throw t.grant_type!=="authorization_code"&&this._storeMfaContext(v,g||t.scope,t.audience),v}}_buildTokenExchangeParams(t){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),{grant_type:"urn:ietf:params:oauth:grant-type:token-exchange",subject_token:t.subject_token,subject_token_type:t.subject_token_type}),t.actor_token&&{actor_token:t.actor_token}),t.actor_token_type&&{actor_token_type:t.actor_token_type}),{scope:Gl(this.scope,t.scope,t.audience||this.options.authorizationParams.audience),audience:t.audience||this.options.authorizationParams.audience,organization:t.organization||this.options.authorizationParams.organization})}async loginWithCustomTokenExchange(t){return this._requestToken(this._buildTokenExchangeParams(t))}async customTokenExchange(t){const n=this._buildTokenExchangeParams(t);try{const a=await Mb(Object.assign(Object.assign({},n),{baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,dpop:this.dpop}),this.worker,!0);return a.id_token&&await this._verifyIdToken(a.id_token,void 0,t.organization),a}catch(a){throw this._storeMfaContext(a,n.scope,n.audience),a}}async exchangeToken(t){return this.loginWithCustomTokenExchange(t)}_assertDpop(t){if(!t)throw new Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(t){return this._assertDpop(this.dpop),this.dpop.getNonce(t)}setDpopNonce(t,n){return this._assertDpop(this.dpop),this.dpop.setNonce(t,n)}generateDpopProof(t){return this._assertDpop(this.dpop),this.dpop.generateProof(t)}createFetcher(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new FA(t,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:n=>{var a;return this.getTokenSilently({authorizationParams:{scope:(a=n==null?void 0:n.scope)===null||a===void 0?void 0:a.join(" "),audience:n==null?void 0:n.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(t.dpopNonceId),setDpopNonce:n=>this.setDpopNonce(n,t.dpopNonceId),generateDpopProof:n=>this.generateDpopProof(n)})}async connectAccountWithRedirect(t){const n=t.openUrl,a=t.appState,r=t.connection,i=t.scopes,o=t.authorization_params,l=t.redirectUri,c=l===void 0?this.options.authorizationParams.redirect_uri||window.location.origin:l;if(!r)throw new Error("connection is required");const u=Tm(Ul()),d=Ul(),h=await Pb(d),g=Ob(h),v=await this.myAccount.connectAccount({connection:r,scopes:i,redirect_uri:c,state:u,code_challenge:g,code_challenge_method:"S256",authorization_params:o}),f=v.connect_uri,y=v.connect_params,b=v.auth_session;this.transactionManager.create({state:u,code_verifier:d,auth_session:b,redirect_uri:c,appState:a,connection:r,response_type:_i.ConnectCode});const m=new URL(f);m.searchParams.set("ticket",y.ticket),n?await n(m.toString()):window.location.assign(m)}async _requestTokenForPasskey(t){const n=t.audience||this.options.authorizationParams.audience,a=t.organization||this.options.authorizationParams.organization;return this._requestToken(Object.assign(Object.assign(Object.assign({grant_type:"urn:okta:params:oauth:grant-type:webauthn",auth_session:t.authSession,authn_response:t.credential},t.realm&&{realm:t.realm}),a&&{organization:a}),{scope:Gl(this.scope,t.scope,n),audience:n}))}async _requestTokenForMfa(t,n){const a=t.mfaToken,r=Qs(t,["mfaToken"]);return this._requestToken(Object.assign(Object.assign({},r),{mfa_token:a}),n)}}async function x2(e){const t=new y2(e);return await t.checkSession(),t}function j2(e){var r;const t=new URLSearchParams(e),n=t.get("error");if(!n)return null;const a=(r=t.get("error_description"))==null?void 0:r.trim();return a?a.length>300?`${a.slice(0,300)}…`:a:`Auth0 rejected the sign-in request (${n}).`}let _a=null,rp=null,jc=!1,gh=null,sf=!1;function b2(e){gh=e}async function w2(e){if(e.provider!=="auth0"||!e.domain||!e.clientId)return _a=null,rp=null,jc=!1,{user:null,freshLogin:!1,error:null};_a=await x2({domain:e.domain,clientId:e.clientId,authorizationParams:{redirect_uri:window.location.origin,audience:e.audience},cacheLocation:"localstorage",useRefreshTokens:!0});const t=window.location.search,n=j2(t);n&&window.history.replaceState({},document.title,window.location.pathname);const a=t.includes("code=")&&t.includes("state=");if(a){try{await _a.handleRedirectCallback()}catch{}window.history.replaceState({},document.title,window.location.pathname)}if(rp=async()=>{try{return await _a.getTokenSilently()}catch{return jc&&!sf&&(sf=!0,gh==null||gh()),null}},!await _a.isAuthenticated())return jc=!1,{user:null,freshLogin:a,error:n};jc=!0,sf=!1;const r=await _a.getUser();return{user:r?{email:r.email,name:r.name,picture:r.picture,emailVerified:r.email_verified}:null,freshLogin:a,error:n}}async function S2(e=!1){_a&&await _a.loginWithRedirect({authorizationParams:e?{screen_hint:"signup"}:{}})}async function N2(){_a&&(jc=!1,await _a.logout({logoutParams:{returnTo:window.location.origin}}))}async function _E(){window.open("https://app.prooflane.ai/billing","_blank","noopener")}async function Ka(){return rp?rp():null}const ul=["security","contracts","rag","prompt","perf"],k2="high",nf={balanced:{weights:{security:.35,contracts:.25,rag:.2,prompt:.1,perf:.1}},enterprise:{weights:{security:.3,contracts:.25,rag:.25,perf:.1,prompt:.1}},developer:{weights:{security:.25,contracts:.2,rag:.15,perf:.2,prompt:.2}}},Tw="balanced",jd=[{id:"development",name:"Development",description:"Fast feedback. Critical security and breaking contracts still block.",weights:nf.developer.weights,passAt:75,reviewAt:60,hardGates:{contracts:!0,securityMaxSeverity:"critical",exposureMaxSeverity:"off",poisoning:"warn"}},{id:"staging",name:"Staging",description:"Balanced release confidence before production.",weights:nf.balanced.weights,passAt:85,reviewAt:70,hardGates:{contracts:!0,securityMaxSeverity:"high",exposureMaxSeverity:"critical",poisoning:"warn",ragMinScore:75,perfMinScore:80}},{id:"production",name:"Production",description:"Strict release policy for customer-facing MCP systems.",weights:nf.enterprise.weights,passAt:90,reviewAt:75,hardGates:{contracts:!0,securityMaxSeverity:"high",exposureMaxSeverity:"critical",poisoning:"block",ragMinScore:85,promptMinScore:90,perfMinScore:90}}],CE="kawach.release.policies",TE="kawach.release.policy",Ev="staging";function ip(){try{const e=JSON.parse(localStorage.getItem(CE)||"null");return Array.isArray(e)&&e.length?e:jd}catch{return jd}}function Rw(e){try{localStorage.setItem(CE,JSON.stringify(e)),window.dispatchEvent(new Event("kawach:policies"))}catch{}}function jx(){try{return localStorage.getItem(TE)||Ev}catch{return Ev}}function RE(e){try{localStorage.setItem(TE,e),window.dispatchEvent(new Event("kawach:policies"))}catch{}}function IE(e,t){return e.find(n=>n.id===t)??e.find(n=>n.id===Ev)??e[0]??jd[1]}const Nl={security:"Security",contracts:"Contracts",rag:"Retrieval",prompt:"Prompts",perf:"Performance"},E2="kawach.deploy.profile";function _2(){try{return localStorage.getItem(E2)||Tw}catch{return Tw}}function fi(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function C2(e){var r,i,o,l,c;const t=IE(jd,e.id),n=e.hardGates??t.hardGates,a=["off","low","medium","high","critical"].includes(n.securityMaxSeverity)?n.securityMaxSeverity:t.hardGates.securityMaxSeverity;return{id:String(e.id).slice(0,100),name:String(e.name).slice(0,120),description:String(e.description).slice(0,500),weights:{security:fi((r=e.weights)==null?void 0:r.security,t.weights.security),contracts:fi((i=e.weights)==null?void 0:i.contracts,t.weights.contracts),rag:fi((o=e.weights)==null?void 0:o.rag,t.weights.rag),prompt:fi((l=e.weights)==null?void 0:l.prompt,t.weights.prompt),perf:fi((c=e.weights)==null?void 0:c.perf,t.weights.perf)},passAt:fi(e.passAt,t.passAt),reviewAt:fi(e.reviewAt,t.reviewAt),hardGates:{contracts:!!n.contracts,securityMaxSeverity:a,...["off","low","medium","high","critical"].includes(n.exposureMaxSeverity??"")?{exposureMaxSeverity:n.exposureMaxSeverity}:{exposureMaxSeverity:t.hardGates.exposureMaxSeverity??"critical"},poisoning:["block","warn","off"].includes(n.poisoning)?n.poisoning:t.hardGates.poisoning??"warn",...typeof n.ragMinScore=="number"&&Number.isFinite(n.ragMinScore)?{ragMinScore:n.ragMinScore}:{},...typeof n.promptMinScore=="number"&&Number.isFinite(n.promptMinScore)?{promptMinScore:n.promptMinScore}:{},...typeof n.perfMinScore=="number"&&Number.isFinite(n.perfMinScore)?{perfMinScore:n.perfMinScore}:{},...["off","low","medium","high","critical"].includes(n.modelSecurityMaxSeverity??"")?{modelSecurityMaxSeverity:n.modelSecurityMaxSeverity}:{}}}}function T2(){return{version:"release-policy-v1",activePolicyId:jx().slice(0,100),profile:_2().slice(0,100),policies:ip().slice(0,25).map(C2)}}const fn=e=>e?e.score??(e.total?Math.round(e.pass/e.total*100):null):null,AE=e=>!!e&&(e.fail>0||e.error>0),PE=e=>e==="security"?"security":e==="contract"||e==="mcp"?"contracts":e==="rag"?"rag":e==="prompt"?"prompt":e==="perf"?"perf":null,R2=e=>e.hardGates.modelSecurityMaxSeverity??k2;function I2(e,t){const n=e.find(i=>i.pillar==="model");if(!n)return null;const a=fn(n),r=bx(n,R2(t))?"blocked":n.fail>0||n.drift>0||n.error>0?"warning":"pass";return{run:n,score:a,status:r}}const Iw={low:1,medium:2,high:3,critical:4},$E=(e,t)=>t!=="off"&&(Iw[e??"low"]??0)>=Iw[t];function bx(e,t){return!e||!e.fail||t==="off"?!1:$E(e.severity,t)}function _v(e,t){return!e||!e.drift||!t||t==="off"?!1:$E(e.exposureSeverity,t)}function OE(e,t){return t==="block"&&!!(e!=null&&e.poisoned)}function A2(e,t){const n=t.weights,a=[...e].reverse(),r={},i=[];for(const o of a){const l=PE(o.pillar);if(!l)continue;r[l]=o;const c={};let u=0,d=0;for(const j of ul){const S=fn(r[j]);c[j]=S,S!=null&&(u+=n[j],d+=S*n[j])}const h=u?Math.round(d/u):null,g=r.security,v=r.contracts,f=r.rag,y=r.prompt,b=r.perf,m=t.hardGates.contracts&&!!(v!=null&&v.fail)||bx(g,t.hardGates.securityMaxSeverity)||_v(g,t.hardGates.exposureMaxSeverity)||OE(g,t.hardGates.poisoning)||AE(b)||t.hardGates.ragMinScore!=null&&(fn(f)??100)<t.hardGates.ragMinScore||t.hardGates.promptMinScore!=null&&(fn(y)??100)<t.hardGates.promptMinScore||t.hardGates.perfMinScore!=null&&(fn(b)??100)<t.hardGates.perfMinScore,x=h==null?"unknown":m?"blocked":h>=t.passAt?"pass":h>=t.reviewAt?"review":"blocked";i.push({at:o.createdAt,overall:h,verdict:x,scores:c})}return i}function P2(e){for(let t=e.length-2;t>=0;t--)if(e[t].verdict==="pass")return e[t];return null}function $2(e,t,n,a){const r=[],{security:i,contracts:o,rag:l,prompt:c,perf:u}=e;if(n.hardGates.contracts&&o&&o.fail>0&&r.push({severity:"blocker",dimension:"contracts",title:"MCP contract validation failed",why:o.finding||"A tool's input/output schema changed since the last green run.",impact:"Consumers may break — clients calling these tools still expect the previous schema.",fix:"Open Contract Diff to see exactly what changed, then restore the schema or update clients.",jumpTo:"contracts",jumpLabel:"Contract Diff"}),i&&bx(i,n.hardGates.securityMaxSeverity)&&r.push({severity:"blocker",dimension:"security",title:`${i.severity==="critical"?"Critical":"High"} verified security breach`,why:i.finding||`${i.fail} red-team attack${i.fail===1?"":"s"} crossed a protected boundary.`,impact:"A protected boundary was observed to cross — the agent leaked data, invoked a forbidden tool, or a payload executed.",fix:"Open Security → review the breached attack, patch the tool or add a guard, then re-run.",jumpTo:"security",jumpLabel:"Review breach"}),(a==null?void 0:a.status)==="blocked"&&r.push({severity:"blocker",dimension:"model",title:`${a.run.severity==="critical"?"Critical":"High"} model supply-chain finding`,why:a.run.finding||`${a.run.fail} Model & Supply Chain finding${a.run.fail===1?"":"s"} at or above the policy severity.`,impact:"The artifact this deployment is built from carries a verified exposure or poisoning. Nothing was executed to establish it — the evidence is structural.",fix:"Open Security → Model & Supply Chain, review the finding, obtain a clean artifact revision, then re-scan.",jumpTo:"security",jumpLabel:"Review artifact"}),i&&_v(i,n.hardGates.exposureMaxSeverity)&&r.push({severity:"blocker",dimension:"security",title:`${i.exposureSeverity==="critical"?"Critical":"High"} verified exposure`,why:`${i.drift} dangerous capabilit${i.drift===1?"y is":"ies are"} advertised with no confirmation, dry-run or approval control declared in the tool contract.`,impact:"Nothing was executed, so no boundary crossing is claimed. But if server-side authorization or approval controls are absent, a compromised agent could potentially invoke the operation.",fix:"Open Security → declare the safeguard in the tool contract (a required confirmation argument or an MCP annotation), or remove the capability from the advertised surface.",jumpTo:"security",jumpLabel:"Review exposure"}),i&&OE(i,n.hardGates.poisoning)&&r.push({severity:"blocker",dimension:"security",title:"Verified poisoning in reachable content",why:`${i.poisoned} finding${i.poisoned===1?"":"s"} located embedded agent-directed instructions in reachable resource content.`,impact:"The instruction-bearing content was verified as present. No agent was observed consuming it, but an agent that does could be influenced into unintended tool use.",fix:"Open Security → remove the embedded instructions from the served resource, or treat resource bodies as untrusted data in the agent harness.",jumpTo:"security",jumpLabel:"Review poisoning"}),n.hardGates.ragMinScore!=null&&(fn(l)??100)<n.hardGates.ragMinScore&&r.push({severity:"blocker",dimension:"rag",title:"RAG score below policy",why:`RAG scored ${fn(l)}; policy requires at least ${n.hardGates.ragMinScore}.`,impact:"Retrieved context may not be reliable enough to release.",fix:"Inspect the failing RAG queries and re-run after correcting retrieval.",jumpTo:"rag",jumpLabel:"Open RAG"}),n.hardGates.promptMinScore!=null&&(fn(c)??100)<n.hardGates.promptMinScore&&r.push({severity:"blocker",dimension:"prompt",title:"Prompt score below policy",why:`Prompts scored ${fn(c)}; policy requires at least ${n.hardGates.promptMinScore}.`,impact:"Pinned agent behavior has regressed below the release bar.",fix:"Open Prompt Automation, fix the regressions, and re-run.",jumpTo:"prompt-automation",jumpLabel:"Open Prompts"}),n.hardGates.perfMinScore!=null&&(fn(u)??100)<n.hardGates.perfMinScore&&r.push({severity:"blocker",dimension:"perf",title:"Performance below policy",why:`Performance scored ${fn(u)}; policy requires at least ${n.hardGates.perfMinScore}.`,impact:"The system does not meet the required load SLO.",fix:"Investigate the load test, then re-run Performance.",jumpTo:"performance",jumpLabel:"Open Performance"}),u&&AE(u)&&!r.some(d=>d.dimension==="perf"&&d.severity==="blocker")&&r.push({severity:"blocker",dimension:"perf",title:"Performance test returned request errors",why:u.finding||`${u.error||u.fail} load-test result${u.error+u.fail===1?"":"s"} failed.`,impact:"Latency from failed responses cannot establish that the service meets its release SLO.",fix:"Open Performance, correct the target errors, and re-run until the error rate is zero.",jumpTo:"performance",jumpLabel:"Open Performance"}),i&&i.drift>0&&!_v(i,n.hardGates.exposureMaxSeverity)&&r.push({severity:"warning",dimension:"security",title:`Verified exposure — ${i.drift} reachable capabilit${i.drift===1?"y":"ies"}`,why:"A dangerous capability is advertised with no safeguard declared in its contract. Prooflane verified reachability by inspection and did not execute it.",impact:"Not a boundary crossing. It becomes one if server-side authorization or approval controls are also missing.",fix:"Open Security → declare the safeguard, or drop the capability from the advertised surface.",jumpTo:"security",jumpLabel:"Open Security"}),i&&(i.poisoned??0)>0&&n.hardGates.poisoning!=="block"&&n.hardGates.poisoning!=="off"&&r.push({severity:"warning",dimension:"security",title:`Verified poisoning — ${i.poisoned} finding${i.poisoned===1?"":"s"}`,why:"Agent-directed instructions were located in reachable resource content. No agent execution was observed.",impact:"An agent that consumes the resource could be influenced into unintended tool use or a policy violation.",fix:"Open Security → inspect the located fragments and sanitize the served content.",jumpTo:"security",jumpLabel:"Open Security"}),i&&i.fail>0&&i.severity!=="critical"&&i.severity!=="high"&&r.push({severity:"warning",dimension:"security",title:`Security breach — ${i.fail} attack${i.fail===1?"":"s"}`,why:i.finding||"A lower-severity red-team attack breached.",impact:"Limited exposure today, but worth closing before it compounds.",fix:"Open Security → triage the breached attacks.",jumpTo:"security",jumpLabel:"Open Security"}),(a==null?void 0:a.status)==="warning"&&r.push({severity:"warning",dimension:"model",title:`Model supply-chain review — ${a.run.fail+a.run.drift+a.run.error} item${a.run.fail+a.run.drift+a.run.error===1?"":"s"}`,why:a.run.finding||"Model & Supply Chain produced findings or inconclusive checks below the blocking severity.",impact:"Artifact provenance, packaging or template integrity is not fully established for this release.",fix:"Open Security → Model & Supply Chain and triage the remaining findings.",jumpTo:"security",jumpLabel:"Open Model Security"}),l&&l.drift>0&&r.push({severity:"warning",dimension:"rag",title:`Retrieval drift — ${l.drift} quer${l.drift===1?"y":"ies"}`,why:"Retrieved context changed versus the golden baseline.",impact:"Answers may cite different sources — a silent quality regression.",fix:"Open RAG Assurance → diff this run against golden to see what moved.",jumpTo:"rag",jumpLabel:"RAG diff"}),l&&l.fail>0&&r.push({severity:"warning",dimension:"rag",title:`Retrieval failing — ${l.fail} quer${l.fail===1?"y":"ies"}`,why:"Retrieval scored below the acceptance bar on these queries.",impact:"Grounding quality is slipping; downstream answers get less reliable.",fix:"Open RAG Assurance → inspect the failing queries.",jumpTo:"rag",jumpLabel:"Open RAG"}),u){const d=fn(u);d!=null&&d<90&&r.push({severity:"warning",dimension:"perf",title:`Performance below SLO — ${d}% under target`,why:"The share of requests under the latency target fell below 90%.",impact:"Users may see slower responses; the SLO is at risk under load.",fix:"Open Performance → inspect p95 latency and the load profile.",jumpTo:"performance",jumpLabel:"Open Performance"})}c&&c.fail>0&&r.push({severity:"warning",dimension:"prompt",title:`Prompt regression — ${c.fail} prompt${c.fail===1?"":"s"}`,why:"Prompt goldens diverged from their expected output.",impact:"Agent behavior shifted on cases you'd pinned as correct.",fix:"Open Prompt Automation → re-run the failing prompts and update or fix.",jumpTo:"prompt-automation",jumpLabel:"Open Prompts"});for(const d of t)d.delta!=null&&d.delta>0&&r.push({severity:"observation",dimension:d.bucket,title:`${Nl[d.bucket]} improved +${d.delta}`,why:"Score rose since the last green deployment.",impact:"No action needed.",fix:"—"});return r}function O2(e,t,n,a){if(a==="unknown")return 0;if(n>0)return Math.round(80+t*20);const r=e!=null?Math.max(0,Math.min(1,(e-75)/25)):0;return Math.round((t*.6+r*.4)*100)}function L2(e,t){var S;const n=t.weights,a=A2(e,t),r=P2(a),i=w=>e.find(C=>C.pillar===w),o=w=>e.find(C=>PE(C.pillar)===w),l={security:i("security"),contracts:o("contracts"),rag:i("rag"),prompt:i("prompt"),perf:i("perf")},c=ul.map(w=>{const C=fn(l[w]),_=r?r.scores[w]:null;return{bucket:w,score:C,prev:_,delta:C!=null&&_!=null?C-_:null,weight:n[w],run:l[w]}}),u=c.filter(w=>w.score!=null),d=u.reduce((w,C)=>w+C.weight,0),h=d?Math.round(u.reduce((w,C)=>w+C.score*C.weight,0)/d):null,g=I2(e,t),v=$2(l,c,t,g),f=v.filter(w=>w.severity==="blocker"),y=v.filter(w=>w.severity==="warning"),b=v.filter(w=>w.severity==="observation"),m=h==null?"unknown":f.length?"blocked":h>=t.passAt?"pass":h>=t.reviewAt?"review":"blocked",x=u.length/ul.length,j=u.reduce((w,C)=>{var _;return w+(((_=C.run)==null?void 0:_.total)??0)},0);return{overall:h,verdict:m,reason:((S=f[0])==null?void 0:S.title)??null,pillars:c,modelSecurity:g,blockers:f,warnings:y,observations:b,timeline:a.slice(-10),lastGreen:r,overallDelta:h!=null&&(r==null?void 0:r.overall)!=null?h-r.overall:null,coverage:x,policyPass:m==="pass",confidence:O2(h,x,f.length,m),evidence:{level:x>=.8?"High":x>=.5?"Medium":"Low",runs:u.length,graded:j},estFixMinutes:f.length?f.length*8:null}}const M2="We couldn't complete this request. Please try again. If the problem continues, contact Prooflane support.";function LE(e){return e.startsWith("/connect")?"We couldn't connect to the MCP server. Verify the connection settings and try again.":e.startsWith("/intelligence")?"We couldn't complete this request. Please try again shortly. No generation credit was consumed.":M2}async function H(e,t,n="POST",a={},r){const i=t!==void 0,o=await Ka(),l={...a};i&&(l["content-type"]="application/json"),o&&(l.authorization=`Bearer ${o}`);const c=await fetch(`/api${e}`,{method:!i&&n==="POST"?"GET":n,headers:l,body:i?JSON.stringify(t):void 0,...r?{cache:r}:{}}),u=await c.text();let d=null;try{d=u?JSON.parse(u):null}catch{d=null}if(!c.ok){const h=typeof(d==null?void 0:d.error)=="string"?d.error:typeof(d==null?void 0:d.message)=="string"?d.message:`Request failed (${c.status})`,g=new Error(c.status>=500?LE(e):h);throw g.status=c.status,g.code=typeof(d==null?void 0:d.code)=="string"?d.code:void 0,g.targetId=typeof(d==null?void 0:d.targetId)=="string"?d.targetId:void 0,g.upgrade=!!(d!=null&&d.upgrade),g.reference=typeof(d==null?void 0:d.reference)=="string"?d.reference:void 0,g}return d}async function Aw(e){const t=await Ka(),n=await fetch(`/api${e}`,{headers:t?{authorization:`Bearer ${t}`}:{}}),a=await n.text();if(!n.ok){let r=`Request failed (${n.status})`;try{const o=JSON.parse(a);r=o.error||o.message||r}catch{}const i=new Error(n.status>=500?LE(e):r);throw i.status=n.status,i}return a}async function D2(e,t,n="GET"){const a=await fetch(`/api${e}`,{method:n,headers:{},body:void 0,cache:"no-store"}),r=await a.text();let i=null;try{i=r?JSON.parse(r):null}catch{i=null}if(!a.ok)throw new Error(typeof(i==null?void 0:i.error)=="string"?i.error:`Local request failed (${a.status}).`);return i}function Pw(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))a==null||a===""||Array.isArray(a)&&!a.length||t.set(n,Array.isArray(a)?a.join(","):String(a));return t.toString()}const L={connect:(e,t)=>H("/connect",{connection:e,name:t}),capabilities:()=>H("/capabilities",void 0,"GET"),mcpConnections:()=>H("/mcp/connections",void 0,"GET"),mcpTools:e=>H(`/mcp/tools${e?`?connectionId=${encodeURIComponent(e)}`:""}`,void 0,"GET"),mcpRefreshTools:e=>H(`/mcp/connections/${encodeURIComponent(e)}/refresh`,{}),mcpReconnectConnection:(e,t,n)=>H(`/mcp/connections/${encodeURIComponent(e)}/reconnect`,{connection:t,displayName:n}),mcpActivateConnection:e=>H(`/mcp/connections/${encodeURIComponent(e)}/activate`,{}),mcpDisconnectConnection:e=>H(`/mcp/connections/${encodeURIComponent(e)}/disconnect`,{}),mcpRemoveConnection:e=>H(`/mcp/connections/${encodeURIComponent(e)}`,void 0,"DELETE"),targets:()=>H("/targets",void 0,"GET"),targetConnect:(e,t)=>H("/targets",{config:e,displayName:t}),targetReconnect:(e,t,n)=>H(`/targets/${encodeURIComponent(e)}/reconnect`,{config:t,displayName:n}),targetActivate:e=>H(`/targets/${encodeURIComponent(e)}/activate`,{}),targetTest:e=>H(`/targets/${encodeURIComponent(e)}/test`,{}),targetRefresh:e=>H(`/targets/${encodeURIComponent(e)}/refresh`,{}),targetDisconnect:e=>H(`/targets/${encodeURIComponent(e)}/disconnect`,{}),targetRemove:e=>H(`/targets/${encodeURIComponent(e)}`,void 0,"DELETE"),mcpBinding:(e,t)=>H(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,void 0,"GET"),mcpPutBinding:(e,t,n)=>H(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,n,"PUT"),mcpDeleteBinding:(e,t)=>H(`/features/${e}/${encodeURIComponent(t)}/mcp-binding`,void 0,"DELETE"),mcpStartRun:(e,t,n)=>H(`/features/${e}/${encodeURIComponent(t)}/mcp-runs`,n?{runId:n}:{}),mcpInvokeRun:(e,t,n=3e4)=>H(`/mcp/runs/${encodeURIComponent(e)}/invoke`,{input:t,timeoutMs:n}),config:()=>H("/config",void 0,"GET",{},"no-store"),disconnect:()=>H("/disconnect",{}),httpRequest:e=>H("/http/request",e),httpSnapshot:(e,t,n="captured")=>H("/http/snapshot",{request:e,response:t,origin:n}),oauthStart:(e,t)=>H("/connect/oauth/start",{url:e,name:t}),oauthStatus:e=>H(`/connect/oauth/status?flowId=${encodeURIComponent(e)}`,void 0,"GET"),callTool:(e,t)=>H(`/tools/${encodeURIComponent(e)}/call`,{input:t}),executeCapability:e=>H("/security/execute-capability",e),verifyHostedCapability:e=>H("/security/verify-capability",e),snapshotTool:(e,t)=>H(`/tools/${encodeURIComponent(e)}/snapshot`,{input:t}),diffValues:(e,t,n)=>H("/diff/values",{tool:e,expected:t,actual:n}),drift:e=>H("/drift",{baseline:e}),readResource:e=>H("/resources/read",{uri:e}),getPrompt:(e,t)=>H(`/prompts/${encodeURIComponent(e)}/get`,{args:t}),recordStart:e=>H("/record/start",{label:e}),recordStatus:()=>H("/record/status",void 0,"GET"),recordStop:()=>H("/record/stop",{}),sessions:()=>H("/sessions",void 0,"GET"),session:e=>H(`/sessions/${e}`,void 0,"GET"),markGolden:(e,t)=>H(`/sessions/${e}/golden`,{golden:t}),automate:(e,t)=>H(`/sessions/${e}/automate`,{format:t}),fault:(e,t,n)=>H(`/sessions/${e}/fault`,{step:t,type:n}),snapshots:()=>H("/snapshots",void 0,"GET"),automateContracts:(e,t)=>H("/automate/contracts",{snapshotIds:e,format:t}),updateSnapshot:(e,t)=>H(`/snapshots/${encodeURIComponent(e)}`,t,"PATCH"),deleteSnapshot:e=>H(`/snapshots/${encodeURIComponent(e)}`,void 0,"DELETE"),generatePrompts:e=>H("/prompts/generate",{tool:e}),customPrompts:()=>H("/prompts/custom",void 0,"GET"),generateAiPrompts:(e,t,n,a)=>H("/prompts/generate-ai",{tool:e,count:t,temperature:n,llm:a}),setPromptGolden:(e,t,n)=>H(`/prompts/custom/${e}/golden`,{expected:t,assert:n}),setPromptChecks:(e,t)=>H(`/prompts/custom/${e}/checks`,t),assertTool:(e,t,n,a)=>H("/prompts/assert",{tool:e,input:t,assertions:n,checkSchema:a}),addCustomPrompt:(e,t,n)=>H("/prompts/custom",{name:e,content:t,tool:n}),updateCustomPrompt:(e,t)=>H(`/prompts/custom/${encodeURIComponent(e)}`,t,"PATCH"),deleteCustomPrompt:e=>H(`/prompts/custom/${e}`,void 0,"DELETE"),saveRun:e=>H("/runs",e),runs:e=>H(`/runs${e?`?limit=${e}`:""}`,void 0,"GET"),assuranceHistory:(e={})=>{const t=Pw(e);return H(`/assurance-history${t?`?${t}`:""}`,void 0,"GET")},assuranceHistoryBackfill:()=>H("/assurance-history/backfill",{}),assuranceHistoryCompare:(e,t)=>H("/assurance-history/compare",{leftId:e,rightId:t}),assuranceHistoryPatterns:()=>H("/assurance-history/patterns",void 0,"GET"),assuranceHistoryAsk:(e,t)=>H("/assurance-history/ask",{question:e,idempotencyKey:t}),assuranceHistoryJob:e=>H(`/assurance-history/jobs/${encodeURIComponent(e)}`,void 0,"GET"),assuranceHistoryCancelJob:e=>H(`/assurance-history/jobs/${encodeURIComponent(e)}/cancel`,{}),assuranceHistorySavedSearches:()=>H("/assurance-history/saved-searches",void 0,"GET"),assuranceHistorySaveSearch:(e,t,n=!1)=>H("/assurance-history/saved-searches",{name:e,query:t,shared:n}),assuranceHistoryAnnotate:(e,t,n)=>H(`/assurance-history/${encodeURIComponent(e)}/annotations`,{disposition:t,note:n}),assuranceHistoryPromotions:()=>H("/assurance-history/promotions",void 0,"GET"),assuranceHistoryPromote:(e,t,n=!0)=>H(`/assurance-history/patterns/${encodeURIComponent(e)}/promote`,{sourceRecordId:t,draftedBySammy:n}),assuranceHistoryCancelPromotion:e=>H(`/assurance-history/promotions/${encodeURIComponent(e)}`,{state:"CANCELLED"}),assuranceHistoryEnterprise:(e={})=>{const t=Pw(e);return H(`/assurance-history/enterprise${t?`?${t}`:""}`,void 0,"GET")},assuranceHistoryEvidenceVault:()=>H("/assurance-history/evidence-vault",void 0,"GET"),assuranceHistoryRetention:e=>H("/assurance-history/enterprise/retention",{before:e}),assuranceHistoryAuditExport:(e,t)=>{const n=new URLSearchParams;return e&&n.set("from",e),t&&n.set("to",t),H(`/assurance-history/enterprise/audit-export${n.size?`?${n.toString()}`:""}`,void 0,"GET")},modelScanRun:e=>H("/model-scans/run",e),modelScans:(e=25)=>H(`/model-scans?limit=${e}`,void 0,"GET"),modelScan:e=>H(`/model-scans/${encodeURIComponent(e)}`,void 0,"GET"),deleteModelScan:e=>H(`/model-scans/${encodeURIComponent(e)}`,void 0,"DELETE"),exportModelScan:async(e,t)=>{var d;const n=await Ka(),a={};n&&(a.authorization=`Bearer ${n}`);const r=await fetch(`/api/model-scans/${encodeURIComponent(e)}/export?format=${t}`,{headers:a});if(!r.ok)throw new Error(`Export failed (${r.status}).`);const i=await r.blob(),l=((d=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:d[1])??`prooflane-model-scan.${t==="sarif"?"sarif.json":t}`,c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=l,u.click(),setTimeout(()=>URL.revokeObjectURL(c),1e3)},modelSecurityCatalog:()=>H("/model-security/packs",void 0,"GET"),modelSecurityHistory:(e=50)=>H(`/model-security?limit=${e}`,void 0,"GET"),modelSecurityScan:e=>H(`/model-security/${encodeURIComponent(e)}`,void 0,"GET"),deleteModelSecurityScan:e=>H(`/model-security/${encodeURIComponent(e)}`,void 0,"DELETE"),modelSecurityRunStream:async(e,t,n)=>{const a=await Ka(),r={"content-type":"application/json"};a&&(r.authorization=`Bearer ${a}`);const i=await fetch("/api/model-security/run",{method:"POST",headers:r,body:JSON.stringify({...e,stream:!0}),signal:n});if(!i.ok||!i.body){const d=await i.text().catch(()=>""),h=d?(()=>{try{return JSON.parse(d)}catch{return null}})():null;return{ok:!1,error:(h==null?void 0:h.error)||`Request failed (${i.status})`}}const o=i.body.getReader(),l=new TextDecoder;let c="",u={ok:!1,error:"The scan stream ended without a result."};for(;;){const d=await o.read();if(d.done)break;c+=l.decode(d.value,{stream:!0});let h;for(;(h=c.indexOf(`
|
|
45
45
|
`))>=0;){const g=c.slice(0,h).trim();if(c=c.slice(h+1),!g)continue;let v;try{v=JSON.parse(g)}catch{continue}v.t==="progress"&&v.event?t(v.event):v.t==="done"&&(u={ok:!!v.ok,report:v.report,error:v.error})}}return u},exportModelSecurityScan:async(e,t)=>{var d;const n=await Ka(),a={};n&&(a.authorization=`Bearer ${n}`);const r=await fetch(`/api/model-security/${encodeURIComponent(e)}/export?format=${t}`,{headers:a});if(!r.ok)throw new Error(`Export failed (${r.status}).`);const i=await r.blob(),l=((d=(r.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:d[1])??`prooflane-model-supply-chain.${t==="sarif"?"sarif.json":t}`,c=URL.createObjectURL(i),u=document.createElement("a");u.href=c,u.download=l,u.click(),setTimeout(()=>URL.revokeObjectURL(c),1e3)},tagsList:()=>H("/tags",void 0,"GET"),tagUpsert:e=>H("/tags",{test:e}),tagRemove:e=>H(`/tags/${encodeURIComponent(e)}`,void 0,"DELETE"),runAgent:(e,t,n,a)=>H("/prompts/run-agent",{tool:e,prompt:t,llm:n,case:a}),redteamCatalog:e=>H(`/redteam/catalog${e?`?layer=${e}`:""}`,void 0,"GET"),redteamPacks:()=>H("/redteam/packs",void 0,"GET"),redteamCampaigns:()=>H("/redteam/campaigns",void 0,"GET"),redteamCampaignRun:(e,t)=>H("/redteam/campaign",{id:e,llm:t}),ragRun:e=>H("/rag/run",e),ragDiff:(e,t=!1)=>H(`/rag/${t?"hosted-diff":"diff"}/${e}`,void 0,"GET"),redteamRun:(e,t,n)=>H("/redteam/run",{layer:e,llm:t,attackIds:n}),redteamRunStream:async(e,t,n,a,r,i)=>{const o=await Ka(),l={"content-type":"application/json"};o&&(l.authorization=`Bearer ${o}`);const c=await fetch("/api/redteam/run",{method:"POST",headers:l,body:JSON.stringify({layer:e,llm:t,attackIds:n,stream:!0,recordHistory:i==null?void 0:i.recordHistory}),signal:r});if(!c.ok||!c.body){const v=await c.text().catch(()=>""),f=v?(()=>{try{return JSON.parse(v)}catch{return null}})():null;return{ok:!1,error:(f==null?void 0:f.error)||`Request failed (${c.status})`}}const u=c.body.getReader(),d=new TextDecoder;let h="",g={ok:!1,error:"stream ended without a result"};for(;;){const{value:v,done:f}=await u.read();if(f)break;h+=d.decode(v,{stream:!0});let y;for(;(y=h.indexOf(`
|
|
46
|
-
`))>=0;){const b=h.slice(0,y).trim();if(h=h.slice(y+1),!b)continue;let m;try{m=JSON.parse(b)}catch{continue}m.t==="progress"?a({done:Number(m.done),total:Number(m.total),id:String(m.id),name:String(m.name),severity:String(m.severity)}):m.t==="done"&&(g={ok:!!m.ok,report:m.report,run:m.run,error:m.error})}}return g},perfRun:(e,t,n,a)=>H("/perf/run",{target:e,vus:t,durationS:n,targetMs:a}),llmRun:e=>H("/llm/run",e),workspaceConsent:(e,t,n)=>H("/workspace/consent",{version:e,termsAccepted:t,dataProcessingAccepted:n}),ciToken:()=>H("/ci/token",{}),githubOidcTrust:()=>H("/governance/github-oidc-trust",void 0,"GET"),githubOidcTrustSave:e=>H("/governance/github-oidc-trust",e,"PUT"),githubOidcTrustRevoke:()=>H("/governance/github-oidc-trust",void 0,"DELETE"),legacyRegressionGroupsList:()=>H("/gates",void 0,"GET"),legacyRegressionGroupSave:e=>H(`/gates/${encodeURIComponent(e.id)}`,{gate:e},"PUT"),legacyRegressionGroupRemove:e=>H(`/gates/${encodeURIComponent(e)}`,void 0,"DELETE"),suitesList:()=>H("/suites",void 0,"GET"),suiteCreate:e=>H("/suites",e),suiteArchive:e=>H(`/suites/${encodeURIComponent(e)}`,void 0,"DELETE"),suiteCreateVersion:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions`,t),suiteUpdateDraft:(e,t,n)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),suiteReview:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/review`,{}),suiteApprove:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/approve`,{}),suiteDeprecate:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),suiteAssessDrift:e=>H(`/governance/suites/${encodeURIComponent(e)}/drift`,{}),localSuiteMigrationStatus:()=>H("/suite-migration/status",void 0,"GET"),localSuiteMigrationSync:e=>H("/suite-migration/sync",{selections:e}),policiesList:()=>H("/policies",void 0,"GET"),governedRuns:(e=50)=>H(`/governed-runs?limit=${e}`,void 0,"GET"),policyCreate:e=>H("/policies",e),policyCreateVersion:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions`,t),policyUpdateDraft:(e,t,n)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),policyReview:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/review`,{}),policyApprove:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/approve`,{}),policyDeprecate:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGatesList:(e=!1)=>H(`/governance/gates${e?"?includeArchived=true":""}`,void 0,"GET"),governedGateCreate:e=>H("/governance/gates",e),governedGateGet:e=>H(`/governance/gates/${encodeURIComponent(e)}`,void 0,"GET"),governedGateRename:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}`,{displayName:t},"PATCH"),governedGateArchive:e=>H(`/governance/gates/${encodeURIComponent(e)}/archive`,{}),governedGateRestore:e=>H(`/governance/gates/${encodeURIComponent(e)}/restore`,{}),governedGateCreateVersion:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions`,t),governedGateGetVersion:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,void 0,"GET"),governedGateUpdateDraft:(e,t,n)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),governedGateReview:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/review`,{}),governedGateApprove:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/approve`,{}),governedGateDeprecate:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGateAliases:e=>H(`/governance/gates/${encodeURIComponent(e)}/aliases`,void 0,"GET"),governedGateAudit:(e,t=50)=>H(`/governance/gates/${encodeURIComponent(e)}/audit?limit=${t}`,void 0,"GET"),governedGateResolve:e=>H(`/governance/gates/${encodeURIComponent(e)}/resolve`,void 0,"GET"),governedGateRunLocal:e=>H(`/governance/gates/${encodeURIComponent(e)}/runs`,{}),governedGateStartLocalJob:e=>H(`/governance/gates/${encodeURIComponent(e)}/local-jobs`,{}),governedGateJobsLocal:(e=50)=>H(`/governance/local-gate-jobs?limit=${e}`,void 0,"GET"),governedGateJobLocal:e=>H(`/governance/local-gate-jobs/${encodeURIComponent(e)}`,void 0,"GET"),governedGateReportsLocal:(e=100)=>H(`/governance/gate-run-reports?limit=${e}`,void 0,"GET"),governedGateReportLocal:e=>H(`/governance/gate-run-reports/${encodeURIComponent(e)}`,void 0,"GET"),governedGateSpineReportLocal:e=>Aw(`/governance/gate-run-reports/${encodeURIComponent(e)}/report.html`),remoteRunners:()=>H("/governance/runners",void 0,"GET"),remoteRunnerRevoke:e=>H(`/governance/runners/${encodeURIComponent(e)}/revoke`,{}),governedGateRunRemote:(e,t,n)=>H(`/governance/gates/${encodeURIComponent(e)}/remote-runs`,{schemaVersion:"prooflane-remote-gate-run-request-v1",runnerId:t,requestId:n}),remoteRunnerJob:e=>H(`/governance/runner-jobs/${encodeURIComponent(e)}`,void 0,"GET"),remoteRunnerJobCancel:e=>H(`/governance/runner-jobs/${encodeURIComponent(e)}/cancel`,{}),governedGateSigningKey:e=>H(`/governance/gate-signing-keys/${encodeURIComponent(e)}`,void 0,"GET"),learningFindings:e=>H(`/governance/learning/runs/${encodeURIComponent(e)}/findings`,void 0,"GET"),learningDisposition:e=>H(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,void 0,"GET"),learningDispositionApprove:(e,t)=>H(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,t,"PUT"),learningGenerations:(e=50)=>H(`/governance/learning/generations?limit=${e}`,void 0,"GET"),learningGenerate:e=>H("/governance/learning/generations",{schemaVersion:"prooflane-learning-generation-request-v1"},"POST",{"idempotency-key":e}),learnedTests:(e=100)=>H(`/governance/learning/tests?limit=${e}`,void 0,"GET"),learnedTestReview:e=>H(`/governance/learning/tests/${encodeURIComponent(e)}/review`,{}),learnedTestApprove:e=>H(`/governance/learning/tests/${encodeURIComponent(e)}/approve`,{}),learningAudit:(e=100)=>H(`/governance/learning/audit?limit=${e}`,void 0,"GET"),legacyAssuranceBindings:()=>H("/assurance/gates",void 0,"GET",{},"no-store"),assurancePolicies:()=>H("/assurance/policies",void 0,"GET"),assurancePolicyCreate:e=>H("/assurance/policies",e),legacyAssuranceBindingPolicyUpdate:(e,t)=>H(`/assurance/gates/${encodeURIComponent(e)}/policy`,{policyVersion:t},"PATCH"),assuranceGateRun:e=>H(`/assurance/gates/${encodeURIComponent(e)}/runs`,{}),assuranceRun:e=>H(`/assurance/runs/${encodeURIComponent(e)}`,void 0,"GET"),assuranceRunReport:e=>Aw(`/assurance/runs/${encodeURIComponent(e)}/report`),assuranceRunCancel:e=>H(`/assurance/runs/${encodeURIComponent(e)}/cancel`,{}),sammyAnalyze:e=>H("/intelligence/analyze-options",e),intelligenceSurface:()=>H("/intelligence/surface",void 0,"GET",{},"no-store"),intelligenceSurfaceRefresh:()=>H("/intelligence/surface/refresh",{}),sammyGenerate:e=>H("/intelligence/generations",e),sammyGenerationJobCreate:e=>H("/intelligence/generation-jobs",e),sammyGenerationJob:e=>H(`/intelligence/generation-jobs/${encodeURIComponent(e)}`,void 0,"GET",{},"no-store"),sammyGenerationJobCancel:e=>H(`/intelligence/generation-jobs/${encodeURIComponent(e)}/cancel`,{}),evaluationAssetCreate:(e,t)=>H("/intelligence/evaluation-assets",{definition:e,...t?{localRef:t}:{}}),evaluationSession:()=>H("/intelligence/evaluation-session",void 0,"GET",{},"no-store"),evaluationSessionConfigure:e=>H("/intelligence/evaluation-session",e,"PUT"),evaluationSessionClear:()=>H("/intelligence/evaluation-session",void 0,"DELETE"),evaluationSessionTest:e=>H("/intelligence/evaluation-session/test",e),evaluationPreview:(e,t)=>H("/intelligence/evaluation-previews",{localRefs:e,executionMode:t}),sammyGeneration:e=>H(`/intelligence/generations/${encodeURIComponent(e)}`,void 0,"GET"),sammyGenerationReview:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/review`,t),sammyGenerationApprove:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/approve`,t),sammyGenerationAddManualItem:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/items/manual`,t),sammyGenerationReviewItem:(e,t,n)=>H(`/intelligence/generations/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}/review`,n),sammyMaterializeSuite:e=>H(`/intelligence/generations/${encodeURIComponent(e)}/materialize-suite`,{}),intelligenceNativeArtifacts:(e,t)=>H(`/intelligence/native-artifacts?pillar=${e}${t?`&generationId=${encodeURIComponent(t)}`:""}`,void 0,"GET"),intelligenceNativeArtifactReview:(e,t,n)=>H(`/intelligence/native-artifacts/${encodeURIComponent(e)}/${encodeURIComponent(t)}/review`,n),regoldenVerifiedBaseline:(e,t)=>H("/contracts/verified-baselines/regolden",{baseline:e,verifiedBy:t}),sammyDatasets:()=>H("/intelligence/datasets",void 0,"GET"),sammyDatasetAdd:e=>H("/intelligence/datasets",e),annotationCreate:e=>H("/annotations",e),assuranceRunEvents:(e,t,n)=>{const a=new EventSource(`/api/assurance/runs/${encodeURIComponent(e)}/events`),r=["RUN_CREATED","RUN_STARTED","SUITE_LOADED","PILLAR_STARTED","TEST_STARTED","TEST_LOG","TEST_COMPLETED","FINDING_CREATED","PILLAR_COMPLETED","GATE_EVALUATING","GATE_DECIDED","RUN_COMPLETED","RUN_CANCELLED","RUN_FAILED"];for(const i of r)a.addEventListener(i,o=>{try{t(JSON.parse(o.data))}catch{}});return a.onerror=n,()=>a.close()},workspaceStatus:()=>H("/workspace/status",void 0,"GET"),gateRuns:(e=200)=>H(`/gate-runs?limit=${e}`,void 0,"GET"),syncGateRuns:e=>H("/gate-runs",{version:"prooflane-gate-runs-v1",runs:e.map(t=>({id:t.id,pillar:t.pillar,label:t.label,total:t.total,pass:t.pass,drift:t.drift,fail:t.fail,error:t.error,...t.score==null?{}:{score:t.score},...t.severity==null?{}:{severity:t.severity},...t.poisoned==null?{}:{poisoned:t.poisoned},...t.exposureSeverity==null?{}:{exposureSeverity:t.exposureSeverity},...t.durationMs==null?{}:{durationMs:t.durationMs},createdAt:t.createdAt,source:"inspector"}))}),workspaceBackupPreference:(e=24)=>H("/workspace/backup-preference",{automaticBackupAccepted:!0,cadenceHours:e}),workspaceBackup:()=>H("/workspace/backup",{releasePolicy:T2()}),workspaceLatestBackup:(e=!1)=>H(`/workspace/backup/latest${e?"?restorable=1":""}`,void 0,"GET"),workspaceBackupVersions:(e=50)=>H(`/workspace/backup/versions?limit=${e}`,void 0,"GET"),workspaceRestore:()=>H("/workspace/restore",{}),localWorkspaceLifecycle:async(e,t,n)=>{const a=await fetch("/api/workspace/local/lifecycle",{method:"POST",headers:{"content-type":"application/json","x-kawach-local-lifecycle":e},body:JSON.stringify({reason:t,subject:n})});if(!a.ok)throw new Error("Could not secure the local workspace.");return a.json()},intelligenceLease:(e,t=1)=>H("/intelligence/leases",{pillar:e,count:t}),securityAuthContext:()=>D2("/security/auth-context"),saveSecurityAuthProfile:e=>H("/security/auth-context/profiles",e),deleteSecurityAuthProfile:e=>H(`/security/auth-context/profiles/${encodeURIComponent(e)}`,void 0,"DELETE"),destroySecurityAuthSession:e=>H(`/security/auth-context/sessions/${encodeURIComponent(e)}/destroy`,{}),preflightSecurityAuth:e=>H("/security/auth-context/preflight",e),securityScanCreate:(e,t,n)=>H("/security/scans",{target:{name:e,type:"agent"},requestedControlIds:t,...n?{authContext:n}:{}}),hostedSecurityCatalog:()=>H("/security/catalog",void 0,"GET"),ragScanCreate:(e,t)=>H("/rag/scans",{target:{name:e,type:"rag"},requestedControlIds:t}),assuranceScanSnapshot:(e,t)=>H(`/${e}/scans/${encodeURIComponent(t)}`,void 0,"GET"),assuranceScanNextTask:(e,t)=>H(`/${e}/scans/${encodeURIComponent(t)}/next-task`,{}),assuranceScanEvidence:(e,t,n,a)=>H(`/${e}/scans/${encodeURIComponent(t)}/evidence`,{lease:n,evidence:a}),securityScanNextTask:e=>H(`/security/scans/${encodeURIComponent(e)}/next-task`,{}),securityScanEvidence:(e,t,n)=>H(`/security/scans/${encodeURIComponent(e)}/evidence`,{lease:t,evidence:n}),intelligenceExecute:e=>H("/intelligence/execute",e),intelligenceEvidence:(e,t)=>H("/intelligence/evidence",{lease:e,evidence:t}),intelligenceEvaluation:(e,t)=>H("/intelligence/evaluations",{lease:e,execution:t}),benchmarkRun:e=>H("/benchmark/run",e),benchmarkEntitlements:()=>H("/benchmark/entitlements",void 0,"GET"),benchmarkVerifyPurchase:e=>H("/benchmark/purchases/verify",e),benchmarkPlan:e=>H("/benchmark/plans",e),benchmarkReviseJudgingStrategy:(e,t)=>H("/benchmark/plans/judging-strategy",{plan:e,strategy:t}),benchmarkRunStream:async(e,t,n)=>{const a=await Ka(),r={"content-type":"application/json"};a&&(r.authorization=`Bearer ${a}`);const i=await fetch("/api/benchmark/run",{method:"POST",headers:r,body:JSON.stringify({...e,stream:!0}),signal:n});if(!i.ok||!i.body){const d=await i.text().catch(()=>""),h=d?(()=>{try{return JSON.parse(d)}catch{return null}})():null;return{ok:!1,error:(h==null?void 0:h.error)??`Request failed (${i.status})`,preflight:h==null?void 0:h.preflight}}const o=i.body.getReader(),l=new TextDecoder;let c="",u={ok:!1,error:"The benchmark stream ended without a result."};for(;;){const{value:d,done:h}=await o.read();if(h)break;c+=l.decode(d,{stream:!0});let g;for(;(g=c.indexOf(`
|
|
46
|
+
`))>=0;){const b=h.slice(0,y).trim();if(h=h.slice(y+1),!b)continue;let m;try{m=JSON.parse(b)}catch{continue}m.t==="progress"?a({done:Number(m.done),total:Number(m.total),id:String(m.id),name:String(m.name),severity:String(m.severity)}):m.t==="done"&&(g={ok:!!m.ok,report:m.report,run:m.run,error:m.error})}}return g},perfRun:(e,t,n,a)=>H("/perf/run",{target:e,vus:t,durationS:n,targetMs:a}),llmRun:e=>H("/llm/run",e),workspaceConsent:(e,t,n)=>H("/workspace/consent",{version:e,termsAccepted:t,dataProcessingAccepted:n}),ciToken:()=>H("/ci/token",{}),githubOidcTrust:()=>H("/governance/github-oidc-trust",void 0,"GET"),githubOidcTrustSave:e=>H("/governance/github-oidc-trust",e,"PUT"),githubOidcTrustRevoke:()=>H("/governance/github-oidc-trust",void 0,"DELETE"),legacyRegressionGroupsList:()=>H("/gates",void 0,"GET"),legacyRegressionGroupSave:e=>H(`/gates/${encodeURIComponent(e.id)}`,{gate:e},"PUT"),legacyRegressionGroupRemove:e=>H(`/gates/${encodeURIComponent(e)}`,void 0,"DELETE"),suitesList:()=>H("/suites",void 0,"GET"),suiteCreate:e=>H("/suites",e),suiteArchive:e=>H(`/suites/${encodeURIComponent(e)}`,void 0,"DELETE"),suiteCreateVersion:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions`,t),suiteUpdateDraft:(e,t,n)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),suiteReview:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/review`,{}),suiteApprove:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/approve`,{}),suiteDeprecate:(e,t)=>H(`/suites/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),suiteAssessDrift:e=>H(`/governance/suites/${encodeURIComponent(e)}/drift`,{}),localSuiteMigrationStatus:()=>H("/suite-migration/status",void 0,"GET"),localSuiteMigrationSync:e=>H("/suite-migration/sync",{selections:e}),policiesList:()=>H("/policies",void 0,"GET"),governedRuns:(e=50)=>H(`/governed-runs?limit=${e}`,void 0,"GET"),policyCreate:e=>H("/policies",e),policyCreateVersion:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions`,t),policyUpdateDraft:(e,t,n)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),policyReview:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/review`,{}),policyApprove:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/approve`,{}),policyDeprecate:(e,t)=>H(`/policies/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGatesList:(e=!1)=>H(`/governance/gates${e?"?includeArchived=true":""}`,void 0,"GET"),governedGateCreate:e=>H("/governance/gates",e),governedGateGet:e=>H(`/governance/gates/${encodeURIComponent(e)}`,void 0,"GET"),governedGateRename:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}`,{displayName:t},"PATCH"),governedGateArchive:e=>H(`/governance/gates/${encodeURIComponent(e)}/archive`,{}),governedGateRestore:e=>H(`/governance/gates/${encodeURIComponent(e)}/restore`,{}),governedGateCreateVersion:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions`,t),governedGateGetVersion:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,void 0,"GET"),governedGateUpdateDraft:(e,t,n)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}`,{manifest:n},"PUT"),governedGateReview:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/review`,{}),governedGateApprove:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/approve`,{}),governedGateDeprecate:(e,t)=>H(`/governance/gates/${encodeURIComponent(e)}/versions/${t}/deprecate`,{}),governedGateAliases:e=>H(`/governance/gates/${encodeURIComponent(e)}/aliases`,void 0,"GET"),governedGateAudit:(e,t=50)=>H(`/governance/gates/${encodeURIComponent(e)}/audit?limit=${t}`,void 0,"GET"),governedGateResolve:e=>H(`/governance/gates/${encodeURIComponent(e)}/resolve`,void 0,"GET"),governedGateRunLocal:e=>H(`/governance/gates/${encodeURIComponent(e)}/runs`,{}),governedGateStartLocalJob:e=>H(`/governance/gates/${encodeURIComponent(e)}/local-jobs`,{}),governedGateJobsLocal:(e=50)=>H(`/governance/local-gate-jobs?limit=${e}`,void 0,"GET"),governedGateJobLocal:e=>H(`/governance/local-gate-jobs/${encodeURIComponent(e)}`,void 0,"GET"),governedGateReportsLocal:(e=100)=>H(`/governance/gate-run-reports?limit=${e}`,void 0,"GET"),governedGateReportLocal:e=>H(`/governance/gate-run-reports/${encodeURIComponent(e)}`,void 0,"GET"),governedGateSpineReportLocal:e=>Aw(`/governance/gate-run-reports/${encodeURIComponent(e)}/report.html`),remoteRunners:()=>H("/governance/runners",void 0,"GET"),remoteRunnerRevoke:e=>H(`/governance/runners/${encodeURIComponent(e)}/revoke`,{}),governedGateRunRemote:(e,t,n)=>H(`/governance/gates/${encodeURIComponent(e)}/remote-runs`,{schemaVersion:"prooflane-remote-gate-run-request-v1",runnerId:t,requestId:n}),remoteRunnerJob:e=>H(`/governance/runner-jobs/${encodeURIComponent(e)}`,void 0,"GET"),remoteRunnerJobCancel:e=>H(`/governance/runner-jobs/${encodeURIComponent(e)}/cancel`,{}),governedGateSigningKey:e=>H(`/governance/gate-signing-keys/${encodeURIComponent(e)}`,void 0,"GET"),learningFindings:e=>H(`/governance/learning/runs/${encodeURIComponent(e)}/findings`,void 0,"GET"),learningDisposition:e=>H(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,void 0,"GET"),learningDispositionApprove:(e,t)=>H(`/governance/learning/runs/${encodeURIComponent(e)}/disposition`,t,"PUT"),learningGenerations:(e=50)=>H(`/governance/learning/generations?limit=${e}`,void 0,"GET"),learningGenerate:e=>H("/governance/learning/generations",{schemaVersion:"prooflane-learning-generation-request-v1"},"POST",{"idempotency-key":e}),learnedTests:(e=100)=>H(`/governance/learning/tests?limit=${e}`,void 0,"GET"),learnedTestReview:e=>H(`/governance/learning/tests/${encodeURIComponent(e)}/review`,{}),learnedTestApprove:e=>H(`/governance/learning/tests/${encodeURIComponent(e)}/approve`,{}),learningAudit:(e=100)=>H(`/governance/learning/audit?limit=${e}`,void 0,"GET"),legacyAssuranceBindings:()=>H("/assurance/gates",void 0,"GET",{},"no-store"),assurancePolicies:()=>H("/assurance/policies",void 0,"GET"),assurancePolicyCreate:e=>H("/assurance/policies",e),legacyAssuranceBindingPolicyUpdate:(e,t)=>H(`/assurance/gates/${encodeURIComponent(e)}/policy`,{policyVersion:t},"PATCH"),assuranceGateRun:e=>H(`/assurance/gates/${encodeURIComponent(e)}/runs`,{}),assuranceRun:e=>H(`/assurance/runs/${encodeURIComponent(e)}`,void 0,"GET"),assuranceRunReport:e=>Aw(`/assurance/runs/${encodeURIComponent(e)}/report`),assuranceRunCancel:e=>H(`/assurance/runs/${encodeURIComponent(e)}/cancel`,{}),sammyAnalyze:e=>H("/intelligence/analyze-options",e),intelligenceSurface:()=>H("/intelligence/surface",void 0,"GET",{},"no-store"),intelligenceSurfaceRefresh:()=>H("/intelligence/surface/refresh",{}),sammyGenerate:e=>H("/intelligence/generations",e),sammyGenerationJobCreate:e=>H("/intelligence/generation-jobs",e),sammyGenerationJob:e=>H(`/intelligence/generation-jobs/${encodeURIComponent(e)}`,void 0,"GET",{},"no-store"),sammyGenerationJobCancel:e=>H(`/intelligence/generation-jobs/${encodeURIComponent(e)}/cancel`,{}),evaluationAssetCreate:(e,t)=>H("/intelligence/evaluation-assets",{definition:e,...t?{localRef:t}:{}}),evaluationSession:()=>H("/intelligence/evaluation-session",void 0,"GET",{},"no-store"),evaluationSessionConfigure:e=>H("/intelligence/evaluation-session",e,"PUT"),evaluationSessionClear:()=>H("/intelligence/evaluation-session",void 0,"DELETE"),evaluationSessionTest:e=>H("/intelligence/evaluation-session/test",e),evaluationPreview:(e,t)=>H("/intelligence/evaluation-previews",{localRefs:e,executionMode:t}),sammyGeneration:e=>H(`/intelligence/generations/${encodeURIComponent(e)}`,void 0,"GET"),sammyGenerationReview:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/review`,t),sammyGenerationApprove:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/approve`,t),sammyGenerationAddManualItem:(e,t)=>H(`/intelligence/generations/${encodeURIComponent(e)}/items/manual`,t),sammyGenerationReviewItem:(e,t,n)=>H(`/intelligence/generations/${encodeURIComponent(e)}/items/${encodeURIComponent(t)}/review`,n),sammyMaterializeSuite:e=>H(`/intelligence/generations/${encodeURIComponent(e)}/materialize-suite`,{}),intelligenceNativeArtifacts:(e,t)=>H(`/intelligence/native-artifacts?pillar=${e}${t?`&generationId=${encodeURIComponent(t)}`:""}`,void 0,"GET",{},"no-store"),intelligenceNativeArtifactReview:(e,t,n)=>H(`/intelligence/native-artifacts/${encodeURIComponent(e)}/${encodeURIComponent(t)}/review`,n),regoldenVerifiedBaseline:(e,t)=>H("/contracts/verified-baselines/regolden",{baseline:e,verifiedBy:t}),sammyDatasets:()=>H("/intelligence/datasets",void 0,"GET"),sammyDatasetAdd:e=>H("/intelligence/datasets",e),annotationCreate:e=>H("/annotations",e),assuranceRunEvents:(e,t,n)=>{const a=new EventSource(`/api/assurance/runs/${encodeURIComponent(e)}/events`),r=["RUN_CREATED","RUN_STARTED","SUITE_LOADED","PILLAR_STARTED","TEST_STARTED","TEST_LOG","TEST_COMPLETED","FINDING_CREATED","PILLAR_COMPLETED","GATE_EVALUATING","GATE_DECIDED","RUN_COMPLETED","RUN_CANCELLED","RUN_FAILED"];for(const i of r)a.addEventListener(i,o=>{try{t(JSON.parse(o.data))}catch{}});return a.onerror=n,()=>a.close()},workspaceStatus:()=>H("/workspace/status",void 0,"GET"),gateRuns:(e=200)=>H(`/gate-runs?limit=${e}`,void 0,"GET"),syncGateRuns:e=>H("/gate-runs",{version:"prooflane-gate-runs-v1",runs:e.map(t=>({id:t.id,pillar:t.pillar,label:t.label,total:t.total,pass:t.pass,drift:t.drift,fail:t.fail,error:t.error,...t.score==null?{}:{score:t.score},...t.severity==null?{}:{severity:t.severity},...t.poisoned==null?{}:{poisoned:t.poisoned},...t.exposureSeverity==null?{}:{exposureSeverity:t.exposureSeverity},...t.durationMs==null?{}:{durationMs:t.durationMs},createdAt:t.createdAt,source:"inspector"}))}),workspaceBackupPreference:(e=24)=>H("/workspace/backup-preference",{automaticBackupAccepted:!0,cadenceHours:e}),workspaceBackup:()=>H("/workspace/backup",{releasePolicy:T2()}),workspaceLatestBackup:(e=!1)=>H(`/workspace/backup/latest${e?"?restorable=1":""}`,void 0,"GET"),workspaceBackupVersions:(e=50)=>H(`/workspace/backup/versions?limit=${e}`,void 0,"GET"),workspaceRestore:()=>H("/workspace/restore",{}),localWorkspaceLifecycle:async(e,t,n)=>{const a=await fetch("/api/workspace/local/lifecycle",{method:"POST",headers:{"content-type":"application/json","x-kawach-local-lifecycle":e},body:JSON.stringify({reason:t,subject:n})});if(!a.ok)throw new Error("Could not secure the local workspace.");return a.json()},intelligenceLease:(e,t=1)=>H("/intelligence/leases",{pillar:e,count:t}),securityAuthContext:()=>D2("/security/auth-context"),saveSecurityAuthProfile:e=>H("/security/auth-context/profiles",e),deleteSecurityAuthProfile:e=>H(`/security/auth-context/profiles/${encodeURIComponent(e)}`,void 0,"DELETE"),destroySecurityAuthSession:e=>H(`/security/auth-context/sessions/${encodeURIComponent(e)}/destroy`,{}),preflightSecurityAuth:e=>H("/security/auth-context/preflight",e),securityScanCreate:(e,t,n)=>H("/security/scans",{target:{name:e,type:"agent"},requestedControlIds:t,...n?{authContext:n}:{}}),hostedSecurityCatalog:()=>H("/security/catalog",void 0,"GET"),ragScanCreate:(e,t)=>H("/rag/scans",{target:{name:e,type:"rag"},requestedControlIds:t}),assuranceScanSnapshot:(e,t)=>H(`/${e}/scans/${encodeURIComponent(t)}`,void 0,"GET"),assuranceScanNextTask:(e,t)=>H(`/${e}/scans/${encodeURIComponent(t)}/next-task`,{}),assuranceScanEvidence:(e,t,n,a)=>H(`/${e}/scans/${encodeURIComponent(t)}/evidence`,{lease:n,evidence:a}),securityScanNextTask:e=>H(`/security/scans/${encodeURIComponent(e)}/next-task`,{}),securityScanEvidence:(e,t,n)=>H(`/security/scans/${encodeURIComponent(e)}/evidence`,{lease:t,evidence:n}),intelligenceExecute:e=>H("/intelligence/execute",e),intelligenceEvidence:(e,t)=>H("/intelligence/evidence",{lease:e,evidence:t}),intelligenceEvaluation:(e,t)=>H("/intelligence/evaluations",{lease:e,execution:t}),benchmarkRun:e=>H("/benchmark/run",e),benchmarkEntitlements:()=>H("/benchmark/entitlements",void 0,"GET"),benchmarkVerifyPurchase:e=>H("/benchmark/purchases/verify",e),benchmarkPlan:e=>H("/benchmark/plans",e),benchmarkReviseJudgingStrategy:(e,t)=>H("/benchmark/plans/judging-strategy",{plan:e,strategy:t}),benchmarkRunStream:async(e,t,n)=>{const a=await Ka(),r={"content-type":"application/json"};a&&(r.authorization=`Bearer ${a}`);const i=await fetch("/api/benchmark/run",{method:"POST",headers:r,body:JSON.stringify({...e,stream:!0}),signal:n});if(!i.ok||!i.body){const d=await i.text().catch(()=>""),h=d?(()=>{try{return JSON.parse(d)}catch{return null}})():null;return{ok:!1,error:(h==null?void 0:h.error)??`Request failed (${i.status})`,preflight:h==null?void 0:h.preflight}}const o=i.body.getReader(),l=new TextDecoder;let c="",u={ok:!1,error:"The benchmark stream ended without a result."};for(;;){const{value:d,done:h}=await o.read();if(h)break;c+=l.decode(d,{stream:!0});let g;for(;(g=c.indexOf(`
|
|
47
47
|
`))>=0;){const v=c.slice(0,g).trim();if(c=c.slice(g+1),!v)continue;let f;try{f=JSON.parse(v)}catch{continue}f.t==="progress"?t(f):f.t==="done"?u={ok:!0,report:f.report,workflow:f.workflow}:f.t==="error"&&(u={ok:!1,error:String(f.error??"The benchmark failed.")})}}return u},benchmarkHistory:()=>H("/benchmark/history",void 0,"GET"),benchmarkStoredRun:e=>H(`/benchmark/runs/${encodeURIComponent(e)}`,void 0,"GET"),benchmarkGenerateEvidence:e=>H("/benchmark/evidence/generate",e),ragRunStream:async(e,t,n,a=!1)=>{const r=await Ka(),i={"content-type":"application/json"};r&&(i.authorization=`Bearer ${r}`);const o=await fetch(`/api/rag/${a?"hosted-run":"run"}`,{method:"POST",headers:i,body:JSON.stringify({...e,stream:!0}),signal:n});if(!o.ok||!o.body){const h=await o.text().catch(()=>""),g=h?(()=>{try{return JSON.parse(h)}catch{return null}})():null;return{ok:!1,error:(g==null?void 0:g.error)||`Request failed (${o.status})`}}const l=o.body.getReader(),c=new TextDecoder;let u="",d={ok:!1,error:"The run ended without a result."};for(;;){const{value:h,done:g}=await l.read();if(g)break;u+=c.decode(h,{stream:!0});let v;for(;(v=u.indexOf(`
|
|
48
48
|
`))>=0;){const f=u.slice(0,v).trim();if(u=u.slice(v+1),!f)continue;let y;try{y=JSON.parse(f)}catch{continue}y.t==="progress"?t({done:Number(y.done),total:Number(y.total),id:String(y.id??""),name:String(y.name??""),mode:String(y.mode??"")}):y.t==="done"?d={ok:!!y.ok,report:y.report,diff:y.diff,run:y.run,error:y.error}:y.t==="error"&&(d={ok:!1,error:String(y.error??"Hosted RAG Assurance could not complete.")})}}return d},generatePromptCases:e=>H("/prompts/generate-cases",e),savePromptCases:(e,t="ai")=>H("/prompts/custom/bulk",{cases:e,source:t}),promptStudioCreate:e=>H("/prompt-studio/sessions",e),promptStudioSessions:()=>H("/prompt-studio/sessions",void 0,"GET"),promptStudioSession:e=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}`,void 0,"GET"),promptStudioDelete:e=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}`,void 0,"DELETE"),promptStudioSend:(e,t,n,a)=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}/messages`,{message:t,llm:n}),promptStudioSuggestions:e=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}/suggestions`,void 0,"GET"),promptStudioStop:e=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}/stop`,{}),promptStudioCallTool:(e,t,n,a=!1)=>H(`/prompt-studio/sessions/${encodeURIComponent(e)}/tools/${encodeURIComponent(t)}`,{input:n,confirmed:a}),boundaryFamilies:()=>H("/boundary/families",void 0,"GET"),boundaryDiscover:()=>H("/boundary/discover",{}),boundaryRun:(e,t)=>H("/boundary/run",{fixtures:e,families:t}),startTrial:()=>H("/trial/start",{})};function ur(){return s.jsx("div",{className:"brand-mark",children:s.jsxs("svg",{viewBox:"0 0 72 72",fill:"none",role:"img","aria-label":"Prooflane Agent Assurance Spine",children:[s.jsx("rect",{x:"10",y:"9",width:"52",height:"8",rx:"1",fill:"#E8A33D"}),s.jsx("rect",{x:"10",y:"20.5",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".82"}),s.jsx("rect",{x:"10",y:"32",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".56"}),s.jsx("rect",{x:"10",y:"43.5",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".38"}),s.jsx("rect",{x:"10",y:"55",width:"52",height:"8",rx:"1",fill:"#E8A33D",opacity:".26"}),s.jsx("path",{d:"M13 37.4 L31.5 57.3 L69.4 3.3 L65.7 2.6 L32.3 47.4 L19.7 33.9 Z",fill:"#34D399",stroke:"var(--bg)",strokeWidth:"2.6",strokeLinejoin:"round"}),s.jsx("path",{d:"M13 37.4 L31.5 57.3 L69.4 3.3 L65.7 2.6 L32.3 47.4 L19.7 33.9 Z",fill:"#34D399"})]})})}function Vc({label:e="Loading…",compact:t=!1}){return s.jsxs("div",{className:`kawach-loader${t?" compact":""}`,role:"status","aria-live":"polite",children:[s.jsx(ur,{}),s.jsx("span",{children:e})]})}function wx({severity:e}){return s.jsx("span",{className:`tag ${e}`,children:e})}function Sx({verdict:e}){return s.jsx("span",{className:`tag ${e}`,children:e})}function Ls({value:e}){const t=typeof e=="string"?e:JSON.stringify(e,null,2);return s.jsx("div",{className:"codeblock",children:t??"null"})}function qc({value:e}){const n=((typeof e=="string"?e:JSON.stringify(e,null,2))??"null").split(`
|
|
49
49
|
`);return s.jsxs("div",{className:"codeblock lined mono",children:[s.jsx("div",{className:"gutter",children:n.map((a,r)=>s.jsx("span",{children:r+1},r))}),s.jsx("div",{className:"code",children:n.map((a,r)=>s.jsx("span",{children:a||" "},r))})]})}function Cv(e){const t=typeof e=="string"?e:JSON.stringify(e??null),n=new TextEncoder().encode(t).length;return n<1024?`${n} B`:`${(n/1024).toFixed(1)} KB`}function hs({children:e}){return s.jsx("div",{className:"empty",children:e})}function $w({message:e}){return s.jsx("div",{className:"toast",children:e})}function Vp({page:e,pageSize:t,total:n,onPage:a}){const r=Math.ceil(n/t);if(r<=1)return null;const i=e*t+1,o=Math.min(n,(e+1)*t);return s.jsxs("div",{className:"row",style:{gap:10,alignItems:"center",justifyContent:"flex-end",marginTop:12},children:[s.jsxs("span",{className:"muted",style:{fontSize:12},children:[i,"–",o," of ",n]}),s.jsx("button",{className:"btn sm ghost",disabled:e<=0,onClick:()=>a(e-1),children:"← Prev"}),s.jsxs("span",{className:"muted",style:{fontSize:12},children:[e+1," / ",r]}),s.jsx("button",{className:"btn sm ghost",disabled:e>=r-1,onClick:()=>a(e+1),children:"Next →"})]})}const bc="1.0",Tv="prooflane.connections.example.json",ME=new Set(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD","TRACE"]),Nx=/^\$\{(env|session):([A-Za-z_][A-Za-z0-9_]*)\}$/,z2=/(?:authorization|api[-_]?key|token|secret|password|credential)/i;function U2(e){let t;try{t=typeof e=="string"?JSON.parse(e):structuredClone(e)}catch{return{manifest:{schemaVersion:bc,connections:[]},valid:!1,issues:[{path:"$",message:"Connection manifest must be valid JSON."}]}}const n=[];if(!Vs(t))return{manifest:{schemaVersion:bc,connections:[]},valid:!1,issues:[{path:"$",message:"Connection manifest must be a JSON object."}]};t.schemaVersion!==bc&&n.push({path:"schemaVersion",message:`schemaVersion must be ${bc}.`}),Array.isArray(t.connections)||n.push({path:"connections",message:"connections must be an array."});const a=Array.isArray(t.connections)?t.connections:[],r=new Set;return a.forEach((i,o)=>W2(i,o,r,n)),{manifest:t,issues:n,valid:n.length===0}}function F2(e,t){var n,a,r,i;if(e.type==="mcp"){const o=e.transport==="stdio"?{transport:"stdio",command:e.command,args:e.args,env:lo(e.env,t.secrets,`${e.id}.env`)}:Y2(e,t.secrets);return{id:e.id,name:e.name,type:"MCP",config:{type:"MCP",name:e.name,connection:o},requiresStdioTrust:e.transport==="stdio"}}if(e.type==="http"){const o={type:"HTTP_API",name:e.name,baseUrl:e.baseUrl,authentication:af(e.auth,t.secrets,e.id),headers:lo(e.headers,t.secrets,`${e.id}.headers`),environmentVariables:lo(e.env,t.secrets,`${e.id}.env`)},l=e.mode==="openapi"?{...o,mode:"OPENAPI",openApiUrl:e.openapi.url,openApiDocument:e.openapi.file?Z2(e.openapi.file,t):void 0}:{...o,mode:"MANUAL",method:e.method.toUpperCase(),path:e.path,capabilityName:e.capabilityName,requestTemplate:e.requestTemplate,responseMapping:e.responseMapping};return{id:e.id,name:e.name,type:"HTTP_API",config:l,requiresStdioTrust:!1}}if(e.type==="rag"){const o=e.retriever;return{id:e.id,name:e.name,type:"RAG",requiresStdioTrust:!1,config:{type:"RAG",mode:e.mode==="full-chain"?"FULL_CHAIN":"RETRIEVER_ONLY",name:e.name,endpoint:o.endpoint,method:((n=o.method)==null?void 0:n.toUpperCase())??"POST",authentication:af(e.auth,t.secrets,e.id),headers:lo(e.headers,t.secrets,`${e.id}.headers`),queryMapping:o.queryMapping,answerMapping:e.mode==="full-chain"?o.answerMapping:void 0,retrievedItemsMapping:o.retrievedItemsMapping,citationMapping:e.mode==="full-chain"?o.citationMapping:void 0,documentIdMapping:o.documentIdMapping,documentTextMapping:o.documentTextMapping,metadataMapping:o.metadataMapping,testQuery:(a=e.connectionTest)==null?void 0:a.query}}}return e.type==="model"?{id:e.id,name:e.name,type:"MODEL",requiresStdioTrust:!1,config:{type:"MODEL",provider:X2(e.compatibility),name:e.name,model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey?Ui(e.apiKey,t.secrets,`${e.id}.apiKey`):void 0,headers:lo(e.headers,t.secrets,`${e.id}.headers`),parameters:e.modelParameters,path:e.compatibility==="custom"?e.path:void 0,requestTemplate:e.compatibility==="custom"?e.requestTemplate:void 0,responseMapping:e.compatibility==="custom"?e.responseMapping:void 0}}:{id:e.id,name:e.name,type:"AGENT",requiresStdioTrust:!1,config:{type:"AGENT",name:e.name,endpoint:e.invocation.endpoint,method:((r=e.invocation.method)==null?void 0:r.toUpperCase())??"POST",authentication:af(e.auth,t.secrets,e.id),headers:lo(e.headers,t.secrets,`${e.id}.headers`),requestTemplate:e.requestTemplate,inputMapping:e.mapping.input,responseMapping:e.mapping.response,toolCallMapping:e.mapping.toolCalls,retrievalMapping:e.mapping.retrieval,stateMapping:e.mapping.state,traceMapping:e.mapping.trace,finalStateMapping:e.mapping.finalState,testInput:(i=e.connectionTest)==null?void 0:i.input}}}function G2(e){return e.type==="mcp"?e.transport==="stdio"?`MCP Server · stdio · ${[e.command,...e.args??[]].join(" ")}`:`MCP Server · remote HTTP · ${e.url}`:e.type==="http"?`HTTP / API · ${e.mode} · ${e.baseUrl}`:e.type==="rag"?`RAG System · ${e.mode} · ${(e.retriever.method??"POST").toUpperCase()} ${e.retriever.endpoint}`:e.type==="model"?`Model Endpoint · ${e.compatibility} · ${e.model}`:`AI Agent · ${(e.invocation.method??"POST").toUpperCase()} ${e.invocation.endpoint}`}const Rv={schemaVersion:bc,connections:[{id:"example-mcp-stdio",name:"Example MCP stdio",type:"mcp",transport:"stdio",command:"node",args:["examples/mock-server.mjs"],env:{API_KEY:"${env:MCP_API_KEY}"}},{id:"example-mcp-remote",name:"Example Remote MCP",type:"mcp",transport:"remote-http",url:"https://example.com/mcp",auth:{type:"bearer",token:"${env:MCP_BEARER_TOKEN}"}},{id:"example-http-openapi",name:"Example OpenAPI target",type:"http",mode:"openapi",baseUrl:"https://api.example.com",openapi:{url:"/openapi.json"},env:{},auth:{type:"none"},headers:{}},{id:"example-http-manual",name:"Example Manual HTTP target",type:"http",mode:"manual",baseUrl:"https://api.example.com",method:"POST",path:"/chat",capabilityName:"chat_completion",requestTemplate:{input:"{{input}}"},responseMapping:{output:"output",answer:"answer",toolCalls:"toolCalls",citations:"citations",metadata:"metadata"},auth:{type:"none"},headers:{},env:{}},{id:"example-rag-retriever",name:"Example Retriever-only RAG",type:"rag",mode:"retriever-only",retriever:{endpoint:"https://rag.example.com/query",method:"POST",queryMapping:"query",retrievedItemsMapping:"retrievedItems",documentIdMapping:"id",documentTextMapping:"text",metadataMapping:"metadata"},connectionTest:{query:"prooflane connection test"},auth:{type:"api-key",header:"x-api-key",key:"${prompt}"},headers:{}},{id:"example-rag-full",name:"Example Full-chain RAG",type:"rag",mode:"full-chain",retriever:{endpoint:"https://rag.example.com/query",method:"POST",queryMapping:"query",retrievedItemsMapping:"retrievedItems",documentIdMapping:"id",documentTextMapping:"text",metadataMapping:"metadata",answerMapping:"answer",citationMapping:"citations"},connectionTest:{query:"prooflane connection test"},auth:{type:"none"},headers:{}},{id:"example-model-openai",name:"Example OpenAI-compatible Model",type:"model",compatibility:"openai-compatible",baseUrl:"http://localhost:11434/v1",model:"example-model",apiKey:"${session:TARGET_MODEL_API_KEY}",modelParameters:{temperature:0},headers:{}},{id:"example-model-anthropic",name:"Example Anthropic-compatible Model",type:"model",compatibility:"anthropic-compatible",baseUrl:"https://api.anthropic.com/v1",model:"example-model",apiKey:"${session:TARGET_MODEL_API_KEY}",modelParameters:{temperature:0},headers:{}},{id:"example-model-custom",name:"Example Custom Model",type:"model",compatibility:"custom",baseUrl:"http://localhost:3000",model:"example-model",path:"/invoke",apiKey:"${session:TARGET_MODEL_API_KEY}",requestTemplate:{prompt:"{{prompt}}"},responseMapping:{answer:"answer",toolCalls:"toolCalls",metadata:"metadata"},modelParameters:{},headers:{}},{id:"example-agent",name:"Example AI Agent",type:"agent",invocation:{endpoint:"http://localhost:3000/agent",method:"POST"},mapping:{input:"input",response:"response",toolCalls:"toolCalls",retrieval:"retrievalEvents",state:"stateTransitions",trace:"trace",finalState:"finalState"},requestTemplate:{},connectionTest:{input:{input:"prooflane connection test"}},auth:{type:"bearer",token:"${prompt}"},headers:{}}]};[...ME];function W2(e,t,n,a){const r=`connections[${t}]`;if(!Vs(e)){a.push({path:r,message:"connection must be an object."});return}if(cn(e,"id",r,a),cn(e,"name",r,a),typeof e.id=="string"&&(n.has(e.id)&&a.push({path:`${r}.id`,message:"connection id must be unique."}),n.add(e.id)),e.enabled!==void 0&&typeof e.enabled!="boolean"&&a.push({path:`${r}.enabled`,message:"enabled must be a boolean."}),!["mcp","http","rag","model","agent"].includes(String(e.type))){a.push({path:`${r}.type`,message:"type must be mcp, http, rag, model, or agent."});return}e.type==="mcp"?H2(e,r,a):e.type==="http"?B2(e,r,a):e.type==="rag"?V2(e,r,a):e.type==="model"?q2(e,r,a):K2(e,r,a),DE(e,r,a)}function H2(e,t,n){e.transport==="stdio"?(cn(e,"command",t,n),e.args!==void 0&&(!Array.isArray(e.args)||e.args.some(a=>typeof a!="string"))&&n.push({path:`${t}.args`,message:"args must be an array of strings."}),hl(e.env,`${t}.env`,n)):e.transport==="remote-http"?(Gd(e,"url",t,n),qp(e.auth,`${t}.auth`,n,!0),Vs(e.auth)&&e.auth.type==="api-key"&&n.push({path:`${t}.auth.type`,message:"MCP remote HTTP does not expose API-key authentication in the current form."})):n.push({path:`${t}.transport`,message:"MCP transport must be stdio or remote-http."})}function B2(e,t,n){if(Gd(e,"baseUrl",t,n),qp(e.auth,`${t}.auth`,n),hl(e.headers,`${t}.headers`,n),hl(e.env,`${t}.env`,n),e.mode==="openapi"){const a=Vs(e.openapi)?e.openapi:null;a?[a.url,a.file].filter(i=>typeof i=="string"&&i.trim()).length!==1&&n.push({path:`${t}.openapi`,message:"Specify exactly one OpenAPI url or file."}):n.push({path:`${t}.openapi`,message:"OpenAPI mode requires an openapi object."})}else e.mode==="manual"?(kx(e,t,n),cn(e,"path",t,n),e.responseMapping!==void 0&&!Vs(e.responseMapping)&&n.push({path:`${t}.responseMapping`,message:"responseMapping must be an object."})):n.push({path:`${t}.mode`,message:"HTTP mode must be openapi or manual."})}function V2(e,t,n){e.mode!=="full-chain"&&e.mode!=="retriever-only"&&n.push({path:`${t}.mode`,message:"RAG mode must be full-chain or retriever-only."});const a=Vs(e.retriever)?e.retriever:null;if(!a){n.push({path:`${t}.retriever`,message:"retriever must be an object."});return}Gd(a,"endpoint",`${t}.retriever`,n),a.method!==void 0&&kx(a,`${t}.retriever`,n);for(const r of["queryMapping","retrievedItemsMapping","documentIdMapping","documentTextMapping"])cn(a,r,`${t}.retriever`,n);e.mode==="full-chain"&&cn(a,"answerMapping",`${t}.retriever`,n),qp(e.auth,`${t}.auth`,n),hl(e.headers,`${t}.headers`,n)}function q2(e,t,n){["openai-compatible","anthropic-compatible","custom"].includes(String(e.compatibility))||n.push({path:`${t}.compatibility`,message:"Unsupported model compatibility mode."}),Gd(e,"baseUrl",t,n),cn(e,"model",t,n),e.apiKey!==void 0&&vh(e.apiKey,`${t}.apiKey`,n),e.modelParameters!==void 0&&!Vs(e.modelParameters)&&n.push({path:`${t}.modelParameters`,message:"modelParameters must be an object."}),hl(e.headers,`${t}.headers`,n),e.compatibility==="custom"&&(cn(e,"path",t,n),(!Vs(e.responseMapping)||!(Ow(e.responseMapping,"answer")||Ow(e.responseMapping,"output")))&&n.push({path:`${t}.responseMapping`,message:"Custom model requires an answer or output response mapping."}))}function K2(e,t,n){const a=Vs(e.invocation)?e.invocation:null,r=Vs(e.mapping)?e.mapping:null;a?(Gd(a,"endpoint",`${t}.invocation`,n),a.method!==void 0&&kx(a,`${t}.invocation`,n)):n.push({path:`${t}.invocation`,message:"invocation must be an object."}),r?(cn(r,"input",`${t}.mapping`,n),cn(r,"response",`${t}.mapping`,n)):n.push({path:`${t}.mapping`,message:"mapping must be an object."}),qp(e.auth,`${t}.auth`,n),hl(e.headers,`${t}.headers`,n)}function qp(e,t,n,a=!1){if(e!==void 0){if(!Vs(e)){n.push({path:t,message:"auth must be an object."});return}e.type==="none"||a&&e.type==="oauth"||(e.type==="bearer"?vh(e.token,`${t}.token`,n):e.type==="basic"?(cn(e,"username",t,n),vh(e.password,`${t}.password`,n)):e.type==="api-key"?(cn(e,"header",t,n),vh(e.key,`${t}.key`,n)):n.push({path:`${t}.type`,message:`auth type must be none, bearer, basic, api-key${a?", or oauth":""}.`}))}}function vh(e,t,n){(typeof e!="string"||!e.trim())&&n.push({path:t,message:"Provide a direct local credential or use ${prompt}, ${env:NAME}, or ${session:NAME}."})}function DE(e,t,n){if(Vs(e))for(const[a,r]of Object.entries(e))typeof r=="string"&&z2.test(a)&&!["username","name"].includes(a)&&r!=="${prompt}"&&!Nx.test(r)&&!J2(t,a)?n.push({path:`${t}.${a}`,message:"This credential-like field is not a supported local credential field. Use the target's auth, headers, env, or model apiKey field."}):Vs(r)&&DE(r,`${t}.${a}`,n)}function J2(e,t){return e.endsWith(".auth")&&["token","password","key"].includes(t)||t==="apiKey"&&/^connections\[\d+\]$/.test(e)?!0:e.endsWith(".headers")||e.endsWith(".env")}function hl(e,t,n){e!==void 0&&(!Vs(e)||Object.values(e).some(a=>typeof a!="string"))&&n.push({path:t,message:"must be an object with string values."})}function cn(e,t,n,a){(typeof e[t]!="string"||!e[t].trim())&&a.push({path:`${n}.${t}`,message:`${t} is required.`})}function Gd(e,t,n,a){if(cn(e,t,n,a),typeof e[t]=="string")try{if(!new URL(e[t]).protocol.startsWith("http"))throw new Error}catch{a.push({path:`${n}.${t}`,message:`${t} must be an HTTP(S) URL.`})}}function kx(e,t,n){cn(e,"method",t,n),typeof e.method=="string"&&!ME.has(e.method.toUpperCase())&&n.push({path:`${t}.method`,message:"method is not supported."})}function Ow(e,t){return Vs(e)&&typeof e[t]=="string"&&!!e[t].trim()}function Vs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function af(e,t,n){return!e||e.type==="none"?{mode:"NONE"}:e.type==="bearer"?{mode:"BEARER",token:Ui(e.token,t,`${n}.auth.token`)}:e.type==="basic"?{mode:"BASIC",username:e.username,password:Ui(e.password,t,`${n}.auth.password`)}:{mode:"API_KEY",header:e.header,key:Ui(e.key,t,`${n}.auth.key`)}}function Y2(e,t){const n=e.auth;if(!n||n.type==="none"||n.type==="oauth")return{transport:"http",url:e.url};if(n.type==="bearer")return{transport:"http",url:e.url,bearerToken:Ui(n.token,t,`${e.id}.auth.token`)};if(n.type==="basic")return{transport:"http",url:e.url,basicAuth:{username:n.username,password:Ui(n.password,t,`${e.id}.auth.password`)}};throw new Error("MCP remote HTTP supports NONE, BEARER, BASIC, or OAuth authentication; API_KEY is not available in the current form.")}function Ui(e,t,n){const a=Nx.exec(e);if(e!=="${prompt}"&&!a)return e;const r=e==="${prompt}"?t.prompt(n):(a==null?void 0:a[1])==="env"?t.env(a[2]):(a==null?void 0:a[1])==="session"?t.session(a[2]):void 0;if(!r)throw new Error(`A local secret is required for ${n}.`);return r}function lo(e,t,n){if(e)return Object.fromEntries(Object.entries(e).map(([a,r])=>[a,r==="${prompt}"||Nx.test(r)?Ui(r,t,`${n}.${a}`):r]))}function Z2(e,t){if(!t.readOpenApiFile)throw new Error(`OpenAPI file ${e} must be selected or resolved locally before connecting.`);return t.readOpenApiFile(e)}function X2(e){return e==="openai-compatible"?"OPENAI_COMPATIBLE":e==="anthropic-compatible"?"ANTHROPIC_COMPATIBLE":"CUSTOM"}function Q2(e){return!!(e&&typeof e=="object"&&"code"in e&&e.code==="TARGET_NOT_FOUND")}function e$({type:e,reconnectTarget:t,onConnected:n,onReconnectTargetMissing:a}){const[r,i]=p.useState((t==null?void 0:t.displayName)??n$(e)),[o,l]=p.useState(()=>e==="RAG"?"FULL_CHAIN":"OPENAPI"),[c,u]=p.useState(""),[d,h]=p.useState(""),[g,v]=p.useState(""),[f,y]=p.useState(),[b,m]=p.useState("POST"),[x,j]=p.useState("/"),[S,w]=p.useState(""),[C,_]=p.useState("{}"),[N,$]=p.useState(""),[E,k]=p.useState("NONE"),[T,P]=p.useState(""),[W,R]=p.useState(""),[q,Y]=p.useState(""),[J,ce]=p.useState("x-api-key"),[B,ae]=p.useState(""),[ue,re]=p.useState("{}"),[V,te]=p.useState("query"),[ee,me]=p.useState("answer"),[fe,A]=p.useState("retrievedItems"),[M,ve]=p.useState("citations"),[D,K]=p.useState("id"),[oe,de]=p.useState("text"),[Se,Ce]=p.useState("metadata"),[_e,ie]=p.useState("prooflane connection test"),[De,Ge]=p.useState("OPENAI_COMPATIBLE"),[le,Te]=p.useState(""),[We,Be]=p.useState("{}"),[Q,O]=p.useState("input"),[he,Pe]=p.useState("response"),[qe,ct]=p.useState("toolCalls"),[ye,Je]=p.useState("retrievalEvents"),[G,se]=p.useState("stateTransitions"),[we,be]=p.useState("trace"),[Ee,ge]=p.useState("finalState"),[F,z]=p.useState('{"input":"prooflane connection test"}'),[I,ne]=p.useState(!1),[Re,ke]=p.useState(null),[Ue,wt]=p.useState(null),je=()=>E==="BEARER"?{mode:"BEARER",token:T}:E==="BASIC"?{mode:"BASIC",username:W,password:q}:E==="API_KEY"?{mode:"API_KEY",header:J,key:B}:{mode:"NONE"},_t=()=>{const pe=Lw(C,"Headers");return e==="HTTP_API"?{type:e,mode:o,name:r,baseUrl:c,authentication:je(),headers:ku(pe,"Headers"),environmentVariables:s$(N),...o==="OPENAPI"?{openApiUrl:g||void 0,openApiDocument:f}:{method:b,path:x,capabilityName:S||void 0,requestTemplate:wc(ue,"Request template"),responseMapping:{output:"output",answer:"answer",toolCalls:"toolCalls",citations:"citations",metadata:"metadata"}}}:e==="RAG"?{type:e,mode:o,name:r,endpoint:d,method:b,authentication:je(),headers:ku(pe,"Headers"),queryMapping:V,answerMapping:o==="FULL_CHAIN"?ee:void 0,retrievedItemsMapping:fe,citationMapping:o==="FULL_CHAIN"&&M||void 0,documentIdMapping:D,documentTextMapping:oe,metadataMapping:Se||void 0,testQuery:_e}:e==="MODEL"?{type:e,provider:De,name:r,model:le,baseUrl:c,apiKey:B||void 0,headers:ku(pe,"Headers"),parameters:Lw(We,"Model parameters"),path:De==="CUSTOM"?x:void 0,requestTemplate:De==="CUSTOM"?wc(ue,"Request template"):void 0,responseMapping:De==="CUSTOM"?{answer:ee,toolCalls:qe,metadata:Se}:void 0}:{type:e,name:r,endpoint:d,method:b,authentication:je(),headers:ku(pe,"Headers"),requestTemplate:ue.trim()&&ue.trim()!=="{}"?wc(ue,"Request template"):void 0,inputMapping:Q,responseMapping:he,toolCallMapping:qe||void 0,retrievalMapping:ye||void 0,stateMapping:G||void 0,traceMapping:we||void 0,finalStateMapping:Ee||void 0,testInput:wc(F,"Test input")}},Dt=async()=>{ne(!0),wt(null),ke("Running a local, non-governed connection test…");try{const pe=_t(),Qe=t?await L.targetReconnect(t.id,pe,r):await L.targetConnect(pe,r);ke(`${Qe.connectionTest.message} Target fingerprint created.`),n(Qe.capabilities,Qe.target)}catch(pe){t&&Q2(pe)?(ke("The saved target no longer exists in this local workspace. Review these values, then create a new connection."),wt(null),a==null||a(t)):(ke(null),wt(pe instanceof Error?pe.message:"The target connection failed."))}finally{ne(!1)}};return s.jsxs("div",{className:"target-adapter-form stack",children:[s.jsx(dt,{label:"Name",children:s.jsx("input",{className:"field",value:r,onChange:pe=>i(pe.target.value)})}),e==="HTTP_API"&&s.jsxs(s.Fragment,{children:[s.jsx(rf,{value:o,onChange:l,values:["OPENAPI","MANUAL"]}),s.jsx(dt,{label:"Base URL",children:s.jsx("input",{className:"field",value:c,onChange:pe=>u(pe.target.value),placeholder:"https://api.example.com"})}),o==="OPENAPI"?s.jsxs(s.Fragment,{children:[s.jsx(dt,{label:"OpenAPI URL",children:s.jsx("input",{className:"field",value:g,onChange:pe=>v(pe.target.value),placeholder:"/openapi.json or https://…"})}),s.jsx(dt,{label:"OpenAPI file (JSON or YAML)",children:s.jsx("input",{className:"field",type:"file",accept:".json,.yaml,.yml,application/json,application/yaml,text/yaml",onChange:pe=>{var St;const Qe=(St=pe.target.files)==null?void 0:St[0];Qe&&Qe.text().then(y)}})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Method",children:s.jsx("input",{className:"field",value:b,onChange:pe=>m(pe.target.value.toUpperCase())})}),s.jsx(dt,{label:"Path",children:s.jsx("input",{className:"field",value:x,onChange:pe=>j(pe.target.value)})})]}),s.jsx(dt,{label:"Capability name",children:s.jsx("input",{className:"field",value:S,onChange:pe=>w(pe.target.value),placeholder:"chat_completion"})}),s.jsx(co,{label:"Request template",value:ue,onChange:re})]}),s.jsx(dt,{label:"Environment variables (KEY=VALUE, local only)",children:s.jsx("textarea",{className:"field",value:N,onChange:pe=>$(pe.target.value)})})]}),e==="RAG"&&s.jsxs(s.Fragment,{children:[s.jsx(rf,{value:o,onChange:l,values:["FULL_CHAIN","RETRIEVER_ONLY"]}),s.jsx(dt,{label:o==="FULL_CHAIN"?"Endpoint":"Retriever endpoint",children:s.jsx("input",{className:"field",value:d,onChange:pe=>h(pe.target.value),placeholder:"https://rag.example.com/query"})}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Method",children:s.jsxs("select",{className:"field",value:b,onChange:pe=>m(pe.target.value),children:[s.jsx("option",{children:"POST"}),s.jsx("option",{children:"GET"}),s.jsx("option",{children:"PUT"}),s.jsx("option",{children:"PATCH"}),s.jsx("option",{children:"DELETE"})]})}),s.jsx(dt,{label:b==="GET"?"Query parameter":"Query mapping",children:s.jsx("input",{className:"field",value:V,onChange:pe=>te(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[o==="FULL_CHAIN"&&s.jsx(dt,{label:"Answer mapping",children:s.jsx("input",{className:"field",value:ee,onChange:pe=>me(pe.target.value)})}),s.jsx(dt,{label:"Retrieved items mapping",children:s.jsx("input",{className:"field",value:fe,onChange:pe=>A(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Document ID mapping",children:s.jsx("input",{className:"field",value:D,onChange:pe=>K(pe.target.value)})}),s.jsx(dt,{label:"Document text mapping",children:s.jsx("input",{className:"field",value:oe,onChange:pe=>de(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[o==="FULL_CHAIN"&&s.jsx(dt,{label:"Citation mapping",children:s.jsx("input",{className:"field",value:M,onChange:pe=>ve(pe.target.value)})}),s.jsx(dt,{label:"Metadata mapping (optional)",children:s.jsx("input",{className:"field",value:Se,onChange:pe=>Ce(pe.target.value)})})]}),b==="GET"&&s.jsxs("div",{className:"target-domain-boundary",children:["GET sends the test query as a URL parameter. For Wikipedia page search, use ",s.jsx("span",{className:"mono",children:"q"}),", ",s.jsx("span",{className:"mono",children:"pages"}),", ",s.jsx("span",{className:"mono",children:"id"}),", and ",s.jsx("span",{className:"mono",children:"excerpt"}),"."]}),s.jsx(dt,{label:"Connection-test query",children:s.jsx("input",{className:"field",value:_e,onChange:pe=>ie(pe.target.value)})})]}),e==="MODEL"&&s.jsxs(s.Fragment,{children:[s.jsx(rf,{value:De,onChange:Ge,values:["OPENAI_COMPATIBLE","ANTHROPIC_COMPATIBLE","CUSTOM"]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Base URL",children:s.jsx("input",{className:"field",value:c,onChange:pe=>u(pe.target.value)})}),s.jsx(dt,{label:"Model",children:s.jsx("input",{className:"field",value:le,onChange:pe=>Te(pe.target.value)})})]}),s.jsx(dt,{label:"Target-model API key (session only)",children:s.jsx("input",{className:"field",type:"password",value:B,onChange:pe=>ae(pe.target.value),autoComplete:"off"})}),s.jsx(co,{label:"Model parameters",value:We,onChange:Be}),De==="CUSTOM"&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{label:"Invocation path",children:s.jsx("input",{className:"field",value:x,onChange:pe=>j(pe.target.value)})}),s.jsx(co,{label:"Request template",value:ue,onChange:re})]}),s.jsx("div",{className:"target-domain-boundary",children:"TARGET MODEL credentials remain separate from evaluation judges and Sammy providers."})]}),e==="AGENT"&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{label:"Invocation endpoint",children:s.jsx("input",{className:"field",value:d,onChange:pe=>h(pe.target.value)})}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Method",children:s.jsx("input",{className:"field",value:b,onChange:pe=>m(pe.target.value.toUpperCase())})}),s.jsx(dt,{label:"Input mapping",children:s.jsx("input",{className:"field",value:Q,onChange:pe=>O(pe.target.value)})})]}),s.jsx(co,{label:"Request template",value:ue,onChange:re}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Response mapping",children:s.jsx("input",{className:"field",value:he,onChange:pe=>Pe(pe.target.value)})}),s.jsx(dt,{label:"Tool-call mapping",children:s.jsx("input",{className:"field",value:qe,onChange:pe=>ct(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Retrieval mapping",children:s.jsx("input",{className:"field",value:ye,onChange:pe=>Je(pe.target.value)})}),s.jsx(dt,{label:"State mapping",children:s.jsx("input",{className:"field",value:G,onChange:pe=>se(pe.target.value)})})]}),s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Trace mapping",children:s.jsx("input",{className:"field",value:we,onChange:pe=>be(pe.target.value)})}),s.jsx(dt,{label:"Final state mapping",children:s.jsx("input",{className:"field",value:Ee,onChange:pe=>ge(pe.target.value)})})]}),s.jsx(co,{label:"Connection-test input",value:F,onChange:z})]}),e!=="MODEL"&&s.jsx(t$,{mode:E,setMode:k,token:T,setToken:P,username:W,setUsername:R,password:q,setPassword:Y,apiKeyHeader:J,setApiKeyHeader:ce,apiKey:B,setApiKey:ae}),s.jsx(co,{label:"Headers (values remain local)",value:C,onChange:_}),Re&&s.jsx("div",{className:"target-form-status",children:Re}),Ue&&s.jsx("div",{className:"mcp-selector-error",children:Ue}),s.jsx("button",{className:"btn primary",onClick:()=>void Dt(),disabled:I,children:I?"Testing connection…":t?"Test & reconnect":"Test & connect"})]})}function t$(e){return s.jsxs(s.Fragment,{children:[s.jsx(dt,{label:"Authentication",children:s.jsxs("select",{className:"field",value:e.mode,onChange:t=>e.setMode(t.target.value),children:[s.jsx("option",{children:"NONE"}),s.jsx("option",{children:"BEARER"}),s.jsx("option",{children:"BASIC"}),s.jsx("option",{children:"API_KEY"})]})}),e.mode==="BEARER"&&s.jsx(dt,{label:"Bearer token",children:s.jsx("input",{className:"field",type:"password",value:e.token,onChange:t=>e.setToken(t.target.value)})}),e.mode==="BASIC"&&s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Username",children:s.jsx("input",{className:"field",value:e.username,onChange:t=>e.setUsername(t.target.value)})}),s.jsx(dt,{label:"Password",children:s.jsx("input",{className:"field",type:"password",value:e.password,onChange:t=>e.setPassword(t.target.value)})})]}),e.mode==="API_KEY"&&s.jsxs("div",{className:"grid-2",children:[s.jsx(dt,{label:"Header",children:s.jsx("input",{className:"field",value:e.apiKeyHeader,onChange:t=>e.setApiKeyHeader(t.target.value)})}),s.jsx(dt,{label:"API key",children:s.jsx("input",{className:"field",type:"password",value:e.apiKey,onChange:t=>e.setApiKey(t.target.value)})})]})]})}function dt({label:e,children:t}){return s.jsxs("label",{children:[s.jsx("span",{className:"label",children:e}),t]})}function co({label:e,value:t,onChange:n}){return s.jsx(dt,{label:e,children:s.jsx("textarea",{className:"field target-json-field",value:t,onChange:a=>n(a.target.value)})})}function rf({value:e,onChange:t,values:n}){return s.jsx("div",{className:"row target-mode-choice",children:n.map(a=>s.jsx("button",{className:`btn sm ${e===a?"primary":"ghost"}`,onClick:()=>t(a),children:a.replaceAll("_"," ")},a))})}function wc(e,t){try{return e.trim()?JSON.parse(e):{}}catch{throw new Error(`${t} must be valid JSON.`)}}function Lw(e,t){const n=wc(e,t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${t} must be a JSON object.`);return n}function ku(e,t){if(Object.values(e).some(n=>typeof n!="string"))throw new Error(`${t} values must be strings.`);return e}function s$(e){return Object.fromEntries(e.split(`
|
package/dist/ui/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600&family=IBM+Plex+Sans:wght@400;500&family=IBM+Plex+Mono:wght@400;500&display=swap"
|
|
11
11
|
rel="stylesheet"
|
|
12
12
|
/>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-BV5kQQPQ.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-BbouSBNv.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
package/package.json
CHANGED