@rizom/brain 0.2.0-alpha.584 → 0.2.0-alpha.586
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 +44 -44
- package/dist/chunks/{app-25fctt6k.js → app-rh4ty0da.js} +2 -2
- package/dist/chunks/{blog-post-adapter-z1dtc2r2.js → blog-post-adapter-0x7wvkzq.js} +2 -2
- package/dist/chunks/{index-d2yxd329.js → index-0j7rk0ht.js} +2 -2
- package/dist/chunks/{index-jnfgrr88.js → index-1dy24s9t.js} +2 -2
- package/dist/chunks/{index-zezv3y29.js → index-3fvrpnmh.js} +2 -2
- package/dist/chunks/{index-ygy8j5wp.js → index-7c9cvp1j.js} +4 -5
- package/dist/chunks/{index-ygy8j5wp.js.map → index-7c9cvp1j.js.map} +3 -3
- package/dist/chunks/{index-vbjcqzth.js → index-n2515xkf.js} +3 -3
- package/dist/chunks/{index-vbjcqzth.js.map → index-n2515xkf.js.map} +1 -1
- package/dist/chunks/{index-jk3w409a.js → index-n9v4ww8s.js} +3 -3
- package/dist/chunks/{linkedin-template-f5g0md30.js → linkedin-template-8c2vjj5e.js} +2 -2
- package/dist/chunks/{rss-datasource-zh4j263b.js → rss-datasource-g6syrm7v.js} +2 -2
- package/dist/entities.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.js +1 -1
- package/dist/model.js +43 -42
- package/dist/model.js.map +3 -3
- package/dist/plugins.js +1 -1
- package/dist/services.js +1 -1
- package/dist/ui/{studio-app-589ca178b493c37825116e19389e661774e7a872452f23d3e48b467ca1514a60.css → studio-app-1d8a85ef60f4d93da4506c0d76de4cc4bfbfcb91a83e2453da2f013b67988223.css} +1 -0
- package/dist/ui/{studio-app-cmq8cwna.js → studio-app-e55r86r3.js} +2 -2
- package/dist/ui/studio-asset-manifest.json +9 -9
- package/dist/ui/studio-chunks/{account-view-8z403hx4.js → account-view-0yz326ez.js} +1 -1
- package/dist/ui/studio-chunks/main-4vaeqvhy.js.map +1 -1
- package/dist/ui/studio-chunks/{main-xvgffskk.js → main-m8wmpxz1.js} +2 -2
- package/dist/ui/studio-chunks/{main-xvgffskk.js.map → main-m8wmpxz1.js.map} +3 -3
- package/package.json +1 -1
- /package/dist/chunks/{app-25fctt6k.js.map → app-rh4ty0da.js.map} +0 -0
- /package/dist/chunks/{blog-post-adapter-z1dtc2r2.js.map → blog-post-adapter-0x7wvkzq.js.map} +0 -0
- /package/dist/chunks/{index-d2yxd329.js.map → index-0j7rk0ht.js.map} +0 -0
- /package/dist/chunks/{index-jnfgrr88.js.map → index-1dy24s9t.js.map} +0 -0
- /package/dist/chunks/{index-zezv3y29.js.map → index-3fvrpnmh.js.map} +0 -0
- /package/dist/chunks/{index-jk3w409a.js.map → index-n9v4ww8s.js.map} +0 -0
- /package/dist/chunks/{linkedin-template-f5g0md30.js.map → linkedin-template-8c2vjj5e.js.map} +0 -0
- /package/dist/chunks/{rss-datasource-zh4j263b.js.map → rss-datasource-g6syrm7v.js.map} +0 -0
- /package/dist/ui/{studio-app-cmq8cwna.js.map → studio-app-e55r86r3.js.map} +0 -0
- /package/dist/ui/studio-chunks/{account-view-8z403hx4.js.map → account-view-0yz326ez.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ja as a,ka as b,la as c,ma as d}from"./index-
|
|
2
|
+
import{ja as a,ka as b,la as c,ma as d}from"./index-n9v4ww8s.js";import"./index-13wwvf9d.js";import"./index-7c9cvp1j.js";import"./index-5e5vv8yh.js";import"./index-xv35a0x3.js";import"./index-qsw9tcjy.js";import"./index-f90s4k5m.js";import"./index-01kchyzt.js";export{d as App,a as STARTUP_CHECK_API_KEY,c as buildShellConfig,b as toAppConfig};
|
|
3
3
|
|
|
4
4
|
//# debugId=0922B8A2BF8AD17664756E2164756E21
|
|
5
|
-
//# sourceMappingURL=app-
|
|
5
|
+
//# sourceMappingURL=app-rh4ty0da.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B as a,C as b}from"./index-
|
|
2
|
+
import{B as a,C as b}from"./index-3fvrpnmh.js";import"./index-1dy24s9t.js";import"./index-7c9cvp1j.js";import"./index-5e5vv8yh.js";import"./index-xv35a0x3.js";import"./index-qsw9tcjy.js";import"./index-f90s4k5m.js";import"./index-01kchyzt.js";export{a as BlogPostAdapter,b as blogPostAdapter};
|
|
3
3
|
|
|
4
4
|
//# debugId=1926E9DFA156C4E064756E2164756E21
|
|
5
|
-
//# sourceMappingURL=blog-post-adapter-
|
|
5
|
+
//# sourceMappingURL=blog-post-adapter-0x7wvkzq.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{S as l,T as y}from"./index-
|
|
2
|
+
import{S as l,T as y}from"./index-n9v4ww8s.js";import{Dl as R,Ul as z,eo as a}from"./index-7c9cvp1j.js";import{rq as i}from"./index-5e5vv8yh.js";import{Lt as c,Mt as h,Nt as C,Pq as e}from"./index-f90s4k5m.js";function _(t,n={}){if(!a(t))throw Error("use() expects a package definition returned by a @rizom/brain define helper");return Object.freeze({kind:"rizom-configured-plugin",definition:t,config:Object.freeze({...n})})}function O(t){if(t===null||typeof t!=="object")return!1;return Reflect.get(t,"kind")==="rizom-configured-plugin"&&a(Reflect.get(t,"definition"))&&typeof Reflect.get(t,"config")==="object"}var Ee=e.array(e.string()),Ie=e.record(e.string(),e.unknown()),Ae=e.unknown();var Be=e.enum(["eval"]),p=e.enum(["person","team","organization"]);function K(t){if(t.bundleContract?.trim().length===0)throw Error("Brain bundleContract must not be empty");return t}function f(t){if(Array.isArray(t))return t.map((n)=>f(n));if(i(t))return Object.fromEntries(Object.entries(t).map(([n,o])=>[n,f(o)]));return t}function u(t){return f(t)}var r=e.string().min(1),V=e.strictObject({member:r,value:e.record(e.string(),e.unknown()),overrides:r.optional()}),G=e.custom(i,{message:"Expected an opaque permission config object"}),q=e.strictObject({member:r,config:G,overrides:r.optional()}),U=e.strictObject({id:r,members:e.array(r),config:e.array(V).optional(),permissions:e.array(q).optional(),agentInstructions:e.array(e.string().min(1)).optional(),evalDisable:e.array(r).optional()});function E(t,n,o,Z){let w=new Set;for(let[j,g]of t.entries()){if(w.has(g))Z.addIssue({code:e.ZodIssueCode.custom,message:`Duplicate ${n} "${g}"`,path:[o,j]});w.add(g)}}var H=U.superRefine((t,n)=>{E(t.members,"member","members",n),E(t.evalDisable??[],"eval exclusion","evalDisable",n)});function I(t){return u(H.parse(t))}function J(t){if(t===void 0)return[];return Array.isArray(t)?t:[t]}var W=e.record(e.string(),e.unknown()),ut=e.record(e.string(),e.unknown()),Y=e.enum(["eval"]),Q=c,s=h,X=e.strictObject({create:s.optional(),update:s.optional(),delete:s.optional(),extract:s.optional(),publish:s.optional()}),ee=e.record(e.string(),X),A=W.superRefine((t,n)=>{if(typeof t.package!=="string")return;n.addIssue({code:"custom",message:'"package" uses the removed alpha external-plugin contract. Default-export a declarative package definition from a @rizom/brain define helper and compose it with use() in defineBrain().'})}),mt=e.strictObject({brain:e.string().optional(),bundleContract:e.string().trim().min(1).optional(),anchor:p.optional(),site:e.object({package:e.string().optional(),variant:e.string().optional(),theme:e.string().optional(),themeOverride:e.string().optional()}).optional(),name:e.string().optional(),kind:e.string().trim().min(1).optional(),logLevel:l.optional(),logFile:e.string().optional(),port:e.number().optional(),domain:e.string().optional(),database:e.string().optional(),embedding:e.strictObject({enabled:e.boolean().optional()}).optional(),model:e.string().optional(),reasoningEffort:y.optional(),bundles:e.array(e.string().min(1)).optional(),mode:Y.optional(),add:e.array(e.string()).optional(),remove:e.array(e.string()).optional(),admins:e.array(e.string()).optional(),anchors:e.array(e.string()).optional(),trusted:e.array(e.string()).optional(),spaces:e.array(e.string()).optional(),plugins:e.record(e.string(),A).optional(),permissions:e.object({admins:e.array(e.string()).optional(),anchors:e.array(e.string()).optional(),trusted:e.array(e.string()).optional(),rules:e.array(e.object({pattern:e.string(),level:Q})).optional(),entityActions:ee.optional()}).optional()});var Pt=e.record(e.string(),e.unknown());var ne=e.strictObject({pattern:e.string(),level:c}),Et=e.strictObject({admins:e.array(e.string()).optional(),anchors:e.array(e.string()).optional(),trusted:e.array(e.string()).optional(),rules:e.array(ne).optional(),entityActions:C.optional()});var D=`/* ============================================
|
|
3
3
|
THEME BASE - Shared utilities for all themes
|
|
4
4
|
============================================
|
|
5
5
|
This file contains CSS that is IDENTICAL across all themes.
|
|
@@ -528,4 +528,4 @@ import{S as l,T as y}from"./index-jk3w409a.js";import{Dl as R,Ul as z,eo as a}fr
|
|
|
528
528
|
`+t}var B=e.custom((t)=>z.safeParse(t).success),se=e.custom((t)=>{if(!i(t))return!1;let{plugin:n,...o}=t;if(n!==void 0&&typeof n!=="function")return!1;return R.safeParse(o).success});var le=e.looseObject({id:e.string().min(1)}),de=e.looseObject({label:e.string().min(1)}),ge=e.custom((t)=>typeof t==="function"),pe=e.looseObject({layouts:e.record(e.string(),e.unknown()).optional(),plugin:ge.optional(),pluginConfig:e.record(e.string(),e.unknown()).optional(),routes:e.array(le).optional(),entityDisplay:e.record(e.string(),de).optional(),content:e.unknown().optional(),themeOverride:e.string().optional(),headScripts:e.array(e.string()).optional(),staticAssets:e.record(e.string(),e.string()).optional()}),Ut=e.custom((t)=>pe.safeParse(t).success);var In=e.looseObject({name:e.string().min(1),version:e.string().min(1),dependencies:e.record(e.string(),e.string()).optional(),peerDependencies:e.record(e.string(),e.string()).optional()});export{_ as M,O as N,K as O,I as P,J as Q,re as R};
|
|
529
529
|
|
|
530
530
|
//# debugId=0C3DDF1C97B4371864756E2164756E21
|
|
531
|
-
//# sourceMappingURL=index-
|
|
531
|
+
//# sourceMappingURL=index-0j7rk0ht.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Mj as o}from"./index-
|
|
2
|
+
import{Mj as o}from"./index-7c9cvp1j.js";import{Pq as t}from"./index-f90s4k5m.js";var a=t.enum(["generating","draft","queued","published","failed"]),e=t.object({title:t.string(),slug:t.string().optional(),status:a,publishedAt:t.string().datetime().optional(),excerpt:t.string(),author:t.string(),coverImageId:t.string().optional(),ogImageId:t.string().optional(),seriesName:t.string().optional(),seriesIndex:t.number().optional(),ogImage:t.string().url().optional(),canonicalUrl:t.string().url().optional()}),i=e.pick({title:!0,status:!0,publishedAt:!0,seriesName:!0,seriesIndex:!0}).extend({slug:t.string(),error:t.string().optional()}),n=o.extend({entityType:t.literal("post"),metadata:i}),r=n.extend({frontmatter:e,body:t.string(),coverImageUrl:t.string().optional()}),s=r.extend({url:t.string().optional(),typeLabel:t.string().optional(),listUrl:t.string().optional(),listLabel:t.string().optional(),seriesUrl:t.string().optional(),coverImageUrl:t.string().optional(),ogImageUrl:t.string().optional(),coverImageWidth:t.number().optional(),coverImageHeight:t.number().optional(),coverImageSrcset:t.string().optional(),coverImageSizes:t.string().optional()}),d=r.extend({url:t.string(),typeLabel:t.string(),listUrl:t.string(),listLabel:t.string(),seriesUrl:t.string().optional(),coverImageUrl:t.string().optional(),ogImageUrl:t.string().optional(),coverImageWidth:t.number().optional(),coverImageHeight:t.number().optional(),coverImageSrcset:t.string().optional(),coverImageSizes:t.string().optional()});
|
|
3
3
|
export{a as E,e as F,n as G,r as H};
|
|
4
4
|
|
|
5
5
|
//# debugId=0E28D9491CC411B164756E2164756E21
|
|
6
|
-
//# sourceMappingURL=index-
|
|
6
|
+
//# sourceMappingURL=index-1dy24s9t.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{F as o,G as n}from"./index-
|
|
2
|
+
import{F as o,G as n}from"./index-1dy24s9t.js";import{bl as s,il as a}from"./index-7c9cvp1j.js";class l extends s{constructor(){super({entityType:"post",purpose:"A long-form published article, essay, or blog post written for an audience.",schema:n,frontmatterSchema:o,supportsCoverImage:!0})}toMarkdown(t){let e=this.extractBody(t.content);try{let r=this.parseFrontMatter(t.content,o),i={...r,slug:r.slug??t.metadata.slug};return this.buildMarkdown(e,i)}catch{return e}}fromMarkdown(t){let e=this.parseFrontMatter(t,o),r=e.slug??a(e.title);return{content:t,entityType:"post",metadata:{title:e.title,slug:r,status:e.status,publishedAt:e.publishedAt,seriesName:e.seriesName,seriesIndex:e.seriesIndex}}}parsePostFrontmatter(t){return this.parseFrontMatter(t.content,o)}createPostContent(t,e){return this.buildMarkdown(e,t)}buildStub(t){let e={title:t.title,slug:t.id,status:"generating",excerpt:"",author:"AI"};return{content:this.buildMarkdown("",e),metadata:{title:t.title,slug:t.id,status:"generating"}}}}var p=new l;
|
|
3
3
|
export{l as B,p as C};
|
|
4
4
|
|
|
5
5
|
//# debugId=62A8C416CE728B7364756E2164756E21
|
|
6
|
-
//# sourceMappingURL=index-
|
|
6
|
+
//# sourceMappingURL=index-3fvrpnmh.js.map
|
|
@@ -80,9 +80,8 @@ params: ${t}`);if(this.query=e,this.params=t,this.cause=n,Error.captureStackTrac
|
|
|
80
80
|
content_hash TEXT NOT NULL,
|
|
81
81
|
PRIMARY KEY(entity_id, entity_type)
|
|
82
82
|
)
|
|
83
|
-
`),await e.execute("DROP INDEX IF EXISTS embeddings_embedding_idx"),await e.execute("UPDATE embeddings SET entity_type = 'note' WHERE entity_type = 'base'")}async function bE(e,t){await e.execute(`ATTACH DATABASE '${t}' AS emb`)}function vE(e){return e.startsWith("file:")?e.slice(5):e}async function $pe(e,t,n){let{firstDelayMs:r,maxDelayMs:i,giveUpAt:a,signal:s,clock:l,onRetry:c}=n,u,d=(f,m)=>{let g=Math.min(r*2**(f-1),i);return Nc.currentTimeMillis.pipe(ge.flatMap((h)=>{if(a!==void 0&&h+g>=a)return ge.succeed({kind:"abandoned",error:m});return c?.(m,g),ge.sleep(g).pipe(ge.andThen(ge.uninterruptibleMask((y)=>ge.tryPromise({try:()=>e(),catch:(w)=>w}).pipe(ge.matchEffect({onSuccess:(w)=>ge.sync(()=>(u={kind:"succeeded",value:w},u)),onFailure:(w)=>y(d(f+1,w))})))))}))},p=await ge.runPromiseExit(bi(d(1,t),l),s?{signal:s}:void 0);if(Yt.isSuccess(p))return p.value;if(u)return u;if(br.hasInterruptsOnly(p.cause))return{kind:"stopped"};throw br.squash(p.cause)}var Upe=1000,Zpe=60000;class tg{options;controller=new AbortController;running=new Set;keyed=new Map;constructor(e){this.options=e}retry(e,t,n,r){let{clock:i,logger:a}=this.options,s=new AbortController;if(r!==void 0)this.keyed.get(r)?.abort(),this.keyed.set(r,s);let l=$pe(e,t,{firstDelayMs:this.options.firstDelayMs??Upe,maxDelayMs:this.options.maxDelayMs??Zpe,clock:i,signal:AbortSignal.any([this.controller.signal,s.signal]),onRetry:(c,u)=>{a.warn(`Failed to ${n}; retrying in ${u}ms`,{error:c})}}).catch((c)=>(a.error(`Retrying "${n}" failed`,{error:c}),{kind:"stopped"}));return this.running.add(l),l.then(()=>{if(this.running.delete(l),r!==void 0&&this.keyed.get(r)===s)this.keyed.delete(r)}),l}async run(e,t,n){try{await e()}catch(r){this.retry(e,r,t,n)}}cancel(e){this.keyed.get(e)?.abort(),this.keyed.delete(e)}async dispose(){this.controller.abort(),await Promise.all([...this.running])}}function Na(e){return"restricted"}var Gpe=o.object({id:o.string().min(1,"Entity ID is required"),entityType:o.string().min(1,"Entity type is required"),contentHash:o.string().min(1,"Content hash is required"),operation:o.enum(["create","update"])});class ng{logger;embeddingService;entityService;messageBus;static createFresh(e,t,n){return new ng(e,t,n)}constructor(e,t,n){if(this.logger=Ii.getInstance().child("EmbeddingJobHandler"),this.embeddingService=t,this.entityService=e,n)this.messageBus=n}async process(e,t,n){try{this.logger.debug("Processing embedding job",{jobId:t,entityId:e.id,entityType:e.entityType,contentHash:e.contentHash});let r=await this.entityService.getEntity({entityType:e.entityType,id:e.id,visibilityScope:Na("embedding regeneration must index every entity, no user surface")});if(!r){this.logger.warn("Entity no longer exists, skipping embedding job",{jobId:t,entityId:e.id,entityType:e.entityType,operation:e.operation});return}if(r.contentHash!==e.contentHash){this.logger.info("Entity content changed since job created, skipping stale embedding",{jobId:t,entityId:e.id,entityType:e.entityType,jobContentHash:e.contentHash,currentContentHash:r.contentHash});return}let{embedding:i,usage:a}=await this.embeddingService.generateEmbedding(r.content);if(this.logger.info("ai:usage",{operation:"embedding",provider:"openai",model:"text-embedding-3-small",inputTokens:a.tokens,outputTokens:0}),await this.entityService.storeEmbedding({entityId:e.id,entityType:e.entityType,embedding:i,contentHash:e.contentHash}),this.messageBus)this.logger.debug(`Emitting entity:embedding:ready event for ${e.entityType}:${e.id}`),await this.messageBus.send({type:Ei.embeddingReady,payload:{entityType:e.entityType,entityId:e.id,entity:r},sender:"entity-service",broadcast:!0});this.logger.debug("Embedding job completed successfully",{jobId:t,entityId:e.id,embeddingDimensions:i.length})}catch(r){throw this.logger.error("Embedding job failed",{jobId:t,entityId:e.id,entityType:e.entityType,error:r}),r}}async onError(e,t,n){this.logger.error("Embedding job error handler called",{jobId:n,entityId:t.id,entityType:t.entityType,contentHash:t.contentHash,errorMessage:e.message,errorStack:e.stack})}validateAndParse(e){let t=Gpe.safeParse(e);if(!t.success)return this.logger.warn("Invalid embedding job data",{data:e,validationError:t.error.issues}),null;return this.logger.debug("Embedding job data validation successful",{entityId:t.data.id,entityType:t.data.entityType,contentHash:t.data.contentHash}),t.data}}var xv=E`json_extract(${V.metadata}, '$.status')`;function Xd(e){if(e&&e.length>0)return E`${xv} IN (${E.join(e.map((t)=>E`${t}`),E`, `)})`;return E`(${xv} = 'published' OR ${xv} = 'active' OR ${xv} IS NULL)`}function SE(e){let t=Object.entries(e).filter(([,i])=>i.length>0);if(t.length===0)return Xd();let n=t.map(([i,a])=>E`(${V.entityType} = ${i} AND ${Xd(a)})`),r=E`(${V.entityType} NOT IN (${E.join(t.map(([i])=>E`${i}`),E`, `)}) AND ${Xd()})`;return E`(${E.join([...n,r],E` OR `)})`}function Gq(e,t={}){if(t.maxNeighborDistance!==void 0&&(!Number.isFinite(t.maxNeighborDistance)||t.maxNeighborDistance<0||t.maxNeighborDistance>2))throw RangeError("maxNeighborDistance must be between 0 and 2");Wpe(e,t.origin);let n=e.map((c)=>Uq(c.embedding)),r=t.origin?Uq(t.origin.embedding):Jpe(n),i=Hpe(n),a=t.origin?{kind:"entity",entityId:t.origin.entityId,entityType:t.origin.entityType}:{kind:"centroid"},s=e.map((c,u)=>({entityId:c.entityId,entityType:c.entityType,coordinates:i[u]??[0,0],distanceToOrigin:Wq(n[u]??new Float64Array,r)})),l=s.map((c)=>c.distanceToOrigin);return{origin:a,points:s,neighbors:Vpe(e,n,t.maxNeighborDistance),distanceRange:{min:l.length>0?Math.min(...l):0,max:l.length>0?Math.max(...l):0}}}function Wpe(e,t){let n=e[0]?.embedding.length??t?.embedding.length;if(n===void 0)return;for(let r of e)if(r.embedding.length!==n)throw RangeError("Semantic embeddings must have matching dimensions");if(t&&t.embedding.length!==n)throw RangeError("Semantic origin must match point dimensions")}function Uq(e){let t=0;for(let i of e)t+=i*i;let n=Math.sqrt(t),r=new Float64Array(e.length);if(n<=0.000000000001)return r;for(let i=0;i<e.length;i+=1)r[i]=(e[i]??0)/n;return r}function Jpe(e){let t=e[0]?.length??0,n=new Float64Array(t);if(e.length===0)return n;for(let a of e)for(let s=0;s<t;s+=1)n[s]=(n[s]??0)+(a[s]??0);let r=0;for(let a of n)r+=a*a;let i=Math.sqrt(r);if(i<=0.000000000001)return new Float64Array(t);for(let a=0;a<t;a+=1)n[a]=(n[a]??0)/i;return n}function Wq(e,t){if(e.length===0||t.length===0)return 1;let n=0,r=0,i=0;for(let s=0;s<e.length;s+=1){let l=e[s]??0,c=t[s]??0;n+=l*c,r+=l*l,i+=c*c}if(r<=0.000000000001||i<=0.000000000001)return 1;return 1-Math.max(-1,Math.min(1,n/Math.sqrt(r*i)))}function Vpe(e,t,n){if(n===void 0)return[];let r=[];for(let i=0;i<e.length;i+=1)for(let a=i+1;a<e.length;a+=1){let s=e[i],l=e[a],c=t[i],u=t[a];if(!s||!l||!c||!u)continue;let d=Wq(c,u);if(d<=n)r.push({source:{entityId:s.entityId,entityType:s.entityType},target:{entityId:l.entityId,entityType:l.entityType},distance:d})}return r}function Hpe(e){let t=e.length;if(t===0)return[];if(t===1)return[[0,0]];let n=e[0]?.length??0,r=new Float64Array(n);for(let l of e)for(let c=0;c<n;c+=1)r[c]=(r[c]??0)+(l[c]??0)/t;let i=Array.from({length:t},()=>Array(t).fill(0));for(let l=0;l<t;l+=1)for(let c=l;c<t;c+=1){let u=0,d=e[l],p=e[c];if(!d||!p)continue;for(let g=0;g<n;g+=1)u+=((d[g]??0)-(r[g]??0))*((p[g]??0)-(r[g]??0));let f=i[l],m=i[c];if(f)f[c]=u;if(m)m[l]=u}let a=[],s=[];for(let l=0;l<2;l+=1){let c=Kpe(i,a,l);if(!c){a.push(Array(t).fill(0)),s.push(0);continue}a.push(c),s.push(Math.max(0,Qpe(i,c)))}return Array.from({length:t},(l,c)=>[(a[0]?.[c]??0)*Math.sqrt(s[0]??0),(a[1]?.[c]??0)*Math.sqrt(s[1]??0)])}function Kpe(e,t,n){let r=e.length,i=Array.from({length:r},(s,l)=>Math.sin((l+1)*(n+1))+Math.cos((l+1)*(n+2)));if(i=Zq(i,t),xE(i)<=0.000000000001)return null;for(let s=0;s<100;s+=1){let l=Zq(Jq(e,i),t),c=xE(l);if(c<=0.000000000001)return null;i=l.map((u)=>u/c)}let a=i.reduce((s,l,c)=>Math.abs(l)>Math.abs(i[s]??0)?c:s,0);if((i[a]??0)<0)i=i.map((s)=>-s);return i}function Jq(e,t){return e.map((n)=>n.reduce((r,i,a)=>r+i*(t[a]??0),0))}function Zq(e,t){let n=[...e];for(let i of t){let a=n.reduce((s,l,c)=>s+l*(i[c]??0),0);for(let s=0;s<n.length;s+=1)n[s]=(n[s]??0)-a*(i[s]??0)}let r=xE(n);return r<=0.000000000001?n:n.map((i)=>i/r)}function xE(e){return Math.sqrt(e.reduce((t,n)=>t+n*n,0))}function Qpe(e,t){let n=Jq(e,t);return t.reduce((r,i,a)=>r+i*(n[a]??0),0)}var rg=12000,Ype=0.82;function Vq(e,t,n=rg){let r=e.trim().replace(/\s+/g," ");if(r.length<=n)return r;return t?.warn("Truncating search query that exceeds max length",{originalLength:r.length,truncatedLength:n}),r.slice(0,n)}var Xpe=o.object({limit:o.number().int().positive().optional().default(20),offset:o.number().int().min(0).optional().default(0),types:o.array(o.string()).optional().default([]),excludeTypes:o.array(o.string()).optional().default([]),weight:o.record(o.string(),o.number()).optional(),visibilityScope:o.enum(["public","shared","restricted"]).optional(),includeUngenerated:o.boolean().optional().default(!1),publishedOnly:o.boolean().optional().default(!1),minScore:o.number().min(0).optional(),signal:o.instanceof(AbortSignal).optional()}),eme=o.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},o.record(o.string(),o.unknown()));class wv{db;embeddingService;serializer;logger;embeddingsEnabled;publishGates;registeredTypes;constructor(e,t,n,r,i=!0,a=()=>({}),s){this.db=e,this.embeddingService=t,this.serializer=n,this.logger=r.child("EntitySearch"),this.embeddingsEnabled=i,this.publishGates=a,this.registeredTypes=s}searchableTypes(e){let t=this.registeredTypes?.();if(!t)return e;return(e.length>0?e:t).filter((r)=>t.includes(r))}async search(e,t){let n=Xpe.parse(t??{}),{offset:r,types:i,excludeTypes:a,weight:s,visibilityScope:l,includeUngenerated:c,publishedOnly:u,minScore:d,signal:p,limit:f}=n;p?.throwIfAborted();let m=this.searchableTypes(i);if(this.registeredTypes&&m.length===0)return[];let g=s&&Object.keys(s).length>0,h=Vq(e,this.logger);if(this.logger.debug(`Searching entities with query (${h.length} chars)`),!this.embeddingsEnabled)return this.searchLexically(h,{limit:f,offset:r,types:m,excludeTypes:a,weight:s,visibilityScope:l,includeUngenerated:c,publishedOnly:u,minScore:d,signal:p});let y=(await(p?this.embeddingService.generateEmbedding(h,p):this.embeddingService.generateEmbedding(h))).embedding;p?.throwIfAborted();let w=JSON.stringify(Array.from(y)),_=this.buildWeightMultiplier(g?s:void 0),b=[];if(m.length>0)b.push(E`${V.entityType} IN (${E.join(m.map((S)=>E`${S}`),E`, `)})`);if(a.length>0)b.push(E`${V.entityType} NOT IN (${E.join(a.map((S)=>E`${S}`),E`, `)})`);return this.searchWithAttachedDb(w,_,[...b,...this.buildVisibilityConditions(l),...this.buildGenerationStatusConditions(c),...this.buildPublishedConditions(u)],f,r,h,d,p)}async searchLexically(e,t){if(!e)return[];let n='"'+e.replace(/"/g,'""')+'"',r=[E`entity_fts MATCH ${n}`];if(t.types.length>0)r.push(Ht(V.entityType,t.types));if(t.excludeTypes.length>0)r.push(E`${V.entityType} NOT IN (${E.join(t.excludeTypes.map((l)=>E`${l}`),E`, `)})`);r.push(...this.buildVisibilityConditions(t.visibilityScope),...this.buildGenerationStatusConditions(t.includeUngenerated),...this.buildPublishedConditions(t.publishedOnly));let i=this.buildWeightMultiplier(t.weight),a=E`(0.5 + 0.5 * ((-bm25(entity_fts)) / (1.0 - bm25(entity_fts)))) * (${i})`;if(t.minScore!==void 0)r.push(E`${a} >= ${t.minScore}`);let s=await this.db.select({id:V.id,entityType:V.entityType,content:V.content,contentHash:V.contentHash,visibility:V.visibility,created:V.created,updated:V.updated,metadata:V.metadata,weighted_score:a.as("weighted_score")}).from(V).innerJoin(E`entity_fts`,E`entity_fts.entity_id = ${V.id} AND entity_fts.entity_type = ${V.entityType}`).where(ve(...r)).orderBy(E`weighted_score DESC`).limit(t.limit).offset(t.offset);return t.signal?.throwIfAborted(),this.mapSearchResults(s,e)}buildVisibilityConditions(e){let t=e??"public";if(t==="restricted")return[];return[Ht(V.visibility,Ma(t))]}buildGenerationStatusConditions(e){if(e)return[];return[E`(json_extract(${V.metadata}, '$.status') IS NULL OR json_extract(${V.metadata}, '$.status') NOT IN ('generating', 'failed'))`]}buildPublishedConditions(e){return e?[SE(this.publishGates())]:[]}static FTS_ALPHA=0.3;buildWeightMultiplier(e){let t=Object.entries(e??{}).filter(([,r])=>Number.isFinite(r));if(t.length===0)return E`1.0`;let n=t.map(([r,i])=>E`WHEN ${V.entityType} = ${r} THEN ${i}`);return E`CASE ${E.join(n,E` `)} ELSE 1.0 END`}async searchWithAttachedDb(e,t,n,r,i,a,s,l){let c=wv.FTS_ALPHA,u=E`(1.0 - vector_distance_cos(emb_e.embedding, vector32(${e})) / 2.0) * (${t})`,d=E`vector_distance_cos(emb_e.embedding, vector32(${e}))`,p='"'+a.replace(/"/g,'""')+'"',f=E`CASE WHEN EXISTS (
|
|
84
|
-
SELECT
|
|
85
|
-
AND entity_id = ${V.id} AND entity_type = ${V.entityType}
|
|
83
|
+
`),await e.execute("DROP INDEX IF EXISTS embeddings_embedding_idx"),await e.execute("UPDATE embeddings SET entity_type = 'note' WHERE entity_type = 'base'")}async function bE(e,t){await e.execute(`ATTACH DATABASE '${t}' AS emb`)}function vE(e){return e.startsWith("file:")?e.slice(5):e}async function $pe(e,t,n){let{firstDelayMs:r,maxDelayMs:i,giveUpAt:a,signal:s,clock:l,onRetry:c}=n,u,d=(f,m)=>{let g=Math.min(r*2**(f-1),i);return Nc.currentTimeMillis.pipe(ge.flatMap((h)=>{if(a!==void 0&&h+g>=a)return ge.succeed({kind:"abandoned",error:m});return c?.(m,g),ge.sleep(g).pipe(ge.andThen(ge.uninterruptibleMask((y)=>ge.tryPromise({try:()=>e(),catch:(w)=>w}).pipe(ge.matchEffect({onSuccess:(w)=>ge.sync(()=>(u={kind:"succeeded",value:w},u)),onFailure:(w)=>y(d(f+1,w))})))))}))},p=await ge.runPromiseExit(bi(d(1,t),l),s?{signal:s}:void 0);if(Yt.isSuccess(p))return p.value;if(u)return u;if(br.hasInterruptsOnly(p.cause))return{kind:"stopped"};throw br.squash(p.cause)}var Upe=1000,Zpe=60000;class tg{options;controller=new AbortController;running=new Set;keyed=new Map;constructor(e){this.options=e}retry(e,t,n,r){let{clock:i,logger:a}=this.options,s=new AbortController;if(r!==void 0)this.keyed.get(r)?.abort(),this.keyed.set(r,s);let l=$pe(e,t,{firstDelayMs:this.options.firstDelayMs??Upe,maxDelayMs:this.options.maxDelayMs??Zpe,clock:i,signal:AbortSignal.any([this.controller.signal,s.signal]),onRetry:(c,u)=>{a.warn(`Failed to ${n}; retrying in ${u}ms`,{error:c})}}).catch((c)=>(a.error(`Retrying "${n}" failed`,{error:c}),{kind:"stopped"}));return this.running.add(l),l.then(()=>{if(this.running.delete(l),r!==void 0&&this.keyed.get(r)===s)this.keyed.delete(r)}),l}async run(e,t,n){try{await e()}catch(r){this.retry(e,r,t,n)}}cancel(e){this.keyed.get(e)?.abort(),this.keyed.delete(e)}async dispose(){this.controller.abort(),await Promise.all([...this.running])}}function Na(e){return"restricted"}var Gpe=o.object({id:o.string().min(1,"Entity ID is required"),entityType:o.string().min(1,"Entity type is required"),contentHash:o.string().min(1,"Content hash is required"),operation:o.enum(["create","update"])});class ng{logger;embeddingService;entityService;messageBus;static createFresh(e,t,n){return new ng(e,t,n)}constructor(e,t,n){if(this.logger=Ii.getInstance().child("EmbeddingJobHandler"),this.embeddingService=t,this.entityService=e,n)this.messageBus=n}async process(e,t,n){try{this.logger.debug("Processing embedding job",{jobId:t,entityId:e.id,entityType:e.entityType,contentHash:e.contentHash});let r=await this.entityService.getEntity({entityType:e.entityType,id:e.id,visibilityScope:Na("embedding regeneration must index every entity, no user surface")});if(!r){this.logger.warn("Entity no longer exists, skipping embedding job",{jobId:t,entityId:e.id,entityType:e.entityType,operation:e.operation});return}if(r.contentHash!==e.contentHash){this.logger.info("Entity content changed since job created, skipping stale embedding",{jobId:t,entityId:e.id,entityType:e.entityType,jobContentHash:e.contentHash,currentContentHash:r.contentHash});return}let{embedding:i,usage:a}=await this.embeddingService.generateEmbedding(r.content);if(this.logger.info("ai:usage",{operation:"embedding",provider:"openai",model:"text-embedding-3-small",inputTokens:a.tokens,outputTokens:0}),await this.entityService.storeEmbedding({entityId:e.id,entityType:e.entityType,embedding:i,contentHash:e.contentHash}),this.messageBus)this.logger.debug(`Emitting entity:embedding:ready event for ${e.entityType}:${e.id}`),await this.messageBus.send({type:Ei.embeddingReady,payload:{entityType:e.entityType,entityId:e.id,entity:r},sender:"entity-service",broadcast:!0});this.logger.debug("Embedding job completed successfully",{jobId:t,entityId:e.id,embeddingDimensions:i.length})}catch(r){throw this.logger.error("Embedding job failed",{jobId:t,entityId:e.id,entityType:e.entityType,error:r}),r}}async onError(e,t,n){this.logger.error("Embedding job error handler called",{jobId:n,entityId:t.id,entityType:t.entityType,contentHash:t.contentHash,errorMessage:e.message,errorStack:e.stack})}validateAndParse(e){let t=Gpe.safeParse(e);if(!t.success)return this.logger.warn("Invalid embedding job data",{data:e,validationError:t.error.issues}),null;return this.logger.debug("Embedding job data validation successful",{entityId:t.data.id,entityType:t.data.entityType,contentHash:t.data.contentHash}),t.data}}var xv=E`json_extract(${V.metadata}, '$.status')`;function Xd(e){if(e&&e.length>0)return E`${xv} IN (${E.join(e.map((t)=>E`${t}`),E`, `)})`;return E`(${xv} = 'published' OR ${xv} = 'active' OR ${xv} IS NULL)`}function SE(e){let t=Object.entries(e).filter(([,i])=>i.length>0);if(t.length===0)return Xd();let n=t.map(([i,a])=>E`(${V.entityType} = ${i} AND ${Xd(a)})`),r=E`(${V.entityType} NOT IN (${E.join(t.map(([i])=>E`${i}`),E`, `)}) AND ${Xd()})`;return E`(${E.join([...n,r],E` OR `)})`}function Gq(e,t={}){if(t.maxNeighborDistance!==void 0&&(!Number.isFinite(t.maxNeighborDistance)||t.maxNeighborDistance<0||t.maxNeighborDistance>2))throw RangeError("maxNeighborDistance must be between 0 and 2");Wpe(e,t.origin);let n=e.map((c)=>Uq(c.embedding)),r=t.origin?Uq(t.origin.embedding):Jpe(n),i=Hpe(n),a=t.origin?{kind:"entity",entityId:t.origin.entityId,entityType:t.origin.entityType}:{kind:"centroid"},s=e.map((c,u)=>({entityId:c.entityId,entityType:c.entityType,coordinates:i[u]??[0,0],distanceToOrigin:Wq(n[u]??new Float64Array,r)})),l=s.map((c)=>c.distanceToOrigin);return{origin:a,points:s,neighbors:Vpe(e,n,t.maxNeighborDistance),distanceRange:{min:l.length>0?Math.min(...l):0,max:l.length>0?Math.max(...l):0}}}function Wpe(e,t){let n=e[0]?.embedding.length??t?.embedding.length;if(n===void 0)return;for(let r of e)if(r.embedding.length!==n)throw RangeError("Semantic embeddings must have matching dimensions");if(t&&t.embedding.length!==n)throw RangeError("Semantic origin must match point dimensions")}function Uq(e){let t=0;for(let i of e)t+=i*i;let n=Math.sqrt(t),r=new Float64Array(e.length);if(n<=0.000000000001)return r;for(let i=0;i<e.length;i+=1)r[i]=(e[i]??0)/n;return r}function Jpe(e){let t=e[0]?.length??0,n=new Float64Array(t);if(e.length===0)return n;for(let a of e)for(let s=0;s<t;s+=1)n[s]=(n[s]??0)+(a[s]??0);let r=0;for(let a of n)r+=a*a;let i=Math.sqrt(r);if(i<=0.000000000001)return new Float64Array(t);for(let a=0;a<t;a+=1)n[a]=(n[a]??0)/i;return n}function Wq(e,t){if(e.length===0||t.length===0)return 1;let n=0,r=0,i=0;for(let s=0;s<e.length;s+=1){let l=e[s]??0,c=t[s]??0;n+=l*c,r+=l*l,i+=c*c}if(r<=0.000000000001||i<=0.000000000001)return 1;return 1-Math.max(-1,Math.min(1,n/Math.sqrt(r*i)))}function Vpe(e,t,n){if(n===void 0)return[];let r=[];for(let i=0;i<e.length;i+=1)for(let a=i+1;a<e.length;a+=1){let s=e[i],l=e[a],c=t[i],u=t[a];if(!s||!l||!c||!u)continue;let d=Wq(c,u);if(d<=n)r.push({source:{entityId:s.entityId,entityType:s.entityType},target:{entityId:l.entityId,entityType:l.entityType},distance:d})}return r}function Hpe(e){let t=e.length;if(t===0)return[];if(t===1)return[[0,0]];let n=e[0]?.length??0,r=new Float64Array(n);for(let l of e)for(let c=0;c<n;c+=1)r[c]=(r[c]??0)+(l[c]??0)/t;let i=Array.from({length:t},()=>Array(t).fill(0));for(let l=0;l<t;l+=1)for(let c=l;c<t;c+=1){let u=0,d=e[l],p=e[c];if(!d||!p)continue;for(let g=0;g<n;g+=1)u+=((d[g]??0)-(r[g]??0))*((p[g]??0)-(r[g]??0));let f=i[l],m=i[c];if(f)f[c]=u;if(m)m[l]=u}let a=[],s=[];for(let l=0;l<2;l+=1){let c=Kpe(i,a,l);if(!c){a.push(Array(t).fill(0)),s.push(0);continue}a.push(c),s.push(Math.max(0,Qpe(i,c)))}return Array.from({length:t},(l,c)=>[(a[0]?.[c]??0)*Math.sqrt(s[0]??0),(a[1]?.[c]??0)*Math.sqrt(s[1]??0)])}function Kpe(e,t,n){let r=e.length,i=Array.from({length:r},(s,l)=>Math.sin((l+1)*(n+1))+Math.cos((l+1)*(n+2)));if(i=Zq(i,t),xE(i)<=0.000000000001)return null;for(let s=0;s<100;s+=1){let l=Zq(Jq(e,i),t),c=xE(l);if(c<=0.000000000001)return null;i=l.map((u)=>u/c)}let a=i.reduce((s,l,c)=>Math.abs(l)>Math.abs(i[s]??0)?c:s,0);if((i[a]??0)<0)i=i.map((s)=>-s);return i}function Jq(e,t){return e.map((n)=>n.reduce((r,i,a)=>r+i*(t[a]??0),0))}function Zq(e,t){let n=[...e];for(let i of t){let a=n.reduce((s,l,c)=>s+l*(i[c]??0),0);for(let s=0;s<n.length;s+=1)n[s]=(n[s]??0)-a*(i[s]??0)}let r=xE(n);return r<=0.000000000001?n:n.map((i)=>i/r)}function xE(e){return Math.sqrt(e.reduce((t,n)=>t+n*n,0))}function Qpe(e,t){let n=Jq(e,t);return t.reduce((r,i,a)=>r+i*(n[a]??0),0)}var rg=12000,Ype=0.82;function Vq(e,t,n=rg){let r=e.trim().replace(/\s+/g," ");if(r.length<=n)return r;return t?.warn("Truncating search query that exceeds max length",{originalLength:r.length,truncatedLength:n}),r.slice(0,n)}var Xpe=o.object({limit:o.number().int().positive().optional().default(20),offset:o.number().int().min(0).optional().default(0),types:o.array(o.string()).optional().default([]),excludeTypes:o.array(o.string()).optional().default([]),weight:o.record(o.string(),o.number()).optional(),visibilityScope:o.enum(["public","shared","restricted"]).optional(),includeUngenerated:o.boolean().optional().default(!1),publishedOnly:o.boolean().optional().default(!1),minScore:o.number().min(0).optional(),signal:o.instanceof(AbortSignal).optional()}),eme=o.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},o.record(o.string(),o.unknown()));class wv{db;embeddingService;serializer;logger;embeddingsEnabled;publishGates;registeredTypes;constructor(e,t,n,r,i=!0,a=()=>({}),s){this.db=e,this.embeddingService=t,this.serializer=n,this.logger=r.child("EntitySearch"),this.embeddingsEnabled=i,this.publishGates=a,this.registeredTypes=s}searchableTypes(e){let t=this.registeredTypes?.();if(!t)return e;return(e.length>0?e:t).filter((r)=>t.includes(r))}async search(e,t){let n=Xpe.parse(t??{}),{offset:r,types:i,excludeTypes:a,weight:s,visibilityScope:l,includeUngenerated:c,publishedOnly:u,minScore:d,signal:p,limit:f}=n;p?.throwIfAborted();let m=this.searchableTypes(i);if(this.registeredTypes&&m.length===0)return[];let g=s&&Object.keys(s).length>0,h=Vq(e,this.logger);if(this.logger.debug(`Searching entities with query (${h.length} chars)`),!this.embeddingsEnabled)return this.searchLexically(h,{limit:f,offset:r,types:m,excludeTypes:a,weight:s,visibilityScope:l,includeUngenerated:c,publishedOnly:u,minScore:d,signal:p});let y=(await(p?this.embeddingService.generateEmbedding(h,p):this.embeddingService.generateEmbedding(h))).embedding;p?.throwIfAborted();let w=JSON.stringify(Array.from(y)),_=this.buildWeightMultiplier(g?s:void 0),b=[];if(m.length>0)b.push(E`${V.entityType} IN (${E.join(m.map((S)=>E`${S}`),E`, `)})`);if(a.length>0)b.push(E`${V.entityType} NOT IN (${E.join(a.map((S)=>E`${S}`),E`, `)})`);return this.searchWithAttachedDb(w,_,[...b,...this.buildVisibilityConditions(l),...this.buildGenerationStatusConditions(c),...this.buildPublishedConditions(u)],f,r,h,d,p)}async searchLexically(e,t){if(!e)return[];let n='"'+e.replace(/"/g,'""')+'"',r=[E`entity_fts MATCH ${n}`];if(t.types.length>0)r.push(Ht(V.entityType,t.types));if(t.excludeTypes.length>0)r.push(E`${V.entityType} NOT IN (${E.join(t.excludeTypes.map((l)=>E`${l}`),E`, `)})`);r.push(...this.buildVisibilityConditions(t.visibilityScope),...this.buildGenerationStatusConditions(t.includeUngenerated),...this.buildPublishedConditions(t.publishedOnly));let i=this.buildWeightMultiplier(t.weight),a=E`(0.5 + 0.5 * ((-bm25(entity_fts)) / (1.0 - bm25(entity_fts)))) * (${i})`;if(t.minScore!==void 0)r.push(E`${a} >= ${t.minScore}`);let s=await this.db.select({id:V.id,entityType:V.entityType,content:V.content,contentHash:V.contentHash,visibility:V.visibility,created:V.created,updated:V.updated,metadata:V.metadata,weighted_score:a.as("weighted_score")}).from(V).innerJoin(E`entity_fts`,E`entity_fts.entity_id = ${V.id} AND entity_fts.entity_type = ${V.entityType}`).where(ve(...r)).orderBy(E`weighted_score DESC`).limit(t.limit).offset(t.offset);return t.signal?.throwIfAborted(),this.mapSearchResults(s,e)}buildVisibilityConditions(e){let t=e??"public";if(t==="restricted")return[];return[Ht(V.visibility,Ma(t))]}buildGenerationStatusConditions(e){if(e)return[];return[E`(json_extract(${V.metadata}, '$.status') IS NULL OR json_extract(${V.metadata}, '$.status') NOT IN ('generating', 'failed'))`]}buildPublishedConditions(e){return e?[SE(this.publishGates())]:[]}static FTS_ALPHA=0.3;buildWeightMultiplier(e){let t=Object.entries(e??{}).filter(([,r])=>Number.isFinite(r));if(t.length===0)return E`1.0`;let n=t.map(([r,i])=>E`WHEN ${V.entityType} = ${r} THEN ${i}`);return E`CASE ${E.join(n,E` `)} ELSE 1.0 END`}async searchWithAttachedDb(e,t,n,r,i,a,s,l){let c=wv.FTS_ALPHA,u=E`(1.0 - vector_distance_cos(emb_e.embedding, vector32(${e})) / 2.0) * (${t})`,d=E`vector_distance_cos(emb_e.embedding, vector32(${e}))`,p='"'+a.replace(/"/g,'""')+'"',f=E`CASE WHEN (${V.entityType}, ${V.id}) IN (
|
|
84
|
+
SELECT entity_type, entity_id FROM entity_fts WHERE entity_fts MATCH ${p}
|
|
86
85
|
) THEN 1.0 ELSE 0.0 END`,m=E`(${1-c} * ${u}) + (${c} * ${f})`,g=await this.db.select({id:V.id,entityType:V.entityType,content:V.content,contentHash:V.contentHash,visibility:V.visibility,created:V.created,updated:V.updated,metadata:V.metadata,distance:d,weighted_score:m}).from(V).innerJoin(E`emb.embeddings AS emb_e`,E`${V.id} = emb_e.entity_id AND ${V.entityType} = emb_e.entity_type`).where(ve(E`${d} < ${Ype}`,...s!==void 0?[E`${m} >= ${s}`]:[],...n)).orderBy(Mn(m)).limit(r).offset(i);return l?.throwIfAborted(),this.mapSearchResults(g,a)}async searchEntities(e,t,n){let r={types:[e],limit:n?.limit??20,offset:0,sortBy:"relevance",sortDirection:"desc"};return this.search(t,r)}async projectSemanticSpace(e){if(!this.embeddingsEnabled)throw new Uc;let t=e.entities?new Set(e.entities.map(Hq)):void 0,n=e.entities?new Set(e.entities.map(({entityType:l})=>l)):e.types&&e.types.length>0?new Set(e.types):void 0,r=(await this.readEmbeddings(n?Array.from(n):void 0,e.visibilityScope,e.entities?.map(({entityId:l})=>l))).filter((l)=>!t||t.has(Hq(l))),i=e.origin,a=i?r.find((l)=>l.entityId===i.entityId&&l.entityType===i.entityType)??(n?.has(i.entityType)===!1?(await this.readEmbeddings([i.entityType],e.visibilityScope,[i.entityId]))[0]:void 0):void 0,s=r.filter((l)=>{let c=n?.has(l.entityType)??!0,u=l.entityId===i?.entityId&&l.entityType===i.entityType;return c&&!u});return Gq(s,{...a&&{origin:a},...e.maxNeighborDistance!==void 0&&{maxNeighborDistance:e.maxNeighborDistance}})}async readEmbeddings(e,t,n){let r=this.buildVisibilityConditions(t);if(e&&e.length>0)r.push(Ht(V.entityType,e));if(n!==void 0)r.push(Ht(V.id,[...n]));let i=E`emb_e.embedding`.mapWith({mapFromDriverValue(a){if(!ArrayBuffer.isView(a))throw TypeError("Expected embedding blob to be an ArrayBuffer view");let s=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(s.byteLength%Float32Array.BYTES_PER_ELEMENT!==0)throw RangeError("Embedding blob byte length must be divisible by 4");let l=new Uint8Array(s.byteLength);return l.set(s),new Float32Array(l.buffer)}});return this.db.select({entityId:V.id,entityType:V.entityType,embedding:i}).from(V).innerJoin(E`emb.embeddings AS emb_e`,E`${V.id} = emb_e.entity_id AND ${V.entityType} = emb_e.entity_type`).where(r.length>0?ve(...r):void 0).orderBy(Dt(V.entityType),Dt(V.id))}async nearestToEntity(e){if(!this.embeddingsEnabled)throw new Uc;let[t]=await this.readEmbeddings([e.origin.entityType],e.visibilityScope,[e.origin.entityId]);if(!t||e.types.length===0)return[];let n=JSON.stringify(Array.from(t.embedding)),r=E`vector_distance_cos(emb_e.embedding, vector32(${n}))`,i=this.db.select({entityId:V.id,entityType:V.entityType,distance:r,metadata:V.metadata}).from(V).innerJoin(E`emb.embeddings AS emb_e`,E`${V.id} = emb_e.entity_id AND ${V.entityType} = emb_e.entity_type`).where(ve(...this.buildVisibilityConditions(e.visibilityScope),Ht(V.entityType,e.types),e.publishedOnly?SE(this.publishGates()):void 0,E`NOT (${V.id} = ${e.origin.entityId} AND ${V.entityType} = ${e.origin.entityType})`,e.maxDistance!==void 0?E`${r} <= ${e.maxDistance}`:void 0)).orderBy(E`${r} ASC`);return(e.limit!==void 0?await i.limit(e.limit):await i).map(({metadata:s,...l})=>e.includeMetadata?{...l,metadata:s}:l)}async searchWithDistances(e,t={}){if(!this.embeddingsEnabled)throw new Uc;let n=Vq(e,this.logger),{embedding:r}=await this.embeddingService.generateEmbedding(n),i=JSON.stringify(Array.from(r)),a=E`vector_distance_cos(emb_e.embedding, vector32(${i}))`;return await this.db.select({entityId:V.id,entityType:V.entityType,distance:a}).from(V).innerJoin(E`emb.embeddings AS emb_e`,E`${V.id} = emb_e.entity_id AND ${V.entityType} = emb_e.entity_type`).where(ve(t.types&&t.types.length>0?Ht(V.entityType,t.types):void 0,t.maxDistance!==void 0?E`${a} <= ${t.maxDistance}`:void 0)).orderBy(E`${a} ASC`)}mapSearchResults(e,t){let n=[];for(let i of e)try{let a=eme.parse(i.metadata),s=this.serializer.reconstructEntity({id:i.id,entityType:i.entityType,content:i.content,contentHash:i.contentHash,visibility:i.visibility,created:i.created,updated:i.updated,metadata:a});n.push({entity:s,score:i.weighted_score,excerpt:this.createExcerpt(i.content,t)})}catch(a){this.logger.error(`Failed to parse entity during search: ${a}`)}let r=t.length>50?t.substring(0,50)+"...":t;return this.logger.debug(`Found ${n.length} results for query "${r}"`),n}createExcerpt(e,t){let n=Nf(e),r=200,i=t.toLowerCase(),s=n.toLowerCase().indexOf(i);if(s!==-1){let l=Math.max(0,s-50),c=Math.min(n.length,s+i.length+50),u=n.slice(l,c);if(l>0)u="..."+u;if(c<n.length)u=u+"...";return u}return n.slice(0,200)+(n.length>200?"...":"")}}function Hq(e){return`${e.entityType}:${e.entityId}`}var wE=o.record(o.string(),o.unknown()),Kq=new Set(["id","entityType","content","contentHash","created","updated","visibility"]);function Qq(e,t,n,r="reject"){if(n.length===0)return t;let i={...t};for(let a of n){let s=Object.keys(a.shape),l=Object.fromEntries(s.filter((u)=>Object.hasOwn(e,u)).map((u)=>[u,e[u]])),c=a.safeParse(l);if(!c.success&&r==="reject")throw c.error;for(let u of s)if(delete i[u],c.success&&Object.hasOwn(e,u)&&c.data[u]!==void 0&&!Kq.has(u))i[u]=c.data[u]}return i}function Tv(e,t,n,r,i=[],a=[]){if(!n)return t;let s=new Set(a.filter((y)=>!y.includes("."))),l=Sl(e),c=Sl(t),u=wE.parse(l.data),d=wE.parse(c.data),p=new Set([...r.flatMap((y)=>Object.keys(y.shape)),...i]),f=Object.entries(u).filter(([y,w])=>!Kq.has(y)&&!s.has(y)&&(!Object.hasOwn(n.shape,y)||p.has(y))&&(!Object.hasOwn(d,y)||JSON.stringify(d[y])!==JSON.stringify(w))),m=[...[...p].filter((y)=>!Object.hasOwn(u,y)&&Object.hasOwn(d,y)),...[...s].filter((y)=>Object.hasOwn(d,y))],g={...d};for(let y of m)delete g[y];for(let[y,w]of f)g[y]=w;let h=_v(g,a)??g;if(f.length===0&&m.length===0&&h===g)return t;return Object.keys(h).length>0?vs(h,c.content):c.content}function kl(e){return[...e.retiredFields??[],...e.translatedFields??[]]}function tme(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function _v(e,t){let n=t.reduce((r,i)=>{let[a,s]=i.split(".",2);if(a===void 0||!Object.hasOwn(r,a))return r;if(s===void 0){let{[a]:d,...p}=r;return p}let l=r[a];if(!tme(l)||!Object.hasOwn(l,s))return r;let{[s]:c,...u}=l;return{...r,[a]:u}},e);return n===e?void 0:n}function ep(e,t){if(t.length===0)return e;let n=Sl(e),r=wE.safeParse(n.data);if(!r.success)return e;let i=_v(r.data,t);if(!i)return e;return Object.keys(i).length>0?vs(i,n.content):n.content}class TE{entityRegistry;logger;constructor(e,t){this.entityRegistry=e,this.logger=t.child("EntitySerializer")}serializeEntity(e){let t=this.entityRegistry.getAdapter(e.entityType);return Tv(e.content,qd(t.toMarkdown(e),e.visibility),this.entityRegistry.getEntityTypeConfig(e.entityType).binaryStorage==="asset"?void 0:t.frontmatterSchema,this.entityRegistry.getFrontmatterExtensions(e.entityType),this.entityRegistry.getGroupings().filter((n)=>n.types.includes(e.entityType)).map((n)=>n.field),kl(this.entityRegistry.getEntityTypeConfig(e.entityType)))}deserializeEntity(e,t){let n=this.entityRegistry.getAdapter(t),r=ep(e,this.retiredFields(t)),i;try{i=n.fromMarkdown(r)}catch(d){throw $d(t,d)??d}let{metadata:a,visibility:s,...l}=i,c=Jb(e),u=this.stripPolicyMetadata(this.entityRegistry.projectMetadata(t,r,a??{}),t);return{...l,...c&&{visibility:c},metadata:u}}async convertToEntity(e){try{return this.reconstructEntity(e)}catch(t){let n=$e(t);return this.logger.error(`Failed to parse entity of type ${e.entityType} with ID ${e.id}: ${n}`),null}}async convertToEntities(e,t){let n=[];for(let r of e)try{n.push(this.reconstructEntity(r))}catch(i){let a=$e(i);this.logger.error(`Failed to parse entity of type ${t} with ID ${r.id}: ${a}`)}return n}reconstructEntity(e){let t=this.entityRegistry.getAdapter(e.entityType),n=t.fromMarkdown(ep(e.content,this.retiredFields(e.entityType))),{metadata:r,visibility:i,...a}=n,s={id:e.id,entityType:e.entityType,content:e.content,contentHash:e.contentHash,created:new Date(e.created).toISOString(),updated:new Date(e.updated).toISOString(),visibility:e.visibility,...a,...this.stripPolicyMetadata(e.metadata,e.entityType),metadata:this.stripPolicyMetadata(e.metadata,e.entityType)};return t.schema.parse(s)}prepareEntityForStorage(e,t){let n=this.entityRegistry.getAdapter(t),r=this.serializeEntity(e),i=this.stripPolicyMetadata(this.entityRegistry.projectMetadata(t,r,n.extractMetadata(e)),t);return{markdown:r,metadata:i}}withoutRetiredFields(e){let t=ep(e.content,this.retiredFields(e.entityType));return t===e.content?e:{...e,content:t}}stripPolicyMetadata(e,t){let{visibility:n,...r}=e,i=kl(this.entityRegistry.getEntityTypeConfig(t));return _v(r,i)??r}retiredFields(e){return this.entityRegistry.getEntityTypeConfig(e).retiredFields??[]}}async function Iv(e,t,n,r){await e.run(E`INSERT OR IGNORE INTO entity_fts_rowids (entity_type, entity_id) VALUES (${t}, ${n})`),await e.run(E`INSERT INTO entity_fts (rowid, entity_id, entity_type, content)
|
|
87
86
|
SELECT fts_rowid, ${n}, ${t}, ${r}
|
|
88
87
|
FROM entity_fts_rowids
|
|
@@ -354,5 +353,5 @@ Result:`);if(n===-1)return;let r=e.slice(n+9).trim();if(!r)return;try{return JSO
|
|
|
354
353
|
`)}function kqe(e){return e.split(`
|
|
355
354
|
`).flatMap((t)=>{let n=t.match(Cqe);if(!n)return[];let r=(n[3]??"").split(",").map((i)=>i.trim()).filter(Boolean);return[{name:n[1]??"",description:n[2]??"",tags:r}]})}var DX=new Bl(Xw,{title:"Agent",mappings:[{key:"about",label:"About",type:"string"},{key:"skills",label:"Skills",type:"custom",formatter:Eqe,parser:kqe},{key:"notes",label:"Notes",type:"string"}]});function Rqe(e){return DX.format(e)}function Aqe(e){if(!e.trim())return Xw.parse({});try{return DX.parse(e)}catch{return Xw.parse({})}}import{EventEmitter as LX}from"events";var Dn={REGISTERED:"registered",INITIALIZED:"initialized",ERROR:"error",DISABLED:"disabled"},Oi={REGISTERED:"plugin:registered",BEFORE_INITIALIZE:"plugin:before_initialize",INITIALIZED:"plugin:initialized",ERROR:"plugin:error",DISABLED:"plugin:disabled"};class Mi extends Error{pluginId;constructor(e,t){super(`Plugin ${e}: ${t}`);this.name="PluginError",this.pluginId=e}}function NX(e,t){return Reflect.get(e,t,e)}function zX(e,t,n){if(typeof e!=="function")throw TypeError("Cannot apply a non-callable trapped member");return Reflect.apply(e,t,n)}class cj{scope;ingress=new Set;closePromise=null;closed=!1;constructor(){this.scope=ge.runSync(en.make())}assertOpen(){if(this.closed)throw Error("Cannot register a resource after plugin teardown")}acquire(e,t){this.assertOpen();let n=e();try{this.addFinalizer(()=>t(n))}catch(r){try{t(n)}catch(i){throw AggregateError([r,i],"Plugin acquisition rollback failed",{cause:i})}throw r}return n}addFinalizer(e){this.assertOpen(),ge.runSync(en.addFinalizer(this.scope,ge.promise(async()=>{await e()})))}addIngress(e){this.assertOpen(),this.ingress.add(e)}close(e=Yt.void){return this.closed=!0,this.closePromise??=this.closeScope(e),this.closePromise}async closeScope(e){let t,n=!1,r=[...this.ingress].reverse();for(let l of r)try{l.stopAdmission()}catch(c){if(!n)t=c;n=!0}let i=await Promise.allSettled(r.map((l)=>Promise.resolve().then(()=>l.drain())));this.ingress.clear();let a=i.find((l)=>l.status==="rejected");if(!n&&a)t=a.reason,n=!0;let s=await ge.runPromiseExit(en.close(this.scope,e));if(!n&&Yt.isFailure(s))t=br.squash(s.cause),n=!0;if(n)throw t}}function Xh(e,t,n,r){return new Proxy(e,{get(i,a){let s=NX(i,a);if(typeof a==="string"&&t.some((l)=>l===a)&&typeof s==="function")return(...l)=>n.acquire(()=>zX(s,i,l),(c)=>r(l,c));return typeof s==="function"?s.bind(i):s}})}function Yh(e,t,n){return Xh(e,t,n,(r)=>{let i=r[0];if(typeof i==="string")e.unregisterPlugin(i)})}function FX(e,t){let n=e.getMessageBus(),r=new Set,i=(v,R,z)=>{t.assertOpen();let B=!0,x=new Set,L=z((N)=>{if(!B)return{noop:!0};let Q,ae=new Promise((be)=>{Q=be});x.add(ae);let J=()=>{x.delete(ae),Q()},oe;try{oe=Promise.resolve(R(N))}catch(be){throw J(),be}return oe.then((be)=>(J(),be),(be)=>{throw J(),be})}),k={type:v,originalHandler:R,stopAdmission:()=>{if(!B)return;B=!1,L(),r.delete(k)}};r.add(k);try{t.addIngress({stopAdmission:k.stopAdmission,drain:async()=>{await Promise.all(x)}})}catch(N){throw k.stopAdmission(),N}return k.stopAdmission},a={send:(v)=>n.send(v),hasHandlers:(v)=>n.hasHandlers?.(v)??!1,subscribe:(v,R,z)=>i(v,R,(B)=>n.subscribe(v,B,z)),observe:(v,R)=>i(v,R,(z)=>n.observe(v,z)),deliverPeer:(v,R)=>n.deliverPeer(v,R),unsubscribe:(v,R)=>{let z=[...r].filter((B)=>B.type===v&&B.originalHandler===R);if(z.length===0){n.unsubscribe(v,R);return}for(let B of z)B.stopAdmission()},collect:(v)=>n.collect(v),validateMessage:(v,R)=>n.validateMessage(v,R),getHandlerCount:(v)=>n.getHandlerCount(v),getTargetedHandlerCount:(v,R)=>n.getTargetedHandlerCount(v,R),clearHandlers:(v)=>n.clearHandlers(v),clearAllHandlers:()=>n.clearAllHandlers()},s=e.getAttachmentRegistry(),l={...s,register:(v,R,z)=>t.acquire(()=>s.register(v,R,z),(B)=>B())},c=e.getEntityRegistry(),u=Xh(c,["registerEntityType"],t,(v)=>{let R=v[0];if(typeof R==="string")c.unregisterEntityType(R)}),d=Yh(e.getProfileKindRegistry(),["register"],t),p=Yh(e.getChannelRegistry(),["registerDescriptor","registerDeliveryProvider"],t),f=Yh(e.getInboxRegistry(),["registerSource"],t),m=Yh(e.getInboxFollowUpRegistry(),["registerKind"],t),g=e.getAccountSettingsRegistry(),h=Xh(g,["register"],t,(v,R)=>{zX(g.unregister,g,[R])}),y=Yh(e.getOperationalHealthRegistry(),["register"],t),w=e.getDataSourceRegistry(),_=Xh(w,["register"],t,(v)=>{let R=v[0];if(typeof R==="object"&&R!==null&&"id"in R&&typeof R.id==="string"){let z=R.id.includes(":")?R.id:`shell:${R.id}`;w.unregister(z)}}),b=e.getAnalyticsRegistry(),S=Xh(b,["register"],t,(v)=>{let R=v[0];if(typeof R==="object"&&R!==null&&"type"in R&&typeof R.type==="string")b.unregister(R.type)}),A=new Proxy(e,{get(v,R){if(R==="getMessageBus")return()=>a;if(R==="getAttachmentRegistry")return()=>l;if(R==="getEntityRegistry")return()=>u;if(R==="getDataSourceRegistry")return()=>_;if(R==="getProfileKindRegistry")return()=>d;if(R==="getChannelRegistry")return()=>p;if(R==="getInboxRegistry")return()=>f;if(R==="getInboxFollowUpRegistry")return()=>m;if(R==="getOperationalHealthRegistry")return()=>y;if(R==="getAccountSettingsRegistry")return()=>h;if(R==="getAnalyticsRegistry")return()=>S;let z=NX(v,R);return typeof z==="function"?z.bind(v):z}});return ZW(e,A),A}class uj{plugins;events;daemonRegistry;logger;projectionRegistry;resourceScopes=new Map;releasePromises=new Map;constructor(e,t,n,r,i){this.plugins=e,this.events=t,this.daemonRegistry=n,this.projectionRegistry=r,this.logger=i.child("PluginLifecycle")}async initializePlugin(e,t,n){let r=this.plugins.get(e);if(!r)throw new Mi(e,"Registration failed: Plugin is not registered");let i=r.plugin,a=new cj;a.addFinalizer(()=>t.unregisterPluginCapabilities?.(e)),a.addFinalizer(()=>t.getJobQueueService().unregisterPluginHandlers(e)),a.addFinalizer(()=>this.projectionRegistry.unregisterPlugin(e)),this.resourceScopes.set(e,a),this.releasePromises.delete(e),this.logger.debug(`Initializing plugin: ${e}`);try{this.events.emit(Oi.BEFORE_INITIALIZE,e,i);let s=await i.register(FX(t,a),n);return r.status=Dn.INITIALIZED,this.logger.debug(`Initialized plugin: ${e}`),this.events.emit(Oi.INITIALIZED,e,i),s}catch(s){throw this.logger.error(`Error initializing plugin ${e}: ${$e(s)}`),await this.failPluginInitialization(e,s),s}}async finalizePluginRegistration(e){let t=this.plugins.get(e);if(!t)throw new Mi(e,"Registration finalization failed: Plugin is not registered");if(t.status!==Dn.INITIALIZED)return;try{await t.plugin.finalizeRegistration?.(),this.logger.debug(`Registration finalized for plugin: ${e}`)}catch(n){throw await this.failPluginInitialization(e,n),n}}async readyPlugin(e){let t=this.plugins.get(e);if(!t)throw new Mi(e,"Ready failed: Plugin is not registered");if(t.status!==Dn.INITIALIZED){this.logger.debug(`Skipping ready hook for non-initialized plugin: ${e}`);return}try{await t.plugin.ready?.(),this.logger.debug(`Ready hook completed for plugin: ${e}`)}catch(n){let r=xp(n);t.status=Dn.ERROR,t.error=r;try{this.events.emit(Oi.ERROR,e,r)}catch(i){this.logger.error(`Plugin error listener failed for ${e}`,i)}throw r}}async startPluginDaemons(e){let t=this.plugins.get(e);if(t?.status!==Dn.INITIALIZED)return;try{await this.daemonRegistry.startPlugin(e),this.logger.debug(`Started daemons for plugin: ${e}`)}catch(n){if(t.plugin.requiresDaemonStartup?.())throw n;this.logger.warn(`Daemon ${e} failed to start: ${$e(n)}`)}}async failPluginInitialization(e,t){let n=this.plugins.get(e);if(!n)return;let r=n.status!==Dn.ERROR,i=xp(t);if(n.status=Dn.ERROR,n.error=i,await this.releasePluginResources(e,Yt.fail(t)),r)try{this.events.emit(Oi.ERROR,e,i)}catch(a){this.logger.error(`Plugin error listener failed for ${e}`,a)}}async disablePlugin(e){let t=this.plugins.get(e);if(!t){this.logger.warn(`Cannot disable plugin ${e}: not registered`);return}if(t.status===Dn.DISABLED)return;this.logger.debug(`Disabling plugin: ${e}`);let n=t.status===Dn.ERROR;await this.releasePluginResources(e,Yt.void);let r=this.plugins.get(e);if(!n&&r&&r.status!==Dn.DISABLED)r.status=Dn.DISABLED,this.events.emit(Oi.DISABLED,e,r.plugin);this.logger.debug(`Disabled plugin: ${e}`)}releasePluginResources(e,t){let n=this.releasePromises.get(e);if(n)return n;let r=this.releasePluginResourcesOnce(e,t);return this.releasePromises.set(e,r),r}async releasePluginResourcesOnce(e,t){let n=this.plugins.get(e);if(!n)return;try{await this.daemonRegistry.stopPlugin(e),this.logger.debug(`Stopped daemons for plugin: ${e}`)}catch(i){this.logger.error(`Failed to stop daemons for plugin: ${e}`,i)}let r=this.resourceScopes.get(e);if(this.resourceScopes.delete(e),r)try{await r.close(t)}catch(i){this.logger.error(`Failed to close resources for plugin ${e}`,i)}if(n.plugin.shutdown)try{await n.plugin.shutdown(),this.logger.debug(`Shutdown completed for plugin: ${e}`)}catch(i){this.logger.error(`Plugin shutdown failed for ${e}:`,i)}for(let i of this.daemonRegistry.getByPlugin(e))try{await this.daemonRegistry.unregister(i.name)}catch(a){this.logger.error(`Failed to unregister daemon ${i.name} for plugin ${e}`,a)}}}class dj{plugins;events;logger;constructor(e,t,n){this.plugins=e,this.events=t,this.logger=n.child("DependencyResolver")}async resolveInitializationOrder(e){this.logger.debug("Resolving plugin initialization order...");let t=Array.from(this.plugins.keys()),n=new Set,r=!0;while(r&&n.size<t.length){r=!1;for(let s of t){if(n.has(s))continue;if(!this.plugins.get(s))continue;if(this.getUnmetDependencies(s).length===0)try{await e(s),n.add(s),r=!0}catch(u){let d=$e(u);this.logger.error(`Failed to initialize plugin ${s}: ${d}`),n.add(s),r=!0}}}let i=t.filter((s)=>!n.has(s));if(i.length>0){let s=i.join(", ");this.logger.error(`Failed to initialize plugins due to dependency issues: ${s}`);for(let l of i){let c=this.getUnmetDependencies(l);this.logger.error(`Plugin ${l} has unmet dependencies: ${c.join(", ")}`);let u=this.plugins.get(l);if(u)u.status=Dn.ERROR,u.error=new Mi(l,`Unmet dependencies: ${c.join(", ")}`);this.events.emit(Oi.ERROR,l,u?.error)}}let a=new Set;for(let[s,l]of this.plugins)if(l.status===Dn.INITIALIZED)a.add(s);return this.logger.debug(`Resolved ${a.size} of ${t.length} plugins`),{initialized:a,failed:i}}getUnmetDependencies(e){let t=this.plugins.get(e);if(!t)return[];let{dependencies:n}=t,r=[];for(let i of n){let a=this.plugins.get(i);if(!a){r.push(i);continue}if(a.status!==Dn.INITIALIZED)r.push(i)}return r}}class pj{logger;projectionRegistry;constructor(e,t){this.logger=e.child("CapabilityRegistrar"),this.projectionRegistry=t}async registerCapabilities(e,t,n,r){if(!r?.executionOnly&&n.tools.length>0)e.registerTools(t,n.tools),this.logger.debug(`Registered ${n.tools.length} tools from ${t}`);if(!r?.executionOnly&&n.resources.length>0)e.registerResources(t,n.resources),this.logger.debug(`Registered ${n.resources.length} resources from ${t}`);if(!r?.executionOnly&&n.instructions)e.registerInstructions(t,n.instructions),this.logger.debug(`Registered instructions from ${t}`);let i=n.projectionRules??[];try{for(let a of i)this.projectionRegistry.registerRule(t,a)}catch(a){throw this.projectionRegistry.unregisterPlugin(t),a}if(i.length>0)this.logger.debug(`Registered ${i.length} projection rules from ${t}`)}}class eT{projections=new Map;rules=new Map;static createFresh(){return new eT}constructor(){}registerRule(e,t){if(!Object.isFrozen(t))throw Error(`Projection rule "${t.id}" must be created with defineProjectionRule`);let n=this.projections.get(t.id);if(n)throw Error(`Projection "${t.id}" is already registered by "${n.pluginId}"`);let r={id:t.id,pluginId:e,targetType:t.targetType,sources:t.sources.map((a)=>({kind:a.kind,types:[...a.types],...a.excludeTypes?{excludeTypes:[...a.excludeTypes]}:{}}))};this.projections.set(t.id,r),this.rules.set(t.id,t);let i=!0;return()=>{if(!i)return;if(i=!1,this.rules.get(t.id)===t)this.rules.delete(t.id);if(this.projections.get(t.id)===r)this.projections.delete(t.id)}}unregisterPlugin(e){for(let[t,n]of this.projections)if(n.pluginId===e)this.projections.delete(t),this.rules.delete(t)}list(){return Array.from(this.projections.values()).sort((e,t)=>e.id.localeCompare(t.id)).map(Mqe)}listRules(){return[...this.rules.values()].sort((e,t)=>e.id.localeCompare(t.id))}validate(e){let t=this.list(),n=new Set(e.map(({type:s})=>s));for(let s of t)if(!n.has(s.targetType))throw Error(`Projection "${s.id}" targets unregistered entity type "${s.targetType}"`);let r=e.filter(({projectionSource:s})=>s).map(({type:s})=>s).sort(),i=jqe(t,r),a=Nqe(t,i)[0];if(a){let s=zqe(a,i);throw Error(`Projection cycle is not supported: ${[...s,s[0]].join(" -> ")}`)}return Oqe({projections:t,edges:i,unknownSourceTypes:Pqe(t,n)})}}function Pqe(e,t){let n=[];for(let r of e){let i=[...new Set(r.sources.flatMap((a)=>[...a.types,...a.excludeTypes??[]]).filter((a)=>a!=="*"&&!t.has(a)))].sort();if(i.length>0)n.push({projectionId:r.id,types:i})}return n}function Oqe(e){for(let t of e.projections){for(let n of t.sources){if(Object.freeze(n.types),n.excludeTypes)Object.freeze(n.excludeTypes);Object.freeze(n)}Object.freeze(t.sources),Object.freeze(t)}for(let t of e.edges)Object.freeze(t.causes),Object.freeze(t);for(let t of e.unknownSourceTypes)Object.freeze(t.types),Object.freeze(t);return Object.freeze(e.unknownSourceTypes),Object.freeze(e.projections),Object.freeze(e.edges),Object.freeze(e)}function Mqe(e){return{...e,sources:e.sources.map((t)=>({...t,types:[...t.types],...t.excludeTypes?{excludeTypes:[...t.excludeTypes]}:{}}))}}function jqe(e,t){let n=new Map;for(let r of e)for(let i of e){let a=Dqe(r,i,t);if(a.length===0)continue;n.set(`${r.id}\x00${i.id}`,new Set(a))}return Array.from(n,([r,i])=>{let[a="",s=""]=r.split("\x00");return{from:a,to:s,causes:[...i].sort()}}).sort((r,i)=>r.from.localeCompare(i.from)||r.to.localeCompare(i.to))}function Dqe(e,t,n){let r=[];for(let i of t.sources){let a=new Set(i.excludeTypes??[]);if((i.types.includes("*")?[...i.types.filter((l)=>l!=="*"),...n]:i.types).includes(e.targetType)&&!a.has(e.targetType))r.push(`entity:${e.targetType}`)}return[...new Set(r)]}function Nqe(e,t){let n=e.map(({id:p})=>p).sort(),r=BX(n,t),i=new Map,a=new Map,s=[],l=new Set,c=[],u=0,d=(p)=>{i.set(p,u),a.set(p,u),u++,s.push(p),l.add(p);for(let h of r.get(p)??[])if(!i.has(h))d(h),a.set(p,Math.min(a.get(p)??0,a.get(h)??0));else if(l.has(h))a.set(p,Math.min(a.get(p)??0,i.get(h)??0));if(a.get(p)!==i.get(p))return;let f=[],m;do{if(m=s.pop(),!m)break;l.delete(m),f.push(m)}while(m!==p);let g=r.get(p)?.includes(p)??!1;if(f.length>1||g)c.push(f.sort())};for(let p of n)if(!i.has(p))d(p);return c.sort((p,f)=>(p[0]??"").localeCompare(f[0]??""))}function zqe(e,t){let n=new Set(e),r=BX(e,t),i=[...e].sort()[0];if(!i)return[];if(r.get(i)?.includes(i))return[i];let a=(s,l)=>{for(let c of r.get(s)??[]){if(!n.has(c))continue;if(c===i)return l;if(l.includes(c))continue;let u=a(c,[...l,c]);if(u)return u}return};return a(i,[i])??[...e].sort()}function BX(e,t){let n=new Map;for(let r of e)n.set(r,[]);for(let r of t){let i=n.get(r.from);if(i&&!i.includes(r.to))i.push(r.to)}for(let r of n.values())r.sort();return n}class tT{plugins=new Map;logger;events=new LX;daemonRegistry;shell=null;initializedPluginIds=[];pluginLifecycle;dependencyResolver;capabilityRegistrar;projectionRegistry=eT.createFresh();projectionGraph;static createFresh(e,t){return new tT(e,t)}setShell(e){this.shell=e}constructor(e,t){this.logger=e.child("PluginManager"),this.events=new LX,this.daemonRegistry=t,this.pluginLifecycle=new uj(this.plugins,this.events,this.daemonRegistry,this.projectionRegistry,e),this.dependencyResolver=new dj(this.plugins,this.events,e),this.capabilityRegistrar=new pj(e,this.projectionRegistry)}registerPlugin(e){if(!e.id)throw new Mi("unknown","Registration failed: Plugin must have an id");if(this.logger.debug(`Registering plugin: ${e.id} (${e.version})`),this.plugins.has(e.id)){let i=this.plugins.get(e.id)?.plugin.version;throw new Mi(e.id,`Registration failed: Plugin is already registered with version ${i}`)}let t=e.dependencies??[],n={plugin:e,status:Dn.REGISTERED,dependencies:t};this.plugins.set(e.id,n),this.logger.debug(`Registered plugin: ${e.id} (${e.version})`),this.events.emit(Oi.REGISTERED,e.id,e)}async initializePlugins(e){this.logger.debug("Initializing plugins..."),this.initializedPluginIds=[];let t=await this.dependencyResolver.resolveInitializationOrder(async(n)=>{await this.initializePlugin(n,e)});this.logger.debug(`Initialized ${t.initialized.size} of ${this.plugins.size} plugins`)}async registerInterfaceChannels(e,t){let n=this.shell;if(!n)throw Error("Cannot register interface channels: Shell not set. Call setShell() first.");for(let r of e)try{await r.registerChannelsForExecution?.(n,t)}catch(i){this.logger.error(`Channel registration failed for interface ${r.id}: ${$e(i)}`)}}async initializePlugin(e,t){if(!this.shell)throw new Mi(e,"Cannot initialize plugin: Shell not set. Call setShell() first.");let n=this.shell;try{let r=await this.pluginLifecycle.initializePlugin(e,n,t);await this.capabilityRegistrar.registerCapabilities(n,e,r,{executionOnly:t?.executionOnly}),this.initializedPluginIds.push(e)}catch(r){throw await this.pluginLifecycle.failPluginInitialization(e,r),r}}async finalizePluginRegistrations(){this.logger.debug("Finalizing plugin registrations...");for(let n of this.initializedPluginIds)await this.pluginLifecycle.finalizePluginRegistration(n);if(!this.shell)throw Error("Cannot validate projections before the shell is set");let e=this.shell.getEntityRegistry(),t=this.projectionRegistry.validate(e.getAllEntityTypes().map((n)=>{let r=e.getEntityTypeConfig(n);return{type:n,projectionSource:r.projectionSource!==!1&&r.projectionSourceRole!=="excluded"}}));this.projectionGraph=t;for(let n of t.unknownSourceTypes)this.logger.warn("Projection declares entity source types no installed plugin registers",{projectionId:n.projectionId,types:n.types});this.logger.debug("Validated projection graph",{projections:t.projections.length,edges:t.edges.length})}getProjectionGraphSnapshot(){if(!this.projectionGraph)throw Error("Projection graph has not been finalized");return this.projectionGraph}getProjectionRulesSnapshot(){if(!this.projectionGraph)throw Error("Projection graph has not been finalized");return Object.freeze(this.projectionRegistry.listRules())}async readyPlugins(){this.logger.debug("Dispatching plugin ready hooks...");try{await gC(this.initializedPluginIds.map((e)=>()=>this.pluginLifecycle.readyPlugin(e)))}catch(e){for(let t of this.initializedPluginIds){let n=this.plugins.get(t);if(n?.status===Dn.ERROR)await this.pluginLifecycle.failPluginInitialization(t,n.error??e)}throw e}}async startPluginDaemons(){this.logger.debug("Starting plugin daemons..."),await gC(this.initializedPluginIds.map((e)=>()=>this.pluginLifecycle.startPluginDaemons(e)))}getPlugin(e){return this.plugins.get(e)?.plugin}getPluginStatus(e){return this.plugins.get(e)?.status}hasPlugin(e){return this.plugins.has(e)}isPluginInitialized(e){return this.plugins.get(e)?.status===Dn.INITIALIZED}getAllPluginIds(){return Array.from(this.plugins.keys())}getAllPlugins(){return new Map(this.plugins)}getFailedPlugins(){return Array.from(this.plugins.entries()).filter((e)=>e[1].status===Dn.ERROR&&e[1].error!==void 0).map(([e,t])=>({id:e,error:t.error}))}getPluginPackageName(e){return this.plugins.get(e)?.plugin.packageName}async disablePlugin(e){await this.pluginLifecycle.disablePlugin(e)}async shutdownPlugins(){let e=new Set;for(let t of[...this.initializedPluginIds].reverse())await this.disablePlugin(t),e.add(t);for(let t of[...this.plugins.keys()].reverse())if(!e.has(t))await this.disablePlugin(t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}getEventEmitter(){return this.events}}var qX={public:0,trusted:1,admin:2},Fqe=new Set(["/chat","/cms","/admin","/account"]),Bqe=[{id:"dashboard",pluginId:"dashboard",label:"Dashboard",visibility:"public",requiresActiveSession:!1},{id:"web-chat",pluginId:"web-chat",label:"Chat",visibility:"trusted",requiresActiveSession:!0},{id:"studio",pluginId:"studio",label:"Studio",visibility:"public",requiresActiveSession:!0}];function Lqe(e,t){let n=qX[t.permissionLevel??"public"],r=[];for(let{id:i,pluginId:a,label:s,visibility:l,requiresActiveSession:c}of Bqe){let u=t.self?.id===i;if(!u&&(n<qX[l]||c&&t.hasActiveSession!==!0))continue;let d=e.filter((m)=>m.pluginId===a&&!(i==="studio"&&Fqe.has(m.fullPath))).map((m)=>m.fullPath).sort((m,g)=>m.length-g.length),p=i==="web-chat"&&d.length>0?e.find((m)=>m.pluginId==="studio"&&m.fullPath==="/chat")?.fullPath:void 0,f=u?t.self?.href:p??d[0];if(f!==void 0)r.push({id:i,label:s,href:f,isActive:i===t.activeId,...c?{requiresActiveSession:!0}:{}})}return r}class $X{definitions=new Map;register(e){this.definitions.set(e.type,e)}unregister(e){this.definitions.delete(e)}getDefinitions(){return Array.from(this.definitions.values())}async run(e){let t=this.definitions.get(e.type);if(!t)throw Error(`Unknown analytics report: ${e.type}. Available: ${Array.from(this.definitions.keys()).join(", ")}`);let n=t.minVisibility??"public";if(!ia.hasPermission(e.permission,n))throw Error(`The ${t.type} report answers ${n} callers only`);let r=t.params.safeParse(e.params??{});if(!r.success){let s=r.error.issues.map((l)=>`${l.path.join(".")||"params"}: ${l.message}`).join("; ");throw Error(`Invalid params for ${t.type}: ${s}`)}let i=vi(e.permission),a=i==="public"?vg(e.entityService,{publishedOnly:!0,visibilityScope:i}):e.entityService;return t.handler(r.data,{entityService:a,visibilityScope:i})}}function qqe(e){return e}export{Zd as oa,Yb as pa,E as qa,Vd as ra,H as sa,_l as ta,ve as ua,Er as va,Ti as wa,CL as xa,po as ya,Ht as za,kr as Aa,xs as Ba,Hc as Ca,Vf as Da,Dt as Ea,Mn as Fa,BL as Ga,LL as Ha,Cl as Ia,at as Ja,Te as Ka,un as La,tn as Ma,JC as Na,mo as Oa,V as Pa,vv as Qa,mE as Ra,ta as Sa,na as Ta,Lq as Ua,Lpe as Va,qpe as Wa,ur as Xa,El as Ya,Vn as Za,$n as _a,Wo as $a,ws as ab,Kt as bb,Ci as cb,qq as db,nn as eb,ZX as fb,hj as gb,j as hb,Et as ib,Zn as jb,ns as kb,xo as lb,Bi as mb,yj as nb,Zqe as ob,Gqe as pb,Wqe as qb,ly as rb,oc as sb,uT as tb,vj as ub,Qqe as vb,WX as wb,Yqe as xb,el as yb,xj as zb,Xqe as Ab,e$e as Bb,t$e as Cb,n$e as Db,r$e as Eb,o$e as Fb,JX as Gb,Qe as Hb,tl as Ib,i$e as Jb,Sn as Kb,jt as Lb,fn as Mb,nl as Nb,rl as Ob,_r as Pb,gT as Qb,Li as Rb,xn as Sb,gn as Tb,d$e as Ub,ree as Vb,Rm as Wb,Wu as Xb,tr as Yb,ST as Zb,h$e as _b,see as $b,Am as ac,no as bc,ya as cc,S$e as dc,cee as ec,ba as fc,No as gc,zr as hc,rn as ic,$i as jc,TT as kc,kn as lc,Zr as mc,Ui as nc,wt as oc,CT as pc,ET as qc,wa as rc,qj as sc,hy as tc,ll as uc,U$e as vc,Fm as wc,Z$e as xc,G$e as yc,eD as zc,wy as Ac,DT as Bc,tD as Cc,it as Dc,gt as Ec,_y as Fc,Lt as Gc,Fr as Hc,Ree as Ic,FT as Jc,BT as Kc,LT as Lc,Fee as Mc,Lee as Nc,hc as Oc,cl as Pc,qee as Qc,Ta as Rc,Wee as Sc,nte as Tc,Gr as Uc,To as Vc,cs as Wc,Oy as Xc,Wr as Yc,Ia as Zc,oo as _c,qm as $c,id as ad,Ca as bd,Gn as cd,ad as dd,Ut as ed,Jr as fd,AT as gd,yy as hd,_t as id,Tt as jd,vte as kd,cD as ld,Ot as md,ci as nd,uD as od,_a as pd,Iy as qd,UT as rd,pD as sd,Cy as td,K$e as ud,eUe as vd,Ey as wd,nUe as xd,rUe as yd,aUe as zd,Bn as Ad,sUe as Bd,lUe as Cd,cUe as Dd,uUe as Ed,hD as Fd,dUe as Gd,pUe as Hd,mUe as Id,fUe as Jd,gUe as Kd,Bm as Ld,hUe as Md,yUe as Nd,bUe as Od,vUe as Pd,SUe as Qd,Wn as Rd,RUe as Sd,gne as Td,AUe as Ud,hne as Vd,Ir as Wd,sd as Xd,Um as Yd,bc as Zd,ui as _d,vne as $d,Zi as ae,PUe as be,OUe as ce,Zy as de,jUe as ee,DUe as fe,Gy as ge,Wy as he,BUe as ie,One as je,LUe as ke,Sc as le,$Ue as me,ul as ne,Ic as oe,dd as pe,Ae as qe,yt as re,bt as se,nf as te,Rt as ue,Vr as ve,Hr as we,sb as xe,Ea as ye,He as ze,_o as Ae,lb as Be,Lo as Ce,n2e as De,ds as Ee,vd as Fe,Sd as Ge,lf as He,hl as Ie,wd as Je,sI as Ke,e1 as Le,yl as Me,gs as Ne,vre as Oe,r2e as Pe,o2e as Qe,xre as Re,i2e as Se,U1 as Te,di as Ue,Fre as Ve,Hoe as We,Koe as Xe,Qoe as Ye,jI as Ze,nie as _e,oie as $e,iie as af,aie as bf,hf as cf,sie as df,yf as ef,cie as ff,die as gf,mie as hf,gie as if,hie as jf,bie as kf,Sie as lf,DI as mf,Iie as nf,Hi as of,Mie as pf,AF as qf,br as rf,Uie as sf,Nc as tf,Bre as uf,xI as vf,wI as wf,Lre as xf,qre as yf,$re as zf,Ure as Af,Rc as Bf,mf as Cf,Wre as Df,Xre as Ef,Yt as Ff,u2e as Gf,Ac as Hf,d2e as If,Id as Jf,p2e as Kf,m2e as Lf,Pc as Mf,f2e as Nf,g2e as Of,TI as Pf,loe as Qf,_I as Rf,_d as Sf,coe as Tf,uoe as Uf,doe as Vf,ff as Wf,Cb as Xf,poe as Yf,en as Zf,Ed as _f,Oc as $f,gf as ag,OI as bg,wF as cg,Mc as dg,woe as eg,Pb as fg,MI as gg,Toe as hg,Cd as ig,Coe as jg,Dc as kg,RF as lg,wf as mg,zc as ng,E2e as og,zF as pg,k2e as qg,Xie as rg,R2e as sg,FF as tg,jb as ug,A2e as vg,P2e as wg,O2e as xg,aae as yg,FI as zg,sae as Ag,LI as Bg,M2e as Cg,kd as Dg,uae as Eg,j2e as Fg,mae as Gg,z2e as Hg,F2e as Ig,q2e as Jg,$2e as Kg,zb as Lg,K2e as Mg,JI as Ng,Q2e as Og,Y2e as Pg,Tf as Qg,vl as Rg,Ra as Sg,Dd as Tg,zae as Ug,Gae as Vg,Jae as Wg,oB as Xg,qb as Yg,hi as Zg,ase as _g,cB as $g,Qi as ah,Ese as bh,zd as ch,Rse as dh,Ase as eh,Lc as fh,Pse as gh,Ose as hh,ys as ih,$o as jh,yi as kh,Mse as lh,XI as mh,jse as nh,Bse as oh,YI as ph,Lse as qh,qse as rh,$se as sh,xB as th,Use as uh,Zse as vh,Fd as wh,Jse as xh,bs as yh,Qse as zh,Yse as Ah,wB as Bh,TB as Ch,qc as Dh,tle as Eh,nle as Fh,rle as Gh,ile as Hh,sle as Ih,lle as Jh,ule as Kh,mle as Lh,fle as Mh,ble as Nh,vle as Oh,Sle as Ph,wle as Qh,_B as Rh,IB as Sh,Ele as Th,kle as Uh,Rle as Vh,Ale as Wh,Ple as Xh,Nle as Yh,Fle as Zh,Ble as _h,Lle as $h,$le as ai,Gle as bi,Wle as ci,Vle as di,Xle as ei,ece as fi,ice as gi,ace as hi,kf as ii,cce as ji,uce as ki,dce as li,mce as mi,fce as ni,gce as oi,hce as pi,EB as qi,vce as ri,Sce as si,xce as ti,Rf as ui,Ice as vi,Cce as wi,Rce as xi,eC as yi,Oce as zi,$c as Ai,Dce as Bi,Nce as Ci,zce as Di,kB as Ei,Lce as Fi,Zce as Gi,rue as Hi,oue as Ii,iue as Ji,aue as Ki,lue as Li,due as Mi,pue as Ni,mue as Oi,fue as Pi,Af as Qi,Pf as Ri,Sue as Si,xue as Ti,wue as Ui,_ue as Vi,Cue as Wi,kue as Xi,AB as Yi,Aue as Zi,Oue as _i,jue as $i,Nue as aj,Bue as bj,tde as cj,nde as dj,rde as ej,ode as fj,ide as gj,ade as hj,ge as ij,Of as jj,lde as kj,cde as lj,ude as mj,pde as nj,mde as oj,Uo as pj,MB as qj,Bd as rj,DB as sj,NB as tj,_Ze as uj,oC as vj,vr as wj,Aa as xj,tJe as yj,bi as zj,gC as Aj,$pe as Bj,Upe as Cj,Zpe as Dj,tg as Ej,Na as Fj,Pa as Gj,Oa as Hj,Kb as Ij,vi as Jj,Ud as Kj,Si as Lj,HB as Mj,oJe as Nj,iJe as Oj,Yi as Pj,Sr as Qj,yC as Rj,Jb as Sj,qd as Tj,co as Uj,JB as Vj,Uc as Wj,Tv as Xj,Cv as Yj,_E as Zj,IE as _j,Ev as $j,kv as ak,EE as bk,Av as ck,tp as dk,Ts as ek,og as fk,ln as gk,c6e as hk,Vo as ik,ra as jk,$E as kk,UE as lk,Eme as mk,kme as nk,VE as ok,KE as pk,Fa as qk,Zv as rk,P$ as sk,Ml as tk,O$ as uk,C8e as vk,E8e as wk,Gv as xk,U as yk,Cs as zk,C as Ak,_e as Bk,I as Ck,Br as Dk,z$ as Ek,Es as Fk,Ko as Gk,go as Hk,cg as Ik,je as Jk,rr as Kk,Ct as Lk,q$ as Mk,$$ as Nk,At as Ok,ip as Pk,ap as Qk,Dl as Rk,hU as Sk,sS as Tk,mp as Uk,Tk as Vk,_k as Wk,jk as Xk,fS as Yk,Gk as Zk,SS as _k,x2 as $k,w2 as al,xl as bl,vC as cl,_he as dl,T2 as el,wS as fl,Wk as gl,_2 as hl,Zc as il,OJe as jl,MJe as kl,jJe as ll,DJe as ml,SC as nl,xC as ol,wC as pl,rpe as ql,NJe as rl,zJe as sl,FJe as tl,BJe as ul,LJe as vl,qJe as wl,$Je as xl,UJe as yl,Vk as zl,I2 as Al,As as Bl,Sp as Cl,nct as Dl,gR as El,hR as Fl,H2 as Gl,K2 as Hl,Q2 as Il,Y2 as Jl,lye as Kl,cye as Ll,ES as Ml,dye as Nl,vp as Ol,Bl as Pl,mye as Ql,tZ as Rl,gye as Sl,oZ as Tl,yye as Ul,kS as Vl,ue as Wl,_n as Xl,Ll as Yl,ER as Zl,RR as _l,AR as $l,PR as am,Eg as bm,kg as cm,OR as dm,MR as em,Nye as fm,Vt as gm,RS as hm,AS as im,Qdt as jm,Ydt as km,zye as lm,TZ as mm,ept as nm,Gye as om,tpt as pm,npt as qm,rpt as rm,opt as sm,ipt as tm,apt as um,spt as vm,lpt as wm,cpt as xm,upt as ym,dpt as zm,Qye as Am,Yye as Bm,mpt as Cm,fpt as Dm,gpt as Em,hpt as Fm,ypt as Gm,bpt as Hm,vpt as Im,Spt as Jm,Fe as Km,dr as Lm,fu as Mm,Os as Nm,PS as Om,OS as Pm,AZ as Qm,PZ as Rm,nbe as Sm,MS as Tm,Hk as Um,Ihe as Vm,Che as Wm,Kk as Xm,Qk as Ym,Og as Zm,DS as _m,$R as $m,sbe as an,ZR as bn,FS as cn,UR as dn,GR as en,dbe as fn,VR as gn,gbe as hn,US as in,O2 as jn,TS as kn,B2 as ln,aR as mn,pR as nn,q2 as on,QS as pn,KR as qn,Mg as rn,YR as sn,txe as tn,nxe as un,rxe as vn,eA as wn,oxe as xn,ixe as yn,axe as zn,sxe as An,pSe as Bn,Ap as Cn,PJ as Dn,DJ as En,QA as Fn,ho as Gn,bx as Hn,zJ as In,eP as Jn,UJ as Kn,Hg as Ln,ZJ as Mn,Mp as Nn,GJ as On,xxe as Pn,WJ as Qn,JJ as Rn,Oxe as Sn,HJ as Tn,zxe as Un,Fxe as Vn,Bxe as Wn,Lxe as Xn,qxe as Yn,nP as Zn,Ds as _n,Vxe as $n,rP as ao,sP as bo,Kxe as co,Pr as do,wbe as eo,Tbe as fo,_be as go,Cbe as ho,yG as io,SG as jo,TG as ko,bA as lo,IG as mo,RW as no,tSe as oo,iSe as po,EG as qo,RG as ro,dA as so,uSe as to,vht as uo,dSe as vo,FW as wo,ex as xo,MA as yo,jA as zo,QW as Ao,Pp as Bo,rx as Co,ox as Do,Gg as Eo,ix as Fo,iJ as Go,Wg as Ho,ISe as Io,CSe as Jo,ESe as Ko,kSe as Lo,RSe as Mo,Jg as No,Vg as Oo,Qxe as Po,iV as Qo,Xxe as Ro,uV as So,$Se as To,WSe as Uo,dx as Vo,gJ as Wo,hJ as Xo,JSe as Yo,dV as Zo,mx as _o,VA as $o,exe as ap,mAe as bp,Q_t as cp,Xp as dp,WO as ep,VO as fp,HO as gp,KO as hp,QO as ip,qe as jp,IM as kp,oLe as lp,B7 as mp,ZM as np,OLe as op,W7 as pp,K7 as qp,Q7 as rp,Y7 as sp,X7 as tp,tX as up,HM as vp,KM as wp,iX as xp,QM as yp,zw as zp,lX as Ap,Fw as Bp,YM as Cp,cX as Dp,uX as Ep,pX as Fp,mX as Gp,Bw as Hp,hX as Ip,yX as Jp,qw as Kp,Wh as Lp,Jh as Mp,bX as Np,vX as Op,SX as Pp,oj as Qp,Vh as Rp,wX as Sp,TX as Tp,_X as Up,IX as Vp,CX as Wp,vqe as Xp,Jw as Yp,EX as Zp,Vw as _p,Hw as $p,Kw as aq,kX as bq,Fu as cq,Qw as dq,Qh as eq,RX as fq,sj as gq,PX as hq,Iqe as iq,lj as jq,Rqe as kq,Aqe as lq,Mi as mq,tT as nq,Lqe as oq,$X as pq,qqe as qq};
|
|
356
355
|
|
|
357
|
-
//# debugId=
|
|
358
|
-
//# sourceMappingURL=index-
|
|
356
|
+
//# debugId=C9FF2646DD8D72EB64756E2164756E21
|
|
357
|
+
//# sourceMappingURL=index-7c9cvp1j.js.map
|