@rizom/brain 0.2.0-alpha.873 → 0.2.0-alpha.875
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/brain.js +10 -10
- package/dist/chunks/app-ekx3p63b.js +5 -0
- package/dist/chunks/{index-3tvzr6ge.js → index-02srst5t.js} +3 -3
- package/dist/chunks/{index-3tvzr6ge.js.map → index-02srst5t.js.map} +1 -1
- package/dist/chunks/{index-1vaa2761.js → index-5fa86d31.js} +2 -2
- package/dist/chunks/{index-nnwk2h8n.js → index-9kdd9kj5.js} +2 -2
- package/dist/chunks/{index-gnbfdewj.js → index-9mfc2kx2.js} +3 -3
- package/dist/chunks/{index-gnbfdewj.js.map → index-9mfc2kx2.js.map} +5 -5
- package/dist/chunks/{index-02pt9z7t.js → index-cywssss6.js} +2 -2
- package/dist/chunks/{index-wete5qfn.js → index-t822ntg2.js} +2 -2
- package/dist/chunks/{package-z5h1920s.js → package-c88dkedp.js} +3 -3
- package/dist/chunks/{package-z5h1920s.js.map → package-c88dkedp.js.map} +1 -1
- package/dist/entities.js +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +1 -1
- package/dist/interfaces.js +1 -1
- package/dist/model.js +6 -6
- package/dist/model.js.map +5 -5
- package/dist/services.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/ui/{studio-app-1edp4r57.js → studio-app-bb5xxwvn.js} +3 -3
- package/dist/ui/studio-asset-manifest.json +21 -21
- package/dist/ui/studio-chunks/{account-view-j9wkxck6.js → account-view-ak5tfxgg.js} +1 -1
- package/dist/ui/studio-chunks/{main-d5szcfbq.js → main-2g8gcg0r.js} +1 -1
- package/dist/ui/studio-chunks/{main-rt6yh800.js → main-2hbxfr9g.js} +1 -1
- package/dist/ui/studio-chunks/{main-pqx64crr.js → main-45xgzy0v.js} +2 -2
- package/dist/ui/studio-chunks/{main-pqx64crr.js.map → main-45xgzy0v.js.map} +5 -5
- package/dist/ui/studio-chunks/{main-fqzf25fv.js → main-q24zjy7e.js} +1 -1
- package/dist/ui/studio-chunks/{main-ggcgvxym.js → main-qyf00dty.js} +1 -1
- package/dist/ui/studio-chunks/{main-6qe1jp8h.js → main-tcyq2xnp.js} +1 -1
- package/dist/ui/studio-chunks/{studio-ask-panel-njthpfwq.js → studio-ask-panel-vjymeavp.js} +1 -1
- package/dist/ui/studio-chunks/{studio-chat-workspace-jw3pye8a.js → studio-chat-workspace-kzcn37qq.js} +1 -1
- package/package.json +1 -1
- package/dist/chunks/app-n0bqjatx.js +0 -5
- /package/dist/chunks/{app-n0bqjatx.js.map → app-ekx3p63b.js.map} +0 -0
- /package/dist/chunks/{index-1vaa2761.js.map → index-5fa86d31.js.map} +0 -0
- /package/dist/chunks/{index-nnwk2h8n.js.map → index-9kdd9kj5.js.map} +0 -0
- /package/dist/chunks/{index-02pt9z7t.js.map → index-cywssss6.js.map} +0 -0
- /package/dist/chunks/{index-wete5qfn.js.map → index-t822ntg2.js.map} +0 -0
- /package/dist/ui/{studio-app-1edp4r57.js.map → studio-app-bb5xxwvn.js.map} +0 -0
- /package/dist/ui/studio-chunks/{account-view-j9wkxck6.js.map → account-view-ak5tfxgg.js.map} +0 -0
- /package/dist/ui/studio-chunks/{main-d5szcfbq.js.map → main-2g8gcg0r.js.map} +0 -0
- /package/dist/ui/studio-chunks/{main-rt6yh800.js.map → main-2hbxfr9g.js.map} +0 -0
- /package/dist/ui/studio-chunks/{main-fqzf25fv.js.map → main-q24zjy7e.js.map} +0 -0
- /package/dist/ui/studio-chunks/{main-ggcgvxym.js.map → main-qyf00dty.js.map} +0 -0
- /package/dist/ui/studio-chunks/{main-6qe1jp8h.js.map → main-tcyq2xnp.js.map} +0 -0
- /package/dist/ui/studio-chunks/{studio-ask-panel-njthpfwq.js.map → studio-ask-panel-vjymeavp.js.map} +0 -0
- /package/dist/ui/studio-chunks/{studio-chat-workspace-jw3pye8a.js.map → studio-chat-workspace-kzcn37qq.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ql as n}from"./index-
|
|
2
|
+
import{ql as n}from"./index-9mfc2kx2.js";function t(i,e={}){if(!n(i))throw Error("use() expects a package definition returned by a @rizom/brain define helper");return Object.freeze({kind:"rizom-configured-plugin",definition:i,config:Object.freeze({...e})})}function f(i){if(i===null||typeof i!=="object")return!1;return Reflect.get(i,"kind")==="rizom-configured-plugin"&&n(Reflect.get(i,"definition"))&&typeof Reflect.get(i,"config")==="object"}
|
|
3
3
|
export{t as nf,f as of};
|
|
4
4
|
|
|
5
5
|
//# debugId=9501E80E7710598064756E2164756E21
|
|
6
|
-
//# sourceMappingURL=index-
|
|
6
|
+
//# sourceMappingURL=index-cywssss6.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lf as Zs,mf as Ws}from"./index-n3cy8ttx.js";import{$i as go,$k as qd,Ag as fr,Ao as rs,Bf as le,Bg as ri,Bh as Ss,Bk as Wi,Cg as Tl,Ck as ul,Df as Do,Dg as qo,Dk as pl,Do as Qs,Eg as Jo,Ek as Ts,Eo as is,Fg as Go,Fk as Es,Fm as qe,Fo as Fs,Gk as ks,Gm as gn,Gn as Pc,Go as ns,Hn as Cc,Im as kn,In as ht,Jg as _r,Jm as be,Kg as Fr,Km as An,Kn as Gd,Lf as zo,Lm as jn,Ln as _s,Mm as Mr,Nm as Ms,Og as Id,Om as Dn,Po as Ks,Qf as Qr,Qg as hr,Qo as Qd,Rf as kt,Sf as Po,So as Ns,Tf as Co,Tk as As,To as Sc,Uo as rr,Vf as To,Vk as js,Wf as Kd,Wi as oc,Wk as Ve,Xi as wt,Xk as gc,Yj as du,Yk as fc,Zf as Eo,Zj as uu,Zk as hc,_f as Mo,_h as Sr,_j as pu,_k as yc,aj as Ps,al as Dc,bg as ge,bj as zn,bl as Qo,cg as fe,ci as Nl,cj as Cs,dg as Vd,dk as ar,eg as Yd,ei as qs,ej as na,ek as ol,el as Cr,fg as Xd,fj as ti,fk as ho,fl as Ds,fn as Ls,gg as eu,gh as Zd,gi as Js,gk as Su,gl as De,gn as Us,hg as tu,hh as oa,hi as yl,hn as qc,ig as ru,ih as Io,ij as au,il as Jd,in as Bs,jg as iu,ji as Gl,jj as cu,jl as zs,jn as Ko,kg as nu,ki as Ql,kj as ss,kl as Ec,kn as $s,lg as ou,lh as Td,lj as as,ll as tc,mg as So,mh as bo,mi as Kl,mj as cs,ml as Ci,ng as wo,ni as ws,nn as Fo,og as Ro,oj as ls,on as Vo,pj as Ud,pn as Yo,qg as Bt,qi as W,qj as Bd,qn as Xo,rf as Bl,rg as vs,ri as sa,rj as $d,rn as es,sf as ut,sg as xt,sj as _d,tg as je,tj as Wd,ug as q,uj as cd,uk as On,vf as sn,vg as Dd,vk as bt,wf as ft,wg as Mc,wk as mc,xf as we,xg as Jl,xk as Hd,yf as jo,zf as U,zg as k,zn as ts,zo as Gs}from"./index-gnbfdewj.js";import{As as Nd,Es as ms,Hr as Ke,Kt as nl,Mr as ia,Nr as er,Oq as Wo,St as Rs,Vq as Ho,Yq as po,Yr as dc,Yt as Is,Zp as V,Zr as uc,Zt as xs,_t as Md,ap as Ll,at as Xa,bp as se,bq as rc,cq as H,cs as Yt,ct as ec,dp as _,ep as _e,eu as Os,fp as Re,gp as at,gu as Va,hp as Pe,ju as me,lr as Ee,mt as oe,nr as P,or as Qe,pu as Z,st as ee,uq as ve,vr as mo,vt as re,wt as qi,zs as jd}from"./index-m2qv3p6y.js";import{qu as Xe,su as ke}from"./index-0k63cxm5.js";import{Ly as D,ZB as R,_y as z,gz as Y,nC as ae,pC as tr,qC as pc,tC as bc,tw as T,xy as ce,zy as bs}from"./index-rwrp530c.js";import{LD as l}from"./index-njqkf4cd.js";function zr(e,t){let r=new Set(t.map((i)=>i.type));return e.byType.filter((i)=>(i.status==="pending"||i.status==="processing")&&!r.has(i.type))}function We(e,t){let r=e.workerSessions,i=r.active===0?"missing":r.stale>0?"stale":"active",n=e.duePending>0&&(e.oldestDuePendingAgeMs??0)>=120000&&e.totals.processing===0&&(e.latestClaimAgeMs===null||e.latestClaimAgeMs>=120000),o=[];if(i==="missing")o.push("No live worker session");else if(i==="stale")o.push(`${r.stale} stale worker session(s)`);if(n)o.push(`${e.duePending} due job(s) have remained unclaimed for at least 120000ms`);if(t){let s=zr(e,t).reduce((a,c)=>a+c.count,0);if(s>0)o.push(`${s} active job(s) have no declared executor`)}return{status:o.length===0?"operational":"degraded",reasons:o,worker:{state:i,activeSessions:r.active,staleSessions:r.stale,latestHeartbeatAgeMs:r.latestHeartbeatAgeMs},queue:{duePending:e.duePending,processing:e.totals.processing,oldestDuePendingAgeMs:e.oldestDuePendingAgeMs,latestClaimAgeMs:e.latestClaimAgeMs,stalled:n}}}async function xn(e){let{config:t,services:r,bootTime:i,endpoints:n,interactions:o}=e,[s,a,c,d]=await Promise.all([r.entityService.getEntityCounts(ft("runtime app info reports operator-facing aggregate status")),r.entityService.countEmbeddings(),r.daemonRegistry.getStatuses(),r.jobQueueService.getDiagnostics()]),u=s.reduce((p,m)=>p+m.count,0);return{model:t.name||"brain-app",version:t.version||"1.0.0",uptime:Math.floor((Date.now()-i)/1000),entities:u,entityCounts:s,embeddings:a,backgroundWork:We(d,r.jobQueueService.getExecutionRegistrations()),ai:{model:t.ai.model,embeddingModel:r.embeddingService.identity.model},daemons:c,endpoints:n(),interactions:o()}}import{readdir as Pn,readFile as _u}from"fs/promises";var Fu=10;async function Nu(e="/proc"){let t=null;try{t=(await Pn(`${e}/self/fd`)).length}catch{}try{let i=(await Pn(e,{withFileTypes:!0})).filter((s)=>s.isDirectory()&&/^\d+$/.test(s.name)).map((s)=>s.name),n=0,o=0;return await Promise.all(i.map(async(s)=>{try{let a=await _u(`${e}/${s}/status`,"utf8");if(o++,/^State:\s+Z\b/m.test(a))n++}catch{}})),{fileDescriptors:t,processCount:o,zombieCount:n}}catch{return{fileDescriptors:t,processCount:null,zombieCount:null}}}function Cn(e,t,r){return t.status==="fulfilled"?{name:e,status:"healthy",message:r}:{name:e,status:"unhealthy",message:P(t.reason)}}function Zu(e){if(!e)return{name:"job-worker",status:"degraded",message:"Worker session state is unavailable"};let t=e.workerSessions,r=We(e).worker;if(r.state==="missing")return{name:"job-worker",status:"degraded",message:"No live worker session",details:{sessions:t}};if(r.state==="stale")return{name:"job-worker",status:"degraded",message:`${t.stale} stale worker session(s)`,details:{sessions:t}};return{name:"job-worker",status:"healthy",message:`${t.active} live worker session(s)`,details:{sessions:t}}}function Wu(e){if(!e)return{name:"job-queue-progress",status:"degraded",message:"Queue progress state is unavailable"};let t=We(e).queue;return t.stalled?{name:"job-queue-progress",status:"degraded",message:`${t.duePending} due job(s) are not being claimed`,details:{queue:t}}:{name:"job-queue-progress",status:"healthy",message:"Due jobs are being claimed",details:{queue:t}}}function Hu(e,t){if(!e||!t)return{name:"job-execution-inventory",status:"degraded",message:"Job execution inventory is unavailable"};let r=zr(e,t),i=r.reduce((n,o)=>n+o.count,0);return i===0?{name:"job-execution-inventory",status:"healthy",message:"Every active job type has a declared executor"}:{name:"job-execution-inventory",status:"degraded",message:`${i} active job(s) have no declared executor`,details:{jobs:r}}}function qu(e){if(!e)return{name:"attempt-leases",status:"degraded",message:"Lease state is unavailable"};return e.staleLeaseCount===0?{name:"attempt-leases",status:"healthy",message:"No stale processing leases"}:{name:"attempt-leases",status:"degraded",message:`${e.staleLeaseCount} processing lease(s) are stale`,details:{staleLeaseCount:e.staleLeaseCount}}}function Ju(e){if(!e.initialized)return{name:"projection-circuits",status:"degraded",message:"Projection runtime supervisor is not initialized"};if(e.openCircuits.length===0)return{name:"projection-circuits",status:"healthy",message:"No projection circuits are open"};return{name:"projection-circuits",status:"degraded",message:`${e.openCircuits.length} projection circuit(s) open`,details:{circuits:e.openCircuits}}}async function Gu(e){let t=e.entityService.getProjectionStore(),[r,i,n]=await Promise.all([t.getActiveWave(),t.getUnresolvedProjectionIncidentDiagnostics(Fu),t.getProjectionBatchDiagnostics?.()??Promise.resolve({preparing:0,open:0,abandoned:0,expiredCallbackLeases:0,oldestActiveAgeMs:null,oldestProgressAgeMs:null})]);if(!r)return{waveId:null,batches:n,strandedRules:[],incidentCount:i.total,incidents:i.incidents};let s=(await t.listWaveRules(r.id)).filter((c)=>c.status==="queued"||c.status==="failed"),a=(await Promise.all(s.map(async(c)=>{let d=c.jobId?await e.jobQueueService.getStatus(c.jobId):null;if(c.status!=="failed"&&d&&(d.status==="pending"||d.status==="processing"))return null;return{ruleId:c.ruleId,jobId:c.jobId,jobStatus:d?.status??"missing"}}))).filter((c)=>c!==null);return{waveId:r.id,batches:n,strandedRules:a,incidentCount:i.total,incidents:i.incidents}}function Qu(e){if(e.batches.abandoned>0)return{name:"projection-waves",status:"degraded",message:`${e.batches.abandoned} projection batch(es) await recovery`,details:{batches:e.batches}};if(e.batches.expiredCallbackLeases>0)return{name:"projection-waves",status:"degraded",message:"A callback projection batch lease has expired",details:{batches:e.batches}};if(e.incidentCount>0)return{name:"projection-waves",status:"degraded",message:`${e.incidentCount} unresolved terminal projection incident(s)`,details:{incidentCount:e.incidentCount,incidentsTruncated:e.incidentCount>e.incidents.length,incidents:e.incidents.map((t)=>({waveId:t.waveId,ruleId:t.ruleId,jobId:t.jobId,failureReason:t.failureReason,createdAt:t.createdAt}))}};if(!e.waveId)return{name:"projection-waves",status:"healthy",message:e.batches.open+e.batches.preparing>0?`${e.batches.open+e.batches.preparing} projection batch(es) active`:"No active projection wave",...e.batches.open+e.batches.preparing>0&&{details:{batches:e.batches}}};if(e.strandedRules.length===0)return{name:"projection-waves",status:"healthy",message:`Projection wave ${e.waveId} is progressing`};return{name:"projection-waves",status:"degraded",message:`Projection wave ${e.waveId} has ${e.strandedRules.length} stranded rule job(s)`,details:{waveId:e.waveId,strandedRules:e.strandedRules}}}function Ku(e){let t=e.filter((r)=>r.status!=="running"||r.health?.status==="error");return t.length===0?{name:"daemons",status:"healthy",message:`${e.length} daemon(s) healthy`}:{name:"daemons",status:"degraded",message:`${t.length} daemon(s) unhealthy`,details:{daemons:t.map((r)=>({name:r.name,status:r.status,health:r.health?.status,message:r.health?.message}))}}}async function Tn(e){let t=e.now?.()??Date.now(),r=(e.memoryUsage??process.memoryUsage)(),[i,n,o,s,a,c,d,u]=await Promise.allSettled([e.entityService.getEntityCounts(ft("runtime readiness database probe")),e.jobQueueService.getDiagnostics(t),Promise.resolve(e.jobQueueService.getExecutionRegistrations()),e.daemonRegistry.getStatuses(),(e.readProcessSignals??Nu)(),e.projectionRuntimeSupervisor.getDiagnostics(),Gu(e),e.operationalHealthRegistry.getChecks()]),p=n.status==="fulfilled"?n.value:null,m=o.status==="fulfilled"?o.value??null:null,g=s.status==="fulfilled"?s.value:[],f=a.status==="fulfilled"?a.value:{fileDescriptors:null,processCount:null,zombieCount:null},h=c.status==="fulfilled"?c.value:{status:"unhealthy",initialized:!1,trackedRoots:0,openCircuits:[]},w=[Cn("entity-database",i,"Entity database is accessible"),Cn("job-queue-database",n,"Job queue database is accessible"),Zu(p),Wu(p),Hu(p,m),qu(p),c.status==="fulfilled"?Ju(h):{name:"projection-circuits",status:"degraded",message:P(c.reason)},d.status==="fulfilled"?Qu(d.value):{name:"projection-waves",status:"degraded",message:P(d.reason)},s.status==="fulfilled"?Ku(g):{name:"daemons",status:"degraded",message:P(s.reason)}],b=u.status==="fulfilled"?u.value:[{name:"plugin-operational-health",status:"degraded",message:"Plugin operational health is unavailable"}],S=[...w,...b];return{status:w.some((y)=>y.status==="unhealthy")?"not_ready":"ready",operationalStatus:S.some((y)=>y.status!=="healthy")?"degraded":"operational",checkedAt:new Date(t).toISOString(),checks:S,resources:{memory:{rssBytes:r.rss,heapUsedBytes:r.heapUsed,heapTotalBytes:r.heapTotal},fileDescriptors:f.fileDescriptors,processes:{total:f.processCount,zombies:f.zombieCount},queue:p,projection:{initialized:h.initialized,trackedRoots:h.trackedRoots,openCircuits:h.openCircuits},worker:p?.workerSessions??{total:0,active:0,stale:0,latestHeartbeatAgeMs:null}}}}function En(){return{dataDir:"./data",cacheDir:"./cache",distDir:"./dist"}}function ye(e){return{database:{url:`file:${e.dataDir}/brain.db`},jobQueueDatabase:{url:`file:${e.dataDir}/brain-jobs.db`},conversationDatabase:{url:`file:${e.dataDir}/conversations.db`},runtimeStateDatabase:{url:`file:${e.dataDir}/runtime-state.db`},embeddingDatabase:{url:`file:${e.dataDir}/embeddings.db`},embedding:{enabled:!0}}}var He=l.strictObject({enabled:l.boolean().optional().describe("Serve HTTP; defaults to whether the selected bundles host the web surface"),preview:l.boolean().optional().describe("Serve the preview site; defaults to whether a site builder runs"),hostname:l.string().trim().min(1).optional().describe("Bind address; use 127.0.0.1 for isolated local tests"),productionDistDir:l.string().min(1).optional().describe("Directory of the production site, when no site builder writes it"),previewDistDir:l.string().min(1).optional().describe("Directory of the preview site, when no site builder writes it"),sharedImagesDir:l.string().min(1).optional().describe("Directory of shared optimized images")}),Or=He.extend({enabled:l.boolean().default(!1),preview:l.boolean().default(!0),port:l.number().default(8080).describe("Port of the production listener")});var ne=l.enum(["debug","info","warn","error"]);var Lr=En(),Vu=l.looseObject({label:l.string().min(1),pluralName:l.string().optional(),layout:l.string().optional(),paginate:l.boolean().optional(),pageSize:l.number().optional(),navigation:l.object({show:l.boolean().optional(),slot:l.enum(["primary","secondary"]).optional(),priority:l.number().optional()}).optional()});function Ur(){return ye(Lr)}var Br=l.object({name:l.string().default("brain-app"),version:l.string().default("1.0.0"),database:Ee,jobQueueDatabase:Ee,jobQueue:l.object({workerConcurrency:l.number().int().min(1).max(32).default(4)}).prefault({}),conversationDatabase:Ee,runtimeStateDatabase:Ee,embeddingDatabase:Ee,ai:l.object({providerKeys:qe.default({}),model:l.string().refine(kn,{error:(e)=>`Unsupported model "${String(e.input)}"`}),embeddingModel:l.string().refine((e)=>Mr(e)!==void 0,{error:(e)=>Dn(String(e.input))}).default(jn),modelRuntimeUrl:l.string().url().optional(),answerModel:l.string().optional(),visionModel:l.string().optional(),imageModel:l.string().optional(),temperature:l.number().min(0).max(2).default(0.7),webSearch:l.boolean().default(!0),reasoningEffort:oe.optional()}).superRefine((e,t)=>{if(e.answerModel&&be(e.answerModel)!=="local")t.addIssue({code:"custom",path:["answerModel"],message:`answerModel must be a local: model, not ${e.answerModel}`});if(e.visionModel&&be(e.visionModel)!=="local")t.addIssue({code:"custom",path:["visionModel"],message:`visionModel must be a local: model, not ${e.visionModel}`});if(e.modelRuntimeUrl)return;let r=[...be(e.model)==="local"?[e.model]:[],...[e.answerModel,e.visionModel].filter((i)=>i!==void 0&&be(i)==="local"),...e.imageModel&&An(e.imageModel).provider==="local"?[e.imageModel]:[],...Mr(e.embeddingModel)?.provider==="local"?[e.embeddingModel]:[]];for(let i of r)t.addIssue({code:"custom",path:["modelRuntimeUrl"],message:`${i} needs modelRuntime.url`})}),embedding:l.object({enabled:l.boolean().default(!0)}),logging:l.object({level:ne.default("info"),format:l.enum(["text","json"]).default("text"),file:l.string().optional(),context:l.string().default("shell")}).prefault({level:"info",context:"shell"}),features:l.object({}).default({}),plugins:l.array(ht).default([]),dataDir:l.string().default("./brain-data"),gitBrokerSocket:l.string().min(1).optional(),gitBrokerCheckout:l.string().min(1).optional(),spaces:l.array(l.string()).default([]),siteBaseUrl:l.string().optional(),localSiteUrl:l.string().optional(),preferLocalUrls:l.boolean().default(!1),production:l.boolean().default(!1),themeCSS:l.string().default(""),entityDisplay:l.record(l.string(),Vu).optional(),profileKind:l.string().trim().min(1).optional(),http:Or.prefault({})});function yt(e={}){let{plugins:t=[],permissions:r={},identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s,ai:a,logging:c,embedding:d,jobQueue:u,...p}=e,{entityDisplay:m,...g}=Br.parse({...Ur(),...H(p),ai:H({...a}),logging:H({...c}),embedding:H({...d}),jobQueue:H({...u}),plugins:[]});return{...g,plugins:t,permissions:r,...H({entityDisplay:m,identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s})}}var B={NOTE:"note",BRAIN_CHARACTER:"brain-character",ANCHOR_PROFILE:"anchor-profile"},Je={KNOWLEDGE_QUERY:"shell:knowledge-query",BASE_ENTITY_DISPLAY:"shell:base-entity-display",CONTENT_GENERATION:"shell:content-generation"},$r={ENTITIES:"shell:entities"};var Yu=zn.extend({templateName:l.string()}),Xu=l.object({slug:l.string()}),ep="The style guide governs voice, tone, wording and form: paragraphing, sentence rhythm, hooks, rhetorical questions and calls to action. The instructions below and any additional instructions in the request govern the task, required content, length limits, platform constraints and output format. When either conflicts with the style guide on voice or form, follow the style guide.",tp="Generate the content described in your instructions.";function rp(e){return e instanceof l.ZodType}function ip(e){if(!e)return;return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}class vt{aiService;entityService;templateRegistry;getIdentityContent;getProfileContent;entityUrls;id="ai-content";name="AI Content Generator";description="Generates content using AI based on templates and prompts";constructor(e,t,r,i,n,o,s){this.aiService=e,this.entityService=t,this.templateRegistry=r,this.getIdentityContent=i,this.getProfileContent=n,this.entityUrls=o,this.siteBaseUrl=ip(s)}siteBaseUrl;async generate(e,t,r){return this.generateWithContext(e,t,r)}async generateScoped(e,t,r){return this.generateWithContext(e,t,r.signal,r)}async generateWithContext(e,t,r,i){r?.throwIfAborted();let n=Yu.parse(e),o=this.templateRegistry.get(n.templateName);if(!o)throw Error(`Template not found: ${n.templateName}`);if(!o.basePrompt)throw Error(`Template ${n.templateName} must have basePrompt for content generation`);let s=i?await On((w,b)=>i.getEntity(w,b),n.templateName,o.basePrompt):await bt(this.entityService,n.templateName,o.basePrompt);r?.throwIfAborted();let a=[s,n.prompt].filter(Boolean).join(" "),c=a.length>0&&o.useKnowledgeContext===!0,d=this.entityService.getWeightMap(),u=Object.keys(d).length>0,p=c?i?await i.search(a,{limit:5,...u&&{weight:d}}):await this.entityService.search({query:a,options:{limit:5,...u&&{weight:d},...r&&{signal:r}}}):[];r?.throwIfAborted();let m=this.buildPrompt(n,p),g=i?await this.readIdentities(i,n.representedIdentity):void 0,f=this.buildSystemPrompt(s,n,g);if(!rp(o.schema))throw Error(`Template ${o.name} cannot be used for AI generation: schema is not an AI generation schema`);r?.throwIfAborted();let h=await this.aiService.generateObject(f,m,o.schema,r);return r?.throwIfAborted(),t.parse(h.object)}async readIdentities(e,t){let r=async(o)=>(await e.getEntity(o,o))?.content??"",[i,n]=await Promise.all([t!=="none"?r(B.BRAIN_CHARACTER):"",t===void 0||t==="anchor"?r(B.ANCHOR_PROFILE):""]);return{brain:i,anchor:n}}buildSystemPrompt(e,t,r){let i=[];if(t.representedIdentity===void 0||t.representedIdentity==="brain"||t.representedIdentity==="anchor")i.push("# Brain Identity",r?.brain??this.getIdentityContent(),"");if(t.representedIdentity===void 0||t.representedIdentity==="anchor")i.push("# Represented Anchor",r?.anchor??this.getProfileContent(),"");let n=this.selectStyleGuidance(t);if(n)i.push("# Style Guide",n,"","# Precedence",ep,"");return i.push("# Instructions",e),i.join(`
|
|
2
|
+
import{lf as Zs,mf as Ws}from"./index-n3cy8ttx.js";import{$i as go,$k as qd,Ag as fr,Ao as rs,Bf as le,Bg as ri,Bh as Ss,Bk as Wi,Cg as Tl,Ck as ul,Df as Do,Dg as qo,Dk as pl,Do as Qs,Eg as Jo,Ek as Ts,Eo as is,Fg as Go,Fk as Es,Fm as qe,Fo as Fs,Gk as ks,Gm as gn,Gn as Pc,Go as ns,Hn as Cc,Im as kn,In as ht,Jg as _r,Jm as be,Kg as Fr,Km as An,Kn as Gd,Lf as zo,Lm as jn,Ln as _s,Mm as Mr,Nm as Ms,Og as Id,Om as Dn,Po as Ks,Qf as Qr,Qg as hr,Qo as Qd,Rf as kt,Sf as Po,So as Ns,Tf as Co,Tk as As,To as Sc,Uo as rr,Vf as To,Vk as js,Wf as Kd,Wi as oc,Wk as Ve,Xi as wt,Xk as gc,Yj as du,Yk as fc,Zf as Eo,Zj as uu,Zk as hc,_f as Mo,_h as Sr,_j as pu,_k as yc,aj as Ps,al as Dc,bg as ge,bj as zn,bl as Qo,cg as fe,ci as Nl,cj as Cs,dg as Vd,dk as ar,eg as Yd,ei as qs,ej as na,ek as ol,el as Cr,fg as Xd,fj as ti,fk as ho,fl as Ds,fn as Ls,gg as eu,gh as Zd,gi as Js,gk as Su,gl as De,gn as Us,hg as tu,hh as oa,hi as yl,hn as qc,ig as ru,ih as Io,ij as au,il as Jd,in as Bs,jg as iu,ji as Gl,jj as cu,jl as zs,jn as Ko,kg as nu,ki as Ql,kj as ss,kl as Ec,kn as $s,lg as ou,lh as Td,lj as as,ll as tc,mg as So,mh as bo,mi as Kl,mj as cs,ml as Ci,ng as wo,ni as ws,nn as Fo,og as Ro,oj as ls,on as Vo,pj as Ud,pn as Yo,qg as Bt,qi as W,qj as Bd,qn as Xo,rf as Bl,rg as vs,ri as sa,rj as $d,rn as es,sf as ut,sg as xt,sj as _d,tg as je,tj as Wd,ug as q,uj as cd,uk as On,vf as sn,vg as Dd,vk as bt,wf as ft,wg as Mc,wk as mc,xf as we,xg as Jl,xk as Hd,yf as jo,zf as U,zg as k,zn as ts,zo as Gs}from"./index-9mfc2kx2.js";import{As as Nd,Es as ms,Hr as Ke,Kt as nl,Mr as ia,Nr as er,Oq as Wo,St as Rs,Vq as Ho,Yq as po,Yr as dc,Yt as Is,Zp as V,Zr as uc,Zt as xs,_t as Md,ap as Ll,at as Xa,bp as se,bq as rc,cq as H,cs as Yt,ct as ec,dp as _,ep as _e,eu as Os,fp as Re,gp as at,gu as Va,hp as Pe,ju as me,lr as Ee,mt as oe,nr as P,or as Qe,pu as Z,st as ee,uq as ve,vr as mo,vt as re,wt as qi,zs as jd}from"./index-m2qv3p6y.js";import{qu as Xe,su as ke}from"./index-0k63cxm5.js";import{Ly as D,ZB as R,_y as z,gz as Y,nC as ae,pC as tr,qC as pc,tC as bc,tw as T,xy as ce,zy as bs}from"./index-rwrp530c.js";import{LD as l}from"./index-njqkf4cd.js";function zr(e,t){let r=new Set(t.map((i)=>i.type));return e.byType.filter((i)=>(i.status==="pending"||i.status==="processing")&&!r.has(i.type))}function We(e,t){let r=e.workerSessions,i=r.active===0?"missing":r.stale>0?"stale":"active",n=e.duePending>0&&(e.oldestDuePendingAgeMs??0)>=120000&&e.totals.processing===0&&(e.latestClaimAgeMs===null||e.latestClaimAgeMs>=120000),o=[];if(i==="missing")o.push("No live worker session");else if(i==="stale")o.push(`${r.stale} stale worker session(s)`);if(n)o.push(`${e.duePending} due job(s) have remained unclaimed for at least 120000ms`);if(t){let s=zr(e,t).reduce((a,c)=>a+c.count,0);if(s>0)o.push(`${s} active job(s) have no declared executor`)}return{status:o.length===0?"operational":"degraded",reasons:o,worker:{state:i,activeSessions:r.active,staleSessions:r.stale,latestHeartbeatAgeMs:r.latestHeartbeatAgeMs},queue:{duePending:e.duePending,processing:e.totals.processing,oldestDuePendingAgeMs:e.oldestDuePendingAgeMs,latestClaimAgeMs:e.latestClaimAgeMs,stalled:n}}}async function xn(e){let{config:t,services:r,bootTime:i,endpoints:n,interactions:o}=e,[s,a,c,d]=await Promise.all([r.entityService.getEntityCounts(ft("runtime app info reports operator-facing aggregate status")),r.entityService.countEmbeddings(),r.daemonRegistry.getStatuses(),r.jobQueueService.getDiagnostics()]),u=s.reduce((p,m)=>p+m.count,0);return{model:t.name||"brain-app",version:t.version||"1.0.0",uptime:Math.floor((Date.now()-i)/1000),entities:u,entityCounts:s,embeddings:a,backgroundWork:We(d,r.jobQueueService.getExecutionRegistrations()),ai:{model:t.ai.model,embeddingModel:r.embeddingService.identity.model},daemons:c,endpoints:n(),interactions:o()}}import{readdir as Pn,readFile as _u}from"fs/promises";var Fu=10;async function Nu(e="/proc"){let t=null;try{t=(await Pn(`${e}/self/fd`)).length}catch{}try{let i=(await Pn(e,{withFileTypes:!0})).filter((s)=>s.isDirectory()&&/^\d+$/.test(s.name)).map((s)=>s.name),n=0,o=0;return await Promise.all(i.map(async(s)=>{try{let a=await _u(`${e}/${s}/status`,"utf8");if(o++,/^State:\s+Z\b/m.test(a))n++}catch{}})),{fileDescriptors:t,processCount:o,zombieCount:n}}catch{return{fileDescriptors:t,processCount:null,zombieCount:null}}}function Cn(e,t,r){return t.status==="fulfilled"?{name:e,status:"healthy",message:r}:{name:e,status:"unhealthy",message:P(t.reason)}}function Zu(e){if(!e)return{name:"job-worker",status:"degraded",message:"Worker session state is unavailable"};let t=e.workerSessions,r=We(e).worker;if(r.state==="missing")return{name:"job-worker",status:"degraded",message:"No live worker session",details:{sessions:t}};if(r.state==="stale")return{name:"job-worker",status:"degraded",message:`${t.stale} stale worker session(s)`,details:{sessions:t}};return{name:"job-worker",status:"healthy",message:`${t.active} live worker session(s)`,details:{sessions:t}}}function Wu(e){if(!e)return{name:"job-queue-progress",status:"degraded",message:"Queue progress state is unavailable"};let t=We(e).queue;return t.stalled?{name:"job-queue-progress",status:"degraded",message:`${t.duePending} due job(s) are not being claimed`,details:{queue:t}}:{name:"job-queue-progress",status:"healthy",message:"Due jobs are being claimed",details:{queue:t}}}function Hu(e,t){if(!e||!t)return{name:"job-execution-inventory",status:"degraded",message:"Job execution inventory is unavailable"};let r=zr(e,t),i=r.reduce((n,o)=>n+o.count,0);return i===0?{name:"job-execution-inventory",status:"healthy",message:"Every active job type has a declared executor"}:{name:"job-execution-inventory",status:"degraded",message:`${i} active job(s) have no declared executor`,details:{jobs:r}}}function qu(e){if(!e)return{name:"attempt-leases",status:"degraded",message:"Lease state is unavailable"};return e.staleLeaseCount===0?{name:"attempt-leases",status:"healthy",message:"No stale processing leases"}:{name:"attempt-leases",status:"degraded",message:`${e.staleLeaseCount} processing lease(s) are stale`,details:{staleLeaseCount:e.staleLeaseCount}}}function Ju(e){if(!e.initialized)return{name:"projection-circuits",status:"degraded",message:"Projection runtime supervisor is not initialized"};if(e.openCircuits.length===0)return{name:"projection-circuits",status:"healthy",message:"No projection circuits are open"};return{name:"projection-circuits",status:"degraded",message:`${e.openCircuits.length} projection circuit(s) open`,details:{circuits:e.openCircuits}}}async function Gu(e){let t=e.entityService.getProjectionStore(),[r,i,n]=await Promise.all([t.getActiveWave(),t.getUnresolvedProjectionIncidentDiagnostics(Fu),t.getProjectionBatchDiagnostics?.()??Promise.resolve({preparing:0,open:0,abandoned:0,expiredCallbackLeases:0,oldestActiveAgeMs:null,oldestProgressAgeMs:null})]);if(!r)return{waveId:null,batches:n,strandedRules:[],incidentCount:i.total,incidents:i.incidents};let s=(await t.listWaveRules(r.id)).filter((c)=>c.status==="queued"||c.status==="failed"),a=(await Promise.all(s.map(async(c)=>{let d=c.jobId?await e.jobQueueService.getStatus(c.jobId):null;if(c.status!=="failed"&&d&&(d.status==="pending"||d.status==="processing"))return null;return{ruleId:c.ruleId,jobId:c.jobId,jobStatus:d?.status??"missing"}}))).filter((c)=>c!==null);return{waveId:r.id,batches:n,strandedRules:a,incidentCount:i.total,incidents:i.incidents}}function Qu(e){if(e.batches.abandoned>0)return{name:"projection-waves",status:"degraded",message:`${e.batches.abandoned} projection batch(es) await recovery`,details:{batches:e.batches}};if(e.batches.expiredCallbackLeases>0)return{name:"projection-waves",status:"degraded",message:"A callback projection batch lease has expired",details:{batches:e.batches}};if(e.incidentCount>0)return{name:"projection-waves",status:"degraded",message:`${e.incidentCount} unresolved terminal projection incident(s)`,details:{incidentCount:e.incidentCount,incidentsTruncated:e.incidentCount>e.incidents.length,incidents:e.incidents.map((t)=>({waveId:t.waveId,ruleId:t.ruleId,jobId:t.jobId,failureReason:t.failureReason,createdAt:t.createdAt}))}};if(!e.waveId)return{name:"projection-waves",status:"healthy",message:e.batches.open+e.batches.preparing>0?`${e.batches.open+e.batches.preparing} projection batch(es) active`:"No active projection wave",...e.batches.open+e.batches.preparing>0&&{details:{batches:e.batches}}};if(e.strandedRules.length===0)return{name:"projection-waves",status:"healthy",message:`Projection wave ${e.waveId} is progressing`};return{name:"projection-waves",status:"degraded",message:`Projection wave ${e.waveId} has ${e.strandedRules.length} stranded rule job(s)`,details:{waveId:e.waveId,strandedRules:e.strandedRules}}}function Ku(e){let t=e.filter((r)=>r.status!=="running"||r.health?.status==="error");return t.length===0?{name:"daemons",status:"healthy",message:`${e.length} daemon(s) healthy`}:{name:"daemons",status:"degraded",message:`${t.length} daemon(s) unhealthy`,details:{daemons:t.map((r)=>({name:r.name,status:r.status,health:r.health?.status,message:r.health?.message}))}}}async function Tn(e){let t=e.now?.()??Date.now(),r=(e.memoryUsage??process.memoryUsage)(),[i,n,o,s,a,c,d,u]=await Promise.allSettled([e.entityService.getEntityCounts(ft("runtime readiness database probe")),e.jobQueueService.getDiagnostics(t),Promise.resolve(e.jobQueueService.getExecutionRegistrations()),e.daemonRegistry.getStatuses(),(e.readProcessSignals??Nu)(),e.projectionRuntimeSupervisor.getDiagnostics(),Gu(e),e.operationalHealthRegistry.getChecks()]),p=n.status==="fulfilled"?n.value:null,m=o.status==="fulfilled"?o.value??null:null,g=s.status==="fulfilled"?s.value:[],f=a.status==="fulfilled"?a.value:{fileDescriptors:null,processCount:null,zombieCount:null},h=c.status==="fulfilled"?c.value:{status:"unhealthy",initialized:!1,trackedRoots:0,openCircuits:[]},w=[Cn("entity-database",i,"Entity database is accessible"),Cn("job-queue-database",n,"Job queue database is accessible"),Zu(p),Wu(p),Hu(p,m),qu(p),c.status==="fulfilled"?Ju(h):{name:"projection-circuits",status:"degraded",message:P(c.reason)},d.status==="fulfilled"?Qu(d.value):{name:"projection-waves",status:"degraded",message:P(d.reason)},s.status==="fulfilled"?Ku(g):{name:"daemons",status:"degraded",message:P(s.reason)}],b=u.status==="fulfilled"?u.value:[{name:"plugin-operational-health",status:"degraded",message:"Plugin operational health is unavailable"}],S=[...w,...b];return{status:w.some((y)=>y.status==="unhealthy")?"not_ready":"ready",operationalStatus:S.some((y)=>y.status!=="healthy")?"degraded":"operational",checkedAt:new Date(t).toISOString(),checks:S,resources:{memory:{rssBytes:r.rss,heapUsedBytes:r.heapUsed,heapTotalBytes:r.heapTotal},fileDescriptors:f.fileDescriptors,processes:{total:f.processCount,zombies:f.zombieCount},queue:p,projection:{initialized:h.initialized,trackedRoots:h.trackedRoots,openCircuits:h.openCircuits},worker:p?.workerSessions??{total:0,active:0,stale:0,latestHeartbeatAgeMs:null}}}}function En(){return{dataDir:"./data",cacheDir:"./cache",distDir:"./dist"}}function ye(e){return{database:{url:`file:${e.dataDir}/brain.db`},jobQueueDatabase:{url:`file:${e.dataDir}/brain-jobs.db`},conversationDatabase:{url:`file:${e.dataDir}/conversations.db`},runtimeStateDatabase:{url:`file:${e.dataDir}/runtime-state.db`},embeddingDatabase:{url:`file:${e.dataDir}/embeddings.db`},embedding:{enabled:!0}}}var He=l.strictObject({enabled:l.boolean().optional().describe("Serve HTTP; defaults to whether the selected bundles host the web surface"),preview:l.boolean().optional().describe("Serve the preview site; defaults to whether a site builder runs"),hostname:l.string().trim().min(1).optional().describe("Bind address; use 127.0.0.1 for isolated local tests"),productionDistDir:l.string().min(1).optional().describe("Directory of the production site, when no site builder writes it"),previewDistDir:l.string().min(1).optional().describe("Directory of the preview site, when no site builder writes it"),sharedImagesDir:l.string().min(1).optional().describe("Directory of shared optimized images")}),Or=He.extend({enabled:l.boolean().default(!1),preview:l.boolean().default(!0),port:l.number().default(8080).describe("Port of the production listener")});var ne=l.enum(["debug","info","warn","error"]);var Lr=En(),Vu=l.looseObject({label:l.string().min(1),pluralName:l.string().optional(),layout:l.string().optional(),paginate:l.boolean().optional(),pageSize:l.number().optional(),navigation:l.object({show:l.boolean().optional(),slot:l.enum(["primary","secondary"]).optional(),priority:l.number().optional()}).optional()});function Ur(){return ye(Lr)}var Br=l.object({name:l.string().default("brain-app"),version:l.string().default("1.0.0"),database:Ee,jobQueueDatabase:Ee,jobQueue:l.object({workerConcurrency:l.number().int().min(1).max(32).default(4)}).prefault({}),conversationDatabase:Ee,runtimeStateDatabase:Ee,embeddingDatabase:Ee,ai:l.object({providerKeys:qe.default({}),model:l.string().refine(kn,{error:(e)=>`Unsupported model "${String(e.input)}"`}),embeddingModel:l.string().refine((e)=>Mr(e)!==void 0,{error:(e)=>Dn(String(e.input))}).default(jn),modelRuntimeUrl:l.string().url().optional(),answerModel:l.string().optional(),visionModel:l.string().optional(),imageModel:l.string().optional(),temperature:l.number().min(0).max(2).default(0.7),webSearch:l.boolean().default(!0),reasoningEffort:oe.optional()}).superRefine((e,t)=>{if(e.answerModel&&be(e.answerModel)!=="local")t.addIssue({code:"custom",path:["answerModel"],message:`answerModel must be a local: model, not ${e.answerModel}`});if(e.visionModel&&be(e.visionModel)!=="local")t.addIssue({code:"custom",path:["visionModel"],message:`visionModel must be a local: model, not ${e.visionModel}`});if(e.modelRuntimeUrl)return;let r=[...be(e.model)==="local"?[e.model]:[],...[e.answerModel,e.visionModel].filter((i)=>i!==void 0&&be(i)==="local"),...e.imageModel&&An(e.imageModel).provider==="local"?[e.imageModel]:[],...Mr(e.embeddingModel)?.provider==="local"?[e.embeddingModel]:[]];for(let i of r)t.addIssue({code:"custom",path:["modelRuntimeUrl"],message:`${i} needs modelRuntime.url`})}),embedding:l.object({enabled:l.boolean().default(!0)}),logging:l.object({level:ne.default("info"),format:l.enum(["text","json"]).default("text"),file:l.string().optional(),context:l.string().default("shell")}).prefault({level:"info",context:"shell"}),features:l.object({}).default({}),plugins:l.array(ht).default([]),dataDir:l.string().default("./brain-data"),gitBrokerSocket:l.string().min(1).optional(),gitBrokerCheckout:l.string().min(1).optional(),spaces:l.array(l.string()).default([]),siteBaseUrl:l.string().optional(),localSiteUrl:l.string().optional(),preferLocalUrls:l.boolean().default(!1),production:l.boolean().default(!1),themeCSS:l.string().default(""),entityDisplay:l.record(l.string(),Vu).optional(),profileKind:l.string().trim().min(1).optional(),http:Or.prefault({})});function yt(e={}){let{plugins:t=[],permissions:r={},identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s,ai:a,logging:c,embedding:d,jobQueue:u,...p}=e,{entityDisplay:m,...g}=Br.parse({...Ur(),...H(p),ai:H({...a}),logging:H({...c}),embedding:H({...d}),jobQueue:H({...u}),plugins:[]});return{...g,plugins:t,permissions:r,...H({entityDisplay:m,identity:i,profile:n,agentInstructions:o,evalHandlerRegistry:s})}}var B={NOTE:"note",BRAIN_CHARACTER:"brain-character",ANCHOR_PROFILE:"anchor-profile"},Je={KNOWLEDGE_QUERY:"shell:knowledge-query",BASE_ENTITY_DISPLAY:"shell:base-entity-display",CONTENT_GENERATION:"shell:content-generation"},$r={ENTITIES:"shell:entities"};var Yu=zn.extend({templateName:l.string()}),Xu=l.object({slug:l.string()}),ep="The style guide governs voice, tone, wording and form: paragraphing, sentence rhythm, hooks, rhetorical questions and calls to action. The instructions below and any additional instructions in the request govern the task, required content, length limits, platform constraints and output format. When either conflicts with the style guide on voice or form, follow the style guide.",tp="Generate the content described in your instructions.";function rp(e){return e instanceof l.ZodType}function ip(e){if(!e)return;return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}class vt{aiService;entityService;templateRegistry;getIdentityContent;getProfileContent;entityUrls;id="ai-content";name="AI Content Generator";description="Generates content using AI based on templates and prompts";constructor(e,t,r,i,n,o,s){this.aiService=e,this.entityService=t,this.templateRegistry=r,this.getIdentityContent=i,this.getProfileContent=n,this.entityUrls=o,this.siteBaseUrl=ip(s)}siteBaseUrl;async generate(e,t,r){return this.generateWithContext(e,t,r)}async generateScoped(e,t,r){return this.generateWithContext(e,t,r.signal,r)}async generateWithContext(e,t,r,i){r?.throwIfAborted();let n=Yu.parse(e),o=this.templateRegistry.get(n.templateName);if(!o)throw Error(`Template not found: ${n.templateName}`);if(!o.basePrompt)throw Error(`Template ${n.templateName} must have basePrompt for content generation`);let s=i?await On((w,b)=>i.getEntity(w,b),n.templateName,o.basePrompt):await bt(this.entityService,n.templateName,o.basePrompt);r?.throwIfAborted();let a=[s,n.prompt].filter(Boolean).join(" "),c=a.length>0&&o.useKnowledgeContext===!0,d=this.entityService.getWeightMap(),u=Object.keys(d).length>0,p=c?i?await i.search(a,{limit:5,...u&&{weight:d}}):await this.entityService.search({query:a,options:{limit:5,...u&&{weight:d},...r&&{signal:r}}}):[];r?.throwIfAborted();let m=this.buildPrompt(n,p),g=i?await this.readIdentities(i,n.representedIdentity):void 0,f=this.buildSystemPrompt(s,n,g);if(!rp(o.schema))throw Error(`Template ${o.name} cannot be used for AI generation: schema is not an AI generation schema`);r?.throwIfAborted();let h=await this.aiService.generateObject(f,m,o.schema,r);return r?.throwIfAborted(),t.parse(h.object)}async readIdentities(e,t){let r=async(o)=>(await e.getEntity(o,o))?.content??"",[i,n]=await Promise.all([t!=="none"?r(B.BRAIN_CHARACTER):"",t===void 0||t==="anchor"?r(B.ANCHOR_PROFILE):""]);return{brain:i,anchor:n}}buildSystemPrompt(e,t,r){let i=[];if(t.representedIdentity===void 0||t.representedIdentity==="brain"||t.representedIdentity==="anchor")i.push("# Brain Identity",r?.brain??this.getIdentityContent(),"");if(t.representedIdentity===void 0||t.representedIdentity==="anchor")i.push("# Represented Anchor",r?.anchor??this.getProfileContent(),"");let n=this.selectStyleGuidance(t);if(n)i.push("# Style Guide",n,"","# Precedence",ep,"");return i.push("# Instructions",e),i.join(`
|
|
3
3
|
`)}selectStyleGuidance(e){if(!e.styleGuide)return"";let t=[];if(e.styleGuide.voice)t.push("## Voice",e.styleGuide.voice);if(e.styleGuide.visual)t.push("## Visual",e.styleGuide.visual);return t.join(`
|
|
4
4
|
`)}buildPrompt(e,t=[]){let r=[];if(e.conversationHistory)r.push(`Recent conversation context:
|
|
5
5
|
${e.conversationHistory}`);if(t.length>0){let i=t.map((n)=>this.formatRelevantEntity(n,this.entityUrls)).join(`
|
|
@@ -115,4 +115,4 @@ ${rl(i)}`:a,args:t.buildArgs((d)=>({...c,confirmed:!0,confirmationToken:d}))}}as
|
|
|
115
115
|
export{ye as je,He as ke,ne as le,yt as me,A as ne,wp as oe,Rp as pe,Ip as qe,kp as re,ao as se,jp as te,Dp as ue,zp as ve,Op as we,Mp as xe,Lp as ye,Up as ze,ei as Ae,pa as Be,Ri as Ce,Oc as De,Yf as Ee,Al as Fe,rh as Ge,Dl as He,lt as Ie,ih as Je,xe as Ke,Ki as Le,Vi as Me,Yi as Ne,oh as Oe,lh as Pe,dh as Qe,$l as Re,_l as Se,mh as Te,gh as Ue,fh as Ve,hh as We,an as Xe,yh as Ye,bh as Ze,Rh as _e,Kh as $e,Vh as af,mn as bf,su as cf,lu as df,mu as ef,gu as ff,dy as gf,ID as hf,TD as if,WD as jf,HD as kf};
|
|
116
116
|
|
|
117
117
|
//# debugId=7FFC4B01C5C5BA8864756E2164756E21
|
|
118
|
-
//# sourceMappingURL=index-
|
|
118
|
+
//# sourceMappingURL=index-t822ntg2.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./index-cyq5dhvm.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.
|
|
2
|
+
import"./index-cyq5dhvm.js";var n="@brains/chat-repl",i="AGPL-3.0-only",t="0.2.0-alpha.875",r={"@brains/contracts":"workspace:*","@brains/sdk":"workspace:*","@brains/utils":"workspace:*",chalk:"^5.4.1",ink:"^7.0.6","ink-spinner":"^5.0.0","ink-text-input":"^6.0.0",marked:"^18.0.5",react:"^19.2.7"},a={"@brains/eslint-config":"workspace:*","@brains/plugins":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.4.0","@types/react":"^19.2.17",typescript:"^7.0.2"},c=["src"],p="./src/index.ts",l="./src/index.ts",o=!0,k={dev:"tsc --watch",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},d="module",b="./src/index.ts",w={name:n,license:i,version:t,dependencies:r,devDependencies:a,files:c,main:p,module:l,private:o,scripts:k,type:d,types:b};export{w as default,r as dependencies,a as devDependencies,c as files,i as license,p as main,l as module,n as name,o as private,k as scripts,d as type,b as types,t as version};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
5
|
-
//# sourceMappingURL=package-
|
|
4
|
+
//# debugId=DC388D377FA5211C64756E2164756E21
|
|
5
|
+
//# sourceMappingURL=package-c88dkedp.js.map
|
package/dist/entities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunks/index-624fhq2j.js";import{Nl as t,Rl as x,Sl as a,Tl as b,Ul as c,Vl as d,Wl as g,gh as m,ui as p}from"./chunks/index-
|
|
2
|
+
import"./chunks/index-624fhq2j.js";import{Nl as t,Rl as x,Sl as a,Tl as b,Ul as c,Vl as d,Wl as g,gh as m,ui as p}from"./chunks/index-9mfc2kx2.js";import{uq as f}from"./chunks/index-m2qv3p6y.js";import"./chunks/index-0k63cxm5.js";import"./chunks/index-rwrp530c.js";import{LD as e}from"./chunks/index-njqkf4cd.js";import"./chunks/index-74vg6r70.js";import"./chunks/index-cyq5dhvm.js";export{m as ProjectionJsonObjectSchema,f as defineChannel,t as defineDashboardWidget,x as defineDataSource,a as defineEntity,b as defineEntityAnalyticsReport,c as defineEntityJob,g as defineEntityPackage,d as defineProjection,p as defineProjectionRule,e as z};
|
|
3
3
|
|
|
4
4
|
//# debugId=6046D37E3CF505DC64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=entities.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -124,10 +124,12 @@ interface RouteDefinitionInput {
|
|
|
124
124
|
/** Languages its plugin fills the page in per request: built in each
|
|
125
125
|
* without saved copy. */
|
|
126
126
|
languages?: string[] | undefined;
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* is
|
|
130
|
-
*
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Every page's words live in the brain: each section's
|
|
129
|
+
* `content` is written there once, then only the brain's text is shown.
|
|
130
|
+
* Legacy: accepted and ignored, so site versions that still set it load;
|
|
131
|
+
* removed with route-copy-option (docs/legacy-code-inventory.json).
|
|
132
|
+
*/
|
|
131
133
|
copy?: "brain" | undefined;
|
|
132
134
|
}
|
|
133
135
|
/** Author-facing metadata for a schema-first content section. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{nf as d,of as t}from"./chunks/index-
|
|
2
|
+
import{nf as d,of as t}from"./chunks/index-cywssss6.js";import{pl as a}from"./chunks/index-9mfc2kx2.js";import"./chunks/index-m2qv3p6y.js";import"./chunks/index-0k63cxm5.js";import"./chunks/index-rwrp530c.js";import"./chunks/index-njqkf4cd.js";import"./chunks/index-74vg6r70.js";import"./chunks/index-cyq5dhvm.js";function s(e,i){let o=new Set,n=new Set;for(let r of e){if(!t(r))throw Error(`${i} contains a value that was not returned by use()`);if(o.has(r.definition))throw Error(`${i} contains duplicate plugin definition "${r.definition.id}"; include each configured definition only once`);if(n.has(r.definition.id))throw Error(`${i} contains duplicate local plugin id "${r.definition.id}"; give each package definition a unique local id before composing it`);o.add(r.definition),n.add(r.definition.id)}}function l(e){a(e.id,"Bundle id"),s(e.members,`Bundle "${e.id}"`);for(let i of e.config??[])if(!t(i.member))throw Error(`Bundle "${e.id}" config contains a value that was not returned by use()`);for(let i of e.permissions??[])if(!t(i.member))throw Error(`Bundle "${e.id}" permissions contains a value that was not returned by use()`);for(let i of e.evalDisable??[])if(!t(i))throw Error(`Bundle "${e.id}" evalDisable contains a value that was not returned by use()`);return Object.freeze({...e,members:Object.freeze([...e.members]),...e.config?{config:Object.freeze([...e.config])}:{},...e.permissions?{permissions:Object.freeze([...e.permissions])}:{},...e.agentInstructions?{agentInstructions:Object.freeze([...e.agentInstructions])}:{},...e.evalDisable?{evalDisable:Object.freeze([...e.evalDisable])}:{}})}function u(e){if(!e.name.trim())throw Error("Brain name must not be empty");if(e.bundleContract?.trim().length===0)throw Error("Brain bundleContract must not be empty");s(e.plugins,`Brain "${e.name}"`);let i=new Set(e.plugins),o=new Set;for(let n of e.bundles??[]){if(o.has(n.id))throw Error(`Brain "${e.name}" has duplicate bundle "${n.id}"`);o.add(n.id);for(let r of n.members)if(!i.has(r))throw Error(`Brain "${e.name}" bundle "${n.id}" references a plugin outside its catalog`);for(let r of n.config??[])if(!i.has(r.member))throw Error(`Brain "${e.name}" bundle "${n.id}" config references a plugin outside its catalog`);for(let r of n.permissions??[])if(!i.has(r.member))throw Error(`Brain "${e.name}" bundle "${n.id}" permissions reference a plugin outside its catalog`);for(let r of n.evalDisable??[])if(!i.has(r))throw Error(`Brain "${e.name}" bundle "${n.id}" evalDisable references a plugin outside its catalog`)}for(let n of e.evalDisable??[])if(!i.has(n))throw Error(`Brain "${e.name}" evalDisable references a plugin outside its catalog`);return Object.freeze({...e,plugins:Object.freeze([...e.plugins]),...e.bundles?{bundles:Object.freeze([...e.bundles])}:{},...e.agentInstructions?{agentInstructions:Object.freeze([...e.agentInstructions])}:{},...e.evalDisable?{evalDisable:Object.freeze([...e.evalDisable])}:{}})}export{u as defineBrain,l as defineBundle,d as use};
|
|
3
3
|
|
|
4
4
|
//# debugId=5C6B614D178C9B1664756E2164756E21
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/interfaces.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunks/index-x8e40qwv.js";import{An as t,Bn as x,Cn as a,Dn as b,En as c,Fn as d,Zl as p}from"./chunks/index-
|
|
2
|
+
import"./chunks/index-x8e40qwv.js";import{An as t,Bn as x,Cn as a,Dn as b,En as c,Fn as d,Zl as p}from"./chunks/index-9mfc2kx2.js";import{Ut as m,tr as f}from"./chunks/index-m2qv3p6y.js";import"./chunks/index-0k63cxm5.js";import"./chunks/index-rwrp530c.js";import{LD as e}from"./chunks/index-njqkf4cd.js";import"./chunks/index-74vg6r70.js";import"./chunks/index-cyq5dhvm.js";export{f as SdkError,m as UserPermissionLevelSchema,p as defineAccountSettings,a as defineDaemon,b as defineInterface,c as defineMessageInterface,d as defineMessageInterfacePackage,x as defineRoute,t as protocol,e as z};
|
|
3
3
|
|
|
4
4
|
//# debugId=2BF1198D1E378AB064756E2164756E21
|
|
5
5
|
//# sourceMappingURL=interfaces.js.map
|