1import{c as oe,o as ie,d as se,e as g,b as a,f as b,g as ne,h as re,O as M,D as $,j as O,B as k,k as ae,m as pe,n as le,s as x,q as ce,t as de,u as P,a as me,v as ue,w as he}from"./AIToolGateTJCcVK_a.js";import{O as d,c as ge,N as fe}from"./chunkReloadRecoveryrjuMb-b8.js";import{D as K,Y as we}from"./OperationQueueKzEpmh-u.js";import{c as U,g as _e,m as Y,e as T,p as B,a as ye,A as R,b as H,d as ve,f as Se}from"./ai-task-modelsBeJRs03P.js";import{c,d as h,e as Ae,f as Ie,g as Ee}from"./scopedSettings39hV2RLq.js";import{r as Te,D as be}from"./ai-image-modelsDeC4X7bn.js";import{D,g as Me,a as Oe,p as ke,d as De}from"./firefoxMlProbeV0nNkr25.js";import"./aiAgentApprovalsDHfWEcxe.js";import"./remoteActionApprovalC_byoH4M.js";import"./classificationEvalProgramStatusBazwXda2.js";import"./item-name.utilsBH3paGZr.js";import"./dexie2jmnBxhj.js";import"./ActivityUtilsDiYdCK40.js";import"./constantsDW26WJ6H.js";import"./url.utils3SlYVg-c.js";import"./reason-code.utilswudkndKE.js";import"./reason-metadataDPJV5z5v.js";import"./socialMediaSitesDTleWHW6.js";import"./regexCcuTG5WM.js";import"./appUsageDisplayBY7OQki1.js";import"./urlGuardsBFjEFH91.js";import"./deviceAppIdsBqiQQIm5.js";import"./sentryUtilsC8JjCXHs.js";import"./ItemServiceDYS7Z6Pr.js";import"./noteAttachmentDId5R_kp.js";import"./file_utilsBvAXo0vA.js";import"./extraction.pure.utilsDQPW8yIh.js";import"./api-typesD1zIcSfT.js";import"./freshSignInv8N2vL5e.js";import"./textEmbeddingUtilsBRNkRshv.js";import"./item.typesx7Q7rrX9.js";import"./searchContentKindsBGoDYC-k.js";import"./content.typesyje91KzF.js";import"./feedback.utilscwcZGi10.js";import"./feedDiscoveryCsjZq3pR.js";import"./itemImageSourcesCubmTdva.js";import"./search-provider.utilsBiOzVtNa.js";import"./statusFacetsB0tsuUpJ.js";import"./browseFacets8dSOpUAG.js";import"./rolloutCapsBJsLLLO7.js";import"./vue-runtimeBHGad_ZB.js";import"./cjs-helpersC4iS2aBk.js";import"./bootstrap-vue-nextDXY4qsO1.js";import"./classificationRulesDUyL5GMw.js";import"./browserTabsCpW6SD42.js";import"./settingsMenuCatalogBT0bsy85.js";import"./tourGateGu4icdk6.js";import"./searchTargets.pureDLBWinh3.js";import"./SearchHistoryStoreBNg-02Jq.js";import"./urlDuplicateMatchingB9T_GhRn.js";import"./siteBlockModeCGmJVg0R.js";import"./alwaysAllowedBZhbIqQn.js";import"./familyClockv2WXhBE2.js";import"./deviceAppPolicyG0TWkbSX.js";import"./familyDowntimeDMv_mvJ9.js";import"./google-ai-modeaEFJUNOw.js";import"./usageBDNfLijZ.js";import"./v4CtRu48qb.js";import"./restrictionPresetsAJUpiAxw.js";import"./deviceAppInventoryMergevnYbxNmN.js";import"./usageIdentityCn48n3s8.js";import"./usageInterventionModeBjzyP5YP.js";import"./TextEmbeddingServiceD7QjSnH7.js";import"./analysis-utilsDkY9KbJt.js";import"./queryEmbeddingl6fVc4SQ.js";import"./usageRuleStateD0i2H3LO.js";import"./TaskServiceWHtFbUzu.js";import"./TaskCompletionRefStateServiceDiefvKK0.js";import"./refStateBatchSupportDh0Q7mM-.js";import"./TaskItemServiceP03d_i_t.js";import"./libraryWriteGuardslN41qmuD.js";import"./restrictedSiteAccessWarning.utilsCD4Urb73.js";import"./ai_lookup_utilszDX_hcwM.js";import"./typespYBkq7G_.js";import"./appTestRunfuVuTQEj.js";import"./aiLimitCopyBGu8nbyi.js";import"./ActivityVisitServiceBx6JVwhp.js";import"./libraryWritesCIlf8O8q.js";import"./ruleOverrideUtilsbdiM4nZd.js";import"./usageRowStatuscqOMbT-P.js";import"./deviceHealthCq8tdRO9.js";import"./sidebarNavDnagZR1g.js";import"./agentParentalGrantCz4Xs1Ac.js";import"./familyDowntimeCopyBHQ3lAwm.js";import"./dayGroupLabelsBMNWfGiA.js";async function W(o){const e=o.trim().replace(/\/+$/,"");if(!e)return{ok:!1,models:[],error:"No endpoint provided"};try{await oe(e)}catch{}try{const t=await fetch(`${e}/api/tags`,{method:"GET"});if(!t.ok)return{ok:!1,models:[],error:`HTTP ${t.status} ${t.statusText}`};const i=await t.json();return{ok:!0,models:Array.isArray(i==null?void 0:i.models)?i.models.map(n=>({name:String((n==null?void 0:n.name)||(n==null?void 0:n.model)||"")})).filter(n=>n.name):[]}}catch(t){return{ok:!1,models:[],error:ie(e,t)}}}const Le="ai.image.provider",Ge="ai.image.model",Ne="ai.image.local.endpoint",Ce="ai.image.local.model",Pe="http://localhost:7860",v={scope:"client"},F=1024,Re=28,Fe=7;function L(o){return o.trim().replace(/\/+$/,"")}async function j(){if((await c(Le,v)||"server")==="local"){const t=L(await c(Ne,v)||Pe),i=await c(Ce,v)||"";return{provider:"local",endpoint:t,model:i}}return{provider:"server",model:Te(await c(Ge,v)||be)}}async function $e(o){const e=await j();if(await se(e.provider==="local"?"private":"kindredly"),e.provider==="local")return{imageData:await xe(e.endpoint,e.model,o),taskId:String(Date.now())};const t=await K("/usertask/generateImage",{prompt:o,model:e.model});return{imageData:t==null?void 0:t.imageData,imageUrl:t==null?void 0:t.imageUrl,taskId:String((t==null?void 0:t.taskId)||Date.now())}}async function xe(o,e,t){const i=L(o);if(!i)throw new Error("No image server address is set.");const p={prompt:t,width:F,height:F,steps:Re,cfg_scale:Fe,batch_size:1,n_iter:1};e&&(p.override_settings={sd_model_checkpoint:e});let n;try{n=await fetch(`${i}/sdapi/v1/txt2img`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})}catch(w){throw new Error(q(i,w))}if(!n.ok)throw new Error(`Your image server answered ${n.status} ${n.statusText}.`);const m=await n.json(),f=Array.isArray(m==null?void 0:m.images)?String(m.images[0]||""):"";if(!f)throw new Error("Your image server returned no picture.");return f.replace(/^data:image\/[a-z+]+;base64,/i,"")}async function Ke(o){const e=L(o);if(!e)return{ok:!1,models:[],error:"No address set."};try{const t=await fetch(`${e}/sdapi/v1/sd-models`,{method:"GET"});if(!t.ok)return{ok:!1,models:[],error:`HTTP ${t.status} ${t.statusText}`};const i=await t.json();return{ok:!0,models:Array.isArray(i)?i.map(n=>String((n==null?void 0:n.title)||(n==null?void 0:n.model_name)||"")).filter(
1Boolean):[]}}catch(t){return{ok:!1,models:[],error:q(e,t)}}}function q(o,e){const t=e instanceof Error?e.message:String(e||"");return`Could not reach ${o}. Check it is running, and that it allows this page (start it with --api and --cors-allow-origins). ${t}`.trim()}const l={scope:"client"},s=[];s.push({path:"/ai/itemSuggestGenerator",handler:async(o,e,t)=>await d()&&!await g("item-suggest")?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{items:[]}):await a.instance.itemSuggestGenerator(e)});s.push({path:"/ai/itemUpdateGenerator",handler:async(o,e,t)=>await d()&&!await g("attr-improve")?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{updates:[]}):await a.instance.itemUpdateGenerator(e)});s.push({path:"/ai/textRequest",handler:async(o,e,t)=>await d()&&!await g(e==null?void 0:e.capability)?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{text:""}):await a.instance.textRequest(e)});s.push({path:"/ai/collectionAuthoringPrompt",handler:async(o,e,t)=>await d()?{formatSpec:""}:await a.instance.getCollectionAuthoringPrompt()});s.push({path:"/ai/sendMessage",handler:async(o,e,t)=>await d()&&!await g(U(e==null?void 0:e.mode))?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{response:""}):await a.instance.sendMessage(e,t)});s.push({path:"/ai/sendActionResult",handler:async(o,e,t)=>await d()&&!await g(U(e==null?void 0:e.mode))?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{response:""}):await a.instance.sendActionResult(e,t)});s.push({path:"/ai/compactSession",handler:async(o,e,t)=>await a.instance.compactSession(e)});s.push({path:"/ai/cancel",handler:async(o,e,t)=>await a.instance.cancelSession(e)});s.push({path:"/ai/approval/respond",handler:async(o,e,t)=>await a.instance.respondToAgentApproval(e)});s.push({path:"/ai/changeset/respond",handler:async(o,e,t)=>await b.instance.respondToAgentChangeSet(e)});s.push({path:"/ai/changeset/history",handler:async(o,e,t)=>({success:!0,entries:await ne({limit:e==null?void 0:e.limit})})});s.push({path:"/ai/changeset/undo",handler:async(o,e,t)=>await b.instance.undoChangeSet(e)});s.push({path:"/ai/uiBridge/respond",handler:async(o,e,t)=>await b.instance.respondToUiBridgeRequest(e)});s.push({path:"/ai/sessionList",handler:async(o,e,t)=>await d()?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),[]):await a.instance.getAgentSession().getSessionList(e)});s.push({path:"/ai/getSessionById",handler:async(o,e,t)=>{const i=await a.instance.getAgentSession().getSessionById(e.id);return await a.instance.renderSessionForDisplay(i)}});s.push({path:"/ai/appendResponseToSession",handler:async(o,e,t)=>({success:!0,saved:await a.instance.getAgentSession().appendResponseToLastEntry(e.sessionId,e.response)})});s.push({path:"/ai/updateSession",handler:async(o,e,t)=>(await a.instance.getAgentSession().updateSession(e.session),{success:!0})});s.push({path:"/ai/renameSession",handler:async(o,e,t)=>({success:await a.instance.getAgentSession().renameSession(e.sessionId,e.name)})});s.push({path:"/ai/setCurrentSessionId",handler:async(o,e,t)=>await a.instance.getAgentSession().setCurrentSessionId(e.id)});s.push({path:"/ai/getCurrentSessionId",handler:async(o,e,t)=>await d()?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),null):await a.instance.getAgentSession().getCurrentSessionId()});s.push({path:"/ai/deleteSession",handler:async(o,e,t)=>(await a.instance.getAgentSession().deleteSession(e.sessionId),{success:!0})});s.push({path:"/ai/provider/listOllamaModels",handler:async(o,e,t)=>await W((e==null?void 0:e.endpoint)||"")});s.push({path:"/ai/provider/getConfig",handler:async(o,e,t)=>{const i=await re(),p=await c(M,l)||$,n=await c(O,l),m=await c(k,l)||D;return{supported:ae(),provider:i.provider,endpoint:i.provider==="ollama"?i.endpoint:p,model:i.provider==="ollama"?i.model:n,thinking:i.provider==="ollama"?i.thinking:!1,browserModelId:i.provider==="browser-ff"?i.modelId:m}}});s.push({path:"/ai/provider/setConfig",handler:async(o,e,t)=>(e!=null&&e.provider&&await h(pe,e.provider,l),typeof(e==null?void 0:e.endpoint)=="str
1ing"&&await h(M,e.endpoint,l),typeof(e==null?void 0:e.model)=="string"&&await h(O,e.model,l),typeof(e==null?void 0:e.thinking)=="boolean"&&await Ae(le,e.thinking,l),typeof(e==null?void 0:e.browserModelId)=="string"&&await h(k,e.browserModelId,l),await x(),{success:!0})});s.push({path:"/ai/provider/browserStatus",handler:async(o,e,t)=>{const i=await ce.run(de(),()=>Me(),{timeoutMs:0,label:"the browser built-in model"});return{apiPresent:i.apiPresent,availability:i.availability,contextWindow:i.contextWindow,reason:i.reason}}});s.push({path:"/ai/provider/firefoxStatus",handler:async(o,e,t)=>await Oe(e==null?void 0:e.modelId)});s.push({path:"/ai/provider/firefoxDownload",handler:async(o,e,t)=>{const i=(e==null?void 0:e.modelId)||D;return await ke(i,p=>{fe.emit("ai-browser-model-progress",{engine:"browser-ff",...p})})}});s.push({path:"/ai/provider/firefoxDeleteModels",handler:async(o,e,t)=>await De()});s.push({path:"/ai/provider/syncOriginRule",handler:async(o,e,t)=>(await x(),{success:!0})});s.push({path:"/ai/image/generate",handler:async(o,e,t)=>{if((await j()).provider==="server"&&await d())throw new Error("Device-only mode is on, so Kindredly.ai cannot make pictures. Point image generation at your own image server, or turn device-only mode off.");return await $e(String((e==null?void 0:e.prompt)||""))}});s.push({path:"/ai/image/credits",handler:async(o,e,t)=>{if(await d())throw new Error("Device-only mode is on, so Kindredly.ai cannot make pictures.");return await K("/usertask/imageCredits",{})}});s.push({path:"/ai/image/probeLocal",handler:async(o,e,t)=>await Ke(String((e==null?void 0:e.endpoint)||""))});s.push({path:"/ai/usage/getSummary",handler:async(o,e,t)=>await d()?(console.warn("[Device-only Mode] AI features are disabled in device-only mode"),{period:"month",periodStart:new Date(0).toISOString(),periodEnd:new Date(0).toISOString(),promptTokensUsed:0,completionTokensUsed:0,tokensUsed:0,limitTokens:null,limits:null}):await a.instance.getUsageSummary(e)});function Ue(o){return o.startsWith("hosted:")?o.slice(7):""}async function V(){const[o,e,t]=await Promise.all([we.instance.getAccountInfo().catch(()=>{}),me(),ue(null)]),i=ye(o==null?void 0:o.accountType),p=!e||Ee(e),n=!!e&&Ie(e),m=new Map;for(const r of R)m.set(r.id,await he(r.capabilities[0]));const f=await c(O,l),w=await c(M,l),G=[f,...[...m.values()].map(r=>r!=null&&r.startsWith("ollama:")?r.slice(7):"")].filter(r=>!!r),z=t.resolved.provider==="ollama"||!!w||G.length>0,_=n&&z?await W((t.resolved.provider==="ollama"?t.resolved.endpoint:"")||w||$).
1catch(()=>null):null,J=new Set([..._!=null&&_.ok?_.models.map(r=>r.name):[],...G]),Q=ge.manifestType==="firefox"?`browser-ff:${await c(k,l)||D}`:"browser:gemini-nano",N=[];for(const r of R){const X=r.capabilities[0],C=m.get(r.id)??null,S=r.hostedOnly?`hosted:${i[0]}`:t.engineId,Z=B(await c(H(X),l))??null,A=(u,te)=>{const y=Y(r.id,u),I=y.fit==="unsupported"?y.reason:te;return{engineId:u,label:T(u),fit:y.fit,reason:y.reason,disabled:!!I,...I?{disabledReason:I}:{}}},ee=[...ve.map(u=>A(`hosted:${u}`,p?i.includes(u)?void 0:"Needs Plus.":"Your family uses private AI only.")),...[...J].map(u=>A(`ollama:${u}`,n?void 0:"Private AI is off for your family.")),A(Q,n?void 0:"Private AI is off for your family.")];N.push({id:r.id,label:r.label,...r.description?{description:r.description}:{},hostedOnly:!!r.hostedOnly,selectedEngineId:C,defaultEngineId:S,defaultLabel:T(S),effort:Z,defaultEffort:Se(r,Ue(C||S),void 0)??null,options:ee})}return{tasks:N}}async function E(o,e,t){for(const i of o.capabilities)await h(e(i),t,l)}s.push({path:"/ai/taskModels/list",handler:async(o,e,t)=>await V()});s.push({path:"/ai/taskModels/set",handler:async(o,e,t)=>{const i=_e(String((e==null?void 0:e.taskId)||""));if(!i)return{success:!1,message:"Unknown AI task."};if(e.engineId!==void 0)if(e.engineId===null||e.engineId==="")await E(i,P,"");else{const p=String(e.engineId),n=Y(i.id,p);if(n.fit==="unsupported")return{success:!1,message:`${T(p)} canât be used for ${i.label}. ${n.reason}`};await E(i,P,JSON.stringify([p]))}if(e.reasoningEffort!==void 0){const p=e.reasoningEffort===null?"":B(e.reasoningEffort);if(p===void 0)return{success:!1,message:"Unknown reasoning level."};await E(i,H,p)}return{success:!0,...await V()}}});export{s as default};
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.