PageSourceSearch

https://citeanything.app/_next/static/chunks/8991-a902b86bbc35cf4f.js

js citeanything.app collected 2026-10-02 00:42:25 UTC 14,884 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8991],{3599:(e,t,n)=>{n.d(t,{t:()=>a,u:()=>s});var o=n(5997);let i="https://citeanything.app";if(!i)throw Error("NEXT_PUBLIC_API_URL is required");let a=i.replace(/\/+$/,""),s=new o.NF({baseUrl:a,getToken:()=>localStorage.getItem("citeanything_token")||""})},5997:(e,t,n)=>{n.d(t,{Um:()=>o,NF:()=>a,MH:()=>c,H2:()=>r});class o extends Error{constructor(e,t){super(t),this.name="CiteAnythingApiError",this.status=e,this.detail=t}}async function i(e,t){let n=e.headers.get("content-type")||"",i=`${t} (${e.status})`;if(n.includes("application/json")){let t=await e.json().catch(()=>null);"string"==typeof t?.detail?i=t.detail:t?.detail&&"string"==typeof t.detail.message?i=t.detail.message:"string"==typeof t?.message&&(i=t.message)}return new o(e.status,i)}class a{constructor(e){this.options=e}get baseUrl(){return("function"==typeof this.options.baseUrl?this.options.baseUrl():this.options.baseUrl).replace(/\/+$/,"")}get fetchImpl(){return this.options.fetch||globalThis.fetch.bind(globalThis)}async request(e,t={}){let n=new Headers(t.headers),o=this.options.getToken?.();return o&&n.set("Authorization",`Bearer ${o}`),"string"!=typeof t.body||n.has("Content-Type")||n.set("Content-Type","application/json"),this.fetchImpl(`${this.baseUrl}${e}`,{...t,headers:n})}async requestJson(e,t={},n="Request failed"){let o=await this.request(e,t);if(!o.ok)throw await i(o,n);return o.json()}getProviders(){return this.requestJson("/api/auth/providers",{},"Unable to load providers")}oauthUrl(e,t,n=""){let o=new URLSearchParams({redirect_uri:t,invite_code:n});return`${this.baseUrl}/api/auth/oauth/${e}?${o}`}login(e,t){return this.requestJson("/api/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})},"Login failed")}register(e,t,n,o=""){return this.requestJson("/api/auth/register",{method:"POST",body:JSON.stringify({email:e,password:t,name:n,invite_code:o})},"Registration failed")}getMe(){return this.requestJson("/api/auth/me",{},"Unable to load account")}getBillingConfig(){return this.requestJson("/api/billing/config",{},"Unable to load billing configuration")}getBillingAccount(){return this.requestJson("/api/billing/me",{},"Unable to load billing account")}
1createBillingCheckout(){return this.requestJson("/api/billing/checkout",{method:"POST"},"Unable to start Checkout")}createBillingPortal(){return this.requestJson("/api/billing/portal",{method:"POST"},"Unable to open the customer portal")}updateProfile(e){return this.requestJson("/api/auth/profile",{method:"PATCH",body:JSON.stringify({name:e})},"Update failed")}getCliAuthorization(e){return this.requestJson(`/api/auth/cli/authorizations/${encodeURIComponent(e)}`,{},"Unable to load CLI authorization")}getCliDeviceAuthorization(e){return this.requestJson(`/api/auth/cli/device?user_code=${encodeURIComponent(e)}`,{},"Device code expired or was not found")}decideCliAuthorization(e){return this.requestJson("/api/auth/cli/authorizations/decision",{method:"POST",body:JSON.stringify(e)},"Unable to authorize CLI")}getMcpAuthorization(e){return this.requestJson(`/api/auth/mcp/authorizations/${encodeURIComponent(e)}`,{},"Unable to load plugin authorization")}decideMcpAuthorization(e){return this.requestJson("/api/auth/mcp/authorizations/decision",{method:"POST",body:JSON.stringify(e)},"Unable to authorize plugin")}async listMcpSessions(){return(await this.requestJson("/api/auth/mcp/sessions",{},"Unable to load connected apps")).sessions||[]}revokeMcpSession(e){return this.requestJson(`/api/auth/mcp/sessions/${encodeURIComponent(e)}`,{method:"DELETE"},"Unable to revoke connected app")}async listConversations(e=50,t=0){return(await this.requestJson(`/api/conversations?limit=${e}&offset=${t}`)).conversations||[]}getConversation(e){return this.requestJson(`/api/conversations/${e}`)}hideConversation(e){return this.requestJson(`/api/conversations/${e}`,{method:"DELETE"},"Unable to remove conversation from history")}searchConversations(e,t=20){let n=new URLSearchParams({q:e,limit:String(t)});return this.requestJson(`/api/conversations/search?${n}`,{},"Unable to search conversations")}openAsk(e,t){return this.request("/api/ask",{method:"POST",body:JSON.stringify(e),signal:t})}createRun(e){return this.requestJson("/api/runs",{method:"POST",body:JSON.stringify(e)},"Unable to start run")}uploadImageAttachment(e){let t=new FormData;return t.append("file",e),this.requestJson("/api/attachments/images",{method:"POST",body:t},"Unable to upload image")}deleteImageAttachment(e){return this.requestJson(`/api/attachments/${encodeURIComponent(e)}`,{method:"DELETE"},"Unable to remove image")}async getImageAttachmentBlob(e){let t=await this.request(`/api/attachments/${encodeURIComponent(e)}/content`);if(!t.ok)throw await i(t,"Unable to load image");return t.blob()}getAgentCapabilities(){return this.requestJson("/api/agent/capabilities",{},"Unable to load agent capabilities")}async listAgentConnections(){return(await this.requestJson("/api/agent/connections",{},"Unable to load agent connections")).connections||[]}startCodexDeviceLogin(){return this.requestJson("/api/agent/connections/codex/device-login",{method:"POST"},"Unable to start Codex login")}getAgentConnection(e,t=!1){return this.requestJson(`/api/agent/connections/${encodeURIComponent(e)}${t?"?refresh_limits=true":""}`,{},"Unable to load Codex connection")}cancelAgentConnectionLogin(e){return this.requestJson(`/api/agent/connections/${encodeURIComponent(e)}/login/cancel`,{method:"POST"},"Unable to cancel Codex login")}logoutAgentConnection(e){return this.requestJson(`/api/agent/connections/${encodeURIComponent(e)}/logout`,{method:"POST"},"Unable to disconnect Codex")}deleteAgentConnection(e){return this.requestJson(`/api/agent/connections/${encodeURIComponent(e)}`,{method:"DELETE"},"Unable to delete Codex connection")}getActiveRun(e){let t=null==e?"":`?conversation_id=${encodeURIComponent(String(e))}`;return this.requestJson(`/api/runs/active${t}`).then(e=>e.run)}getRun(e){return this.requestJson(`/api/runs/${encodeURIComponent(e)}`)}openRunEvents(e,t=0,n){return this.request(`/api/runs/${encodeURIComponent(e)}/events?after=${Math.max(0,t)}`,{signal:n})}cancelRun(e){return this.requestJson(`/api/runs/${encodeURIComponent(e)}/cancel`,{method:"POST"},"Unable to cancel run")}async listDocuments(){return(await this.requestJson("/api/kb/documents")).documents||[]}uploadDocument(e){let t=new FormData;return t.append("file",e),this.requestJson("/api/kb/upload",{method:"POST",body:t},"Upload failed")}deleteDocument(e){return this.requestJson(`/api/kb/documents/${e}`,{method:"DELETE"})}resetKnowledgeBase(){return this.requestJson("/api/kb/reset",{method:"POST"})}listWorks(){return this.requestJson("/api/machines/default/works",{}
1,"Unable to load works")}readMachineFile(e){let t=new URLSearchParams({path:e});return this.requestJson(`/api/machines/default/file?${t}`,{},"Unable to read work source")}writeMachineFile(e,t){return this.requestJson("/api/machines/default/file",{method:"PUT",body:JSON.stringify({path:e,content:t})},"Unable to save work source")}runMachineCommand(e,t,n,o=300){return this.requestJson("/api/machines/default/commands",{method:"POST",body:JSON.stringify({command:e,args:t,cwd:n,timeout_seconds:o})},"Unable to build work")}refreshWorkPublication(e){return this.requestJson("/api/machines/default/works/refresh-publication",{method:"POST",body:JSON.stringify({work_path:e})},"Unable to refresh published work")}getWorkWebsiteAccess(e){return this.requestJson("/api/machines/default/works/site-access",{method:"POST",body:JSON.stringify({work_path:e})},"Unable to open website preview")}async openWorkContent(e,t=!1){let n=new URLSearchParams({path:e});t&&n.set("download","true");let o=await this.request(`/api/machines/default/works/content?${n}`);if(!o.ok)throw await i(o,"Unable to open work");return o}publishWork(e){return this.requestJson("/api/machines/default/works/publish",{method:"POST",body:JSON.stringify(e)},"Unable to publish work")}unpublishWork(e,t){return this.requestJson("/api/machines/default/works/unpublish",{method:"POST",body:JSON.stringify({owner_slug:e,work_slug:t})},"Unable to unpublish work")}getPublicWork(e,t){return this.requestJson(`/api/public/works/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{},"Published work not found")}unlockPublicWork(e,t,n){return this.requestJson(`/api/public/works/${encodeURIComponent(e)}/${encodeURIComponent(t)}/unlock`,{method:"POST",body:JSON.stringify({passcode:n})},"Unable to unlock work")}async openPublicWorkContent(e,t,n,o){let a=`/api/public/works/${encodeURIComponent(e)}/${encodeURIComponent(t)}/content?kind=${n}`,s=await this.request(a,{headers:{"X-Work-Access":o}});if(!s.ok)throw await i(s,"Unable to open published work");return s}createApiKey(e,t){return this.requestJson("/api/auth/api-keys",{method:"POST",body:JSON.stringify({name:e,scopes:t})})}}async function s(e,t="Request failed"){if(!e.ok)throw await i(e,t);return e}function r(e){return"pro"===e?100:20}function u(e,t){return("completed"===e.status||"failed"===e.status||"cancelled"===e.status)&&t>=Math.max(0,e.last_sequence||0)}async function l(e,t,n={}){if(await s(e),!e.body)throw Error("Empty response");let o=e.body.getReader();n.onReader?.(o);let i=new TextDecoder,a="";try{for(;;){let{done:e,value:n}=await o.read();if(e)break;for(a+=i.decode(n,{stream:!0});a.includes("\n\n");){let e=a.indexOf("\n\n"),n=a.slice(0,e).trim();a=a.slice(e+2);let o=n.split("\n"),i=o.find(e=>e.startsWith("data: "));if(!i)continue;let s=i.slice(6);if(s&&"[DONE]"!==s)try{let e=JSON.parse(s);if("number"!=typeof e._run_sequence){let t=o.find(e=>e.startsWith("id: ")),n=t?Number(t.slice(4)):NaN;Number.isFinite(n)&&(e._run_sequence=n)}await t(e)}catch(e){if(e instanceof SyntaxError)continue;throw e}}}}finally{n.onReader?.(null)}}async function c(e,t,n,o={}){let i=Math.max(0,o.initialSequence||0),a=Math.max(100,o.retryDelayMs||700);for(;;){if(o.signal?.aborted)throw new DOMException("Aborted","AbortError");let s=null;try{let a=await e.openRunEvents(t,i,o.signal);if(await l(a,async a=>{let r=Number(a._run_sequence);if(Number.isFinite(r)){if(r<=i)return;i=r,o.onSequence?.(i)}if(await n(a),"run_status"===a.type){let n=String(a.status||"");("completed"===n||"failed"===n||"cancelled"===n)&&(s=await e.getRun(t))}},{onReader:o.onReader}),s&&u(s,i))return s;let r=await e.getRun(t);if(u(r,i))return r}catch(t){if(o.signal?.aborted)throw t;let e="object"==typeof t&&null!==t&&"status"in t?Number(t.status):0;if(e>=400&&e<500&&408!==e&&429!==e)throw t}await function(e,t){return new Promise((n,o)=>{if(t?.aborted)return void o(new DOMException("Aborted","AbortError"));let i=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(i),o(new DOMException("Aborted","AbortError"))},{once:!0})})}(a,o.signal)}}},8991:(e,t,n)=>{n.d(t,{AuthProvider:()=>h,A:()=>p});var o=n(4568),i=n(7620),a=n(9748),s=n(3599),r=n(5038);let u=null;function l(){if(u)return u;let e="https://rdusuwbfjsnujozomzfo.supabase.co",t="sb_publishable_ujfbMbZb29V4-FBRq8I2qg_H9ixZYJP";if(!e||!t)throw Error("Supabase authentication is not configured for this deployment");return u=(0,r.UU)(e,t,{auth:{flowType:"pkce",detectSessionInUrl:!0,persistSession:!0,autoRefreshToken:!0}})}let c=(0,i.createContext)(null);function h({children:e}){let t=(0,a.useRouter)(),[n,r]=(0,i.useState)(null),[u,p]=(0,i.useState)(null),[g,m]=(0,i.useState)(!0),[f,b]=(0,i.useState)(null),[w,y]=(0,i.useState)([]);async function k(e){try{let t=await s.u.requestJson("/api/auth/me",{headers:{Authorization:`Bearer ${e}`}});r(t)}catch{localStorage.removeItem("citeanything_token"),p(null),r(null)}}(0,i.useEffect)(()=>{let e,t=!1;return async function(){let n=null;try{let o=await s.u.getProviders();if(t)return;if(n=o.identity_provider,b(o.identity_provider),y(o.providers),"supabase"===o.identity_provider){let n=l(),o=n.auth.onAuthStateChange((e,n)=>{window.setTimeout(()=>{if(!t){if(!n){localStorage.removeItem("citeanything_token"),p(null),r(null),m(!1);return}q(n.access_token).then(I).finally(()=>{t||m(!1)})}},0)});e=()=>o.data.subscription.unsubscribe();let{data:i,error:a}=await n.auth.getSession();if(a)throw a;i.session?(await q(i.session.access_token),I()):t||(localStorage.removeItem("citeanything_token"),p(null),r(null));return}let i=localStorage.getItem("citeanything_token");i&&(p(i),await k(i))}catch{if(t)return}finally{t||m(!1)}}(),()=>{t=!0,e?.()}},[]),(0,i.useEffect)(()=>{function e(){let e=localStorage.getItem("citeanything_token");e&&k(e)}return window.addEventListener("citeanything:refresh",e),()=>window.removeEventListener("citeanything:refresh",e)},[]);let U=(0,i.useCallback)(async()=>{u&&await k(u)},[u]);async function S(e,t){if("supabase"===f){let{data:n,error:o}=await l().auth.signInWithPassword({email:e,password:t});if(o)throw o;if(!n.session)throw Error("No Supabase session was created");await q(n.session.access_token);return}let n=await s.u.login(e,t);localStorage.setItem("citeanything_token",n.token),p(n.token),r(n)}async function q(e){localStorage.setItem("citeanything_token",e),p(e),await k(e)}async function J(e,t="/",n=""){if("supabase"!==f){let t=`${window.location.origin}/auth/callback`;window.location.href=s.u.oauthUrl(e,t,n);return}n&&localStorage.setItem("citeanything_pending_invite",n),"/"!==d(t)&&sessionStorage.setItem("citeanything_auth_next",d(t));let{error:o}=await l().auth.signInWithOAuth({provider:e,options:{redirectTo:window.location.origin}});if(o)throw o}async function C(e){let{data:t,error:n}=await l().auth.exchangeCodeForSession(e);if(n)throw n;if(!t.session)throw Error("No Supabase session was created");await q(t.session.access_token)}async function v(e,t,n,o){if("supabase"===f){let{data:i,error:a}=await l().auth.signUp({email:e,password:t,options:{data:{name:n||"",invite_code:o||""}}});if(a)throw a;if(!i.session)throw Error("Check your email to confirm your account, then log in");await q(i.session.access_token);return}let i=await s.u.register(e,t,n||"",o||"");
1localStorage.setItem("citeanything_token",i.token),p(i.token),r(i)}async function _(e){if(!u)throw Error("Not logged in");await s.u.updateProfile(e),r(t=>t?{...t,name:e}:t)}function I(){let e=sessionStorage.getItem("citeanything_auth_next");sessionStorage.removeItem("citeanything_auth_next"),e&&d(e)!==window.location.pathname&&window.location.replace(d(e))}return(0,o.jsx)(c.Provider,{value:{user:n,token:u,loading:g,identityProvider:f,providers:w,login:S,loginWithToken:q,loginWithOAuth:J,completeOAuth:C,register:v,logout:function(){"supabase"===f&&l().auth.signOut(),localStorage.removeItem("citeanything_token"),p(null),r(null),t.replace("/login")},refreshUser:U,updateName:_},children:e})}function d(e){return!e.startsWith("/")||e.startsWith("//")?"/":e}function p(){let e=(0,i.useContext)(c);if(!e)throw Error("useAuth must be used within AuthProvider");return e}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.