@rizom/brain 0.2.0-alpha.737 → 0.2.0-alpha.738

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.
@@ -1,3 +0,0 @@
1
- import{a as c,b as o,c as ge,d as be}from"./main-mae8fsbz.js";import{Hb as Ae,Jb as a,Kb as J,Lb as A,Mb as Ie,Ob as L,Pb as j,cb as N,gb as y,hb as V,ic as Be,jc as Fe,kb as K,lc as ze,mc as qe,rb as Ue,tb as Le,tc as ve,ub as je,vb as R,vc as W,wb as E}from"./main-hy7k3vwx.js";import{Cc as Z,wc as v}from"./main-hft323ae.js";var te=v(Z(),1);var Ve=a.object({displayName:a.string(),role:a.enum(["admin","trusted","public"]),profileEntityId:a.string().optional(),passkeys:a.array(a.object({id:a.string(),transports:a.array(a.string()).optional(),credentialDeviceType:a.string().optional(),credentialBackedUp:a.boolean(),createdAt:a.number(),updatedAt:a.number()})),appPasswords:a.array(a.object({id:a.string(),username:a.string(),label:a.string(),access:a.enum(["read","write"]),createdAt:a.number(),expiresAt:a.number(),lastUsedAt:a.number().optional()})),connectedChannels:a.array(a.object({type:a.string(),label:a.string(),verifiedAt:a.number()})),pluginSettings:a.array(a.object({id:a.string(),title:a.string(),description:a.string().optional(),configured:a.boolean(),revision:a.number().nullable(),fields:a.array(a.object({name:a.string(),label:a.string(),control:a.enum(["text","url","number","checkbox"]),secret:a.boolean(),required:a.boolean(),value:a.union([a.string(),a.number(),a.boolean(),a.null()]).optional(),set:a.boolean().optional()}))})),sessions:a.array(a.object({id:a.string(),current:a.boolean(),createdAt:a.number(),expiresAt:a.number()}))});function Ye(e){return Ve.safeParse(e).success}var de=a.custom(Ye,{message:"Invalid account response"}),ne=a.object({account:de}),Ge=a.object({account:de.optional(),appPassword:a.object({username:a.string(),password:a.string()}).optional(),revoked:a.object({sessions:a.number(),refreshTokens:a.number().optional()}).optional(),signedOut:a.boolean().optional()});function _e(e){return Ge.safeParse(e).success}var Je=a.custom(_e,{message:"Invalid account mutation response"}),We=a.custom((e)=>{if(!J(e))return!1;return typeof e.challenge==="string"&&J(e.rp)&&J(e.user)&&Array.isArray(e.pubKeyCredParams)},{message:"Invalid passkey registration options"});class pe extends Error{status;constructor(e,t){super(e);this.name="AccountApiError",this.status=t}}async function q(e,t){let n;try{n=await e.json()}catch{n={}}if(!e.ok){let i=typeof n==="object"&&n!==null&&"error"in n&&typeof n.error==="string"?n.error:"Account request failed";throw new pe(i,e.status)}return t.parse(n)}function oe(e){let t=e.replaceAll("-","+").replaceAll("_","/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),(n)=>n.charCodeAt(0)).buffer}function ae(e){let t=new Uint8Array(e),n="";for(let i of t)n+=String.fromCharCode(i);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Ke(e){return{challenge:oe(e.challenge),rp:e.rp,user:{...e.user,id:oe(e.user.id)},pubKeyCredParams:e.pubKeyCredParams,...e.timeout!==void 0?{timeout:e.timeout}:{},...e.excludeCredentials?{excludeCredentials:e.excludeCredentials.map((t)=>({...t,id:oe(t.id)}))}:{},...e.authenticatorSelection?{authenticatorSelection:e.authenticatorSelection}:{},...e.attestation?{attestation:e.attestation}:{},...e.extensions?{extensions:e.extensions}:{}}}var Xe=(e,t)=>fetch(e,t);class se{fetchFn;constructor(e={}){this.fetchFn=e.fetch??Xe}async fetchAccount(){return(await q(await this.fetchFn("/auth/account",{credentials:"same-origin",cache:"no-store"}),ne)).account}async mutatePluginSettings(e){return(await q(await this.fetchFn("/auth/account/plugin-settings",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),ne)).account}async mutateAccount(e){return q(await this.fetchFn("/auth/account/mutations",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),Je)}async registerPasskey(){let e=await q(await this.fetchFn("/auth/account/passkeys/options",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"}),We),t=await navigator.credentials.create({publicKey:Ke(e)});if(!(t instanceof PublicKeyCredential))throw Error("Passkey registration was cancelled");if(!(t.response instanceof AuthenticatorAttestationResponse))throw Error("Authenticator returned an invalid passkey response");let n=t.response,i={id:t.id,rawId:ae(t.rawId),type:t.type,...t.authenticatorAttachment?{authenticatorAttachment:t.authenticatorAttachment}:{},clientExtensionResults:t.getClientExtensionResults(),response:{clientDataJSON:ae(n.clientDataJSON),attestationObject:ae(n.attestationObject),transports:typeof n.getTransports==="function"?n.getTransports():[]}};return(await q(await this.fetchFn("/auth/account/passkeys/verify",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),ne.extend({verified:a.literal(!0)}))).account}}function me(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map((t)=>t.slice(0,1).toUpperCase()).join("")}function fe(e,t){let n=t.indexOf("/");if(n<=0||n===t.length-1)return;let i=t.slice(0,n),s=t.slice(n+1);return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(i)}/${encodeURIComponent(s)}`}function D(e,t=!1){return new Date(t?e:e*1000).toISOString()}var P=v(N(),1);function H(e){return P.jsxDEV(y,{variant:e.tone==="danger"?"danger":e.tone==="primary"?"primary":"outline",type:e.type??"button",onClick:e.onClick,disabled:e.disabled,children:e.children},void 0,!1,void 0,this)}function M(e){return P.jsxDEV("div",{className:o("account-access-item",c.access),children:[P.jsxDEV(ge,{density:"comfortable",title:e.kind,description:e.description,metadata:e.metadata??[]},void 0,!1,void 0,this),e.action]},void 0,!0,void 0,this)}function w(e){return P.jsxDEV("section",{className:o("account-detail-section",c.section),children:[P.jsxDEV("div",{className:"account-section-label",children:[P.jsxDEV("h3",{className:o("",c.heading,W.section),children:e.title},void 0,!1,void 0,this),e.description?P.jsxDEV("p",{className:o("",c.description),children:e.description},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),P.jsxDEV("div",{className:o("people-stack",c.stack),children:e.children},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function he(e,t){let n=Object.fromEntries(t.entries());for(let i of e)if(i.control==="checkbox")n[i.name]=t.has(i.name);else if(i.control==="number"&&typeof n[i.name]==="string"&&n[i.name]!=="")n[i.name]=Number(n[i.name]);return n}function ye(e){if(e.secret)return"password";if(e.control==="url"||e.control==="number")return e.control;return"text"}var r=v(N(),1);function ke(e){let{account:t,actions:n,title:i,studioPath:s}=e,h=t.role,f=t.profileEntityId?fe(s,t.profileEntityId):void 0;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV(w,{title:"Profile",children:[r.jsxDEV("div",{className:o("account-identity",c.identity),children:r.jsxDEV("div",{className:o("people-detail-person",c.person),children:[r.jsxDEV("span",{className:o("people-avatar people-avatar--large",c.avatar),children:me(i)},void 0,!1,void 0,this),r.jsxDEV("span",{className:o("",c.personCopy),children:[r.jsxDEV("span",{className:o("people-detail-name",c.name,W.secondaryDisplay),children:i},void 0,!1,void 0,this),r.jsxDEV("span",{"data-account-role":h,className:o("account-role",c.role),children:Ae(h)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t.profileEntityId?r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:o("account-profile-note",c.description),children:"Managed by the Anchor profile — your account name follows the published profile."},void 0,!1,void 0,this),r.jsxDEV(M,{kind:"Anchor profile",description:i,action:f?r.jsxDEV(y,{asChild:!0,variant:"link",children:r.jsxDEV("a",{href:f,children:"Edit Anchor Profile →"},void 0,!1,void 0,this)},void 0,!1,void 0,this):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this):r.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(C)=>{C.preventDefault(),n.saveName()},children:[r.jsxDEV("label",{className:o("",c.formLabel),htmlFor:"display-name",children:"Display name"},void 0,!1,void 0,this),r.jsxDEV(V,{id:"display-name",maxLength:200,autoComplete:"name",required:!0,value:n.displayName,onChange:(C)=>n.setDisplayName(C.target.value)},void 0,!1,void 0,this),r.jsxDEV(H,{type:"submit",disabled:n.busy,children:"Save name"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV("p",{className:o("",c.description),children:"Your role controls access to this brain. An administrator manages access in Administration."},void 0,!1,void 0,this),h==="admin"&&r.jsxDEV(y,{asChild:!0,variant:"outline",children:r.jsxDEV("a",{href:ve(s,"admin:administration"),children:"Manage people in Administration →"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Se(e){let t=e.account.connectedChannels;return r.jsxDEV(w,{title:"Linked identities",description:"How this brain recognizes messages from you. These are your identities, not services configured for the whole brain.",children:t.length===0?r.jsxDEV("p",{className:o("people-empty",c.empty),children:"No linked identities."},void 0,!1,void 0,this):t.map((n)=>r.jsxDEV(M,{kind:n.type,description:n.label,metadata:[`Verified: ${D(n.verifiedAt,!0)}`]},`${n.type}:${n.label}`,!1,void 0,this))},void 0,!1,void 0,this)}function xe(e){let{account:t,actions:n}=e;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:o("",c.description),children:"Settings for your account only. These do not configure shared services for the brain."},void 0,!1,void 0,this),t.pluginSettings.map((i)=>r.jsxDEV(be,{label:i.title,density:"comfortable",presentation:"disclosure",children:[r.jsxDEV("p",{className:o("account-settings-description",c.description),children:i.description??"Private settings for this account."},void 0,!1,void 0,this),r.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(s)=>{s.preventDefault(),n.saveSettings(i,new FormData(s.currentTarget))},children:[i.fields.map((s)=>r.jsxDEV("label",{htmlFor:`setting-${i.id}-${s.name}`,className:o("",c.field),children:[r.jsxDEV("span",{className:o("",c.formLabel),children:s.label},void 0,!1,void 0,this),s.control==="checkbox"?r.jsxDEV(K,{id:`setting-${i.id}-${s.name}`,name:s.name,defaultChecked:s.value===!0},void 0,!1,void 0,this):r.jsxDEV(V,{id:`setting-${i.id}-${s.name}`,name:s.name,type:ye(s),required:s.required&&(!i.configured||s.secret)&&!s.set,defaultValue:s.secret?"":typeof s.value==="string"||typeof s.value==="number"?s.value:"",placeholder:s.secret&&s.set?"Stored — leave blank to keep":void 0,autoComplete:"off"},void 0,!1,void 0,this)]},s.name,!0,void 0,this)),r.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:[r.jsxDEV(H,{type:"submit",tone:"primary",disabled:n.busy,children:"Save settings"},void 0,!1,void 0,this),i.configured?r.jsxDEV(y,{variant:"danger",disabled:n.busy,type:"button",onClick:()=>n.removeSettings(i),children:"Remove"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},`${i.id}:${i.revision??"unset"}`,!0,void 0,this)]},i.id,!0,void 0,this))]},void 0,!0,void 0,this)}function we(e){let{account:t,actions:n}=e,{busy:i}=n;return r.jsxDEV("div",{className:o("",c.column),children:[r.jsxDEV(w,{title:"Sign-in",description:"Passkeys used to access this account. Your final passkey is protected from revocation.",children:[t.passkeys.map((s)=>r.jsxDEV(M,{kind:s.credentialBackedUp?"Synced passkey":"Device passkey",metadata:[`Added: ${D(s.createdAt,!0)}`],action:t.passkeys.length>1?r.jsxDEV(y,{variant:"danger",disabled:i,type:"button",onClick:()=>n.revokePasskey(s.id),children:"Revoke"},void 0,!1,void 0,this):void 0},s.id,!1,void 0,this)),r.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:r.jsxDEV(y,{variant:"outline",disabled:i,type:"button",onClick:n.addPasskey,children:"Add passkey"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV(w,{title:"Signed-in sessions",children:t.sessions.map((s)=>r.jsxDEV(M,{kind:s.current?"This session":"Browser session",metadata:[`Started: ${D(s.createdAt)}`,...s.current?["Current browser"]:[]],action:!s.current?r.jsxDEV(y,{variant:"danger",disabled:i,type:"button",onClick:()=>n.revokeSession(s.id),children:"End"},void 0,!1,void 0,this):void 0},s.id,!1,void 0,this))},void 0,!1,void 0,this),r.jsxDEV("footer",{className:o("account-session-actions",c.footer),children:[r.jsxDEV("small",{children:"Access changes require an Admin."},void 0,!1,void 0,this),r.jsxDEV("div",{className:o("",c.actions),children:[r.jsxDEV(H,{disabled:i||t.sessions.every((s)=>s.current),onClick:n.revokeOtherSessions,children:"End other sessions"},void 0,!1,void 0,this),r.jsxDEV(H,{tone:"danger",disabled:i,onClick:n.revokeAllSessions,children:"Sign out everywhere"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Te=v(Z(),1);var p={clients:{k1xSpc:"xrvj5dj",kumcoG:"x12p5jtz",kOIVth:"x1af02g3",k7Eaqz:"xeuugli",$$css:!0},client:{k7Eaqz:"xeuugli",k1xSpc:"xrvj5dj",kfiyM8:"x10ukxgv",kOIVth:"x883omv",kmVPX3:"x1np1h16",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",kWkggS:"x18s3upu",$$css:!0},clientName:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},text:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},steps:{kogj98:"x1ghz6dp",kE3dHu:"x5tiur9",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},fields:{k1xSpc:"xrvj5dj",kumcoG:"x16lqc3j",kOIVth:"x1vtxxvk",kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",$$css:!0},field:{k1xSpc:"xjp7ctv",$$css:!0},fieldLabel:{k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},fieldValue:{kogj98:"x1ghz6dp",k7Eaqz:"xeuugli",kHjlTd:"xj0a0fe",kMwMTN:"x1ar3pfp",$$css:!0},code:{kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x12oqio5",kmVPX3:"x1nyoefi",$$css:!0},snippet:{k1xSpc:"x78zum5",kGNEyG:"x1cy8zhl",kOIVth:"x167g77z",k7Eaqz:"xeuugli",$$css:!0},snippetCode:{kUk6DE:"x98rzlu",k7Eaqz:"xeuugli",kogj98:"x1ghz6dp",kmVPX3:"x6yrr3s",kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kLWn49:"x1jjo3f5",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x1kogg8i",khDVqt:"x1sdyfia",kXHlph:"xw2csxc",$$css:!0},developer:{k7Eaqz:"xeuugli",kmVPX3:"x1d8yrva",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",$$css:!0},developerSummary:{kkrTdU:"x1ypdohk",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},developerClients:{keoZOQ:"x1hmvnq2",kumcoG:"x1mkdm3x",$$css:!0},developerHint:{k1xSpc:"x1lliihq",keoZOQ:"x1gslohp",k63SB2:"xo1l8bm",kGuDYH:"xfifm61",kMwMTN:"x1ar3pfp",$$css:!0}};function re(e){return new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ie(e){return JSON.stringify(e,null,2)}function Ce(e,t,n){return["Already have servers there? Add only the ",{code:`"${n}"`}," entry inside ",{code:`"${t}"`},` of ${e}.`]}function Ne(e){let t=re(e),n="Sign in with your passkey when asked.";return[{id:"claude",group:"primary",name:"Claude",note:["Desktop app and claude.ai."],steps:[["Open Settings → Connectors → Add custom connector."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when asked."]]},{id:"chatgpt",group:"primary",name:"ChatGPT",steps:[["Open Settings → Apps & Connectors → Advanced and turn on Developer mode."],["Choose Create, name it ",{code:t},", paste your brain’s address and pick OAuth."],["Sign in with your passkey when asked."]]},{id:"claude-code",group:"developer",name:"Claude Code",lead:[["Add the server in your terminal:"]],snippet:{label:"Claude Code command",code:`claude mcp add --transport http ${t} ${e}`},after:[["Then start Claude Code, run ",{code:"/mcp"},", choose ",{code:t}," and sign in with your passkey."]]},{id:"cursor",group:"developer",name:"Cursor",steps:[["Open Cursor Settings → MCP → Add new global MCP server."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when Cursor asks."]],lead:[["Or add it to ",{code:"~/.cursor/mcp.json"},":"]],snippet:{label:"Cursor configuration",code:ie({mcpServers:{[t]:{url:e}}})},after:[Ce("the file","mcpServers",t)]},{id:"vscode",group:"developer",name:"VS Code",steps:[["Open the Command Palette and run ",{code:"MCP: Add Server"},"."],["Choose HTTP, paste your brain’s address and name it ",{code:t},"."],["Choose Global, then sign in with your passkey when asked."]],lead:[["Or run ",{code:"MCP: Open User Configuration"}," and add:"]],snippet:{label:"VS Code configuration",code:ie({servers:{[t]:{type:"http",url:e}}})},after:[Ce("your user configuration","servers",t)]},{id:"other",group:"developer",name:"Any other MCP client",inlineName:"any other MCP client",note:["Look for “add MCP server”, “connector” or “integration” in the tool’s settings and fill in:"],fields:[{label:"Name",value:[{code:t}]},{label:"Type",value:["Remote server, Streamable HTTP — not stdio, not SSE"]},{label:"URL",value:[{code:e}]},{label:"Authentication",value:["OAuth. Leave API key, token, client ID and secret empty; the tool registers itself."]}],lead:[["When you connect, your browser opens “Authorize <tool>?” on your brain. Approve MCP access with your passkey. The tool then has two tools: ",{code:"chat"},", to ask your brain anything as you would in chat, and ",{code:"confirm"},", to approve changes when the brain asks."],["Tool only takes local (stdio) servers, or insists on an API key? Bridge it with ",{code:"mcp-remote"},", which handles the sign-in:"]],snippet:{label:"mcp-remote bridge configuration",code:ie({mcpServers:{[t]:{command:"npx",args:["-y","mcp-remote",e]}}})}}]}var l=v(N(),1);function Y(e){return l.jsxDEV(l.Fragment,{children:e.text.map((t,n)=>typeof t==="string"?t:l.jsxDEV("code",{className:o("",p.code),children:t.code},n,!1,void 0,this))},void 0,!1,void 0,this)}function U(e){let[t,n]=Te.useState("idle"),i=async()=>{try{await navigator.clipboard.writeText(e.code),n("copied")}catch{n("unavailable")}};return l.jsxDEV("div",{className:o("ai-tools-snippet",p.snippet),children:[l.jsxDEV("pre",{className:o("",p.snippetCode),"aria-label":e.label,children:e.code},void 0,!1,void 0,this),l.jsxDEV(y,{variant:"outline",size:"sm",onClick:()=>void i(),"aria-label":`Copy ${e.label}`,children:t==="copied"?"Copied":t==="unavailable"?"Select to copy":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function X(e){let{client:t}=e;return l.jsxDEV("article",{className:o("ai-tools-client",p.client),children:[l.jsxDEV("h4",{className:o("",p.clientName),children:t.name},void 0,!1,void 0,this),t.note?l.jsxDEV("p",{className:o("",p.text),children:l.jsxDEV(Y,{text:t.note},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,t.steps?l.jsxDEV("ol",{className:o("",p.steps),children:t.steps.map((n,i)=>l.jsxDEV("li",{children:l.jsxDEV(Y,{text:n},void 0,!1,void 0,this)},i,!1,void 0,this))},void 0,!1,void 0,this):null,t.fields?l.jsxDEV("dl",{className:o("",p.fields),children:t.fields.map((n)=>l.jsxDEV("div",{className:o("",p.field),children:[l.jsxDEV("dt",{className:o("",p.fieldLabel),children:n.label},void 0,!1,void 0,this),l.jsxDEV("dd",{className:o("",p.fieldValue),children:l.jsxDEV(Y,{text:n.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},n.label,!0,void 0,this))},void 0,!1,void 0,this):null,t.lead?.map((n,i)=>l.jsxDEV("p",{className:o("",p.text),children:l.jsxDEV(Y,{text:n},void 0,!1,void 0,this)},`lead-${i}`,!1,void 0,this)),t.snippet?l.jsxDEV(U,{...t.snippet},void 0,!1,void 0,this):null,t.after?.map((n,i)=>l.jsxDEV("p",{className:o("",p.text),children:l.jsxDEV(Y,{text:n},void 0,!1,void 0,this)},`after-${i}`,!1,void 0,this))]},void 0,!0,void 0,this)}function Ze(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function Pe(e){let t=Ne(e.mcpUrl),n=t.filter((s)=>s.group==="primary"),i=t.filter((s)=>s.group==="developer");return l.jsxDEV(w,{title:"AI tools",description:"Connect AI tools you already use to this brain. A connected tool talks to the brain as you do in chat — asking, saving and updating within your access — after you sign in with your passkey.",children:[l.jsxDEV("article",{className:o("ai-tools-address",p.client),children:[l.jsxDEV("h4",{className:o("",p.clientName),children:"Your brain’s address"},void 0,!1,void 0,this),l.jsxDEV(U,{label:"brain address",code:e.mcpUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:o("ai-tools-clients",p.clients),children:n.map((s)=>l.jsxDEV(X,{client:s},s.id,!1,void 0,this))},void 0,!1,void 0,this),l.jsxDEV("details",{className:o("ai-tools-developer",p.developer),children:[l.jsxDEV("summary",{className:o("",p.developerSummary),children:["Developer tools and other clients",l.jsxDEV("span",{className:o("",p.developerHint),children:Ze(i.map((s)=>s.inlineName??s.name))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:o("ai-tools-clients",p.clients,p.developerClients),children:i.map((s)=>l.jsxDEV(X,{client:s},s.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Me=v(Z(),1);var Qe="Enter the username and password of an app password from this page.";function $e(e){let t=new URL(e),n=`${t.protocol==="https:"?"davs":"dav"}://${t.host}${t.pathname}`,i=re(e);return[{id:"gnome-files",name:"GNOME Files",note:["The file manager on Ubuntu, Fedora and other GNOME desktops."],steps:[["Open Files → Other Locations (or Network)."],["Under Connect to Server, enter the address below and connect."],[Qe]],snippet:{label:"GNOME Files address",code:n}},{id:"rclone",name:"rclone",note:["Linux, macOS and Windows, from a terminal."],lead:[["Store the drive as a remote, with your app password’s username and password:"]],snippet:{label:"rclone remote command",code:`rclone config create ${i} webdav url=${e} vendor=other user=YOUR_USERNAME pass=YOUR_PASSWORD --obscure`},after:[["Then mount it on an empty folder: ",{code:`rclone mount ${i}: ~/Brain --vfs-cache-mode writes`},"."]]}]}var m=v(N(),1),Q="app-password-label",Oe="app-password-write";function ce(e){return D(e).slice(0,10)}function et(e,t){return[`Created: ${ce(e.createdAt)}`,`${e.expiresAt<=t?"Expired":"Expires"}: ${ce(e.expiresAt)}`,e.lastUsedAt===void 0?"Never used":`Last used: ${ce(e.lastUsedAt)}`]}function Re(e){let{account:t,actions:n}=e,{busy:i,createdAppPassword:s}=n,h=Math.floor(Date.now()/1000),[f,C]=Me.useState(!1);return m.jsxDEV("div",{className:o("",c.column),children:[m.jsxDEV(w,{title:"Drive",description:"Mount this brain as a network drive. It shows the notes, posts and files you can see here, as folders and files, to open and edit on your computer.",children:m.jsxDEV("article",{className:o("drive-address",p.client),children:[m.jsxDEV("h4",{className:o("",p.clientName),children:"Your brain’s drive address"},void 0,!1,void 0,this),m.jsxDEV(U,{label:"drive address",code:e.davUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),m.jsxDEV(w,{title:"App passwords",description:"A mount signs in with an app password instead of your passkey. It works only for the drive, expires after a year and can be revoked here. It can only read unless you allow saving changes.",children:[s?m.jsxDEV("article",{"data-app-password-reveal":!0,className:o("drive-reveal",p.client),children:[m.jsxDEV("h4",{className:o("",p.clientName),children:"Your new app password"},void 0,!1,void 0,this),m.jsxDEV("p",{className:o("",p.text),children:"Copy both now. The password is shown only once."},void 0,!1,void 0,this),m.jsxDEV(U,{label:"username",code:s.username},void 0,!1,void 0,this),m.jsxDEV(U,{label:"password",code:s.password},void 0,!1,void 0,this),m.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:m.jsxDEV(y,{variant:"outline",type:"button",onClick:n.dismissCreatedAppPassword,children:"Done"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,t.appPasswords.length===0?m.jsxDEV("p",{className:o("",p.text),children:"No app passwords yet."},void 0,!1,void 0,this):t.appPasswords.map((g)=>m.jsxDEV(M,{kind:g.label,description:`${g.username} · ${g.access==="write"?"Read and write":"Read-only"}`,metadata:et(g,h),action:m.jsxDEV(y,{variant:"danger",disabled:i,type:"button",onClick:()=>n.revokeAppPassword(g.id),children:"Revoke"},void 0,!1,void 0,this)},g.id,!1,void 0,this)),m.jsxDEV("form",{className:o("name-form",c.form),onSubmit:(g)=>{g.preventDefault();let k=g.currentTarget,x=String(new FormData(k).get(Q)??"");if(x.trim()==="")return;n.createAppPassword(x.trim(),f?"write":"read"),k.reset(),C(!1)},children:[m.jsxDEV("label",{htmlFor:Q,className:o("",c.field),children:[m.jsxDEV("span",{className:o("",c.formLabel),children:"Name it after the computer it is for"},void 0,!1,void 0,this),m.jsxDEV(V,{id:Q,name:Q,type:"text",required:!0,maxLength:100,placeholder:"Laptop",autoComplete:"off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("label",{htmlFor:Oe,className:o("",c.field),children:[m.jsxDEV("span",{className:o("",c.formLabel),children:"Allow saving changes"},void 0,!1,void 0,this),m.jsxDEV(K,{id:Oe,"aria-label":"Allow saving changes",checked:f,onCheckedChange:C},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{className:o("people-inline-actions",c.inlineActions),children:m.jsxDEV(y,{variant:"outline",disabled:i,type:"submit",children:"New app password"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV(w,{title:"Mount it",children:m.jsxDEV("div",{className:o("drive-clients",p.clients),children:$e(e.davUrl).map((g)=>m.jsxDEV(X,{client:g},g.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var S=v(Z(),1);var ee={revokePasskey:{title:"Revoke this passkey?",message:"You will not be able to use this passkey again.",confirmLabel:"Revoke passkey",pending:"Revoking passkey…",complete:"Passkey revoked."},revokeSession:{title:"End this browser session?",message:"That browser will need a passkey to sign in again.",confirmLabel:"End session",pending:"Ending session…",complete:"Session ended."},revokeAppPassword:{title:"Revoke this app password?",message:"Anything mounted with it stops working at once. Its password cannot be recovered.",confirmLabel:"Revoke app password",pending:"Revoking app password…",complete:"App password revoked."},revokeOtherSessions:{title:"End every other browser session?",message:"Your current browser will remain signed in.",confirmLabel:"End other sessions",pending:"Ending other sessions…",complete:"Other sessions ended."}};function Ee(e){return Ie(e,"Account request failed")}function De(e){let{client:t,initialAccount:n}=e,[i,s]=S.useState(n),[h,f]=S.useState(n?.displayName??e.initialDisplayName),[C,g]=S.useState(""),[k,x]=S.useState(!1),[T,G]=S.useState(!1),[B,F]=S.useState(null),[He,le]=S.useState(null);S.useEffect(()=>{if(n)return;let u=!1;return t.fetchAccount().then((b)=>{if(u)return;s(b),f(b.displayName)}).catch((b)=>{if(u)return;x(!0),g(Ee(b))}),()=>{u=!0}},[t,n]);let O=S.useCallback(async(u,b,I)=>{G(!0),x(!1),g(u);try{let z=await I();if(z)s(z),f(z.displayName);g(b)}catch(z){x(!0),g(Ee(z))}finally{G(!1)}},[]),ue=async(u)=>(await t.mutateAccount(u)).account,_=(u,b)=>F({title:u.title,message:u.message,confirmLabel:u.confirmLabel,action:()=>{O(u.pending,u.complete,()=>ue(b))}});return{account:i,displayName:h,setDisplayName:f,status:C,error:k,busy:T,confirmation:B,cancelConfirmation:()=>F(null),confirm:()=>{if(!B)return;F(null),B.action()},saveName:()=>{O("Saving…","Display name updated.",()=>ue({action:A.updateDisplayName,confirmation:A.updateDisplayName,displayName:h}))},addPasskey:()=>{O("Waiting for your authenticator…","Passkey added.",()=>t.registerPasskey())},revokePasskey:(u)=>_(ee.revokePasskey,{action:A.revokePasskey,confirmation:A.revokePasskey,credentialId:u}),revokeSession:(u)=>_(ee.revokeSession,{action:A.revokeSession,confirmation:A.revokeSession,sessionId:u}),revokeOtherSessions:()=>_(ee.revokeOtherSessions,{action:A.revokeOtherSessions,confirmation:A.revokeOtherSessions}),revokeAllSessions:()=>F({title:"Sign out everywhere?",message:"This ends every session, including this one. You will need your passkey to return.",confirmLabel:"Sign out everywhere",action:()=>{O("Signing out everywhere…","Signed out.",async()=>{await t.mutateAccount({action:A.revokeAllSessions,confirmation:A.revokeAllSessions}),window.location.assign(`/login?return_to=${encodeURIComponent(e.routePath)}`);return})}}),saveSettings:(u,b)=>{let I=he(u.fields,b);O(`Saving ${u.title}…`,`${u.title} updated.`,()=>t.mutatePluginSettings({action:"save",definitionId:u.id,values:I}))},createdAppPassword:He,createAppPassword:(u,b)=>{O("Creating app password…","App password created.",async()=>{let I=await t.mutateAccount({action:A.createAppPassword,confirmation:A.createAppPassword,label:u,...b==="write"?{access:b}:{}});return le(I.appPassword??null),I.account})},dismissCreatedAppPassword:()=>le(null),revokeAppPassword:(u)=>_(ee.revokeAppPassword,{action:A.revokeAppPassword,confirmation:A.revokeAppPassword,appPasswordId:u}),removeSettings:(u)=>F({title:`Remove ${u.title}?`,message:"The stored settings for this integration will be removed from your account only.",confirmLabel:"Remove settings",action:()=>{O(`Removing ${u.title}…`,`${u.title} removed.`,()=>t.mutatePluginSettings({action:"delete",definitionId:u.id}))}})}}var d=v(N(),1),tt=["profile","security","identities","settings",L,j];function nt(e){let t=tt.find((n)=>n===e.initialSection);if(!t||t===L&&!e.mcpUrl||t===j&&!e.davUrl)return"profile";return t}function ot(e){let t=["your profile","sign-in security","linked identities",...e.settings?["personal settings"]:[],...e.aiTools?["AI tools"]:[],...e.drive?["your drive"]:[]];return`Your account on this brain. Manage ${`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`} here—not shared services or other people’s access.`}function on({bootstrap:e,initialAccount:t,client:n}){let i=Be(),s=te.useMemo(()=>n??new se({fetch:i.fetch}),[n,i]),h=De({client:s,initialAccount:t,initialDisplayName:e.displayName,routePath:e.routePath}),{account:f,status:C,error:g,busy:k,confirmation:x}=h,[T,G]=te.useState(()=>nt(e)),B=f?.displayName??e.displayName;return d.jsxDEV(d.Fragment,{children:[d.jsxDEV("div",{className:o("account-shell",c.shell,Fe.inset),children:[d.jsxDEV(qe,{model:{access:ze("public"),title:"Your account",totals:[]}},void 0,!1,void 0,this),d.jsxDEV("p",{className:o("account-scope",c.description),children:ot({settings:(f?.pluginSettings.length??0)>0,aiTools:Boolean(e.mcpUrl),drive:Boolean(e.davUrl)})},void 0,!1,void 0,this),d.jsxDEV("p",{className:o(`account-status${g?" is-error":""}`,c.feedback,g&&c.feedbackError),role:"status","aria-live":"polite",children:C},void 0,!1,void 0,this),!f?d.jsxDEV("p",{className:o("account-loading",c.loading),children:"Reading your account…"},void 0,!1,void 0,this):d.jsxDEV(Le,{className:"account-details",value:T,onValueChange:G,children:[d.jsxDEV(je,{"aria-label":"Account sections",className:o("account-tabs",c.tabs),children:[d.jsxDEV(R,{value:"profile",disabled:k,children:"Profile"},void 0,!1,void 0,this),d.jsxDEV(R,{value:"security",disabled:k,children:"Sign-in & sessions"},void 0,!1,void 0,this),d.jsxDEV(R,{value:"identities",disabled:k,children:"Linked identities"},void 0,!1,void 0,this),f.pluginSettings.length>0&&d.jsxDEV(R,{value:"settings",disabled:k,children:"Personal settings"},void 0,!1,void 0,this),e.mcpUrl&&d.jsxDEV(R,{value:L,disabled:k,children:"AI tools"},void 0,!1,void 0,this),e.davUrl&&d.jsxDEV(R,{value:j,disabled:k,children:"Drive"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.jsxDEV(E,{value:"profile",forceMount:!0,hidden:T!=="profile",className:o("account-detail-sections",c.tabPanel),children:d.jsxDEV(ke,{account:f,actions:h,title:B,studioPath:e.studioPath},void 0,!1,void 0,this)},void 0,!1,void 0,this),d.jsxDEV(E,{value:"identities",forceMount:!0,hidden:T!=="identities",className:o("",c.tabPanel),children:d.jsxDEV(Se,{account:f},void 0,!1,void 0,this)},void 0,!1,void 0,this),f.pluginSettings.length>0&&d.jsxDEV(E,{value:"settings",forceMount:!0,hidden:T!=="settings",className:o("",c.tabPanel),children:d.jsxDEV(xe,{account:f,actions:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),d.jsxDEV(E,{value:"security",forceMount:!0,hidden:T!=="security",className:o("",c.tabPanel),children:d.jsxDEV(we,{account:f,actions:h},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.mcpUrl&&d.jsxDEV(E,{value:L,forceMount:!0,hidden:T!==L,className:o("",c.tabPanel),children:d.jsxDEV(Pe,{mcpUrl:e.mcpUrl},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.davUrl&&d.jsxDEV(E,{value:j,forceMount:!0,hidden:T!==j,className:o("",c.tabPanel),children:d.jsxDEV(Re,{davUrl:e.davUrl,account:f,actions:h},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),x&&d.jsxDEV(Ue,{mark:"!",title:x.title,titleId:"account-confirmation-title",cancelLabel:"Cancel",confirmLabel:x.confirmLabel,confirmVariant:"danger",pending:k,onCancel:h.cancelConfirmation,onConfirm:h.confirm,children:d.jsxDEV("p",{children:x.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{on as AccountApp};
2
-
3
- //# debugId=4FD8414DFB5CCF5F64756E2164756E21