@rizom/brain 0.2.0-alpha.55 → 0.2.0-alpha.57
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 +644 -626
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins.js +2 -2
- package/dist/plugins.js.map +4 -4
- package/dist/seed-content/relay/anchor-profile/anchor-profile.md +8 -11
- package/dist/seed-content/relay/brain-character/brain-character.md +5 -4
- package/dist/seed-content/relay/site-content/home/diagram.md +184 -0
- package/dist/site.js +5 -5
- package/dist/site.js.map +4 -4
- package/package.json +1 -1
- package/dist/seed-content/relay/site-content/home/hero.md +0 -82
- package/dist/seed-content/relay/site-content/home/loop.md +0 -62
- package/dist/seed-content/relay/site-content/home/surface.md +0 -58
package/dist/site.js
CHANGED
|
@@ -169,7 +169,7 @@ Please report this to https://github.com/markedjs/marked.`,$){let Y="<p>An error
|
|
|
169
169
|
`)}extractTextFromParagraph($){return this.extractInlineText($.children).trim()}extractInlineText($){let X=[];for(let G of $)if(G.type==="text")X.push(this.extractTextValue(G));else if(G.type==="emphasis"){let Y=this.extractInlineText(G.children);if(Y)X.push(`*${Y}*`)}else if(G.type==="strong"){let Y=this.extractInlineText(G.children);if(Y)X.push(`**${Y}**`)}return X.join("")}extractSimpleArrayItems($){let X=[];for(let G of $)if(G.type==="list"){let Y=G;for(let J of Y.children){let W=this.extractTextFromListItem(J);if(W)X.push(W)}}return X}extractObjectArrayItems($,X,G){let Y=[],J=[],W=!1;for(let H of $)if(H.type==="heading"&&H.depth===X){if(W&&J.length>0){let U=this.extractSubsections(J,X+1),F=this.buildDataFromSections(U,G,X+1);Y.push(F)}J=[],W=!0}else if(W)J.push(H);if(W&&J.length>0){let H=this.extractSubsections(J,X+1),U=this.buildDataFromSections(H,G,X+1);Y.push(U)}return Y}extractTextFromListItem($){let X=[];for(let G of $.children)if(G.type==="paragraph"){let Y=this.extractTextFromParagraph(G);if(Y)X.push(Y)}return X.join(`
|
|
170
170
|
`)}}var GQ=B(()=>{x6();lX()});var YQ=B(()=>{c9()});var JQ=B(()=>{c9()});var WQ=B(()=>{r4();tM();$Q();XQ();GQ();YQ();JQ()});var Eu;var HQ=B(()=>{x6();Eu=K.object({slug:K.string(),title:K.string(),type:K.string(),entityId:K.string(),contentHash:K.string()})});var UQ=B(()=>{WQ();HQ()});var KQ="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";import{webcrypto as FQ}from"crypto";function TT($){if(!p2||p2.length<$)p2=Buffer.allocUnsafe($*CT),FQ.getRandomValues(p2),b6=0;else if(b6+$>p2.length)FQ.getRandomValues(p2),b6=0;b6+=$}function MQ($=21){TT($|=0);let X="";for(let G=b6-$;G<b6;G++)X+=KQ[p2[G]&63];return X}var CT=128,p2,b6;var QQ=()=>{};function C5($=12){return MQ($)}var qQ=B(()=>{QQ()});function f1($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function M3($){let G=$.split(/\s+/).filter((Y)=>Y.length>0).length;return Math.max(1,Math.ceil(G/200))}function Q3($){let X=$.trim().replace(/^https?:\/\//,""),G=X.split(".").filter(Boolean);if(G.length>=3){let[Y,...J]=G;if(!Y||J.length===0)return`preview.${X}`;return`${Y}-preview.${J.join(".")}`}return`preview.${X}`}var q3=()=>{};var OQ=B(()=>{q3()});function h6($,X){let G=$.metadata.publishedAt??$.created,Y=X.metadata.publishedAt??X.created;return new Date(Y).getTime()-new Date(G).getTime()}var i4;var ZQ=B(()=>{i4={START:0,INIT:10,FETCH:20,PROCESS:40,GENERATE:50,EXTRACT:60,SAVE:80,COMPLETE:100}});function S0($){return $ instanceof Error?$.message:String($)}function n4($){return $ instanceof Error?$:Error(String($))}var O3;var RQ=B(()=>{O3={success($){return{success:!0,...$}},failure($){return{success:!1,error:S0($)}}}});var o4;var AQ=B(()=>{G5();o4=K.object({success:K.boolean(),entityId:K.string().optional(),error:K.string().optional()})});var BQ=()=>{};var VQ=()=>{};function Z3($){let X={};for(let Y of $.matchAll(NQ)){let J=Y[1]??"";for(let H of J.matchAll(/([\w-]+)=["']([^"']*?)["']/g)){let U=H[1],F=H[2];if(U&&F!==void 0)X[U]=F}let W=J.replace(/([\w-]+)=["']([^"']*?)["']/g,"").trim();if(W)for(let H of W.matchAll(/(?:^|\s)([\w-]+)(?=\s|$)/g)){let U=H[1];if(U)X[U]="true"}}let G=$.replace(NQ,"").replace(/^\n+/,"").replace(/\n{3,}/g,`
|
|
171
171
|
|
|
172
|
-
`).trim();return{attributes:X,markdown:G}}function R3($){let X=$.split(IT);return X.length>1?X:null}var NQ,IT;var wQ=B(()=>{NQ=/<!--\s*\.slide:\s*(.*?)\s*-->/g;IT=/<!--\s*\.break\s*-->/});function vT($){return $.replace(kT,(X)=>ST[X]??X)}function n9($){return $.replace(jT,(X,G)=>{return`<div class="mermaid">${vT(G)}</div>`})}var jT,ST,kT;var _Q=B(()=>{jT=/<pre><code class="language-mermaid">([\s\S]*?)<\/code><\/pre>/g,ST={"&":"&","<":"<",">":">",""":'"',"'":"'"},kT=/&(?:amp|lt|gt|quot|#39);/g});var I=B(()=>{YJ();J7();J7();UM();aM();qQ();q3();OQ();r9();x6();ZQ();RQ();AQ();BQ();VQ();wQ();_Q();UQ()});var bT,PQ;var LQ=B(()=>{I();bT=K.object({status:K.enum(["healthy","warning","error","unknown"]),message:K.string().optional(),lastCheck:K.date().optional(),details:K.record(K.string(),K.unknown()).optional()}),PQ=K.object({name:K.string(),pluginId:K.string(),status:K.string(),health:bT.optional()})});var A3;var B3=B(()=>{I();A3=K.enum(["anchor","trusted","public"])});function CQ($,X){return(G)=>{let Y=$.parse(G);return X(Y)}}function L0($){let{layout:X,schema:G,...Y}=$,J={...Y,schema:G};if(X){if(J.layout={},X.component)J.layout.component=CQ(G,X.component);if(X.fullscreen!==void 0)J.layout.fullscreen=X.fullscreen}return J}var hT;var TQ=B(()=>{I();B3();hT=K.object({name:K.string(),description:K.string(),schema:K.any(),basePrompt:K.string().optional(),useKnowledgeContext:K.boolean().optional(),requiredPermission:A3,formatter:K.any().optional(),layout:K.object({component:K.any(),fullscreen:K.boolean().optional()}).optional(),dataSourceId:K.string().optional()})});class s4{static canGenerate($){return!!$.basePrompt&&!!$.dataSourceId&&$.dataSourceId.includes("ai-content")}static canFetch($){return!!$.dataSourceId&&!this.canGenerate($)}static canRender($){return!!$.layout?.component}static isStaticOnly($){return!this.canGenerate($)&&!this.canFetch($)}static getCapabilities($){return{canGenerate:this.canGenerate($),canFetch:this.canFetch($),canRender:this.canRender($),isStaticOnly:this.isStaticOnly($)}}static validate($){let X=[];if($.dataSourceId?.includes("ai-content")&&!$.basePrompt)X.push(`Template "${$.name}" has AI-content dataSourceId but no basePrompt. AI generation requires a basePrompt.`);if($.basePrompt&&(!$.dataSourceId||!$.dataSourceId.includes("ai-content")))X.push(`Template "${$.name}" has basePrompt but no AI-content dataSourceId. The basePrompt won't be used.`);return X}static logCapabilities($,X){let G=this.getCapabilities($),Y=this.validate($);if(X)X.debug(`Template capabilities for "${$.name}":`,{...G,errors:Y.length>0?Y:void 0})}}var EQ=()=>{};var yT,fT,gT,mT;var IQ=B(()=>{I();yT=K.enum(["site-content-preview","site-content-production"]),fT=K.object({name:K.string(),schema:K.any(),description:K.string().optional(),pluginId:K.string(),renderers:K.object({web:K.union([K.function(),K.string()]).optional()})}),gT=K.object({enableContentGeneration:K.boolean().default(!1),outputDir:K.string(),workingDir:K.string().optional(),environment:K.enum(["preview","production"]).default("preview"),siteConfig:K.object({title:K.string(),description:K.string(),url:K.string().optional()}).optional()}),mT=K.object({success:K.boolean(),routesBuilt:K.number(),errors:K.array(K.string()).optional(),warnings:K.array(K.string()).optional()})});var U5=B(()=>{TQ();EQ();B3();IQ()});import{McpServer as tl,ResourceTemplate as el}from"@modelcontextprotocol/sdk/server/mcp.js";var SQ=B(()=>{U5();I()});var kQ=B(()=>{SQ()});var o9,vQ,xQ,bQ,V3;var hQ=B(()=>{I();o9=K.object({interfaceType:K.string(),userId:K.string(),channelId:K.string().optional(),channelName:K.string().optional()}),vQ=K.object({success:K.literal(!0),data:K.unknown(),message:K.string().optional()}),xQ=K.object({success:K.literal(!1),error:K.string(),code:K.string().optional()}),bQ=K.object({needsConfirmation:K.literal(!0),toolName:K.string(),description:K.string(),args:K.unknown()}),V3=K.union([vQ,xQ,bQ])});var yQ;var fQ=B(()=>{I();yQ=K.union([K.object({success:K.literal(!0),data:K.unknown(),message:K.string().optional()}),K.object({success:K.literal(!1),error:K.string(),code:K.string().optional()})])});var gQ=B(()=>{I()});var N3=B(()=>{kQ();hQ();fQ();gQ()});var Tc,Ec,mQ,cT,rT;var w3=B(()=>{I();I();LQ();N3();Tc=K.object({id:K.string(),type:K.string(),version:K.string(),status:K.string()}),Ec=K.object({name:K.string(),description:K.string()}),mQ=K.object({label:K.string(),url:K.string(),pluginId:K.string(),priority:K.number().default(100)}),cT=K.object({model:K.string(),version:K.string(),uptime:K.number(),entities:K.number(),embeddings:K.number(),ai:K.object({model:K.string(),embeddingModel:K.string()}),daemons:K.array(PQ),endpoints:K.array(mQ)}),rT=K.object({id:K.string(),version:K.string(),type:K.enum(["core","entity","service","interface"]),description:K.string().optional(),dependencies:K.array(K.string()).optional(),packageName:K.string()})});class y6{id;version;description;packageName;config;context;get logger(){return this.context?.logger??t0.createFresh({context:this.id})}constructor($,X,G,Y){this.id=$,this.packageName=X.name,this.version=X.version,this.description=X.description??`${X.name} plugin`,this.config=Y.parse(G)}setupMessageHandlers($){$.messaging.subscribe(`plugin:${this.id}:tool:execute`,async(X)=>{try{let{toolName:G,args:Y,progressToken:J,hasProgress:W,interfaceType:H,userId:U,channelId:F}=iT.parse(X.payload),Q=(await this.getTools()).find((Z)=>Z.name===G);if(!Q)return{success:!1,error:`Tool not found: ${G}`};let q={interfaceType:H,userId:U,...F&&{channelId:F},...W&&J!==void 0&&{progressToken:J,sendProgress:async(Z)=>{await $.messaging.send({type:`plugin:${this.id}:progress`,payload:{progressToken:J,notification:Z}})}}};return{success:!0,data:await Q.handler(Y,q)}}catch(G){if(G instanceof K.ZodError)return{success:!1,error:"Invalid tool execution request format"};return this.logger.error("Tool execution error",G),{success:!1,error:S0(G)}}}),$.messaging.subscribe(`plugin:${this.id}:resource:get`,async(X)=>{try{let{resourceUri:G}=nT.parse(X.payload),J=(await this.getResources()).find((H)=>H.uri===G);if(!J)return{success:!1,error:`Resource not found: ${G}`};return{success:!0,data:await J.handler()}}catch(G){if(G instanceof K.ZodError)return{success:!1,error:"Invalid resource get request format"};return this.logger.error("Resource fetch error",G),{success:!1,error:S0(G)}}})}async onRegister($){}async onReady($){}async ready(){await this.onReady(this.getContext())}async getCapabilities(){let $=await this.getInstructions();return{tools:await this.getTools(),resources:await this.getResources(),...$&&{instructions:$}}}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}async shutdown(){await this.onShutdown()}async onShutdown(){}getContext(){if(!this.context)throw Error(`Plugin ${this.id}: Plugin not registered yet`);return this.context}determineUserPermissionLevel($){return"public"}createProgressBridge($){if(!$)return;let X=this.context;if(!X)return;let G=this.id;return o5.from(async(Y)=>{await X.messaging.send({type:`plugin:${G}:progress`,payload:{progressToken:$,notification:{progress:Y.progress,total:Y.total,message:Y.message}}})})}}var iT,nT;var s9=B(()=>{w3();I();I();iT=K.object({toolName:K.string(),args:K.unknown(),progressToken:K.union([K.string(),K.number()]).optional(),hasProgress:K.boolean().optional(),...o9.shape}),nT=K.object({resourceUri:K.string()})});var pQ,uQ,a4,hc;var a9=B(()=>{I();pQ=K.enum(["file_operations","content_operations","data_processing","batch_processing"]),uQ=K.object({pluginId:K.string().optional(),progressToken:K.union([K.string(),K.number()]).optional(),operationType:pQ,operationTarget:K.string().optional(),interfaceType:K.string().optional(),channelId:K.string().optional()}),a4=uQ.extend({rootJobId:K.string()}),hc=K.enum(["none","skip","replace","coalesce"])});var _3,dQ,oT,sT,lQ,z3;var e5=B(()=>{I();a9();_3=K.enum(["pending","processing","completed","failed"]),dQ=K.enum(["completed","failed"]),oT=K.object({id:K.string(),type:K.string(),status:_3,data:K.unknown(),result:K.unknown().optional(),lastError:K.string().optional().nullable(),attempts:K.number(),maxRetries:K.number(),priority:K.number(),createdAt:K.date(),updatedAt:K.date(),processedAt:K.date().optional().nullable(),completedAt:K.date().optional().nullable(),failedAt:K.date().optional().nullable()}),sT=K.object({jobId:K.string(),type:K.string(),status:dQ,result:K.unknown().optional(),error:K.string().optional()}),lQ=K.object({success:K.literal(!1),error:K.string().optional()}),z3=K.object({id:K.string(),type:K.enum(["job","batch"]),status:_3,message:K.string().optional(),progress:K.object({current:K.number(),total:K.number(),percentage:K.number()}).optional(),aggregationKey:K.string().optional(),batchDetails:K.object({totalOperations:K.number(),completedOperations:K.number(),failedOperations:K.number(),currentOperation:K.string().optional(),errors:K.array(K.string()).optional()}).optional(),jobDetails:K.object({jobType:K.string(),priority:K.number(),retryCount:K.number()}).optional(),metadata:a4})});function e($,X){if(!$||typeof $!=="object")return!1;if($ instanceof X)return!0;if(!Object.prototype.hasOwnProperty.call(X,k))throw Error(`Class "${X.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let G=Object.getPrototypeOf($).constructor;if(G)while(G){if(k in G&&G[k]===X[k])return!0;G=Object.getPrototypeOf(G)}return!1}var k;var w0=B(()=>{k=Symbol.for("drizzle:entityKind")});var P1;var $2=B(()=>{w0();P1=class P1{constructor($,X){this.table=$,this.config=X,this.name=X.name,this.keyAsName=X.keyAsName,this.notNull=X.notNull,this.default=X.default,this.defaultFn=X.defaultFn,this.onUpdateFn=X.onUpdateFn,this.hasDefault=X.hasDefault,this.primary=X.primaryKey,this.isUnique=X.isUnique,this.uniqueName=X.uniqueName,this.uniqueType=X.uniqueType,this.dataType=X.dataType,this.columnType=X.columnType,this.generated=X.generated,this.generatedIdentity=X.generatedIdentity}static[k]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var D3;var P3=B(()=>{w0();D3=class D3{static[k]="ColumnBuilder";config;constructor($,X,G){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:X,columnType:G,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}});var n1;var t4=B(()=>{n1=Symbol.for("drizzle:Name")});function cQ($,...X){return $(...X)}var rQ=()=>{};function iQ($,X){return`${$[n1]}_${X.join("_")}_unique`}var nQ=B(()=>{t4()});var e4,aT;var oQ=B(()=>{$2();w0();nQ();e4=class e4 extends P1{constructor($,X){if(!X.uniqueName)X.uniqueName=iQ($,[X.name]);super($,X);this.table=$}static[k]="PgColumn"};aT=class aT extends e4{static[k]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}});function aQ($){return!!$&&typeof $==="function"&&sQ in $&&$[sQ]===!0}var tT,sQ,eT;var tQ=B(()=>{w0();oQ();tT=class tT extends e4{static[k]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}};sQ=Symbol.for("drizzle:isPgEnum");eT=class eT extends e4{static[k]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}}});var A1;var X2=B(()=>{w0();A1=class A1{static[k]="Subquery";constructor($,X,G,Y=!1,J=[]){this._={brand:"Subquery",sql:$,selectedFields:X,alias:G,isWith:Y,usedTables:J}}}});var eQ="0.44.7";var $q=()=>{};var L3,C3,Xq;var Gq=B(()=>{rQ();$q();Xq={startActiveSpan($,X){if(!L3)return X();if(!C3)C3=L3.trace.getTracer("drizzle-orm",eQ);return cQ((G,Y)=>Y.startActiveSpan($,(J)=>{try{return X(J)}catch(W){throw J.setStatus({code:G.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Unknown error"}),W}finally{J.end()}}),L3,C3)}}});var m0;var G2=B(()=>{m0=Symbol.for("drizzle:ViewBaseConfig")});var T3,Yq,Jq,E3,I3,$8,Wq,$E,W0;var T5=B(()=>{w0();t4();T3=Symbol.for("drizzle:Schema"),Yq=Symbol.for("drizzle:Columns"),Jq=Symbol.for("drizzle:ExtraConfigColumns"),E3=Symbol.for("drizzle:OriginalName"),I3=Symbol.for("drizzle:BaseName"),$8=Symbol.for("drizzle:IsAlias"),Wq=Symbol.for("drizzle:ExtraConfigBuilder"),$E=Symbol.for("drizzle:IsDrizzleTable");W0=class W0{static[k]="Table";static Symbol={Name:n1,Schema:T3,OriginalName:E3,Columns:Yq,ExtraConfigColumns:Jq,BaseName:I3,IsAlias:$8,ExtraConfigBuilder:Wq};[n1];[E3];[T3];[Yq];[Jq];[I3];[$8]=!1;[$E]=!0;[Wq]=void 0;constructor($,X,G){this[n1]=this[E3]=$,this[T3]=X,this[I3]=G}}});function XE($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function GE($){let X={sql:"",params:[]};for(let G of $)if(X.sql+=G.sql,X.params.push(...G.params),G.typings?.length){if(!X.typings)X.typings=[];X.typings.push(...G.typings)}return X}function f6($,...X){let G=[];if(X.length>0||$.length>0&&$[0]!=="")G.push(new g1($[0]));for(let[Y,J]of X.entries())G.push(J,new g1($[Y+1]));return new Z0(G)}var g1,Z0,t9,Hq,Uq,_r,$$,e9,YE,K5;var Y2=B(()=>{w0();tQ();X2();Gq();G2();$2();T5();g1=class g1{static[k]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new Z0([this])}};Z0=class Z0{constructor($){this.queryChunks=$;for(let X of $)if(e(X,W0)){let G=X[W0.Symbol.Schema];this.usedTables.push(G===void 0?X[W0.Symbol.Name]:G+"."+X[W0.Symbol.Name])}}static[k]="SQL";decoder=Hq;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return Xq.startActiveSpan("drizzle.buildSQL",(X)=>{let G=this.buildQueryFromSourceParams(this.queryChunks,$);return X?.setAttributes({"drizzle.query.text":G.sql,"drizzle.query.params":JSON.stringify(G.params)}),G})}buildQueryFromSourceParams($,X){let G=Object.assign({},X,{inlineParams:X.inlineParams||this.shouldInlineParams,paramStartIndex:X.paramStartIndex||{value:0}}),{casing:Y,escapeName:J,escapeParam:W,prepareTyping:H,inlineParams:U,paramStartIndex:F}=G;return GE($.map((M)=>{if(e(M,g1))return{sql:M.value.join(""),params:[]};if(e(M,t9))return{sql:J(M.value),params:[]};if(M===void 0)return{sql:"",params:[]};if(Array.isArray(M)){let Q=[new g1("(")];for(let[q,A]of M.entries())if(Q.push(A),q<M.length-1)Q.push(new g1(", "));return Q.push(new g1(")")),this.buildQueryFromSourceParams(Q,G)}if(e(M,Z0))return this.buildQueryFromSourceParams(M.queryChunks,{...G,inlineParams:U||M.shouldInlineParams});if(e(M,W0)){let Q=M[W0.Symbol.Schema],q=M[W0.Symbol.Name];return{sql:Q===void 0||M[$8]?J(q):J(Q)+"."+J(q),params:[]}}if(e(M,P1)){let Q=Y.getColumnCasing(M);if(X.invokeSource==="indexes")return{sql:J(Q),params:[]};let q=M.table[W0.Symbol.Schema];return{sql:M.table[$8]||q===void 0?J(M.table[W0.Symbol.Name])+"."+J(Q):J(q)+"."+J(M.table[W0.Symbol.Name])+"."+J(Q),params:[]}}if(e(M,K5)){let Q=M[m0].schema,q=M[m0].name;return{sql:Q===void 0||M[m0].isAlias?J(q):J(Q)+"."+J(q),params:[]}}if(e(M,$$)){if(e(M.value,e9))return{sql:W(F.value++,M),params:[M],typings:["none"]};let Q=M.value===null?null:M.encoder.mapToDriverValue(M.value);if(e(Q,Z0))return this.buildQueryFromSourceParams([Q],G);if(U)return{sql:this.mapInlineParam(Q,G),params:[]};let q=["none"];if(H)q=[H(M.encoder)];return{sql:W(F.value++,Q),params:[Q],typings:q}}if(e(M,e9))return{sql:W(F.value++,M),params:[M],typings:["none"]};if(e(M,Z0.Aliased)&&M.fieldAlias!==void 0)return{sql:J(M.fieldAlias),params:[]};if(e(M,A1)){if(M._.isWith)return{sql:J(M._.alias),params:[]};return this.buildQueryFromSourceParams([new g1("("),M._.sql,new g1(") "),new t9(M._.alias)],G)}if(aQ(M)){if(M.schema)return{sql:J(M.schema)+"."+J(M.enumName),params:[]};return{sql:J(M.enumName),params:[]}}if(XE(M)){if(M.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([M.getSQL()],G);return this.buildQueryFromSourceParams([new g1("("),M.getSQL(),new g1(")")],G)}if(U)return{sql:this.mapInlineParam(M,G),params:[]};return{sql:W(F.value++,M),params:[M],typings:["none"]}}))}mapInlineParam($,{escapeString:X}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return X($);if(typeof $==="object"){let G=$.toString();if(G==="[object Object]")return X(JSON.stringify($));return X(G)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new Z0.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}};t9=class t9{constructor($){this.value=$}static[k]="Name";brand;getSQL(){return new Z0([this])}};Hq={mapFromDriverValue:($)=>$},Uq={mapToDriverValue:($)=>$},_r={...Hq,...Uq};$$=class $${constructor($,X=Uq){this.value=$,this.encoder=X}static[k]="Param";brand;getSQL(){return new Z0([this])}};(($)=>{function X(){return new Z0([])}$.empty=X;function G(F){return new Z0(F)}$.fromList=G;function Y(F){return new Z0([new g1(F)])}$.raw=Y;function J(F,M){let Q=[];for(let[q,A]of F.entries()){if(q>0&&M!==void 0)Q.push(M);Q.push(A)}return new Z0(Q)}$.join=J;function W(F){return new t9(F)}$.identifier=W;function H(F){return new e9(F)}$.placeholder=H;function U(F,M){return new $$(F,M)}$.param=U})(f6||(f6={}));(($)=>{class X{constructor(G,Y){this.sql=G,this.fieldAlias=Y}static[k]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new X(this.sql,this.fieldAlias)}}$.Aliased=X})(Z0||(Z0={}));e9=class e9{constructor($){this.name=$}static[k]="Placeholder";getSQL(){return new Z0([this])}};YE=Symbol.for("drizzle:IsDrizzleView");K5=class K5{static[k]="View";[m0];[YE]=!0;constructor({name:$,schema:X,selectedFields:G,query:Y}){this[m0]={name:$,originalName:$,schema:X,selectedFields:G,query:Y,isExisting:!Y,isAlias:!1}}getSQL(){return new Z0([this])}};P1.prototype.getSQL=function(){return new Z0([this])};W0.prototype.getSQL=function(){return new Z0([this])};A1.prototype.getSQL=function(){return new Z0([this])}});function g6($,X){return Object.entries($).reduce((G,[Y,J])=>{if(typeof Y!=="string")return G;let W=X?[...X,Y]:[Y];if(e(J,P1)||e(J,Z0)||e(J,Z0.Aliased))G.push({path:W,field:J});else if(e(J,W0))G.push(...g6(J[W0.Symbol.Columns],W));else G.push(...g6(J,W));return G},[])}function j3($,X){let G=Object.keys($),Y=Object.keys(X);if(G.length!==Y.length)return!1;for(let[J,W]of G.entries())if(W!==Y[J])return!1;return!0}function Kq($,X){for(let G of X)for(let Y of Object.getOwnPropertyNames(G.prototype)){if(Y==="constructor")continue;Object.defineProperty($.prototype,Y,Object.getOwnPropertyDescriptor(G.prototype,Y)||Object.create(null))}}function X8($){return e($,A1)?$._.alias:e($,K5)?$[m0].name:e($,Z0)?void 0:$[W0.Symbol.IsAlias]?$[W0.Symbol.Name]:$[W0.Symbol.BaseName]}function F5($,X){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:X}}var S3;var E5=B(()=>{$2();w0();Y2();X2();T5();G2();S3=typeof TextDecoder>"u"?null:new TextDecoder});var Fq=()=>{};var Mq=()=>{};var Qq=()=>{};var qq=B(()=>{Mq();Qq()});var Oq=()=>{};var G8,k3;var v3=B(()=>{$2();w0();T5();G2();G8=class G8{constructor($){this.table=$}static[k]="ColumnAliasProxyHandler";get($,X){if(X==="table")return this.table;return $[X]}};k3=class k3{constructor($,X){this.alias=$,this.replaceOriginalName=X}static[k]="TableAliasProxyHandler";get($,X){if(X===W0.Symbol.IsAlias)return!0;if(X===W0.Symbol.Name)return this.alias;if(this.replaceOriginalName&&X===W0.Symbol.OriginalName)return this.alias;if(X===m0)return{...$[m0],name:this.alias,isAlias:!0};if(X===W0.Symbol.Columns){let Y=$[W0.Symbol.Columns];if(!Y)return Y;let J={};return Object.keys(Y).map((W)=>{J[W]=new Proxy(Y[W],new G8(new Proxy($,this)))}),J}let G=$[X];if(e(G,P1))return new Proxy(G,new G8(new Proxy($,this)));return G}}});var L1;var x3=B(()=>{v3();$2();w0();Y2();X2();G2();L1=class L1{static[k]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,X){if(X==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(X===m0)return{...$[m0],selectedFields:new Proxy($[m0].selectedFields,this)};if(typeof X==="symbol")return $[X];let Y=(e($,A1)?$._.selectedFields:e($,K5)?$[m0].selectedFields:$)[X];if(e(Y,Z0.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!Y.isSelectionField)return Y.sql;let J=Y.clone();return J.isSelectionField=!0,J}if(e(Y,Z0)){if(this.config.sqlBehavior==="sql")return Y;throw Error(`You tried to reference "${X}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(e(Y,P1)){if(this.config.alias)return new Proxy(Y,new G8(new Proxy(Y.table,new k3(this.config.alias,this.config.replaceOriginalName??!1))));return Y}if(typeof Y!=="object"||Y===null)return Y;return new Proxy(Y,new L1(this.config))}}});var Y8;var X$=B(()=>{w0();Y8=class Y8{static[k]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}then($,X){return this.execute().then($,X)}}});var b3,Zq;var h3=B(()=>{w0();t4();b3=class b3{static[k]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,X){if(this.reference=()=>{let{name:G,columns:Y,foreignColumns:J}=$();return{name:G,columns:Y,foreignTable:J[0].table,foreignColumns:J}},X)this._onUpdate=X.onUpdate,this._onDelete=X.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new Zq($,this)}};Zq=class Zq{constructor($,X){this.table=$,this.reference=X.reference,this.onUpdate=X._onUpdate,this.onDelete=X._onDelete}static[k]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:X,foreignColumns:G}=this.reference(),Y=X.map((H)=>H.name),J=G.map((H)=>H.name),W=[this.table[n1],...Y,G[0].table[n1],...J];return $??`${W.join("_")}_fk`}}});function Rq($,X){return`${$[n1]}_${X.join("_")}_unique`}var y3=B(()=>{t4()});var i0,n0;var J2=B(()=>{P3();$2();w0();h3();y3();i0=class i0 extends D3{static[k]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,X={}){return this.foreignKeyConfigs.push({ref:$,actions:X}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,X){return this.config.generated={as:$,type:"always",mode:X?.mode??"virtual"},this}buildForeignKeys($,X){return this.foreignKeyConfigs.map(({ref:G,actions:Y})=>{return((J,W)=>{let H=new b3(()=>{let U=J();return{columns:[$],foreignColumns:[U]}});if(W.onUpdate)H.onUpdate(W.onUpdate);if(W.onDelete)H.onDelete(W.onDelete);return H.build(X)})(G,Y)})}};n0=class n0 extends P1{constructor($,X){if(!X.uniqueName)X.uniqueName=Rq($,[X.name]);super($,X);this.table=$}static[k]="SQLiteColumn"}});function zq($,X){let{name:G,config:Y}=F5($,X);if(Y?.mode==="json")return new Vq(G);if(Y?.mode==="bigint")return new Aq(G);return new wq(G)}var Aq,Bq,Vq,Nq,wq,_q;var f3=B(()=>{w0();E5();J2();Aq=class Aq extends i0{static[k]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new Bq($,this.config)}};Bq=class Bq extends n0{static[k]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let X=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(X.toString("utf8"))}return BigInt(S3.decode($))}mapToDriverValue($){return Buffer.from($.toString())}};Vq=class Vq extends i0{static[k]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new Nq($,this.config)}};Nq=class Nq extends n0{static[k]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let X=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(X.toString("utf8"))}return JSON.parse(S3.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}};wq=class wq extends i0{static[k]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new _q($,this.config)}};_q=class _q extends n0{static[k]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}});function G$($){return(X,G)=>{let{name:Y,config:J}=F5(X,G);return new Dq(Y,J,$)}}var Dq,Pq;var g3=B(()=>{w0();E5();J2();Dq=class Dq extends i0{static[k]="SQLiteCustomColumnBuilder";constructor($,X,G){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=X,this.config.customTypeParams=G}build($){return new Pq($,this.config)}};Pq=class Pq extends n0{static[k]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,X){super($,X);this.sqlName=X.customTypeParams.dataType(X.fieldConfig),this.mapTo=X.customTypeParams.toDriver,this.mapFrom=X.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}});function B1($,X){let{name:G,config:Y}=F5($,X);if(Y?.mode==="timestamp"||Y?.mode==="timestamp_ms")return new Tq(G,Y.mode);if(Y?.mode==="boolean")return new Iq(G,Y.mode);return new Lq(G)}var Y$,J$,Lq,Cq,Tq,Eq,Iq,jq;var m3=B(()=>{w0();Y2();E5();J2();Y$=class Y$ extends i0{static[k]="SQLiteBaseIntegerBuilder";constructor($,X,G){super($,X,G);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};J$=class J$ extends n0{static[k]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};Lq=class Lq extends Y${static[k]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new Cq($,this.config)}};Cq=class Cq extends J${static[k]="SQLiteInteger"};Tq=class Tq extends Y${static[k]="SQLiteTimestampBuilder";constructor($,X){super($,"date","SQLiteTimestamp");this.config.mode=X}defaultNow(){return this.default(f6`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new Eq($,this.config)}};Eq=class Eq extends J${static[k]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let X=$.getTime();if(this.config.mode==="timestamp")return Math.floor(X/1000);return X}};Iq=class Iq extends Y${static[k]="SQLiteBooleanBuilder";constructor($,X){super($,"boolean","SQLiteBoolean");this.config.mode=X}build($){return new jq($,this.config)}};jq=class jq extends J${static[k]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}});function yq($,X){let{name:G,config:Y}=F5($,X),J=Y?.mode;return J==="number"?new vq(G):J==="bigint"?new bq(G):new Sq(G)}var Sq,kq,vq,xq,bq,hq;var p3=B(()=>{w0();E5();J2();Sq=class Sq extends i0{static[k]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new kq($,this.config)}};kq=class kq extends n0{static[k]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}};vq=class vq extends i0{static[k]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new xq($,this.config)}};xq=class xq extends n0{static[k]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}};bq=class bq extends i0{static[k]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new hq($,this.config)}};hq=class hq extends n0{static[k]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function mq($){return new fq($??"")}var fq,gq;var u3=B(()=>{w0();J2();fq=class fq extends i0{static[k]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new gq($,this.config)}};gq=class gq extends n0{static[k]="SQLiteReal";getSQLType(){return"real"}}});function Y0($,X={}){let{name:G,config:Y}=F5($,X);if(Y.mode==="json")return new dq(G);return new pq(G,Y)}var pq,uq,dq,lq;var d3=B(()=>{w0();E5();J2();pq=class pq extends i0{static[k]="SQLiteTextBuilder";constructor($,X){super($,"string","SQLiteText");this.config.enumValues=X.enum,this.config.length=X.length}build($){return new uq($,this.config)}};uq=class uq extends n0{static[k]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,X){super($,X)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};dq=class dq extends i0{static[k]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new lq($,this.config)}};lq=class lq extends n0{static[k]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}});function cq(){return{blob:zq,customType:G$,integer:B1,numeric:yq,real:mq,text:Y0}}var rq=B(()=>{f3();g3();m3();p3();u3();d3()});function JE($,X,G,Y,J=$){let W=new M5($,Y,J),H=typeof X==="function"?X(cq()):X,U=Object.fromEntries(Object.entries(H).map(([M,Q])=>{let q=Q;q.setName(M);let A=q.build(W);return W[l3].push(...q.buildForeignKeys(A,W)),[M,A]})),F=Object.assign(W,U);if(F[W0.Symbol.Columns]=U,F[W0.Symbol.ExtraConfigColumns]=U,G)F[M5.Symbol.ExtraConfigBuilder]=G;return F}var l3,M5,Q5=($,X,G)=>{return JE($,X,G)};var J8=B(()=>{w0();T5();rq();l3=Symbol.for("drizzle:SQLiteInlineForeignKeys");M5=class M5 extends W0{static[k]="SQLiteTable";static Symbol=Object.assign({},W0.Symbol,{InlineForeignKeys:l3});[W0.Symbol.Columns];[l3]=[];[W0.Symbol.ExtraConfigBuilder]=void 0}});var iq=()=>{};function o1($){return new nq($,!1)}var nq,oq,sq;var aq=B(()=>{w0();nq=class nq{constructor($,X){this.name=$,this.unique=X}static[k]="SQLiteIndexBuilderOn";on(...$){return new oq(this.name,$,this.unique)}};oq=class oq{static[k]="SQLiteIndexBuilder";config;constructor($,X,G){this.config={name:$,columns:X,unique:G,where:void 0}}where($){return this.config.where=$,this}build($){return new sq(this.config,$)}};sq=class sq{static[k]="SQLiteIndex";config;constructor($,X){this.config={...$,table:X}}}});function W$(...$){if($[0].columns)return new c3($[0].columns,$[0].name);return new c3($)}var c3,tq;var eq=B(()=>{w0();J8();c3=class c3{static[k]="SQLitePrimaryKeyBuilder";columns;name;constructor($,X){this.columns=$,this.name=X}build($){return new tq($,this.columns,this.name)}};tq=class tq{constructor($,X,G){this.table=$,this.columns=X,this.name=G}static[k]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[M5.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}});function u2($){if(e($,M5))return[`${$[W0.Symbol.BaseName]}`];if(e($,A1))return $._.usedTables??[];if(e($,Z0))return $.usedTables??[];return[]}var H$=B(()=>{w0();Y2();X2();T5();J8()});var $O=()=>{};var XO=()=>{};var GO=()=>{};var YO=()=>{};var JO=B(()=>{GO();YO()});var WO=B(()=>{qq();JO();Y2()});var HO=B(()=>{f3();J2();g3();m3();p3();u3();d3()});var r3;var UO=B(()=>{w0();Y2();r3=class r3 extends K5{static[k]="SQLiteViewBase"}});var KO=()=>{};var i3;var FO=B(()=>{w0();i3=class i3{static[k]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function U$($,X){return(G,Y,...J)=>{let W=[Y,...J].map((H)=>({type:$,isAll:X,rightSelect:H}));for(let H of W)if(!j3(G.getSelectedFields(),H.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return G.addSetOperators(W)}}var MO,QO,WE=()=>({union:HE,unionAll:UE,intersect:KE,except:FE}),HE,UE,KE,FE;var qO=B(()=>{w0();FO();X$();x3();Y2();X2();T5();E5();G2();H$();MO=class MO extends i3{static[k]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:$,fields:X,isPartialSelect:G,session:Y,dialect:J,withList:W,distinct:H}){super();this.config={withList:W,table:$,fields:{...X},distinct:H,setOperators:[]},this.isPartialSelect=G,this.session=Y,this.dialect=J,this._={selectedFields:X,config:this.config},this.tableName=X8($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let U of u2($))this.usedTables.add(U)}getUsedTables(){return[...this.usedTables]}createJoin($){return(X,G)=>{let Y=this.tableName,J=X8(X);for(let W of u2(X))this.usedTables.add(W);if(typeof J==="string"&&this.config.joins?.some((W)=>W.alias===J))throw Error(`Alias "${J}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Y==="string")this.config.fields={[Y]:this.config.fields};if(typeof J==="string"&&!e(X,Z0)){let W=e(X,A1)?X._.selectedFields:e(X,K5)?X[m0].selectedFields:X[W0.Symbol.Columns];this.config.fields[J]=W}}if(typeof G==="function")G=G(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:G,table:X,joinType:$,alias:J}),typeof J==="string")switch($){case"left":{this.joinsNotNullableMap[J]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[J]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[J]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[J]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator($,X){return(G)=>{let Y=typeof G==="function"?G(WE()):G;if(!j3(this.getSelectedFields(),Y.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:X,rightSelect:Y}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(X)?X:[X]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),G=Array.isArray(X)?X:[X];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=G;else this.config.orderBy=G}else{let X=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=X;else this.config.orderBy=X}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}as($){let X=[];if(X.push(...u2(this.config.table)),this.config.joins)for(let G of this.config.joins)X.push(...u2(G.table));return new Proxy(new A1(this.getSQL(),this.config.fields,$,!1,[...new Set(X)]),new L1({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new L1({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};QO=class QO extends MO{static[k]="SQLiteSelect";_prepare($=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let X=g6(this.config.fields),G=this.session[$?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),X,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return G.joinsNotNullableMap=this.joinsNotNullableMap,G}$withCache($){return this.cacheConfig=$===void 0?{config:{},enable:!0,autoInvalidate:!0}:$===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...$},this}prepare(){return this._prepare(!1)}run=($)=>{return this._prepare().run($)};all=($)=>{return this._prepare().all($)};get=($)=>{return this._prepare().get($)};values=($)=>{return this._prepare().values($)};async execute(){return this.all()}};Kq(QO,[Y8]);HE=U$("union",!1),UE=U$("union",!0),KE=U$("intersect",!1),FE=U$("except",!1)});var OO=()=>{};var ZO=()=>{};var ME;var RO=B(()=>{w0();X$();x3();J8();X2();T5();E5();G2();H$();UO();ME=class ME extends Y8{constructor($,X,G,Y,J){super();this.session=G,this.dialect=Y,this.config={set:X,table:$,withList:J,joins:[]}}static[k]="SQLiteUpdate";config;from($){return this.config.from=$,this}createJoin($){return(X,G)=>{let Y=X8(X);if(typeof Y==="string"&&this.config.joins.some((J)=>J.alias===Y))throw Error(`Alias "${Y}" is already used in this query`);if(typeof G==="function"){let J=this.config.from?e(X,M5)?X[W0.Symbol.Columns]:e(X,A1)?X._.selectedFields:e(X,r3)?X[m0].selectedFields:void 0:void 0;G=G(new Proxy(this.config.table[W0.Symbol.Columns],new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),J&&new Proxy(J,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:G,table:X,joinType:$,alias:Y}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.table[W0.Symbol.Columns],new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),G=Array.isArray(X)?X:[X];this.config.orderBy=G}else{let X=$;this.config.orderBy=X}return this}limit($){return this.config.limit=$,this}returning($=this.config.table[M5.Symbol.Columns]){return this.config.returning=g6($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($=!0){return this.session[$?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:u2(this.config.table)})}prepare(){return this._prepare(!1)}run=($)=>{return this._prepare().run($)};all=($)=>{return this._prepare().all($)};get=($)=>{return this._prepare().get($)};values=($)=>{return this._prepare().values($)};async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var AO=B(()=>{$O();ZO();OO();qO();RO()});var BO=()=>{};var VO=()=>{};var NO=()=>{};var wO=()=>{};var m6=B(()=>{VO();iq();HO();BO();KO();h3();aq();eq();AO();NO();J8();y3();H$();wO()});var _O;var n3=B(()=>{m6();I();_O=Q5("job_queue",{id:Y0("id").primaryKey().$defaultFn(()=>C5()),type:Y0("type").notNull(),data:Y0("data").notNull(),result:Y0("result",{mode:"json"}),source:Y0("source"),metadata:Y0("metadata",{mode:"json"}).$type().notNull(),status:Y0("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:B1("priority").notNull().default(0),retryCount:B1("retryCount").notNull().default(0),maxRetries:B1("maxRetries").notNull().default(3),lastError:Y0("lastError"),createdAt:B1("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:B1("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:B1("startedAt"),completedAt:B1("completedAt")},($)=>({queueReadyIdx:o1("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:o1("idx_job_queue_type").on($.type,$.status),jobSourceIdx:o1("idx_job_queue_source").on($.source)}))});import{createClient as So}from"@libsql/client";var zO=B(()=>{n3()});var DO=B(()=>{v3();P3();$2();w0();XO();Fq();X$();Oq();WO();X2();T5();E5();G2()});var PO=B(()=>{n3();e5()});var LO=B(()=>{e5()});var CO=B(()=>{I();e5();zO();PO();LO()});var TO=B(()=>{I();e5();e5()});var EO=B(()=>{e5()});var IO=B(()=>{I()});class H8{logger;schema;jobTypeName;constructor($,X){this.logger=$,this.schema=X.schema,this.jobTypeName=X.jobTypeName}validateAndParse($){if(!this.schema)throw Error(`${this.jobTypeName}: No schema provided. Override validateAndParse() or provide a schema.`);try{let X=this.schema.parse($);return this.logger.debug(`${this.jobTypeName} job data validation successful`,{data:this.summarizeDataForLog(X)}),X}catch(X){return this.logger.warn(`Invalid ${this.jobTypeName} job data`,{data:$,validationError:X instanceof K.ZodError?X.issues:X}),null}}async onError($,X,G,Y){this.logger.error(`${this.jobTypeName} job error handler triggered`,{jobId:G,errorMessage:$.message,errorStack:$.stack,data:this.summarizeDataForLog(X)})}async reportProgress($,X){await $.report({progress:X.progress,total:X.total??100,message:X.message})}summarizeDataForLog($){return $}}var jO=B(()=>{I()});var QE;var SO=B(()=>{a9();I();QE=K.object({id:K.string(),type:K.string(),data:K.string(),status:K.enum(["pending","processing","completed","failed"]),source:K.string().nullable(),priority:K.number(),retryCount:K.number(),maxRetries:K.number(),lastError:K.string().nullable(),createdAt:K.number(),scheduledFor:K.number(),startedAt:K.number().nullable(),completedAt:K.number().nullable(),metadata:a4,result:K.unknown().nullable().optional()})});function o3($,X,G){return async(Y)=>{let{type:J,data:W,toolContext:H=null,options:U}=Y,{metadata:F,...M}=U??{},Q={source:X,...U?.rootJobId&&{rootJobId:U.rootJobId},...M,metadata:{operationType:"data_processing",pluginId:X,...H&&{interfaceType:H.interfaceType,channelId:H.channelId},...F}},q=G&&!J.includes(":")?`${X}:${J}`:J;return $.enqueue({type:q,data:W,options:Q})}}function s3($,X){return async(G,Y)=>{let J=C5(),W=G.map((U)=>({...U,type:U.type.includes(":")?U.type:`${X}:${U.type}`})),H={...Y,source:X,rootJobId:J,metadata:{...Y?.metadata,operationType:"batch_processing",pluginId:X}};return await $.enqueueBatch(W,H,J,X),J}}function a3($,X){return(G,Y)=>{let J=G.includes(":")?G:`${X}:${G}`;$.registerHandler(J,Y,X)}}var kO=B(()=>{I()});var U8=B(()=>{CO();TO();EO();IO();jO();SO();e5();a9();kO()});function vO($){return qE.safeParse($).success}var qE;var t3=B(()=>{I();qE=K.object({name:K.string(),schema:K.custom(($)=>$ instanceof K.ZodType)})});function OE($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function xO($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((X)=>({name:X.name,pluginId:X.pluginId,status:X.status,health:OE(X.health)})),endpoints:$.endpoints}}var K8;var e3=B(()=>{G5();K8=K.record(K.unknown())});var ZE,$G,RE;var XG=B(()=>{G5();e3();ZE=K.object({id:K.string(),sessionId:K.string(),interfaceType:K.string(),channelId:K.string(),channelName:K.string().optional(),startedAt:K.string(),lastActiveAt:K.string(),createdAt:K.string(),updatedAt:K.string(),metadata:K8}),$G=K.enum(["user","assistant","system"]),RE=K.object({id:K.string(),conversationId:K.string(),role:$G,content:K.string(),timestamp:K.string(),metadata:K8})});function bO($){if(!$)return{};try{let X=JSON.parse($);if(X&&typeof X==="object"&&!Array.isArray(X))return X}catch{}return{}}function AE($){let X=$G.safeParse($);return X.success?X.data:"user"}function K$($){let X=bO($.metadata),G=typeof X.channelName==="string"?X.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:G,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:X}}function hO($){return{id:$.id,conversationId:$.conversationId,role:AE($.role),content:$.content,timestamp:$.timestamp,metadata:bO($.metadata)}}var yO=B(()=>{XG()});var GG,YG;var JG=B(()=>{G5();GG=K.object({name:K.string(),role:K.string(),purpose:K.string(),values:K.array(K.string())}),YG=K.object({name:K.string(),kind:K.enum(["professional","team","collective"]),organization:K.string().optional(),description:K.string().optional(),avatar:K.string().optional(),website:K.string().optional(),email:K.string().optional(),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]),url:K.string(),label:K.string().optional()})).optional()})});function fO($){return GG.parse($)}function gO($){return YG.parse($)}var mO=B(()=>{JG()});function pO($){return async()=>{return xO(await $.getAppInfo())}}function uO($,X){return{get:()=>fO($.getIdentity()),getProfile:()=>gO($.getProfile()),getAppInfo:X}}function dO($,X,G){let Y=$.getMessageBus();return{send:async(W)=>{return Y.send({...W,sender:X})},subscribe:(W,H)=>{if(vO(W)){let U=W,F=H,M=async(Q)=>{let q=U.schema.safeParse(Q.payload);if(!q.success)return G.warn(`Invalid payload for channel ${U.name}`,{error:q.error.message}),{noop:!0};let{payload:A,...Z}=Q;return F(q.data,Z)};return Y.subscribe(U.name,M)}return Y.subscribe(W,H)}}}function lO($,X){let G=$.getJobQueueService();return{...$.jobs,enqueue:o3(G,X,!0),enqueueBatch:s3($.jobs,X),registerHandler:a3(G,X)}}function cO($){return{get:async(X)=>{let Y=await $.getConversationService().getConversation(X);return Y?K$(Y):null},search:async(X)=>{return(await $.getConversationService().searchConversations(X)).map(K$)},list:async(X)=>{return(await $.getConversationService().listConversations(X)).map(K$)},getMessages:async(X,G)=>{return(await $.getConversationService().getMessages(X,G)).map(hO)},countMessages:async(X)=>{return $.getConversationService().countMessages(X)}}}function rO($,X){return{registerHandler:(G,Y)=>{$.registerEvalHandler(X,G,Y)}}}function iO($){return{register:(X,G)=>{$.getInsightsRegistry().register(X,G)}}}function nO($,X){return{register:({label:G,url:Y,priority:J=100})=>{$.registerEndpoint({label:G,url:Y,pluginId:X,priority:J})}}}var oO=B(()=>{U8();t3();yO();mO()});function p6($,X,G){let Y=$.getEntityService(),J=$.getLogger().child(X),W=$.getDomain(),H=pO($);return{pluginId:X,logger:J,entityService:Y,identity:uO($,H),appInfo:H,domain:W,siteUrl:W?`https://${W}`:void 0,previewUrl:W?`https://${Q3(W)}`:void 0,entityDisplay:G?.entityDisplay,messaging:dO($,X,J),jobs:lO($,X),conversations:cO($),dataDir:$.getDataDir(),eval:rO($,X),insights:iO($),endpoints:nO($,X)}}var F8=B(()=>{I();oO()});var F$;var M8=B(()=>{DO();m6();F$=Q5("entities",{id:Y0("id").notNull(),entityType:Y0("entityType").notNull(),content:Y0("content").notNull(),contentHash:Y0("contentHash").notNull(),metadata:Y0("metadata",{mode:"json"}).$type().notNull().default(f6`'{}'`),created:B1("created").notNull().$defaultFn(()=>Date.now()),updated:B1("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:W$({columns:[$.id,$.entityType]})}})});import{createClient as Aa}from"@libsql/client";var sO=B(()=>{M8()});var aO;var tO=B(()=>{m6();aO=G$({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}})});var M$;var Q8=B(()=>{m6();tO();M$=Q5("embeddings",{entityId:Y0("entity_id").notNull(),entityType:Y0("entity_type").notNull(),embedding:aO("embedding").notNull(),contentHash:Y0("content_hash").notNull()},($)=>{return{pk:W$({columns:[$.entityId,$.entityType]})}})});import{createClient as La}from"@libsql/client";var WG=B(()=>{Q8()});var ja;var HG=B(()=>{I();ja=K.object({id:K.string().min(1,"Entity ID is required"),entityType:K.string().min(1,"Entity type is required"),contentHash:K.string().min(1,"Content hash is required"),operation:K.enum(["create","update"])})});var xa;var eO=B(()=>{I();M8();xa=K.object({limit:K.number().int().positive().optional().default(20),offset:K.number().int().min(0).optional().default(0),types:K.array(K.string()).optional().default([]),excludeTypes:K.array(K.string()).optional().default([]),weight:K.record(K.string(),K.number()).optional()})});var $Z=B(()=>{I()});var BE,la;var XZ=B(()=>{M8();Q8();I();BE=K.object({field:K.string(),direction:K.enum(["asc","desc"]),nullsFirst:K.boolean().optional()}),la=K.object({limit:K.number().int().positive().optional(),offset:K.number().int().min(0).optional().default(0),sortFields:K.array(BE).optional(),filter:K.object({metadata:K.record(K.string(),K.unknown()).optional()}).optional(),publishedOnly:K.boolean().optional()})});var GZ=()=>{};var YZ=B(()=>{I();GZ();M8();Q8()});var JZ=B(()=>{I()});var WZ=B(()=>{sO();WG();Q8();I();HG();eO();$Z();XZ();YZ();JZ()});function W2($,X){if(Object.keys(X).length===0)return $;let G=Object.fromEntries(Object.entries(X).filter(([,Y])=>Y!==void 0));return Q$.default.stringify($,G)}function UG($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(UG);if($!==null&&typeof $==="object"){let X={};for(let[G,Y]of Object.entries($))X[G]=UG(Y);return X}return $}function I0($,X){let{content:G,data:Y}=Q$.default($),J=UG(Y);return{content:G.trim(),metadata:X.parse(J)}}function KG($){if(Object.keys($).length===0)return"";let G=Q$.default.stringify("",$).match(/^---\n[\s\S]*?\n---/);return G?G[0]:""}var Q$;var q$=B(()=>{Q$=x8(C7(),1)});var HZ=B(()=>{I();q$()});class V1{entityType;schema;frontmatterSchema;isSingleton;hasBody;supportsCoverImage;fmSchema;bodyFormatter;constructor($){if(this.entityType=$.entityType,this.schema=$.schema,this.frontmatterSchema=$.frontmatterSchema,this.fmSchema=$.frontmatterSchema,this.bodyFormatter=$.bodyFormatter??CE,$.isSingleton!==void 0)this.isSingleton=$.isSingleton;if($.hasBody!==void 0)this.hasBody=$.hasBody;if($.supportsCoverImage!==void 0)this.supportsCoverImage=$.supportsCoverImage}toMarkdown($){let X=this.renderBody($),Y={...this.readExistingFrontmatter($.content)},J=Object.keys(this.frontmatterSchema.shape);for(let[W,H]of Object.entries($.metadata))if(J.includes(W))Y[W]=H;return this.buildMarkdown(X,Y)}renderBody($){return this.extractBody($.content)}readExistingFrontmatter($){try{return I0($,K.record(K.unknown())).metadata}catch{return{}}}extractMetadata($){return $.metadata}parseFrontMatter($,X){return I0($,X).metadata}getBodyTemplate(){return this.bodyFormatter.generateBodyTemplate()}generateFrontMatter($){let X=$.metadata;return KG(X)}extractBody($){try{return I0($,K.record(K.unknown())).content}catch{return $}}parseFrontmatter($){return I0($,this.fmSchema).metadata}buildMarkdown($,X){return W2($,X)}}var CE;var FG=B(()=>{I();q$();CE={generateBodyTemplate:()=>""}});var N1;var MG=B(()=>{I();N1=K.object({id:K.string(),entityType:K.string(),content:K.string(),created:K.string().datetime(),updated:K.string().datetime(),metadata:K.record(K.string(),K.unknown()),contentHash:K.string()})});var UZ=B(()=>{I();MG();FG()});var KZ=B(()=>{FG();UZ()});class u6{cache=null;cacheParseError=null;logger;entityService;entityType;defaultBody;constructor($,X,G,Y){this.entityService=$,this.logger=X.child(this.constructor.name),this.entityType=G,this.defaultBody=Y}async initialize(){if(await this.load())return;if(await this.load())return;this.logger.info(`No ${this.entityType} found, creating default ${this.entityType}`);try{let $=this.createContent(this.defaultBody);await this.entityService.createEntity({entity:{id:this.entityType,entityType:this.entityType,content:$,metadata:{}}}),await this.load(),this.logger.info(`Default ${this.entityType} created successfully`)}catch($){this.logger.error(`Failed to create default ${this.entityType}`,{error:$})}}get(){if(this.cache&&!this.cacheParseError)return this.parseBody(this.cache.content);return this.defaultBody}getContent(){if(this.cache)return this.cache.content;return this.createContent(this.defaultBody)}async refreshCache(){await this.load()}async load(){try{let $=await this.entityService.getEntity({entityType:this.entityType,id:this.entityType});if(this.cache=$,this.cacheParseError=null,$)try{return this.parseBody($.content),this.logger.debug(`${this.entityType} loaded`),!0}catch(X){return this.cacheParseError=X instanceof Error?X:Error(String(X)),this.logger.error(`Failed to parse ${this.entityType} \u2014 using default. Fix the entity content to clear this error.`,{error:this.cacheParseError.message}),!0}else this.logger.debug(`No ${this.entityType} found in database`)}catch($){this.logger.warn(`Failed to load ${this.entityType}`,{error:$}),this.cache=null,this.cacheParseError=null}return!1}}function QG($,X,G){let Y=Math.max(1,Math.ceil($/G));return{currentPage:X,totalPages:Y,totalItems:$,pageSize:G,hasNextPage:X<Y,hasPrevPage:X>1}}var O$;var FZ=B(()=>{I();O$=K.object({currentPage:K.number(),totalPages:K.number(),totalItems:K.number(),pageSize:K.number(),hasNextPage:K.boolean(),hasPrevPage:K.boolean()})});var v1=B(()=>{WZ();HG();HZ();KZ();WG();MG();q$();FZ()});function EE($){return $.replace(/:/g,"-")}function IE($){return $.split(/[:.-]/).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join(" ")}async function OG($,X,G){let Y=qG.get(X);if(Y!==void 0)return Y;let J=EE(X),W;try{W=await $.getEntity({entityType:"prompt",id:J})}catch{return G}if(W?.content){let H=I0(W.content,K.record(K.unknown())).content;return qG.set(X,H),H}try{let H=IE(X),U=W2(G,{title:H,target:X});await $.createEntity({entity:{id:J,entityType:"prompt",content:U,metadata:{title:H,target:X,slug:J}}})}catch{}return qG.set(X,G),G}var qG;var ZG=B(()=>{v1();I();qG=new Map});function Z$($){let X=$.getEntityService(),G=$.getEntityRegistry(),Y=$.getDataSourceRegistry();return{register:(J,W,H,U)=>{G.registerEntityType(J,W,H,U)},getAdapter:(J)=>{try{return G.getAdapter(J)}catch{return}},extendFrontmatterSchema:(J,W)=>{G.extendFrontmatterSchema(J,W)},getEffectiveFrontmatterSchema:(J)=>{return G.getEffectiveFrontmatterSchema(J)},registerCreateInterceptor:(J,W)=>{G.registerCreateInterceptor(J,W)},update:async(J)=>{return X.updateEntity({entity:J})},registerDataSource:(J)=>{Y.register(J)}}}function R$($){return{resolve:(X,G)=>{return OG($,X,G)}}}var RG=B(()=>{ZG()});function AG($,X,G){let Y=p6($,X,G),J=$.getEntityService(),W=$.getRenderService(),H=$.getContentService();return{...Y,entityService:J,entities:Z$($),templates:{register:(U,F)=>{$.registerTemplates(U,F??X)},format:(U,F)=>{return H.formatContent(U,F,{pluginId:X})},parse:(U,F)=>{return H.parseContent(U,F,X)},resolve:async(U,F)=>{return await H.resolveContent(U,F,X)},getCapabilities:(U)=>{let F=U.includes(":")?U:`${X}:${U}`,M=$.getTemplate(F);if(!M)return null;let Q=s4.getCapabilities(M);return{canGenerate:Q.canGenerate,canFetch:Q.canFetch,canRender:Q.canRender,isStaticOnly:Q.isStaticOnly}}},views:{get:(U)=>{return W.get(U)??void 0},list:()=>{return W.list()},hasRenderer:(U)=>{return W.hasRenderer(U,"web")},getRenderer:(U)=>{return W.getRenderer(U,"web")},validate:(U,F)=>{return W.validate(U,F)}},prompts:R$(J),registerInstructions:(U)=>{$.registerInstructions(X,U)}}}var BG=B(()=>{F8();RG();U5()});var d6;var MZ=B(()=>{s9();BG();d6=class d6 extends y6{type="service";getApiRoutes(){return[]}getWebRoutes(){return[]}async register($,X){let G=AG($,this.id,X);return this.context=G,this.setupMessageHandlers(G),await this.onRegister(G),this.getCapabilities()}get entityService(){return this.getContext().entityService}registerEntityType($,X,G,Y){this.getContext().entities.register($,X,G,Y)}async enqueueJob($){return this.getContext().jobs.enqueue($)}async enqueueBatch($,X){return this.getContext().jobs.enqueueBatch($,X)}async registerEntityTypes($){}async registerJobHandlers($){}async onRegister($){await this.registerEntityTypes($),await this.registerJobHandlers($)}}});function VG($,X,G){let Y=p6($,X,G),J=$.getEntityService();return{...Y,entityService:J,entities:Z$($),ai:{query:(W,H)=>$.query(W,H),generate:async(W)=>{return $.generateContent(W)},generateObject:async(W,H)=>{return $.generateObject(W,H)},generateImage:async(W,H)=>{return $.generateImage(W,H)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:R$(J)}}var NG=B(()=>{F8();RG()});function wG($,X,G){let Y=!1,J=!1;if($.jobs.registerHandler(G.job.type,G.job.handler),G.initialSync){let W=G.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(Y)return{success:!0};if(Y=!0,!(await W.shouldEnqueue?.()??!0))return X.info("Skipping derived entity projection initial sync",{projectionId:G.id,targetType:G.targetType}),{success:!0};return J=await QZ($,X,G,W.jobData,SE(W.jobOptions),"initial-sync"),{success:!0}})}if(G.sourceChange){let W=G.sourceChange,H=new Set(W.sourceTypes),U=W.events??["entity:created","entity:updated"],F=async(M)=>{if(W.requireInitialSync&&!Y)return{success:!0};let Q=M.payload,q=jE(W,Q);if(!q||!H.has("*")&&!H.has(q))return{success:!0};if(!(await W.shouldEnqueue?.(Q)??!0))return{success:!0};let Z=await W.jobData(Q);if(!Z)return{success:!0};return await QZ($,X,G,Z,W.jobOptions?.(Q),"source-change"),{success:!0}};for(let M of U)$.messaging.subscribe(M,F)}return{hasObservedInitialSync:()=>Y,hasQueuedInitialSync:()=>J}}function jE($,X){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return X.entityType}async function QZ($,X,G,Y,J,W){try{return await $.jobs.enqueue({type:G.job.type,data:Y,...J?{options:J}:{}}),X.info("Queued derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:W}),!0}catch(H){return X.error("Failed to queue derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:W,error:S0(H)}),!1}}function SE($){return typeof $==="function"?$():$}var _G=B(()=>{I()});var kE,H2;var qZ=B(()=>{s9();I();NG();_G();kE=K.object({});H2=class H2 extends y6{type="entity";derivedEntityProjectionControllers=new Map;constructor($,X,G={},Y=kE){super($,X,G,Y)}async register($,X){let G=VG($,this.id,X);if(this.context=G,this.setupMessageHandlers(G),G.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==H2.prototype.interceptCreate)G.entities.registerCreateInterceptor(this.entityType,(F,M)=>this.interceptCreate(F,M,G));let Y=this.createGenerationHandler(G);if(Y)G.jobs.registerHandler(`${this.entityType}:generation`,Y);let J=this.getTemplates();if(J&&Object.keys(J).length>0)$.registerTemplates(J,this.id);let W=this.getDataSources();for(let F of W)G.entities.registerDataSource(F);let H=this.getDerivedEntityProjections(G);for(let F of H){let M=wG(G,this.logger,F);this.derivedEntityProjectionControllers.set(F.id,M)}await this.onRegister(this.context);let U=await this.getInstructions();return{tools:[],resources:[],...U&&{instructions:U}}}async interceptCreate($,X,G){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}});var zG=B(()=>{F8()});var DG=B(()=>{s9();zG()});var OZ=()=>{};class l6{logger;constructor($){this.logger=$}buildDetailResult($,X){throw Error(`${this.id}: buildDetailResult() not implemented. Override this method or override fetch() to handle detail views.`)}parseQuery($){let X=B$.parse($);return{entityType:X.entityType??this.config.entityType,query:X.query??{}}}async fetch($,X,G){let Y=this.parseQuery($),J=G.entityService;if(Y.query.id){let H=await this.fetchDetail(Y.query.id,J);return X.parse(this.buildDetailResult(H.item,H.navigation))}let W=await this.fetchList(Y.query,J);return X.parse(this.buildListResult(W.items,W.pagination,Y.query))}async fetchDetail($,X){let G=await this.lookupEntity($,X),Y=this.transformEntity(G),J=null;if(this.config.enableNavigation)J=await this.resolveNavigation(G,X);return{item:Y,navigation:J}}async fetchList($,X,G){let Y=$.page??1,J=$.pageSize??$.limit??this.config.defaultLimit??100,W=(Y-1)*J,H=$.page!==void 0,[U,F]=await Promise.all([X.listEntities({entityType:this.config.entityType,options:{limit:J,offset:W,sortFields:this.config.defaultSort,...G}}),H?X.countEntities({entityType:this.config.entityType,options:G?.filter?{filter:G.filter}:void 0}):Promise.resolve(0)]),M=U.map((q)=>this.transformEntity(q)),Q=H?QG(F,Y,J):null;return{items:M,pagination:Q}}async resolveNavigation($,X,G){let Y=this.config.navigationLimit??1000,J=await X.listEntities({entityType:this.config.entityType,options:{limit:Y,sortFields:G??this.config.defaultSort}}),W=J.findIndex((Q)=>Q.id===$.id),H=W>0?J[W-1]:void 0,U=W<J.length-1?J[W+1]:void 0,F=H?this.transformEntity(H):null,M=U?this.transformEntity(U):null;return{prev:F,next:M}}async lookupEntity($,X){if(this.config.lookupField==="id"){let J=await X.getEntity({entityType:this.config.entityType,id:$});if(!J)throw Error(`${this.config.entityType} not found: ${$}`);return J}let Y=(await X.listEntities({entityType:this.config.entityType,options:{filter:{metadata:{slug:$}},limit:1}}))[0];if(!Y)throw Error(`${this.config.entityType} not found with slug: ${$}`);return Y}}var A$,B$;var ZZ=B(()=>{v1();I();A$=K.object({id:K.string().optional(),limit:K.number().optional(),page:K.number().optional(),pageSize:K.number().optional(),baseUrl:K.string().optional()}).passthrough(),B$=K.object({entityType:K.string().optional(),query:A$.optional()}).passthrough()});var c6,PG;var RZ=B(()=>{U8();I();c6=class c6 extends H8{context;entityType;constructor($,X,G){super($,{schema:G.schema,jobTypeName:G.jobTypeName});this.context=X,this.entityType=G.entityType}async afterCreate($,X,G,Y){}async onGenerationFailure($,X){}async process($,X,G){try{await this.reportProgress(G,{progress:i4.START,message:`Starting ${this.jobTypeName}`});let Y=await this.generate($,G);await this.reportProgress(G,{progress:i4.SAVE,message:`Saving ${this.entityType} to database`});let J=await this.context.entityService.createEntity({entity:{id:Y.id,entityType:this.entityType,content:Y.content,metadata:Y.metadata},options:Y.createOptions});return await this.afterCreate($,J.entityId,G,Y),await this.reportProgress(G,{progress:i4.COMPLETE,message:`${Y.title??this.entityType} created successfully`}),{success:!0,entityId:J.entityId,...Y.resultExtras}}catch(Y){if(Y instanceof PG)return await this.onGenerationFailure($,Y.message),{success:!1,error:Y.message};let J=S0(Y);return this.logger.error(`${this.jobTypeName} job failed`,{error:Y,jobId:X,data:this.summarizeDataForLog($)}),await this.onGenerationFailure($,J),O3.failure(Y)}}failEarly($){throw new PG($)}};PG=class PG extends Error{constructor($){super($);this.name="GenerationFailure"}}});var xE,AZ,BZ,bE;var VZ=B(()=>{G5();xE=K.object({userPermissionLevel:K.enum(["public","trusted","anchor"]).optional(),interfaceType:K.string().optional(),channelId:K.string().optional(),channelName:K.string().optional()}),AZ=K.object({toolName:K.string(),description:K.string(),args:K.unknown()}),BZ=K.object({toolName:K.string(),args:K.record(K.unknown()).optional(),jobId:K.string().optional(),data:K.unknown().optional()}),bE=K.object({text:K.string(),toolResults:K.array(BZ).optional(),pendingConfirmation:AZ.optional(),usage:K.object({promptTokens:K.number(),completionTokens:K.number(),totalTokens:K.number()})})});var hE,yE,fE,gE;var NZ=B(()=>{G5();hE=K.object({label:K.string(),url:K.string(),pluginId:K.string(),priority:K.number()}),yE=K.object({status:K.enum(["healthy","warning","error","unknown"]),message:K.string().optional(),lastCheck:K.string().optional(),details:K.record(K.unknown()).optional()}),fE=K.object({name:K.string(),pluginId:K.string(),status:K.string(),health:yE.optional()}),gE=K.object({model:K.string(),version:K.string(),uptime:K.number(),entities:K.number(),embeddings:K.number(),ai:K.object({model:K.string(),embeddingModel:K.string()}),daemons:K.array(fE),endpoints:K.array(hE)})});var mE,pE;var wZ=B(()=>{G5();e3();mE=K.union([K.object({success:K.boolean(),data:K.unknown().optional(),error:K.string().optional()}),K.object({noop:K.literal(!0)})]),pE=K.object({id:K.string(),timestamp:K.string(),type:K.string(),source:K.string(),target:K.string().optional(),metadata:K8.optional()})});var V$,_Z,zZ;var LG=B(()=>{m6();V$=Q5("conversations",{id:Y0("id").primaryKey(),sessionId:Y0("session_id").notNull(),interfaceType:Y0("interface_type").notNull(),channelId:Y0("channel_id").notNull(),started:Y0("started").notNull(),lastActive:Y0("last_active").notNull(),metadata:Y0("metadata"),created:Y0("created").notNull(),updated:Y0("updated").notNull()},($)=>({sessionIdx:o1("idx_conversations_session").on($.sessionId),channelIdx:o1("idx_conversations_channel").on($.channelId),interfaceSessionIdx:o1("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:o1("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),_Z=Q5("messages",{id:Y0("id").primaryKey(),conversationId:Y0("conversation_id").notNull().references(()=>V$.id,{onDelete:"cascade"}),role:Y0("role").notNull(),content:Y0("content").notNull(),timestamp:Y0("timestamp").notNull(),metadata:Y0("metadata")},($)=>({conversationIdx:o1("idx_messages_conversation").on($.conversationId),timestampIdx:o1("idx_messages_timestamp").on($.timestamp)})),zZ=Q5("summary_tracking",{conversationId:Y0("conversation_id").primaryKey().references(()=>V$.id,{onDelete:"cascade"}),lastSummarizedAt:Y0("last_summarized_at"),lastMessageId:Y0("last_message_id"),messagesSinceSummary:B1("messages_since_summary").default(0),updated:Y0("updated").notNull()})});import{createClient as G00}from"@libsql/client";var DZ=B(()=>{LG()});var uE,PZ;var CG=B(()=>{I();uE=K.object({id:K.string(),conversationId:K.string(),role:K.string(),content:K.string(),timestamp:K.string(),metadata:K.string().nullable()}),PZ=K.object({conversationId:K.string(),messageCount:K.number(),messages:K.array(uE),windowStart:K.number(),windowEnd:K.number(),windowSize:K.number(),timestamp:K.string()})});var LZ=B(()=>{DZ();CG();LG();I()});var CZ=B(()=>{LZ();CG()});var TG=B(()=>{U8()});var cE,EG;var TZ=B(()=>{I();cE=["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"],EG=K.object({captureUrls:K.boolean().default(!1),blockedUrlDomains:K.array(K.string()).default(cE)})});var EZ=B(()=>{DG();TG();TZ()});var IZ=()=>{};var jZ=B(()=>{EZ();TG();IZ()});async function q8($){let{entityType:X,title:G,deriveId:Y,regeneratePrompt:J,context:W}=$,H=Y(G);if(!await W.entityService.getEntity({entityType:X,id:H}))return G;W.logger.debug(`Entity ID collision: ${X}/${H}, asking AI for a new title`);let F=K.object({title:K.string().max(80).describe("A short, unique title (2-6 words)")}),{object:M}=await W.ai.generateObject(`The title "${G}" is already taken. ${J}`,F),Q=M.title;return W.logger.debug(`AI suggested new title: "${Q}"`),Q}var SZ=B(()=>{I()});var eE,kZ,$I,vZ,XI,GI,YI,JI;var xZ=B(()=>{I();eE=K.object({id:K.string(),template:K.string(),content:K.unknown().optional(),dataQuery:K.object({entityType:K.string().optional(),template:K.string().optional(),query:K.object({id:K.string().optional(),limit:K.number().optional(),offset:K.number().optional()}).passthrough().optional()}).passthrough().optional(),order:K.number().optional()}),kZ=["primary","secondary"],$I=K.object({show:K.boolean().default(!1),label:K.string().optional(),slot:K.enum(kZ).default("primary"),priority:K.number().min(0).max(100).default(50)}).optional(),vZ=K.object({id:K.string(),path:K.string(),title:K.string().default(""),description:K.string().default(""),sections:K.array(eE).default([]),layout:K.string().default("default"),fullscreen:K.boolean().optional(),pluginId:K.string().optional(),sourceEntityType:K.string().optional(),external:K.boolean().optional(),navigation:$I}),XI=K.object({routes:K.array(vZ),pluginId:K.string()}),GI=K.object({paths:K.array(K.string()).optional(),pluginId:K.string().optional()}),YI=K.object({pluginId:K.string().optional()}),JI=K.object({path:K.string()})});var WI;var bZ=B(()=>{I();WI=K.object({enabled:K.boolean().describe("Whether the plugin is enabled"),debug:K.boolean().describe("Enable debug logging for this plugin")})});var IG,N$;var jG=B(()=>{I();v1();IG=N1.extend({id:K.literal("brain-character"),entityType:K.literal("brain-character")}),N$=K.object({name:K.string().describe("The brain's friendly display name"),role:K.string().describe("The brain's primary role"),purpose:K.string().describe("The brain's purpose and goals"),values:K.array(K.string()).describe("Core values that guide behavior")})});var w$;var SG=B(()=>{v1();jG();w$=class w$ extends V1{constructor(){super({entityType:"brain-character",schema:IG,frontmatterSchema:N$,isSingleton:!0,hasBody:!1})}createCharacterContent($){return this.buildMarkdown("",$)}parseCharacterBody($){return this.parseFrontmatter($)}toMarkdown($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}fromMarkdown($){return{content:$,entityType:"brain-character"}}extractMetadata($){let X=this.parseFrontmatter($.content);return{role:X.role,values:X.values}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}});var U2;var hZ=B(()=>{v1();SG();U2=class U2 extends u6{static instance=null;adapter=new w$;static getDefaultCharacter(){return{name:"Brain",role:"Knowledge assistant",purpose:"Help organize, understand, and retrieve information from your knowledge base",values:["clarity","accuracy","helpfulness"]}}static getInstance($,X,G){return U2.instance??=new U2($,X,G),U2.instance}static resetInstance(){U2.instance=null}static createFresh($,X,G){return new U2($,X,G)}constructor($,X,G){super($,X,"brain-character",G??U2.getDefaultCharacter())}parseBody($){return this.adapter.parseCharacterBody($)}createContent($){return this.adapter.createCharacterContent($)}getCharacter(){return this.get()}getCharacterContent(){return this.getContent()}}});async function q5($){let G=(await $.listEntities({entityType:"anchor-profile",options:{limit:1}}))[0];if(!G)throw Error("Profile not found \u2014 create an anchor-profile entity");return G.content}var r6;var yZ=B(()=>{I();r6=K.object({tagline:K.string().optional().describe("Short, punchy one-liner for homepage"),intro:K.string().optional().describe("Optional longer introduction for homepage"),story:K.string().optional().describe("Extended bio/narrative (multi-paragraph markdown)")})});var kG,O5;var vG=B(()=>{I();v1();kG=N1.extend({id:K.literal("anchor-profile"),entityType:K.literal("anchor-profile")}),O5=K.object({name:K.string().describe("Name (person or organization)"),kind:K.enum(["professional","team","collective"]).describe("Type of anchor: professional (individual), team, or collective"),organization:K.string().optional().describe("Organization the anchor belongs to"),description:K.string().optional().describe("Short description or biography"),avatar:K.string().optional().describe("URL or asset path to avatar/logo"),website:K.string().optional().describe("Primary website URL"),email:K.string().optional().describe("Contact email"),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")})).optional().describe("Social media and contact links")})});var m1;var xG=B(()=>{v1();vG();m1=class m1 extends V1{constructor(){super({entityType:"anchor-profile",schema:kG,frontmatterSchema:O5,isSingleton:!0,hasBody:!0})}createProfileContent($){let X=O5.parse($);return this.buildMarkdown("",X)}parseProfileBody($,X){if(X){let{metadata:G,content:Y}=I0($,X);return Y?{...G,story:Y}:G}return this.parseFrontmatter($)}fromMarkdown($){return{content:$,entityType:"anchor-profile"}}extractMetadata($){let X=this.parseFrontmatter($.content);return{name:X.name,email:X.email,website:X.website}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}});var I5;var fZ=B(()=>{v1();xG();I5=class I5 extends u6{static instance=null;adapter=new m1;static getDefaultProfile(){return{name:"Unknown",kind:"professional"}}static getInstance($,X,G){return I5.instance??=new I5($,X,G),I5.instance}static resetInstance(){I5.instance=null}static createFresh($,X,G){return new I5($,X,G)}constructor($,X,G){super($,X,"anchor-profile",G??I5.getDefaultProfile())}parseBody($){return this.adapter.parseProfileBody($)}createContent($){return this.adapter.createProfileContent($)}getProfile(){return this.get()}getProfileContent(){return this.getContent()}}});var d2=B(()=>{hZ();SG();jG();yZ();fZ();xG();vG()});var gZ,HI,UI,KI;var mZ=B(()=>{I();d2();gZ=K.object({id:K.string(),description:K.string(),name:K.string().optional(),tags:K.array(K.string()).optional().default([])}).passthrough(),HI=K.object({uri:K.string(),params:K.record(K.unknown()).optional()}).passthrough(),UI=K.object({name:K.string(),url:K.string(),description:K.string().optional(),skills:K.array(gZ).optional().default([]),capabilities:K.object({extensions:K.array(HI).optional().default([])}).passthrough().optional()}).passthrough(),KI=K.object({name:K.string(),description:K.string(),tags:K.array(K.string()),examples:K.array(K.string())})});var i6=()=>{};var s1;var O8=B(()=>{s1=class s1 extends Error{pluginId;constructor($,X){super(`Plugin ${$}: ${X}`);this.name="PluginError",this.pluginId=$}}});class bG{plugins;events;daemonRegistry;logger;constructor($,X,G,Y){this.plugins=$;this.events=X;this.daemonRegistry=G;this.logger=Y.child("PluginLifecycle")}async initializePlugin($,X,G){let Y=this.plugins.get($);if(!Y)throw new s1($,"Registration failed: Plugin is not registered");let J=Y.plugin;this.logger.debug(`Initializing plugin: ${$}`),this.events.emit("plugin:before_initialize",$,J);try{let W=await J.register(X,G);return Y.status="initialized",this.logger.debug(`Initialized plugin: ${$}`),this.events.emit("plugin:initialized",$,J),W}catch(W){let H=S0(W);throw this.logger.error(`Error initializing plugin ${$}: ${H}`),Y.status="error",Y.error=n4(W),this.events.emit("plugin:error",$,W),W}}async readyPlugin($){let X=this.plugins.get($);if(!X)throw new s1($,"Ready failed: Plugin is not registered");if(X.status!=="initialized"){this.logger.debug(`Skipping ready hook for non-initialized plugin: ${$}`);return}try{await X.plugin.ready?.(),this.logger.debug(`Ready hook completed for plugin: ${$}`)}catch(G){let Y=n4(G);throw X.status="error",X.error=Y,this.events.emit("plugin:error",$,Y),Y}}async startPluginDaemons($){let X=this.plugins.get($);if(X?.status!=="initialized")return;try{await this.daemonRegistry.startPlugin($),this.logger.debug(`Started daemons for plugin: ${$}`)}catch(G){if(X.plugin.requiresDaemonStartup?.())throw G;this.logger.warn(`Daemon ${$} failed to start: ${S0(G)}`)}}async disablePlugin($){let X=this.plugins.get($);if(!X){this.logger.warn(`Cannot disable plugin ${$}: not registered`);return}this.logger.debug(`Disabling plugin: ${$}`);try{await this.daemonRegistry.stopPlugin($),this.logger.debug(`Stopped daemons for plugin: ${$}`)}catch(G){this.logger.error(`Failed to stop daemons for plugin: ${$}`,G)}if(X.plugin.shutdown)try{await X.plugin.shutdown(),this.logger.debug(`Shutdown completed for plugin: ${$}`)}catch(G){this.logger.error(`Plugin shutdown failed for ${$}:`,G)}X.status="disabled",this.events.emit("plugin:disabled",$,X.plugin),this.logger.debug(`Disabled plugin: ${$}`)}async enablePlugin($){let X=this.plugins.get($);if(!X){this.logger.warn(`Cannot enable plugin ${$}: not registered`);return}if(X.status!=="disabled"){this.logger.warn(`Cannot enable plugin ${$}: not disabled`);return}this.logger.debug(`Enabling plugin: ${$}`),X.status="initialized";try{await this.daemonRegistry.startPlugin($),this.logger.debug(`Started daemons for plugin: ${$}`)}catch(G){this.logger.error(`Failed to start daemons for plugin: ${$}`,G)}this.events.emit("plugin:enabled",$,X.plugin),this.logger.debug(`Enabled plugin: ${$}`)}}var pZ=B(()=>{I();i6();O8()});class hG{plugins;events;logger;constructor($,X,G){this.plugins=$;this.events=X;this.logger=G.child("DependencyResolver")}async resolveInitializationOrder($){this.logger.debug("Resolving plugin initialization order...");let X=Array.from(this.plugins.keys()),G=new Set,Y=!0;while(Y&&G.size<X.length){Y=!1;for(let H of X){if(G.has(H))continue;if(!this.plugins.get(H))continue;if(this.getUnmetDependencies(H).length===0)try{await $(H),G.add(H),Y=!0}catch(M){let Q=S0(M);this.logger.error(`Failed to initialize plugin ${H}: ${Q}`),G.add(H),Y=!0}}}let J=X.filter((H)=>!G.has(H));if(J.length>0){let H=J.join(", ");this.logger.error(`Failed to initialize plugins due to dependency issues: ${H}`);for(let U of J){let F=this.getUnmetDependencies(U);this.logger.error(`Plugin ${U} has unmet dependencies: ${F.join(", ")}`);let M=this.plugins.get(U);if(M)M.status="error",M.error=new s1(U,`Unmet dependencies: ${F.join(", ")}`);this.events.emit("plugin:error",U,M?.error)}}let W=new Set;for(let[H,U]of this.plugins)if(U.status==="initialized")W.add(H);return this.logger.debug(`Resolved ${W.size} of ${X.length} plugins`),{initialized:W,failed:J}}getUnmetDependencies($){let X=this.plugins.get($);if(!X)return[];let{dependencies:G}=X,Y=[];for(let J of G){let W=this.plugins.get(J);if(!W){Y.push(J);continue}if(W.status!=="initialized")Y.push(J)}return Y}}var uZ=B(()=>{I();i6();O8()});class yG{logger;constructor($){this.logger=$.child("CapabilityRegistrar")}async registerCapabilities($,X,G){if(G.tools.length>0)$.registerTools(X,G.tools),this.logger.debug(`Registered ${G.tools.length} tools from ${X}`);if(G.resources.length>0)$.registerResources(X,G.resources),this.logger.debug(`Registered ${G.resources.length} resources from ${X}`);if(G.instructions)$.registerInstructions(X,G.instructions),this.logger.debug(`Registered instructions from ${X}`)}}import{EventEmitter as dZ}from"events";class K2{static instance=null;plugins=new Map;logger;events=new dZ;daemonRegistry;shell=null;initializedPluginIds=[];pluginLifecycle;dependencyResolver;capabilityRegistrar;static getInstance($,X){return K2.instance??=new K2($,X),K2.instance}static resetInstance(){K2.instance=null}static createFresh($,X){return new K2($,X)}setShell($){this.shell=$}constructor($,X){this.logger=$.child("PluginManager"),this.events=new dZ,this.daemonRegistry=X,this.pluginLifecycle=new bG(this.plugins,this.events,this.daemonRegistry,$),this.dependencyResolver=new hG(this.plugins,this.events,$),this.capabilityRegistrar=new yG($)}registerPlugin($){if(!$.id)throw new s1("unknown","Registration failed: Plugin must have an id");if(this.logger.debug(`Registering plugin: ${$.id} (${$.version})`),this.plugins.has($.id)){let J=this.plugins.get($.id)?.plugin.version;throw new s1($.id,`Registration failed: Plugin is already registered with version ${J}`)}let X=$.dependencies??[],G={plugin:$,status:"registered",dependencies:X};this.plugins.set($.id,G),this.logger.debug(`Registered plugin: ${$.id} (${$.version})`),this.events.emit("plugin:registered",$.id,$)}async initializePlugins($){this.logger.debug("Initializing plugins..."),this.initializedPluginIds=[];let X=await this.dependencyResolver.resolveInitializationOrder(async(G)=>{await this.initializePlugin(G,$)});this.logger.debug(`Initialized ${X.initialized.size} of ${this.plugins.size} plugins`)}async initializePlugin($,X){if(!this.shell)throw new s1($,"Cannot initialize plugin: Shell not set. Call setShell() first.");let G=this.shell,Y=await this.pluginLifecycle.initializePlugin($,G,X);await this.capabilityRegistrar.registerCapabilities(G,$,Y),this.initializedPluginIds.push($)}async readyPlugins(){this.logger.debug("Dispatching plugin ready hooks..."),await Promise.all(this.initializedPluginIds.map(($)=>this.pluginLifecycle.readyPlugin($)))}async startPluginDaemons(){this.logger.debug("Starting plugin daemons..."),await Promise.all(this.initializedPluginIds.map(($)=>this.pluginLifecycle.startPluginDaemons($)))}getPlugin($){return this.plugins.get($)?.plugin}getPluginStatus($){return this.plugins.get($)?.status}hasPlugin($){return this.plugins.has($)}isPluginInitialized($){return this.plugins.get($)?.status==="initialized"}getAllPluginIds(){return Array.from(this.plugins.keys())}getAllPlugins(){return new Map(this.plugins)}getFailedPlugins(){return Array.from(this.plugins.entries()).filter(($)=>$[1].status==="error"&&$[1].error!==void 0).map(([$,X])=>({id:$,error:X.error}))}getPluginPackageName($){return this.plugins.get($)?.plugin.packageName}async disablePlugin($){await this.pluginLifecycle.disablePlugin($)}async enablePlugin($){await this.pluginLifecycle.enablePlugin($)}on($,X){this.events.on($,X)}once($,X){this.events.once($,X)}off($,X){this.events.off($,X)}getEventEmitter(){return this.events}}var lZ=B(()=>{i6();O8();pZ();uZ();i6()});var cZ=B(()=>{lZ();i6()});var Q0=B(()=>{MZ();qZ();_G();NG();ZG();DG();OZ();t3();BG();F8();zG();w3();v1();ZZ();v1();U8();RZ();U5();VZ();NZ();XG();JG();wZ();CZ();jZ();N3();SZ();I();xZ();bZ();d2();mZ();cZ();O8()});var FI,Q1,MI,n6,Z8,a1,R8;var Z5=B(()=>{I();Q0();FI=K.enum(["draft","queued","published"]),Q1=K.object({title:K.string(),slug:K.string().optional(),status:FI,publishedAt:K.string().datetime().optional(),excerpt:K.string(),author:K.string(),coverImageId:K.string().optional(),seriesName:K.string().optional(),seriesIndex:K.number().optional(),ogImage:K.string().url().optional(),ogDescription:K.string().optional(),twitterCard:K.enum(["summary","summary_large_image"]).optional(),canonicalUrl:K.string().url().optional()}),MI=Q1.pick({title:!0,status:!0,publishedAt:!0,seriesName:!0,seriesIndex:!0}).extend({slug:K.string()}),n6=N1.extend({entityType:K.literal("post"),metadata:MI}),Z8=n6.extend({frontmatter:Q1,body:K.string(),coverImageUrl:K.string().optional()}),a1=Z8.extend({url:K.string().optional(),typeLabel:K.string().optional(),listUrl:K.string().optional(),listLabel:K.string().optional(),seriesUrl:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional(),coverImageSrcset:K.string().optional(),coverImageSizes:K.string().optional()}),R8=Z8.extend({url:K.string(),typeLabel:K.string(),listUrl:K.string(),listLabel:K.string(),seriesUrl:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional(),coverImageSrcset:K.string().optional(),coverImageSizes:K.string().optional()})});var rZ={};b8(rZ,{blogPostAdapter:()=>l2,BlogPostAdapter:()=>D$});var D$,l2;var A8=B(()=>{Q0();I();Z5();D$=class D$ extends V1{constructor(){super({entityType:"post",schema:n6,frontmatterSchema:Q1,supportsCoverImage:!0})}toMarkdown($){let X=this.extractBody($.content);try{let G=this.parseFrontMatter($.content,Q1),Y={...G,slug:G.slug??$.metadata.slug};return this.buildMarkdown(X,Y)}catch{return X}}fromMarkdown($){let X=this.parseFrontMatter($,Q1),G=X.slug??f1(X.title);return{content:$,entityType:"post",metadata:{title:X.title,slug:G,status:X.status,publishedAt:X.publishedAt,seriesName:X.seriesName,seriesIndex:X.seriesIndex}}}parsePostFrontmatter($){return this.parseFrontMatter($.content,Q1)}createPostContent($,X){return this.buildMarkdown(X,$)}};l2=new D$});function b1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function TR($){return new Date($).toUTCString()}function S$($,X){let G=$.filter((M)=>{if(X.includeAllPosts)return!0;return M.frontmatter.status==="published"&&M.frontmatter.publishedAt}).sort((M,Q)=>{let q=new Date(M.frontmatter.publishedAt??M.created);return new Date(Q.frontmatter.publishedAt??Q.created).getTime()-q.getTime()}),Y=G.length>0&&G[0]?G[0].frontmatter.publishedAt??G[0].created:new Date().toISOString(),J=G.map((M)=>{let Q=`${X.link}/posts/${M.metadata.slug}`,q=M.frontmatter.publishedAt??M.created,A=M.frontmatter.excerpt,Z=M.frontmatter.author;return` <item>
|
|
172
|
+
`).trim();return{attributes:X,markdown:G}}function R3($){let X=$.split(IT);return X.length>1?X:null}var NQ,IT;var wQ=B(()=>{NQ=/<!--\s*\.slide:\s*(.*?)\s*-->/g;IT=/<!--\s*\.break\s*-->/});function vT($){return $.replace(kT,(X)=>ST[X]??X)}function n9($){return $.replace(jT,(X,G)=>{return`<div class="mermaid">${vT(G)}</div>`})}var jT,ST,kT;var _Q=B(()=>{jT=/<pre><code class="language-mermaid">([\s\S]*?)<\/code><\/pre>/g,ST={"&":"&","<":"<",">":">",""":'"',"'":"'"},kT=/&(?:amp|lt|gt|quot|#39);/g});var I=B(()=>{YJ();J7();J7();UM();aM();qQ();q3();OQ();r9();x6();ZQ();RQ();AQ();BQ();VQ();wQ();_Q();UQ()});var bT,PQ;var LQ=B(()=>{I();bT=K.object({status:K.enum(["healthy","warning","error","unknown"]),message:K.string().optional(),lastCheck:K.date().optional(),details:K.record(K.string(),K.unknown()).optional()}),PQ=K.object({name:K.string(),pluginId:K.string(),status:K.string(),health:bT.optional()})});var A3;var B3=B(()=>{I();A3=K.enum(["anchor","trusted","public"])});function CQ($,X){return(G)=>{let Y=$.parse(G);return X(Y)}}function L0($){let{layout:X,schema:G,...Y}=$,J={...Y,schema:G};if(X){if(J.layout={},X.component)J.layout.component=CQ(G,X.component);if(X.fullscreen!==void 0)J.layout.fullscreen=X.fullscreen}return J}var hT;var TQ=B(()=>{I();B3();hT=K.object({name:K.string(),description:K.string(),schema:K.any(),basePrompt:K.string().optional(),useKnowledgeContext:K.boolean().optional(),requiredPermission:A3,formatter:K.any().optional(),layout:K.object({component:K.any(),fullscreen:K.boolean().optional()}).optional(),dataSourceId:K.string().optional()})});class s4{static canGenerate($){return!!$.basePrompt&&!!$.dataSourceId&&$.dataSourceId.includes("ai-content")}static canFetch($){return!!$.dataSourceId&&!this.canGenerate($)}static canRender($){return!!$.layout?.component}static isStaticOnly($){return!this.canGenerate($)&&!this.canFetch($)}static getCapabilities($){return{canGenerate:this.canGenerate($),canFetch:this.canFetch($),canRender:this.canRender($),isStaticOnly:this.isStaticOnly($)}}static validate($){let X=[];if($.dataSourceId?.includes("ai-content")&&!$.basePrompt)X.push(`Template "${$.name}" has AI-content dataSourceId but no basePrompt. AI generation requires a basePrompt.`);if($.basePrompt&&(!$.dataSourceId||!$.dataSourceId.includes("ai-content")))X.push(`Template "${$.name}" has basePrompt but no AI-content dataSourceId. The basePrompt won't be used.`);return X}static logCapabilities($,X){let G=this.getCapabilities($),Y=this.validate($);if(X)X.debug(`Template capabilities for "${$.name}":`,{...G,errors:Y.length>0?Y:void 0})}}var EQ=()=>{};var yT,fT,gT,mT;var IQ=B(()=>{I();yT=K.enum(["site-content-preview","site-content-production"]),fT=K.object({name:K.string(),schema:K.any(),description:K.string().optional(),pluginId:K.string(),renderers:K.object({web:K.union([K.function(),K.string()]).optional()})}),gT=K.object({enableContentGeneration:K.boolean().default(!1),outputDir:K.string(),workingDir:K.string().optional(),environment:K.enum(["preview","production"]).default("preview"),siteConfig:K.object({title:K.string(),description:K.string(),url:K.string().optional()}).optional()}),mT=K.object({success:K.boolean(),routesBuilt:K.number(),errors:K.array(K.string()).optional(),warnings:K.array(K.string()).optional()})});var U5=B(()=>{TQ();EQ();B3();IQ()});import{McpServer as tl,ResourceTemplate as el}from"@modelcontextprotocol/sdk/server/mcp.js";var SQ=B(()=>{U5();I()});var kQ=B(()=>{SQ()});var o9,vQ,xQ,bQ,V3;var hQ=B(()=>{I();o9=K.object({interfaceType:K.string(),userId:K.string(),channelId:K.string().optional(),channelName:K.string().optional()}),vQ=K.object({success:K.literal(!0),data:K.unknown(),message:K.string().optional()}),xQ=K.object({success:K.literal(!1),error:K.string(),code:K.string().optional()}),bQ=K.object({needsConfirmation:K.literal(!0),toolName:K.string(),description:K.string(),args:K.unknown()}),V3=K.union([vQ,xQ,bQ])});var yQ;var fQ=B(()=>{I();yQ=K.union([K.object({success:K.literal(!0),data:K.unknown(),message:K.string().optional()}),K.object({success:K.literal(!1),error:K.string(),code:K.string().optional()})])});var gQ=B(()=>{I()});var N3=B(()=>{kQ();hQ();fQ();gQ()});var Tc,Ec,mQ,cT,rT;var w3=B(()=>{I();I();LQ();N3();Tc=K.object({id:K.string(),type:K.string(),version:K.string(),status:K.string()}),Ec=K.object({name:K.string(),description:K.string()}),mQ=K.object({label:K.string(),url:K.string(),pluginId:K.string(),priority:K.number().default(100)}),cT=K.object({model:K.string(),version:K.string(),uptime:K.number(),entities:K.number(),embeddings:K.number(),ai:K.object({model:K.string(),embeddingModel:K.string()}),daemons:K.array(PQ),endpoints:K.array(mQ)}),rT=K.object({id:K.string(),version:K.string(),type:K.enum(["core","entity","service","interface"]),description:K.string().optional(),dependencies:K.array(K.string()).optional(),packageName:K.string()})});class y6{id;version;description;packageName;config;context;get logger(){return this.context?.logger??t0.createFresh({context:this.id})}constructor($,X,G,Y){this.id=$,this.packageName=X.name,this.version=X.version,this.description=X.description??`${X.name} plugin`,this.config=Y.parse(G)}setupMessageHandlers($){$.messaging.subscribe(`plugin:${this.id}:tool:execute`,async(X)=>{try{let{toolName:G,args:Y,progressToken:J,hasProgress:W,interfaceType:H,userId:U,channelId:F}=iT.parse(X.payload),Q=(await this.getTools()).find((Z)=>Z.name===G);if(!Q)return{success:!1,error:`Tool not found: ${G}`};let q={interfaceType:H,userId:U,...F&&{channelId:F},...W&&J!==void 0&&{progressToken:J,sendProgress:async(Z)=>{await $.messaging.send({type:`plugin:${this.id}:progress`,payload:{progressToken:J,notification:Z}})}}};return{success:!0,data:await Q.handler(Y,q)}}catch(G){if(G instanceof K.ZodError)return{success:!1,error:"Invalid tool execution request format"};return this.logger.error("Tool execution error",G),{success:!1,error:S0(G)}}}),$.messaging.subscribe(`plugin:${this.id}:resource:get`,async(X)=>{try{let{resourceUri:G}=nT.parse(X.payload),J=(await this.getResources()).find((H)=>H.uri===G);if(!J)return{success:!1,error:`Resource not found: ${G}`};return{success:!0,data:await J.handler()}}catch(G){if(G instanceof K.ZodError)return{success:!1,error:"Invalid resource get request format"};return this.logger.error("Resource fetch error",G),{success:!1,error:S0(G)}}})}async onRegister($){}async onReady($){}async ready(){await this.onReady(this.getContext())}async getCapabilities(){let $=await this.getInstructions();return{tools:await this.getTools(),resources:await this.getResources(),...$&&{instructions:$}}}async getTools(){return[]}async getResources(){return[]}async getInstructions(){return}async shutdown(){await this.onShutdown()}async onShutdown(){}getContext(){if(!this.context)throw Error(`Plugin ${this.id}: Plugin not registered yet`);return this.context}determineUserPermissionLevel($){return"public"}createProgressBridge($){if(!$)return;let X=this.context;if(!X)return;let G=this.id;return o5.from(async(Y)=>{await X.messaging.send({type:`plugin:${G}:progress`,payload:{progressToken:$,notification:{progress:Y.progress,total:Y.total,message:Y.message}}})})}}var iT,nT;var s9=B(()=>{w3();I();I();iT=K.object({toolName:K.string(),args:K.unknown(),progressToken:K.union([K.string(),K.number()]).optional(),hasProgress:K.boolean().optional(),...o9.shape}),nT=K.object({resourceUri:K.string()})});var pQ,uQ,a4,hc;var a9=B(()=>{I();pQ=K.enum(["file_operations","content_operations","data_processing","batch_processing"]),uQ=K.object({pluginId:K.string().optional(),progressToken:K.union([K.string(),K.number()]).optional(),operationType:pQ,operationTarget:K.string().optional(),interfaceType:K.string().optional(),channelId:K.string().optional()}),a4=uQ.extend({rootJobId:K.string()}),hc=K.enum(["none","skip","replace","coalesce"])});var _3,dQ,oT,sT,lQ,z3;var e5=B(()=>{I();a9();_3=K.enum(["pending","processing","completed","failed"]),dQ=K.enum(["completed","failed"]),oT=K.object({id:K.string(),type:K.string(),status:_3,data:K.unknown(),result:K.unknown().optional(),lastError:K.string().optional().nullable(),attempts:K.number(),maxRetries:K.number(),priority:K.number(),createdAt:K.date(),updatedAt:K.date(),processedAt:K.date().optional().nullable(),completedAt:K.date().optional().nullable(),failedAt:K.date().optional().nullable()}),sT=K.object({jobId:K.string(),type:K.string(),status:dQ,result:K.unknown().optional(),error:K.string().optional()}),lQ=K.object({success:K.literal(!1),error:K.string().optional()}),z3=K.object({id:K.string(),type:K.enum(["job","batch"]),status:_3,message:K.string().optional(),progress:K.object({current:K.number(),total:K.number(),percentage:K.number()}).optional(),aggregationKey:K.string().optional(),batchDetails:K.object({totalOperations:K.number(),completedOperations:K.number(),failedOperations:K.number(),currentOperation:K.string().optional(),errors:K.array(K.string()).optional()}).optional(),jobDetails:K.object({jobType:K.string(),priority:K.number(),retryCount:K.number()}).optional(),metadata:a4})});function e($,X){if(!$||typeof $!=="object")return!1;if($ instanceof X)return!0;if(!Object.prototype.hasOwnProperty.call(X,k))throw Error(`Class "${X.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let G=Object.getPrototypeOf($).constructor;if(G)while(G){if(k in G&&G[k]===X[k])return!0;G=Object.getPrototypeOf(G)}return!1}var k;var w0=B(()=>{k=Symbol.for("drizzle:entityKind")});var P1;var $2=B(()=>{w0();P1=class P1{constructor($,X){this.table=$,this.config=X,this.name=X.name,this.keyAsName=X.keyAsName,this.notNull=X.notNull,this.default=X.default,this.defaultFn=X.defaultFn,this.onUpdateFn=X.onUpdateFn,this.hasDefault=X.hasDefault,this.primary=X.primaryKey,this.isUnique=X.isUnique,this.uniqueName=X.uniqueName,this.uniqueType=X.uniqueType,this.dataType=X.dataType,this.columnType=X.columnType,this.generated=X.generated,this.generatedIdentity=X.generatedIdentity}static[k]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue($){return $}mapToDriverValue($){return $}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}});var D3;var P3=B(()=>{w0();D3=class D3{static[k]="ColumnBuilder";config;constructor($,X,G){this.config={name:$,keyAsName:$==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:X,columnType:G,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default($){return this.config.default=$,this.config.hasDefault=!0,this}$defaultFn($){return this.config.defaultFn=$,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn($){return this.config.onUpdateFn=$,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName($){if(this.config.name!=="")return;this.config.name=$}}});var n1;var t4=B(()=>{n1=Symbol.for("drizzle:Name")});function cQ($,...X){return $(...X)}var rQ=()=>{};function iQ($,X){return`${$[n1]}_${X.join("_")}_unique`}var nQ=B(()=>{t4()});var e4,aT;var oQ=B(()=>{$2();w0();nQ();e4=class e4 extends P1{constructor($,X){if(!X.uniqueName)X.uniqueName=iQ($,[X.name]);super($,X);this.table=$}static[k]="PgColumn"};aT=class aT extends e4{static[k]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op($){return this.indexConfig.opClass=$,this}}});function aQ($){return!!$&&typeof $==="function"&&sQ in $&&$[sQ]===!0}var tT,sQ,eT;var tQ=B(()=>{w0();oQ();tT=class tT extends e4{static[k]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}};sQ=Symbol.for("drizzle:isPgEnum");eT=class eT extends e4{static[k]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor($,X){super($,X);this.enum=X.enum}getSQLType(){return this.enum.enumName}}});var A1;var X2=B(()=>{w0();A1=class A1{static[k]="Subquery";constructor($,X,G,Y=!1,J=[]){this._={brand:"Subquery",sql:$,selectedFields:X,alias:G,isWith:Y,usedTables:J}}}});var eQ="0.44.7";var $q=()=>{};var L3,C3,Xq;var Gq=B(()=>{rQ();$q();Xq={startActiveSpan($,X){if(!L3)return X();if(!C3)C3=L3.trace.getTracer("drizzle-orm",eQ);return cQ((G,Y)=>Y.startActiveSpan($,(J)=>{try{return X(J)}catch(W){throw J.setStatus({code:G.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Unknown error"}),W}finally{J.end()}}),L3,C3)}}});var m0;var G2=B(()=>{m0=Symbol.for("drizzle:ViewBaseConfig")});var T3,Yq,Jq,E3,I3,$8,Wq,$E,W0;var T5=B(()=>{w0();t4();T3=Symbol.for("drizzle:Schema"),Yq=Symbol.for("drizzle:Columns"),Jq=Symbol.for("drizzle:ExtraConfigColumns"),E3=Symbol.for("drizzle:OriginalName"),I3=Symbol.for("drizzle:BaseName"),$8=Symbol.for("drizzle:IsAlias"),Wq=Symbol.for("drizzle:ExtraConfigBuilder"),$E=Symbol.for("drizzle:IsDrizzleTable");W0=class W0{static[k]="Table";static Symbol={Name:n1,Schema:T3,OriginalName:E3,Columns:Yq,ExtraConfigColumns:Jq,BaseName:I3,IsAlias:$8,ExtraConfigBuilder:Wq};[n1];[E3];[T3];[Yq];[Jq];[I3];[$8]=!1;[$E]=!0;[Wq]=void 0;constructor($,X,G){this[n1]=this[E3]=$,this[T3]=X,this[I3]=G}}});function XE($){return $!==null&&$!==void 0&&typeof $.getSQL==="function"}function GE($){let X={sql:"",params:[]};for(let G of $)if(X.sql+=G.sql,X.params.push(...G.params),G.typings?.length){if(!X.typings)X.typings=[];X.typings.push(...G.typings)}return X}function f6($,...X){let G=[];if(X.length>0||$.length>0&&$[0]!=="")G.push(new g1($[0]));for(let[Y,J]of X.entries())G.push(J,new g1($[Y+1]));return new Z0(G)}var g1,Z0,t9,Hq,Uq,_r,$$,e9,YE,K5;var Y2=B(()=>{w0();tQ();X2();Gq();G2();$2();T5();g1=class g1{static[k]="StringChunk";value;constructor($){this.value=Array.isArray($)?$:[$]}getSQL(){return new Z0([this])}};Z0=class Z0{constructor($){this.queryChunks=$;for(let X of $)if(e(X,W0)){let G=X[W0.Symbol.Schema];this.usedTables.push(G===void 0?X[W0.Symbol.Name]:G+"."+X[W0.Symbol.Name])}}static[k]="SQL";decoder=Hq;shouldInlineParams=!1;usedTables=[];append($){return this.queryChunks.push(...$.queryChunks),this}toQuery($){return Xq.startActiveSpan("drizzle.buildSQL",(X)=>{let G=this.buildQueryFromSourceParams(this.queryChunks,$);return X?.setAttributes({"drizzle.query.text":G.sql,"drizzle.query.params":JSON.stringify(G.params)}),G})}buildQueryFromSourceParams($,X){let G=Object.assign({},X,{inlineParams:X.inlineParams||this.shouldInlineParams,paramStartIndex:X.paramStartIndex||{value:0}}),{casing:Y,escapeName:J,escapeParam:W,prepareTyping:H,inlineParams:U,paramStartIndex:F}=G;return GE($.map((M)=>{if(e(M,g1))return{sql:M.value.join(""),params:[]};if(e(M,t9))return{sql:J(M.value),params:[]};if(M===void 0)return{sql:"",params:[]};if(Array.isArray(M)){let Q=[new g1("(")];for(let[q,A]of M.entries())if(Q.push(A),q<M.length-1)Q.push(new g1(", "));return Q.push(new g1(")")),this.buildQueryFromSourceParams(Q,G)}if(e(M,Z0))return this.buildQueryFromSourceParams(M.queryChunks,{...G,inlineParams:U||M.shouldInlineParams});if(e(M,W0)){let Q=M[W0.Symbol.Schema],q=M[W0.Symbol.Name];return{sql:Q===void 0||M[$8]?J(q):J(Q)+"."+J(q),params:[]}}if(e(M,P1)){let Q=Y.getColumnCasing(M);if(X.invokeSource==="indexes")return{sql:J(Q),params:[]};let q=M.table[W0.Symbol.Schema];return{sql:M.table[$8]||q===void 0?J(M.table[W0.Symbol.Name])+"."+J(Q):J(q)+"."+J(M.table[W0.Symbol.Name])+"."+J(Q),params:[]}}if(e(M,K5)){let Q=M[m0].schema,q=M[m0].name;return{sql:Q===void 0||M[m0].isAlias?J(q):J(Q)+"."+J(q),params:[]}}if(e(M,$$)){if(e(M.value,e9))return{sql:W(F.value++,M),params:[M],typings:["none"]};let Q=M.value===null?null:M.encoder.mapToDriverValue(M.value);if(e(Q,Z0))return this.buildQueryFromSourceParams([Q],G);if(U)return{sql:this.mapInlineParam(Q,G),params:[]};let q=["none"];if(H)q=[H(M.encoder)];return{sql:W(F.value++,Q),params:[Q],typings:q}}if(e(M,e9))return{sql:W(F.value++,M),params:[M],typings:["none"]};if(e(M,Z0.Aliased)&&M.fieldAlias!==void 0)return{sql:J(M.fieldAlias),params:[]};if(e(M,A1)){if(M._.isWith)return{sql:J(M._.alias),params:[]};return this.buildQueryFromSourceParams([new g1("("),M._.sql,new g1(") "),new t9(M._.alias)],G)}if(aQ(M)){if(M.schema)return{sql:J(M.schema)+"."+J(M.enumName),params:[]};return{sql:J(M.enumName),params:[]}}if(XE(M)){if(M.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([M.getSQL()],G);return this.buildQueryFromSourceParams([new g1("("),M.getSQL(),new g1(")")],G)}if(U)return{sql:this.mapInlineParam(M,G),params:[]};return{sql:W(F.value++,M),params:[M],typings:["none"]}}))}mapInlineParam($,{escapeString:X}){if($===null)return"null";if(typeof $==="number"||typeof $==="boolean")return $.toString();if(typeof $==="string")return X($);if(typeof $==="object"){let G=$.toString();if(G==="[object Object]")return X(JSON.stringify($));return X(G)}throw Error("Unexpected param value: "+$)}getSQL(){return this}as($){if($===void 0)return this;return new Z0.Aliased(this,$)}mapWith($){return this.decoder=typeof $==="function"?{mapFromDriverValue:$}:$,this}inlineParams(){return this.shouldInlineParams=!0,this}if($){return $?this:void 0}};t9=class t9{constructor($){this.value=$}static[k]="Name";brand;getSQL(){return new Z0([this])}};Hq={mapFromDriverValue:($)=>$},Uq={mapToDriverValue:($)=>$},_r={...Hq,...Uq};$$=class $${constructor($,X=Uq){this.value=$,this.encoder=X}static[k]="Param";brand;getSQL(){return new Z0([this])}};(($)=>{function X(){return new Z0([])}$.empty=X;function G(F){return new Z0(F)}$.fromList=G;function Y(F){return new Z0([new g1(F)])}$.raw=Y;function J(F,M){let Q=[];for(let[q,A]of F.entries()){if(q>0&&M!==void 0)Q.push(M);Q.push(A)}return new Z0(Q)}$.join=J;function W(F){return new t9(F)}$.identifier=W;function H(F){return new e9(F)}$.placeholder=H;function U(F,M){return new $$(F,M)}$.param=U})(f6||(f6={}));(($)=>{class X{constructor(G,Y){this.sql=G,this.fieldAlias=Y}static[k]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new X(this.sql,this.fieldAlias)}}$.Aliased=X})(Z0||(Z0={}));e9=class e9{constructor($){this.name=$}static[k]="Placeholder";getSQL(){return new Z0([this])}};YE=Symbol.for("drizzle:IsDrizzleView");K5=class K5{static[k]="View";[m0];[YE]=!0;constructor({name:$,schema:X,selectedFields:G,query:Y}){this[m0]={name:$,originalName:$,schema:X,selectedFields:G,query:Y,isExisting:!Y,isAlias:!1}}getSQL(){return new Z0([this])}};P1.prototype.getSQL=function(){return new Z0([this])};W0.prototype.getSQL=function(){return new Z0([this])};A1.prototype.getSQL=function(){return new Z0([this])}});function g6($,X){return Object.entries($).reduce((G,[Y,J])=>{if(typeof Y!=="string")return G;let W=X?[...X,Y]:[Y];if(e(J,P1)||e(J,Z0)||e(J,Z0.Aliased))G.push({path:W,field:J});else if(e(J,W0))G.push(...g6(J[W0.Symbol.Columns],W));else G.push(...g6(J,W));return G},[])}function j3($,X){let G=Object.keys($),Y=Object.keys(X);if(G.length!==Y.length)return!1;for(let[J,W]of G.entries())if(W!==Y[J])return!1;return!0}function Kq($,X){for(let G of X)for(let Y of Object.getOwnPropertyNames(G.prototype)){if(Y==="constructor")continue;Object.defineProperty($.prototype,Y,Object.getOwnPropertyDescriptor(G.prototype,Y)||Object.create(null))}}function X8($){return e($,A1)?$._.alias:e($,K5)?$[m0].name:e($,Z0)?void 0:$[W0.Symbol.IsAlias]?$[W0.Symbol.Name]:$[W0.Symbol.BaseName]}function F5($,X){return{name:typeof $==="string"&&$.length>0?$:"",config:typeof $==="object"?$:X}}var S3;var E5=B(()=>{$2();w0();Y2();X2();T5();G2();S3=typeof TextDecoder>"u"?null:new TextDecoder});var Fq=()=>{};var Mq=()=>{};var Qq=()=>{};var qq=B(()=>{Mq();Qq()});var Oq=()=>{};var G8,k3;var v3=B(()=>{$2();w0();T5();G2();G8=class G8{constructor($){this.table=$}static[k]="ColumnAliasProxyHandler";get($,X){if(X==="table")return this.table;return $[X]}};k3=class k3{constructor($,X){this.alias=$,this.replaceOriginalName=X}static[k]="TableAliasProxyHandler";get($,X){if(X===W0.Symbol.IsAlias)return!0;if(X===W0.Symbol.Name)return this.alias;if(this.replaceOriginalName&&X===W0.Symbol.OriginalName)return this.alias;if(X===m0)return{...$[m0],name:this.alias,isAlias:!0};if(X===W0.Symbol.Columns){let Y=$[W0.Symbol.Columns];if(!Y)return Y;let J={};return Object.keys(Y).map((W)=>{J[W]=new Proxy(Y[W],new G8(new Proxy($,this)))}),J}let G=$[X];if(e(G,P1))return new Proxy(G,new G8(new Proxy($,this)));return G}}});var L1;var x3=B(()=>{v3();$2();w0();Y2();X2();G2();L1=class L1{static[k]="SelectionProxyHandler";config;constructor($){this.config={...$}}get($,X){if(X==="_")return{...$._,selectedFields:new Proxy($._.selectedFields,this)};if(X===m0)return{...$[m0],selectedFields:new Proxy($[m0].selectedFields,this)};if(typeof X==="symbol")return $[X];let Y=(e($,A1)?$._.selectedFields:e($,K5)?$[m0].selectedFields:$)[X];if(e(Y,Z0.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!Y.isSelectionField)return Y.sql;let J=Y.clone();return J.isSelectionField=!0,J}if(e(Y,Z0)){if(this.config.sqlBehavior==="sql")return Y;throw Error(`You tried to reference "${X}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}if(e(Y,P1)){if(this.config.alias)return new Proxy(Y,new G8(new Proxy(Y.table,new k3(this.config.alias,this.config.replaceOriginalName??!1))));return Y}if(typeof Y!=="object"||Y===null)return Y;return new Proxy(Y,new L1(this.config))}}});var Y8;var X$=B(()=>{w0();Y8=class Y8{static[k]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch($){return this.then(void 0,$)}finally($){return this.then((X)=>{return $?.(),X},(X)=>{throw $?.(),X})}then($,X){return this.execute().then($,X)}}});var b3,Zq;var h3=B(()=>{w0();t4();b3=class b3{static[k]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor($,X){if(this.reference=()=>{let{name:G,columns:Y,foreignColumns:J}=$();return{name:G,columns:Y,foreignTable:J[0].table,foreignColumns:J}},X)this._onUpdate=X.onUpdate,this._onDelete=X.onDelete}onUpdate($){return this._onUpdate=$,this}onDelete($){return this._onDelete=$,this}build($){return new Zq($,this)}};Zq=class Zq{constructor($,X){this.table=$,this.reference=X.reference,this.onUpdate=X._onUpdate,this.onDelete=X._onDelete}static[k]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:$,columns:X,foreignColumns:G}=this.reference(),Y=X.map((H)=>H.name),J=G.map((H)=>H.name),W=[this.table[n1],...Y,G[0].table[n1],...J];return $??`${W.join("_")}_fk`}}});function Rq($,X){return`${$[n1]}_${X.join("_")}_unique`}var y3=B(()=>{t4()});var i0,n0;var J2=B(()=>{P3();$2();w0();h3();y3();i0=class i0 extends D3{static[k]="SQLiteColumnBuilder";foreignKeyConfigs=[];references($,X={}){return this.foreignKeyConfigs.push({ref:$,actions:X}),this}unique($){return this.config.isUnique=!0,this.config.uniqueName=$,this}generatedAlwaysAs($,X){return this.config.generated={as:$,type:"always",mode:X?.mode??"virtual"},this}buildForeignKeys($,X){return this.foreignKeyConfigs.map(({ref:G,actions:Y})=>{return((J,W)=>{let H=new b3(()=>{let U=J();return{columns:[$],foreignColumns:[U]}});if(W.onUpdate)H.onUpdate(W.onUpdate);if(W.onDelete)H.onDelete(W.onDelete);return H.build(X)})(G,Y)})}};n0=class n0 extends P1{constructor($,X){if(!X.uniqueName)X.uniqueName=Rq($,[X.name]);super($,X);this.table=$}static[k]="SQLiteColumn"}});function zq($,X){let{name:G,config:Y}=F5($,X);if(Y?.mode==="json")return new Vq(G);if(Y?.mode==="bigint")return new Aq(G);return new wq(G)}var Aq,Bq,Vq,Nq,wq,_q;var f3=B(()=>{w0();E5();J2();Aq=class Aq extends i0{static[k]="SQLiteBigIntBuilder";constructor($){super($,"bigint","SQLiteBigInt")}build($){return new Bq($,this.config)}};Bq=class Bq extends n0{static[k]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let X=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return BigInt(X.toString("utf8"))}return BigInt(S3.decode($))}mapToDriverValue($){return Buffer.from($.toString())}};Vq=class Vq extends i0{static[k]="SQLiteBlobJsonBuilder";constructor($){super($,"json","SQLiteBlobJson")}build($){return new Nq($,this.config)}};Nq=class Nq extends n0{static[k]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue($){if(typeof Buffer<"u"&&Buffer.from){let X=Buffer.isBuffer($)?$:$ instanceof ArrayBuffer?Buffer.from($):$.buffer?Buffer.from($.buffer,$.byteOffset,$.byteLength):Buffer.from($);return JSON.parse(X.toString("utf8"))}return JSON.parse(S3.decode($))}mapToDriverValue($){return Buffer.from(JSON.stringify($))}};wq=class wq extends i0{static[k]="SQLiteBlobBufferBuilder";constructor($){super($,"buffer","SQLiteBlobBuffer")}build($){return new _q($,this.config)}};_q=class _q extends n0{static[k]="SQLiteBlobBuffer";mapFromDriverValue($){if(Buffer.isBuffer($))return $;return Buffer.from($)}getSQLType(){return"blob"}}});function G$($){return(X,G)=>{let{name:Y,config:J}=F5(X,G);return new Dq(Y,J,$)}}var Dq,Pq;var g3=B(()=>{w0();E5();J2();Dq=class Dq extends i0{static[k]="SQLiteCustomColumnBuilder";constructor($,X,G){super($,"custom","SQLiteCustomColumn");this.config.fieldConfig=X,this.config.customTypeParams=G}build($){return new Pq($,this.config)}};Pq=class Pq extends n0{static[k]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor($,X){super($,X);this.sqlName=X.customTypeParams.dataType(X.fieldConfig),this.mapTo=X.customTypeParams.toDriver,this.mapFrom=X.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue($){return typeof this.mapFrom==="function"?this.mapFrom($):$}mapToDriverValue($){return typeof this.mapTo==="function"?this.mapTo($):$}}});function B1($,X){let{name:G,config:Y}=F5($,X);if(Y?.mode==="timestamp"||Y?.mode==="timestamp_ms")return new Tq(G,Y.mode);if(Y?.mode==="boolean")return new Iq(G,Y.mode);return new Lq(G)}var Y$,J$,Lq,Cq,Tq,Eq,Iq,jq;var m3=B(()=>{w0();Y2();E5();J2();Y$=class Y$ extends i0{static[k]="SQLiteBaseIntegerBuilder";constructor($,X,G){super($,X,G);this.config.autoIncrement=!1}primaryKey($){if($?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}};J$=class J$ extends n0{static[k]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}};Lq=class Lq extends Y${static[k]="SQLiteIntegerBuilder";constructor($){super($,"number","SQLiteInteger")}build($){return new Cq($,this.config)}};Cq=class Cq extends J${static[k]="SQLiteInteger"};Tq=class Tq extends Y${static[k]="SQLiteTimestampBuilder";constructor($,X){super($,"date","SQLiteTimestamp");this.config.mode=X}defaultNow(){return this.default(f6`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build($){return new Eq($,this.config)}};Eq=class Eq extends J${static[k]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue($){if(this.config.mode==="timestamp")return new Date($*1000);return new Date($)}mapToDriverValue($){let X=$.getTime();if(this.config.mode==="timestamp")return Math.floor(X/1000);return X}};Iq=class Iq extends Y${static[k]="SQLiteBooleanBuilder";constructor($,X){super($,"boolean","SQLiteBoolean");this.config.mode=X}build($){return new jq($,this.config)}};jq=class jq extends J${static[k]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue($){return Number($)===1}mapToDriverValue($){return $?1:0}}});function yq($,X){let{name:G,config:Y}=F5($,X),J=Y?.mode;return J==="number"?new vq(G):J==="bigint"?new bq(G):new Sq(G)}var Sq,kq,vq,xq,bq,hq;var p3=B(()=>{w0();E5();J2();Sq=class Sq extends i0{static[k]="SQLiteNumericBuilder";constructor($){super($,"string","SQLiteNumeric")}build($){return new kq($,this.config)}};kq=class kq extends n0{static[k]="SQLiteNumeric";mapFromDriverValue($){if(typeof $==="string")return $;return String($)}getSQLType(){return"numeric"}};vq=class vq extends i0{static[k]="SQLiteNumericNumberBuilder";constructor($){super($,"number","SQLiteNumericNumber")}build($){return new xq($,this.config)}};xq=class xq extends n0{static[k]="SQLiteNumericNumber";mapFromDriverValue($){if(typeof $==="number")return $;return Number($)}mapToDriverValue=String;getSQLType(){return"numeric"}};bq=class bq extends i0{static[k]="SQLiteNumericBigIntBuilder";constructor($){super($,"bigint","SQLiteNumericBigInt")}build($){return new hq($,this.config)}};hq=class hq extends n0{static[k]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}});function mq($){return new fq($??"")}var fq,gq;var u3=B(()=>{w0();J2();fq=class fq extends i0{static[k]="SQLiteRealBuilder";constructor($){super($,"number","SQLiteReal")}build($){return new gq($,this.config)}};gq=class gq extends n0{static[k]="SQLiteReal";getSQLType(){return"real"}}});function Y0($,X={}){let{name:G,config:Y}=F5($,X);if(Y.mode==="json")return new dq(G);return new pq(G,Y)}var pq,uq,dq,lq;var d3=B(()=>{w0();E5();J2();pq=class pq extends i0{static[k]="SQLiteTextBuilder";constructor($,X){super($,"string","SQLiteText");this.config.enumValues=X.enum,this.config.length=X.length}build($){return new uq($,this.config)}};uq=class uq extends n0{static[k]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor($,X){super($,X)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}};dq=class dq extends i0{static[k]="SQLiteTextJsonBuilder";constructor($){super($,"json","SQLiteTextJson")}build($){return new lq($,this.config)}};lq=class lq extends n0{static[k]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue($){return JSON.parse($)}mapToDriverValue($){return JSON.stringify($)}}});function cq(){return{blob:zq,customType:G$,integer:B1,numeric:yq,real:mq,text:Y0}}var rq=B(()=>{f3();g3();m3();p3();u3();d3()});function JE($,X,G,Y,J=$){let W=new M5($,Y,J),H=typeof X==="function"?X(cq()):X,U=Object.fromEntries(Object.entries(H).map(([M,Q])=>{let q=Q;q.setName(M);let A=q.build(W);return W[l3].push(...q.buildForeignKeys(A,W)),[M,A]})),F=Object.assign(W,U);if(F[W0.Symbol.Columns]=U,F[W0.Symbol.ExtraConfigColumns]=U,G)F[M5.Symbol.ExtraConfigBuilder]=G;return F}var l3,M5,Q5=($,X,G)=>{return JE($,X,G)};var J8=B(()=>{w0();T5();rq();l3=Symbol.for("drizzle:SQLiteInlineForeignKeys");M5=class M5 extends W0{static[k]="SQLiteTable";static Symbol=Object.assign({},W0.Symbol,{InlineForeignKeys:l3});[W0.Symbol.Columns];[l3]=[];[W0.Symbol.ExtraConfigBuilder]=void 0}});var iq=()=>{};function o1($){return new nq($,!1)}var nq,oq,sq;var aq=B(()=>{w0();nq=class nq{constructor($,X){this.name=$,this.unique=X}static[k]="SQLiteIndexBuilderOn";on(...$){return new oq(this.name,$,this.unique)}};oq=class oq{static[k]="SQLiteIndexBuilder";config;constructor($,X,G){this.config={name:$,columns:X,unique:G,where:void 0}}where($){return this.config.where=$,this}build($){return new sq(this.config,$)}};sq=class sq{static[k]="SQLiteIndex";config;constructor($,X){this.config={...$,table:X}}}});function W$(...$){if($[0].columns)return new c3($[0].columns,$[0].name);return new c3($)}var c3,tq;var eq=B(()=>{w0();J8();c3=class c3{static[k]="SQLitePrimaryKeyBuilder";columns;name;constructor($,X){this.columns=$,this.name=X}build($){return new tq($,this.columns,this.name)}};tq=class tq{constructor($,X,G){this.table=$,this.columns=X,this.name=G}static[k]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[M5.Symbol.Name]}_${this.columns.map(($)=>$.name).join("_")}_pk`}}});function u2($){if(e($,M5))return[`${$[W0.Symbol.BaseName]}`];if(e($,A1))return $._.usedTables??[];if(e($,Z0))return $.usedTables??[];return[]}var H$=B(()=>{w0();Y2();X2();T5();J8()});var $O=()=>{};var XO=()=>{};var GO=()=>{};var YO=()=>{};var JO=B(()=>{GO();YO()});var WO=B(()=>{qq();JO();Y2()});var HO=B(()=>{f3();J2();g3();m3();p3();u3();d3()});var r3;var UO=B(()=>{w0();Y2();r3=class r3 extends K5{static[k]="SQLiteViewBase"}});var KO=()=>{};var i3;var FO=B(()=>{w0();i3=class i3{static[k]="TypedQueryBuilder";getSelectedFields(){return this._.selectedFields}}});function U$($,X){return(G,Y,...J)=>{let W=[Y,...J].map((H)=>({type:$,isAll:X,rightSelect:H}));for(let H of W)if(!j3(G.getSelectedFields(),H.rightSelect.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return G.addSetOperators(W)}}var MO,QO,WE=()=>({union:HE,unionAll:UE,intersect:KE,except:FE}),HE,UE,KE,FE;var qO=B(()=>{w0();FO();X$();x3();Y2();X2();T5();E5();G2();H$();MO=class MO extends i3{static[k]="SQLiteSelectQueryBuilder";_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:$,fields:X,isPartialSelect:G,session:Y,dialect:J,withList:W,distinct:H}){super();this.config={withList:W,table:$,fields:{...X},distinct:H,setOperators:[]},this.isPartialSelect=G,this.session=Y,this.dialect=J,this._={selectedFields:X,config:this.config},this.tableName=X8($),this.joinsNotNullableMap=typeof this.tableName==="string"?{[this.tableName]:!0}:{};for(let U of u2($))this.usedTables.add(U)}getUsedTables(){return[...this.usedTables]}createJoin($){return(X,G)=>{let Y=this.tableName,J=X8(X);for(let W of u2(X))this.usedTables.add(W);if(typeof J==="string"&&this.config.joins?.some((W)=>W.alias===J))throw Error(`Alias "${J}" is already used in this query`);if(!this.isPartialSelect){if(Object.keys(this.joinsNotNullableMap).length===1&&typeof Y==="string")this.config.fields={[Y]:this.config.fields};if(typeof J==="string"&&!e(X,Z0)){let W=e(X,A1)?X._.selectedFields:e(X,K5)?X[m0].selectedFields:X[W0.Symbol.Columns];this.config.fields[J]=W}}if(typeof G==="function")G=G(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));if(!this.config.joins)this.config.joins=[];if(this.config.joins.push({on:G,table:X,joinType:$,alias:J}),typeof J==="string")switch($){case"left":{this.joinsNotNullableMap[J]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[J]=!0;break}case"cross":case"inner":{this.joinsNotNullableMap[J]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([W])=>[W,!1])),this.joinsNotNullableMap[J]=!1;break}}return this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");crossJoin=this.createJoin("cross");createSetOperator($,X){return(G)=>{let Y=typeof G==="function"?G(WE()):G;if(!j3(this.getSelectedFields(),Y.getSelectedFields()))throw Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:$,isAll:X,rightSelect:Y}),this}}union=this.createSetOperator("union",!1);unionAll=this.createSetOperator("union",!0);intersect=this.createSetOperator("intersect",!1);except=this.createSetOperator("except",!1);addSetOperators($){return this.config.setOperators.push(...$),this}where($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.where=$,this}having($){if(typeof $==="function")$=$(new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})));return this.config.having=$,this}groupBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(X)?X:[X]}else this.config.groupBy=$;return this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.fields,new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),G=Array.isArray(X)?X:[X];if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=G;else this.config.orderBy=G}else{let X=$;if(this.config.setOperators.length>0)this.config.setOperators.at(-1).orderBy=X;else this.config.orderBy=X}return this}limit($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).limit=$;else this.config.limit=$;return this}offset($){if(this.config.setOperators.length>0)this.config.setOperators.at(-1).offset=$;else this.config.offset=$;return this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}as($){let X=[];if(X.push(...u2(this.config.table)),this.config.joins)for(let G of this.config.joins)X.push(...u2(G.table));return new Proxy(new A1(this.getSQL(),this.config.fields,$,!1,[...new Set(X)]),new L1({alias:$,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new L1({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}};QO=class QO extends MO{static[k]="SQLiteSelect";_prepare($=!0){if(!this.session)throw Error("Cannot execute a query on a query builder. Please use a database instance instead.");let X=g6(this.config.fields),G=this.session[$?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),X,"all",!0,void 0,{type:"select",tables:[...this.usedTables]},this.cacheConfig);return G.joinsNotNullableMap=this.joinsNotNullableMap,G}$withCache($){return this.cacheConfig=$===void 0?{config:{},enable:!0,autoInvalidate:!0}:$===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...$},this}prepare(){return this._prepare(!1)}run=($)=>{return this._prepare().run($)};all=($)=>{return this._prepare().all($)};get=($)=>{return this._prepare().get($)};values=($)=>{return this._prepare().values($)};async execute(){return this.all()}};Kq(QO,[Y8]);HE=U$("union",!1),UE=U$("union",!0),KE=U$("intersect",!1),FE=U$("except",!1)});var OO=()=>{};var ZO=()=>{};var ME;var RO=B(()=>{w0();X$();x3();J8();X2();T5();E5();G2();H$();UO();ME=class ME extends Y8{constructor($,X,G,Y,J){super();this.session=G,this.dialect=Y,this.config={set:X,table:$,withList:J,joins:[]}}static[k]="SQLiteUpdate";config;from($){return this.config.from=$,this}createJoin($){return(X,G)=>{let Y=X8(X);if(typeof Y==="string"&&this.config.joins.some((J)=>J.alias===Y))throw Error(`Alias "${Y}" is already used in this query`);if(typeof G==="function"){let J=this.config.from?e(X,M5)?X[W0.Symbol.Columns]:e(X,A1)?X._.selectedFields:e(X,r3)?X[m0].selectedFields:void 0:void 0;G=G(new Proxy(this.config.table[W0.Symbol.Columns],new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),J&&new Proxy(J,new L1({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}return this.config.joins.push({on:G,table:X,joinType:$,alias:Y}),this}}leftJoin=this.createJoin("left");rightJoin=this.createJoin("right");innerJoin=this.createJoin("inner");fullJoin=this.createJoin("full");where($){return this.config.where=$,this}orderBy(...$){if(typeof $[0]==="function"){let X=$[0](new Proxy(this.config.table[W0.Symbol.Columns],new L1({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),G=Array.isArray(X)?X:[X];this.config.orderBy=G}else{let X=$;this.config.orderBy=X}return this}limit($){return this.config.limit=$,this}returning($=this.config.table[M5.Symbol.Columns]){return this.config.returning=g6($),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:$,...X}=this.dialect.sqlToQuery(this.getSQL());return X}_prepare($=!0){return this.session[$?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"insert",tables:u2(this.config.table)})}prepare(){return this._prepare(!1)}run=($)=>{return this._prepare().run($)};all=($)=>{return this._prepare().all($)};get=($)=>{return this._prepare().get($)};values=($)=>{return this._prepare().values($)};async execute(){return this.config.returning?this.all():this.run()}$dynamic(){return this}}});var AO=B(()=>{$O();ZO();OO();qO();RO()});var BO=()=>{};var VO=()=>{};var NO=()=>{};var wO=()=>{};var m6=B(()=>{VO();iq();HO();BO();KO();h3();aq();eq();AO();NO();J8();y3();H$();wO()});var _O;var n3=B(()=>{m6();I();_O=Q5("job_queue",{id:Y0("id").primaryKey().$defaultFn(()=>C5()),type:Y0("type").notNull(),data:Y0("data").notNull(),result:Y0("result",{mode:"json"}),source:Y0("source"),metadata:Y0("metadata",{mode:"json"}).$type().notNull(),status:Y0("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:B1("priority").notNull().default(0),retryCount:B1("retryCount").notNull().default(0),maxRetries:B1("maxRetries").notNull().default(3),lastError:Y0("lastError"),createdAt:B1("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:B1("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:B1("startedAt"),completedAt:B1("completedAt")},($)=>({queueReadyIdx:o1("idx_job_queue_ready").on($.status,$.priority,$.scheduledFor),jobTypeIdx:o1("idx_job_queue_type").on($.type,$.status),jobSourceIdx:o1("idx_job_queue_source").on($.source)}))});import{createClient as So}from"@libsql/client";var zO=B(()=>{n3()});var DO=B(()=>{v3();P3();$2();w0();XO();Fq();X$();Oq();WO();X2();T5();E5();G2()});var PO=B(()=>{n3();e5()});var LO=B(()=>{e5()});var CO=B(()=>{I();e5();zO();PO();LO()});var TO=B(()=>{I();e5();e5()});var EO=B(()=>{e5()});var IO=B(()=>{I()});class H8{logger;schema;jobTypeName;constructor($,X){this.logger=$,this.schema=X.schema,this.jobTypeName=X.jobTypeName}validateAndParse($){if(!this.schema)throw Error(`${this.jobTypeName}: No schema provided. Override validateAndParse() or provide a schema.`);try{let X=this.schema.parse($);return this.logger.debug(`${this.jobTypeName} job data validation successful`,{data:this.summarizeDataForLog(X)}),X}catch(X){return this.logger.warn(`Invalid ${this.jobTypeName} job data`,{data:$,validationError:X instanceof K.ZodError?X.issues:X}),null}}async onError($,X,G,Y){this.logger.error(`${this.jobTypeName} job error handler triggered`,{jobId:G,errorMessage:$.message,errorStack:$.stack,data:this.summarizeDataForLog(X)})}async reportProgress($,X){await $.report({progress:X.progress,total:X.total??100,message:X.message})}summarizeDataForLog($){return $}}var jO=B(()=>{I()});var QE;var SO=B(()=>{a9();I();QE=K.object({id:K.string(),type:K.string(),data:K.string(),status:K.enum(["pending","processing","completed","failed"]),source:K.string().nullable(),priority:K.number(),retryCount:K.number(),maxRetries:K.number(),lastError:K.string().nullable(),createdAt:K.number(),scheduledFor:K.number(),startedAt:K.number().nullable(),completedAt:K.number().nullable(),metadata:a4,result:K.unknown().nullable().optional()})});function o3($,X,G){return async(Y)=>{let{type:J,data:W,toolContext:H=null,options:U}=Y,{metadata:F,...M}=U??{},Q={source:X,...U?.rootJobId&&{rootJobId:U.rootJobId},...M,metadata:{operationType:"data_processing",pluginId:X,...H&&{interfaceType:H.interfaceType,channelId:H.channelId},...F}},q=G&&!J.includes(":")?`${X}:${J}`:J;return $.enqueue({type:q,data:W,options:Q})}}function s3($,X){return async(G,Y)=>{let J=C5(),W=G.map((U)=>({...U,type:U.type.includes(":")?U.type:`${X}:${U.type}`})),H={...Y,source:X,rootJobId:J,metadata:{...Y?.metadata,operationType:"batch_processing",pluginId:X}};return await $.enqueueBatch(W,H,J,X),J}}function a3($,X){return(G,Y)=>{let J=G.includes(":")?G:`${X}:${G}`;$.registerHandler(J,Y,X)}}var kO=B(()=>{I()});var U8=B(()=>{CO();TO();EO();IO();jO();SO();e5();a9();kO()});function vO($){return qE.safeParse($).success}var qE;var t3=B(()=>{I();qE=K.object({name:K.string(),schema:K.custom(($)=>$ instanceof K.ZodType)})});function OE($){if(!$)return;return{status:$.status,message:$.message,lastCheck:$.lastCheck?.toISOString(),details:$.details}}function xO($){return{model:$.model,version:$.version,uptime:$.uptime,entities:$.entities,embeddings:$.embeddings,ai:$.ai,daemons:$.daemons.map((X)=>({name:X.name,pluginId:X.pluginId,status:X.status,health:OE(X.health)})),endpoints:$.endpoints}}var K8;var e3=B(()=>{G5();K8=K.record(K.unknown())});var ZE,$G,RE;var XG=B(()=>{G5();e3();ZE=K.object({id:K.string(),sessionId:K.string(),interfaceType:K.string(),channelId:K.string(),channelName:K.string().optional(),startedAt:K.string(),lastActiveAt:K.string(),createdAt:K.string(),updatedAt:K.string(),metadata:K8}),$G=K.enum(["user","assistant","system"]),RE=K.object({id:K.string(),conversationId:K.string(),role:$G,content:K.string(),timestamp:K.string(),metadata:K8})});function bO($){if(!$)return{};try{let X=JSON.parse($);if(X&&typeof X==="object"&&!Array.isArray(X))return X}catch{}return{}}function AE($){let X=$G.safeParse($);return X.success?X.data:"user"}function K$($){let X=bO($.metadata),G=typeof X.channelName==="string"?X.channelName:void 0;return{id:$.id,sessionId:$.sessionId,interfaceType:$.interfaceType,channelId:$.channelId,channelName:G,startedAt:$.started,lastActiveAt:$.lastActive,createdAt:$.created,updatedAt:$.updated,metadata:X}}function hO($){return{id:$.id,conversationId:$.conversationId,role:AE($.role),content:$.content,timestamp:$.timestamp,metadata:bO($.metadata)}}var yO=B(()=>{XG()});var GG,YG;var JG=B(()=>{G5();GG=K.object({name:K.string(),role:K.string(),purpose:K.string(),values:K.array(K.string())}),YG=K.object({name:K.string(),kind:K.enum(["professional","team","collective"]),organization:K.string().optional(),description:K.string().optional(),avatar:K.string().optional(),website:K.string().optional(),email:K.string().optional(),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]),url:K.string(),label:K.string().optional()})).optional()})});function fO($){return GG.parse($)}function gO($){return YG.parse($)}var mO=B(()=>{JG()});function pO($){return async()=>{return xO(await $.getAppInfo())}}function uO($,X){return{get:()=>fO($.getIdentity()),getProfile:()=>gO($.getProfile()),getAppInfo:X}}function dO($,X,G){let Y=$.getMessageBus();return{send:async(W)=>{return Y.send({...W,sender:X})},subscribe:(W,H)=>{if(vO(W)){let U=W,F=H,M=async(Q)=>{let q=U.schema.safeParse(Q.payload);if(!q.success)return G.warn(`Invalid payload for channel ${U.name}`,{error:q.error.message}),{noop:!0};let{payload:A,...Z}=Q;return F(q.data,Z)};return Y.subscribe(U.name,M)}return Y.subscribe(W,H)}}}function lO($,X){let G=$.getJobQueueService();return{...$.jobs,enqueue:o3(G,X,!0),enqueueBatch:s3($.jobs,X),registerHandler:a3(G,X)}}function cO($){return{get:async(X)=>{let Y=await $.getConversationService().getConversation(X);return Y?K$(Y):null},search:async(X)=>{return(await $.getConversationService().searchConversations(X)).map(K$)},list:async(X)=>{return(await $.getConversationService().listConversations(X)).map(K$)},getMessages:async(X,G)=>{return(await $.getConversationService().getMessages(X,G)).map(hO)},countMessages:async(X)=>{return $.getConversationService().countMessages(X)}}}function rO($,X){return{registerHandler:(G,Y)=>{$.registerEvalHandler(X,G,Y)}}}function iO($){return{register:(X,G)=>{$.getInsightsRegistry().register(X,G)}}}function nO($,X){return{register:({label:G,url:Y,priority:J=100})=>{$.registerEndpoint({label:G,url:Y,pluginId:X,priority:J})}}}var oO=B(()=>{U8();t3();yO();mO()});function p6($,X,G){let Y=$.getEntityService(),J=$.getLogger().child(X),W=$.getDomain(),H=pO($);return{pluginId:X,logger:J,entityService:Y,identity:uO($,H),appInfo:H,domain:W,siteUrl:W?`https://${W}`:void 0,previewUrl:W?`https://${Q3(W)}`:void 0,entityDisplay:G?.entityDisplay,spaces:$.getSpaces(),messaging:dO($,X,J),jobs:lO($,X),conversations:cO($),dataDir:$.getDataDir(),eval:rO($,X),insights:iO($),endpoints:nO($,X)}}var F8=B(()=>{I();oO()});var F$;var M8=B(()=>{DO();m6();F$=Q5("entities",{id:Y0("id").notNull(),entityType:Y0("entityType").notNull(),content:Y0("content").notNull(),contentHash:Y0("contentHash").notNull(),metadata:Y0("metadata",{mode:"json"}).$type().notNull().default(f6`'{}'`),created:B1("created").notNull().$defaultFn(()=>Date.now()),updated:B1("updated").notNull().$defaultFn(()=>Date.now())},($)=>{return{pk:W$({columns:[$.id,$.entityType]})}})});import{createClient as Aa}from"@libsql/client";var sO=B(()=>{M8()});var aO;var tO=B(()=>{m6();aO=G$({dataType(){return"F32_BLOB(1536)"},toDriver($){return Buffer.from($.buffer)},fromDriver($){return new Float32Array($.buffer,$.byteOffset,$.byteLength/4)}})});var M$;var Q8=B(()=>{m6();tO();M$=Q5("embeddings",{entityId:Y0("entity_id").notNull(),entityType:Y0("entity_type").notNull(),embedding:aO("embedding").notNull(),contentHash:Y0("content_hash").notNull()},($)=>{return{pk:W$({columns:[$.entityId,$.entityType]})}})});import{createClient as La}from"@libsql/client";var WG=B(()=>{Q8()});var ja;var HG=B(()=>{I();ja=K.object({id:K.string().min(1,"Entity ID is required"),entityType:K.string().min(1,"Entity type is required"),contentHash:K.string().min(1,"Content hash is required"),operation:K.enum(["create","update"])})});var xa;var eO=B(()=>{I();M8();xa=K.object({limit:K.number().int().positive().optional().default(20),offset:K.number().int().min(0).optional().default(0),types:K.array(K.string()).optional().default([]),excludeTypes:K.array(K.string()).optional().default([]),weight:K.record(K.string(),K.number()).optional()})});var $Z=B(()=>{I()});var BE,la;var XZ=B(()=>{M8();Q8();I();BE=K.object({field:K.string(),direction:K.enum(["asc","desc"]),nullsFirst:K.boolean().optional()}),la=K.object({limit:K.number().int().positive().optional(),offset:K.number().int().min(0).optional().default(0),sortFields:K.array(BE).optional(),filter:K.object({metadata:K.record(K.string(),K.unknown()).optional()}).optional(),publishedOnly:K.boolean().optional()})});var GZ=()=>{};var YZ=B(()=>{I();GZ();M8();Q8()});var JZ=B(()=>{I()});var WZ=B(()=>{sO();WG();Q8();I();HG();eO();$Z();XZ();YZ();JZ()});function W2($,X){if(Object.keys(X).length===0)return $;let G=Object.fromEntries(Object.entries(X).filter(([,Y])=>Y!==void 0));return Q$.default.stringify($,G)}function UG($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(UG);if($!==null&&typeof $==="object"){let X={};for(let[G,Y]of Object.entries($))X[G]=UG(Y);return X}return $}function I0($,X){let{content:G,data:Y}=Q$.default($),J=UG(Y);return{content:G.trim(),metadata:X.parse(J)}}function KG($){if(Object.keys($).length===0)return"";let G=Q$.default.stringify("",$).match(/^---\n[\s\S]*?\n---/);return G?G[0]:""}var Q$;var q$=B(()=>{Q$=x8(C7(),1)});var HZ=B(()=>{I();q$()});class V1{entityType;schema;frontmatterSchema;isSingleton;hasBody;supportsCoverImage;fmSchema;bodyFormatter;constructor($){if(this.entityType=$.entityType,this.schema=$.schema,this.frontmatterSchema=$.frontmatterSchema,this.fmSchema=$.frontmatterSchema,this.bodyFormatter=$.bodyFormatter??CE,$.isSingleton!==void 0)this.isSingleton=$.isSingleton;if($.hasBody!==void 0)this.hasBody=$.hasBody;if($.supportsCoverImage!==void 0)this.supportsCoverImage=$.supportsCoverImage}toMarkdown($){let X=this.renderBody($),Y={...this.readExistingFrontmatter($.content)},J=Object.keys(this.frontmatterSchema.shape);for(let[W,H]of Object.entries($.metadata))if(J.includes(W))Y[W]=H;return this.buildMarkdown(X,Y)}renderBody($){return this.extractBody($.content)}readExistingFrontmatter($){try{return I0($,K.record(K.unknown())).metadata}catch{return{}}}extractMetadata($){return $.metadata}parseFrontMatter($,X){return I0($,X).metadata}getBodyTemplate(){return this.bodyFormatter.generateBodyTemplate()}generateFrontMatter($){let X=$.metadata;return KG(X)}extractBody($){try{return I0($,K.record(K.unknown())).content}catch{return $}}parseFrontmatter($){return I0($,this.fmSchema).metadata}buildMarkdown($,X){return W2($,X)}}var CE;var FG=B(()=>{I();q$();CE={generateBodyTemplate:()=>""}});var N1;var MG=B(()=>{I();N1=K.object({id:K.string(),entityType:K.string(),content:K.string(),created:K.string().datetime(),updated:K.string().datetime(),metadata:K.record(K.string(),K.unknown()),contentHash:K.string()})});var UZ=B(()=>{I();MG();FG()});var KZ=B(()=>{FG();UZ()});class u6{cache=null;cacheParseError=null;logger;entityService;entityType;defaultBody;constructor($,X,G,Y){this.entityService=$,this.logger=X.child(this.constructor.name),this.entityType=G,this.defaultBody=Y}async initialize(){if(await this.load())return;if(await this.load())return;this.logger.info(`No ${this.entityType} found, creating default ${this.entityType}`);try{let $=this.createContent(this.defaultBody);await this.entityService.createEntity({entity:{id:this.entityType,entityType:this.entityType,content:$,metadata:{}}}),await this.load(),this.logger.info(`Default ${this.entityType} created successfully`)}catch($){this.logger.error(`Failed to create default ${this.entityType}`,{error:$})}}get(){if(this.cache&&!this.cacheParseError)return this.parseBody(this.cache.content);return this.defaultBody}getContent(){if(this.cache)return this.cache.content;return this.createContent(this.defaultBody)}async refreshCache(){await this.load()}async load(){try{let $=await this.entityService.getEntity({entityType:this.entityType,id:this.entityType});if(this.cache=$,this.cacheParseError=null,$)try{return this.parseBody($.content),this.logger.debug(`${this.entityType} loaded`),!0}catch(X){return this.cacheParseError=X instanceof Error?X:Error(String(X)),this.logger.error(`Failed to parse ${this.entityType} \u2014 using default. Fix the entity content to clear this error.`,{error:this.cacheParseError.message}),!0}else this.logger.debug(`No ${this.entityType} found in database`)}catch($){this.logger.warn(`Failed to load ${this.entityType}`,{error:$}),this.cache=null,this.cacheParseError=null}return!1}}function QG($,X,G){let Y=Math.max(1,Math.ceil($/G));return{currentPage:X,totalPages:Y,totalItems:$,pageSize:G,hasNextPage:X<Y,hasPrevPage:X>1}}var O$;var FZ=B(()=>{I();O$=K.object({currentPage:K.number(),totalPages:K.number(),totalItems:K.number(),pageSize:K.number(),hasNextPage:K.boolean(),hasPrevPage:K.boolean()})});var v1=B(()=>{WZ();HG();HZ();KZ();WG();MG();q$();FZ()});function EE($){return $.replace(/:/g,"-")}function IE($){return $.split(/[:.-]/).map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join(" ")}async function OG($,X,G){let Y=qG.get(X);if(Y!==void 0)return Y;let J=EE(X),W;try{W=await $.getEntity({entityType:"prompt",id:J})}catch{return G}if(W?.content){let H=I0(W.content,K.record(K.unknown())).content;return qG.set(X,H),H}try{let H=IE(X),U=W2(G,{title:H,target:X});await $.createEntity({entity:{id:J,entityType:"prompt",content:U,metadata:{title:H,target:X,slug:J}}})}catch{}return qG.set(X,G),G}var qG;var ZG=B(()=>{v1();I();qG=new Map});function Z$($){let X=$.getEntityService(),G=$.getEntityRegistry(),Y=$.getDataSourceRegistry();return{register:(J,W,H,U)=>{G.registerEntityType(J,W,H,U)},getAdapter:(J)=>{try{return G.getAdapter(J)}catch{return}},extendFrontmatterSchema:(J,W)=>{G.extendFrontmatterSchema(J,W)},getEffectiveFrontmatterSchema:(J)=>{return G.getEffectiveFrontmatterSchema(J)},registerCreateInterceptor:(J,W)=>{G.registerCreateInterceptor(J,W)},update:async(J)=>{return X.updateEntity({entity:J})},registerDataSource:(J)=>{Y.register(J)}}}function R$($){return{resolve:(X,G)=>{return OG($,X,G)}}}var RG=B(()=>{ZG()});function AG($,X,G){let Y=p6($,X,G),J=$.getEntityService(),W=$.getRenderService(),H=$.getContentService();return{...Y,entityService:J,entities:Z$($),templates:{register:(U,F)=>{$.registerTemplates(U,F??X)},format:(U,F)=>{return H.formatContent(U,F,{pluginId:X})},parse:(U,F)=>{return H.parseContent(U,F,X)},resolve:async(U,F)=>{return await H.resolveContent(U,F,X)},getCapabilities:(U)=>{let F=U.includes(":")?U:`${X}:${U}`,M=$.getTemplate(F);if(!M)return null;let Q=s4.getCapabilities(M);return{canGenerate:Q.canGenerate,canFetch:Q.canFetch,canRender:Q.canRender,isStaticOnly:Q.isStaticOnly}}},views:{get:(U)=>{return W.get(U)??void 0},list:()=>{return W.list()},hasRenderer:(U)=>{return W.hasRenderer(U,"web")},getRenderer:(U)=>{return W.getRenderer(U,"web")},validate:(U,F)=>{return W.validate(U,F)}},prompts:R$(J),registerInstructions:(U)=>{$.registerInstructions(X,U)}}}var BG=B(()=>{F8();RG();U5()});var d6;var MZ=B(()=>{s9();BG();d6=class d6 extends y6{type="service";getApiRoutes(){return[]}getWebRoutes(){return[]}async register($,X){let G=AG($,this.id,X);return this.context=G,this.setupMessageHandlers(G),await this.onRegister(G),this.getCapabilities()}get entityService(){return this.getContext().entityService}registerEntityType($,X,G,Y){this.getContext().entities.register($,X,G,Y)}async enqueueJob($){return this.getContext().jobs.enqueue($)}async enqueueBatch($,X){return this.getContext().jobs.enqueueBatch($,X)}async registerEntityTypes($){}async registerJobHandlers($){}async onRegister($){await this.registerEntityTypes($),await this.registerJobHandlers($)}}});function VG($,X,G){let Y=p6($,X,G),J=$.getEntityService();return{...Y,entityService:J,entities:Z$($),ai:{query:(W,H)=>$.query(W,H),generate:async(W)=>{return $.generateContent(W)},generateObject:async(W,H)=>{return $.generateObject(W,H)},generateImage:async(W,H)=>{return $.generateImage(W,H)},canGenerateImages:()=>{return $.canGenerateImages()}},prompts:R$(J)}}var NG=B(()=>{F8();RG()});function wG($,X,G){let Y=!1,J=!1;if($.jobs.registerHandler(G.job.type,G.job.handler),G.initialSync){let W=G.initialSync;$.messaging.subscribe("sync:initial:completed",async()=>{if(Y)return{success:!0};if(Y=!0,!(await W.shouldEnqueue?.()??!0))return X.info("Skipping derived entity projection initial sync",{projectionId:G.id,targetType:G.targetType}),{success:!0};return J=await QZ($,X,G,W.jobData,SE(W.jobOptions),"initial-sync"),{success:!0}})}if(G.sourceChange){let W=G.sourceChange,H=new Set(W.sourceTypes),U=W.events??["entity:created","entity:updated"],F=async(M)=>{if(W.requireInitialSync&&!Y)return{success:!0};let Q=M.payload,q=jE(W,Q);if(!q||!H.has("*")&&!H.has(q))return{success:!0};if(!(await W.shouldEnqueue?.(Q)??!0))return{success:!0};let Z=await W.jobData(Q);if(!Z)return{success:!0};return await QZ($,X,G,Z,W.jobOptions?.(Q),"source-change"),{success:!0}};for(let M of U)$.messaging.subscribe(M,F)}return{hasObservedInitialSync:()=>Y,hasQueuedInitialSync:()=>J}}function jE($,X){if($.sourceType)return $.sourceType;if($.sourceKind&&$.sourceKind!=="entity")return $.sourceKind;return X.entityType}async function QZ($,X,G,Y,J,W){try{return await $.jobs.enqueue({type:G.job.type,data:Y,...J?{options:J}:{}}),X.info("Queued derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:W}),!0}catch(H){return X.error("Failed to queue derived entity projection",{projectionId:G.id,targetType:G.targetType,reason:W,error:S0(H)}),!1}}function SE($){return typeof $==="function"?$():$}var _G=B(()=>{I()});var kE,H2;var qZ=B(()=>{s9();I();NG();_G();kE=K.object({});H2=class H2 extends y6{type="entity";derivedEntityProjectionControllers=new Map;constructor($,X,G={},Y=kE){super($,X,G,Y)}async register($,X){let G=VG($,this.id,X);if(this.context=G,this.setupMessageHandlers(G),G.entities.register(this.entityType,this.schema,this.adapter,this.getEntityTypeConfig()),this.interceptCreate!==H2.prototype.interceptCreate)G.entities.registerCreateInterceptor(this.entityType,(F,M)=>this.interceptCreate(F,M,G));let Y=this.createGenerationHandler(G);if(Y)G.jobs.registerHandler(`${this.entityType}:generation`,Y);let J=this.getTemplates();if(J&&Object.keys(J).length>0)$.registerTemplates(J,this.id);let W=this.getDataSources();for(let F of W)G.entities.registerDataSource(F);let H=this.getDerivedEntityProjections(G);for(let F of H){let M=wG(G,this.logger,F);this.derivedEntityProjectionControllers.set(F.id,M)}await this.onRegister(this.context);let U=await this.getInstructions();return{tools:[],resources:[],...U&&{instructions:U}}}async interceptCreate($,X,G){return{kind:"continue",input:$}}createGenerationHandler($){return null}getTemplates(){return null}getDataSources(){return[]}getEntityTypeConfig(){return}getDerivedEntityProjections($){return[]}getDerivedEntityProjectionController($){return this.derivedEntityProjectionControllers.get($)}}});var zG=B(()=>{F8()});var DG=B(()=>{s9();zG()});var OZ=()=>{};class l6{logger;constructor($){this.logger=$}buildDetailResult($,X){throw Error(`${this.id}: buildDetailResult() not implemented. Override this method or override fetch() to handle detail views.`)}parseQuery($){let X=B$.parse($);return{entityType:X.entityType??this.config.entityType,query:X.query??{}}}async fetch($,X,G){let Y=this.parseQuery($),J=G.entityService;if(Y.query.id){let H=await this.fetchDetail(Y.query.id,J);return X.parse(this.buildDetailResult(H.item,H.navigation))}let W=await this.fetchList(Y.query,J);return X.parse(this.buildListResult(W.items,W.pagination,Y.query))}async fetchDetail($,X){let G=await this.lookupEntity($,X),Y=this.transformEntity(G),J=null;if(this.config.enableNavigation)J=await this.resolveNavigation(G,X);return{item:Y,navigation:J}}async fetchList($,X,G){let Y=$.page??1,J=$.pageSize??$.limit??this.config.defaultLimit??100,W=(Y-1)*J,H=$.page!==void 0,[U,F]=await Promise.all([X.listEntities({entityType:this.config.entityType,options:{limit:J,offset:W,sortFields:this.config.defaultSort,...G}}),H?X.countEntities({entityType:this.config.entityType,options:G?.filter?{filter:G.filter}:void 0}):Promise.resolve(0)]),M=U.map((q)=>this.transformEntity(q)),Q=H?QG(F,Y,J):null;return{items:M,pagination:Q}}async resolveNavigation($,X,G){let Y=this.config.navigationLimit??1000,J=await X.listEntities({entityType:this.config.entityType,options:{limit:Y,sortFields:G??this.config.defaultSort}}),W=J.findIndex((Q)=>Q.id===$.id),H=W>0?J[W-1]:void 0,U=W<J.length-1?J[W+1]:void 0,F=H?this.transformEntity(H):null,M=U?this.transformEntity(U):null;return{prev:F,next:M}}async lookupEntity($,X){if(this.config.lookupField==="id"){let J=await X.getEntity({entityType:this.config.entityType,id:$});if(!J)throw Error(`${this.config.entityType} not found: ${$}`);return J}let Y=(await X.listEntities({entityType:this.config.entityType,options:{filter:{metadata:{slug:$}},limit:1}}))[0];if(!Y)throw Error(`${this.config.entityType} not found with slug: ${$}`);return Y}}var A$,B$;var ZZ=B(()=>{v1();I();A$=K.object({id:K.string().optional(),limit:K.number().optional(),page:K.number().optional(),pageSize:K.number().optional(),baseUrl:K.string().optional()}).passthrough(),B$=K.object({entityType:K.string().optional(),query:A$.optional()}).passthrough()});var c6,PG;var RZ=B(()=>{U8();I();c6=class c6 extends H8{context;entityType;constructor($,X,G){super($,{schema:G.schema,jobTypeName:G.jobTypeName});this.context=X,this.entityType=G.entityType}async afterCreate($,X,G,Y){}async onGenerationFailure($,X){}async process($,X,G){try{await this.reportProgress(G,{progress:i4.START,message:`Starting ${this.jobTypeName}`});let Y=await this.generate($,G);await this.reportProgress(G,{progress:i4.SAVE,message:`Saving ${this.entityType} to database`});let J=await this.context.entityService.createEntity({entity:{id:Y.id,entityType:this.entityType,content:Y.content,metadata:Y.metadata},options:Y.createOptions});return await this.afterCreate($,J.entityId,G,Y),await this.reportProgress(G,{progress:i4.COMPLETE,message:`${Y.title??this.entityType} created successfully`}),{success:!0,entityId:J.entityId,...Y.resultExtras}}catch(Y){if(Y instanceof PG)return await this.onGenerationFailure($,Y.message),{success:!1,error:Y.message};let J=S0(Y);return this.logger.error(`${this.jobTypeName} job failed`,{error:Y,jobId:X,data:this.summarizeDataForLog($)}),await this.onGenerationFailure($,J),O3.failure(Y)}}failEarly($){throw new PG($)}};PG=class PG extends Error{constructor($){super($);this.name="GenerationFailure"}}});var xE,AZ,BZ,bE;var VZ=B(()=>{G5();xE=K.object({userPermissionLevel:K.enum(["public","trusted","anchor"]).optional(),interfaceType:K.string().optional(),channelId:K.string().optional(),channelName:K.string().optional()}),AZ=K.object({toolName:K.string(),description:K.string(),args:K.unknown()}),BZ=K.object({toolName:K.string(),args:K.record(K.unknown()).optional(),jobId:K.string().optional(),data:K.unknown().optional()}),bE=K.object({text:K.string(),toolResults:K.array(BZ).optional(),pendingConfirmation:AZ.optional(),usage:K.object({promptTokens:K.number(),completionTokens:K.number(),totalTokens:K.number()})})});var hE,yE,fE,gE;var NZ=B(()=>{G5();hE=K.object({label:K.string(),url:K.string(),pluginId:K.string(),priority:K.number()}),yE=K.object({status:K.enum(["healthy","warning","error","unknown"]),message:K.string().optional(),lastCheck:K.string().optional(),details:K.record(K.unknown()).optional()}),fE=K.object({name:K.string(),pluginId:K.string(),status:K.string(),health:yE.optional()}),gE=K.object({model:K.string(),version:K.string(),uptime:K.number(),entities:K.number(),embeddings:K.number(),ai:K.object({model:K.string(),embeddingModel:K.string()}),daemons:K.array(fE),endpoints:K.array(hE)})});var mE,pE;var wZ=B(()=>{G5();e3();mE=K.union([K.object({success:K.boolean(),data:K.unknown().optional(),error:K.string().optional()}),K.object({noop:K.literal(!0)})]),pE=K.object({id:K.string(),timestamp:K.string(),type:K.string(),source:K.string(),target:K.string().optional(),metadata:K8.optional()})});var V$,_Z,zZ;var LG=B(()=>{m6();V$=Q5("conversations",{id:Y0("id").primaryKey(),sessionId:Y0("session_id").notNull(),interfaceType:Y0("interface_type").notNull(),channelId:Y0("channel_id").notNull(),started:Y0("started").notNull(),lastActive:Y0("last_active").notNull(),metadata:Y0("metadata"),created:Y0("created").notNull(),updated:Y0("updated").notNull()},($)=>({sessionIdx:o1("idx_conversations_session").on($.sessionId),channelIdx:o1("idx_conversations_channel").on($.channelId),interfaceSessionIdx:o1("idx_conversations_interface_session").on($.interfaceType,$.sessionId),interfaceChannelIdx:o1("idx_conversations_interface_channel").on($.interfaceType,$.channelId)})),_Z=Q5("messages",{id:Y0("id").primaryKey(),conversationId:Y0("conversation_id").notNull().references(()=>V$.id,{onDelete:"cascade"}),role:Y0("role").notNull(),content:Y0("content").notNull(),timestamp:Y0("timestamp").notNull(),metadata:Y0("metadata")},($)=>({conversationIdx:o1("idx_messages_conversation").on($.conversationId),timestampIdx:o1("idx_messages_timestamp").on($.timestamp)})),zZ=Q5("summary_tracking",{conversationId:Y0("conversation_id").primaryKey().references(()=>V$.id,{onDelete:"cascade"}),lastSummarizedAt:Y0("last_summarized_at"),lastMessageId:Y0("last_message_id"),messagesSinceSummary:B1("messages_since_summary").default(0),updated:Y0("updated").notNull()})});import{createClient as G00}from"@libsql/client";var DZ=B(()=>{LG()});var uE,PZ;var CG=B(()=>{I();uE=K.object({id:K.string(),conversationId:K.string(),role:K.string(),content:K.string(),timestamp:K.string(),metadata:K.string().nullable()}),PZ=K.object({conversationId:K.string(),messageCount:K.number(),messages:K.array(uE),windowStart:K.number(),windowEnd:K.number(),windowSize:K.number(),timestamp:K.string()})});var LZ=B(()=>{DZ();CG();LG();I()});var CZ=B(()=>{LZ();CG()});var TG=B(()=>{U8()});var cE,EG;var TZ=B(()=>{I();cE=["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"],EG=K.object({captureUrls:K.boolean().default(!1),blockedUrlDomains:K.array(K.string()).default(cE)})});var EZ=B(()=>{DG();TG();TZ()});var IZ=()=>{};var jZ=B(()=>{EZ();TG();IZ()});async function q8($){let{entityType:X,title:G,deriveId:Y,regeneratePrompt:J,context:W}=$,H=Y(G);if(!await W.entityService.getEntity({entityType:X,id:H}))return G;W.logger.debug(`Entity ID collision: ${X}/${H}, asking AI for a new title`);let F=K.object({title:K.string().max(80).describe("A short, unique title (2-6 words)")}),{object:M}=await W.ai.generateObject(`The title "${G}" is already taken. ${J}`,F),Q=M.title;return W.logger.debug(`AI suggested new title: "${Q}"`),Q}var SZ=B(()=>{I()});var eE,kZ,$I,vZ,XI,GI,YI,JI;var xZ=B(()=>{I();eE=K.object({id:K.string(),template:K.string(),content:K.unknown().optional(),dataQuery:K.object({entityType:K.string().optional(),template:K.string().optional(),query:K.object({id:K.string().optional(),limit:K.number().optional(),offset:K.number().optional()}).passthrough().optional()}).passthrough().optional(),order:K.number().optional()}),kZ=["primary","secondary"],$I=K.object({show:K.boolean().default(!1),label:K.string().optional(),slot:K.enum(kZ).default("primary"),priority:K.number().min(0).max(100).default(50)}).optional(),vZ=K.object({id:K.string(),path:K.string(),title:K.string().default(""),description:K.string().default(""),sections:K.array(eE).default([]),layout:K.string().default("default"),fullscreen:K.boolean().optional(),pluginId:K.string().optional(),sourceEntityType:K.string().optional(),external:K.boolean().optional(),navigation:$I}),XI=K.object({routes:K.array(vZ),pluginId:K.string()}),GI=K.object({paths:K.array(K.string()).optional(),pluginId:K.string().optional()}),YI=K.object({pluginId:K.string().optional()}),JI=K.object({path:K.string()})});var WI;var bZ=B(()=>{I();WI=K.object({enabled:K.boolean().describe("Whether the plugin is enabled"),debug:K.boolean().describe("Enable debug logging for this plugin")})});var IG,N$;var jG=B(()=>{I();v1();IG=N1.extend({id:K.literal("brain-character"),entityType:K.literal("brain-character")}),N$=K.object({name:K.string().describe("The brain's friendly display name"),role:K.string().describe("The brain's primary role"),purpose:K.string().describe("The brain's purpose and goals"),values:K.array(K.string()).describe("Core values that guide behavior")})});var w$;var SG=B(()=>{v1();jG();w$=class w$ extends V1{constructor(){super({entityType:"brain-character",schema:IG,frontmatterSchema:N$,isSingleton:!0,hasBody:!1})}createCharacterContent($){return this.buildMarkdown("",$)}parseCharacterBody($){return this.parseFrontmatter($)}toMarkdown($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}fromMarkdown($){return{content:$,entityType:"brain-character"}}extractMetadata($){let X=this.parseFrontmatter($.content);return{role:X.role,values:X.values}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}});var U2;var hZ=B(()=>{v1();SG();U2=class U2 extends u6{static instance=null;adapter=new w$;static getDefaultCharacter(){return{name:"Brain",role:"Knowledge assistant",purpose:"Help organize, understand, and retrieve information from your knowledge base",values:["clarity","accuracy","helpfulness"]}}static getInstance($,X,G){return U2.instance??=new U2($,X,G),U2.instance}static resetInstance(){U2.instance=null}static createFresh($,X,G){return new U2($,X,G)}constructor($,X,G){super($,X,"brain-character",G??U2.getDefaultCharacter())}parseBody($){return this.adapter.parseCharacterBody($)}createContent($){return this.adapter.createCharacterContent($)}getCharacter(){return this.get()}getCharacterContent(){return this.getContent()}}});async function q5($){let G=(await $.listEntities({entityType:"anchor-profile",options:{limit:1}}))[0];if(!G)throw Error("Profile not found \u2014 create an anchor-profile entity");return G.content}var r6;var yZ=B(()=>{I();r6=K.object({tagline:K.string().optional().describe("Short, punchy one-liner for homepage"),intro:K.string().optional().describe("Optional longer introduction for homepage"),story:K.string().optional().describe("Extended bio/narrative (multi-paragraph markdown)")})});var kG,O5;var vG=B(()=>{I();v1();kG=N1.extend({id:K.literal("anchor-profile"),entityType:K.literal("anchor-profile")}),O5=K.object({name:K.string().describe("Name (person or organization)"),kind:K.enum(["professional","team","collective"]).describe("Type of anchor: professional (individual), team, or collective"),organization:K.string().optional().describe("Organization the anchor belongs to"),description:K.string().optional().describe("Short description or biography"),avatar:K.string().optional().describe("URL or asset path to avatar/logo"),website:K.string().optional().describe("Primary website URL"),email:K.string().optional().describe("Contact email"),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")})).optional().describe("Social media and contact links")})});var m1;var xG=B(()=>{v1();vG();m1=class m1 extends V1{constructor(){super({entityType:"anchor-profile",schema:kG,frontmatterSchema:O5,isSingleton:!0,hasBody:!0})}createProfileContent($){let X=O5.parse($);return this.buildMarkdown("",X)}parseProfileBody($,X){if(X){let{metadata:G,content:Y}=I0($,X);return Y?{...G,story:Y}:G}return this.parseFrontmatter($)}fromMarkdown($){return{content:$,entityType:"anchor-profile"}}extractMetadata($){let X=this.parseFrontmatter($.content);return{name:X.name,email:X.email,website:X.website}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}});var I5;var fZ=B(()=>{v1();xG();I5=class I5 extends u6{static instance=null;adapter=new m1;static getDefaultProfile(){return{name:"Unknown",kind:"professional"}}static getInstance($,X,G){return I5.instance??=new I5($,X,G),I5.instance}static resetInstance(){I5.instance=null}static createFresh($,X,G){return new I5($,X,G)}constructor($,X,G){super($,X,"anchor-profile",G??I5.getDefaultProfile())}parseBody($){return this.adapter.parseProfileBody($)}createContent($){return this.adapter.createProfileContent($)}getProfile(){return this.get()}getProfileContent(){return this.getContent()}}});var d2=B(()=>{hZ();SG();jG();yZ();fZ();xG();vG()});var gZ,HI,UI,KI;var mZ=B(()=>{I();d2();gZ=K.object({id:K.string(),description:K.string(),name:K.string().optional(),tags:K.array(K.string()).optional().default([])}).passthrough(),HI=K.object({uri:K.string(),params:K.record(K.unknown()).optional()}).passthrough(),UI=K.object({name:K.string(),url:K.string(),description:K.string().optional(),skills:K.array(gZ).optional().default([]),capabilities:K.object({extensions:K.array(HI).optional().default([])}).passthrough().optional()}).passthrough(),KI=K.object({name:K.string(),description:K.string(),tags:K.array(K.string()),examples:K.array(K.string())})});var i6=()=>{};var s1;var O8=B(()=>{s1=class s1 extends Error{pluginId;constructor($,X){super(`Plugin ${$}: ${X}`);this.name="PluginError",this.pluginId=$}}});class bG{plugins;events;daemonRegistry;logger;constructor($,X,G,Y){this.plugins=$;this.events=X;this.daemonRegistry=G;this.logger=Y.child("PluginLifecycle")}async initializePlugin($,X,G){let Y=this.plugins.get($);if(!Y)throw new s1($,"Registration failed: Plugin is not registered");let J=Y.plugin;this.logger.debug(`Initializing plugin: ${$}`),this.events.emit("plugin:before_initialize",$,J);try{let W=await J.register(X,G);return Y.status="initialized",this.logger.debug(`Initialized plugin: ${$}`),this.events.emit("plugin:initialized",$,J),W}catch(W){let H=S0(W);throw this.logger.error(`Error initializing plugin ${$}: ${H}`),Y.status="error",Y.error=n4(W),this.events.emit("plugin:error",$,W),W}}async readyPlugin($){let X=this.plugins.get($);if(!X)throw new s1($,"Ready failed: Plugin is not registered");if(X.status!=="initialized"){this.logger.debug(`Skipping ready hook for non-initialized plugin: ${$}`);return}try{await X.plugin.ready?.(),this.logger.debug(`Ready hook completed for plugin: ${$}`)}catch(G){let Y=n4(G);throw X.status="error",X.error=Y,this.events.emit("plugin:error",$,Y),Y}}async startPluginDaemons($){let X=this.plugins.get($);if(X?.status!=="initialized")return;try{await this.daemonRegistry.startPlugin($),this.logger.debug(`Started daemons for plugin: ${$}`)}catch(G){if(X.plugin.requiresDaemonStartup?.())throw G;this.logger.warn(`Daemon ${$} failed to start: ${S0(G)}`)}}async disablePlugin($){let X=this.plugins.get($);if(!X){this.logger.warn(`Cannot disable plugin ${$}: not registered`);return}this.logger.debug(`Disabling plugin: ${$}`);try{await this.daemonRegistry.stopPlugin($),this.logger.debug(`Stopped daemons for plugin: ${$}`)}catch(G){this.logger.error(`Failed to stop daemons for plugin: ${$}`,G)}if(X.plugin.shutdown)try{await X.plugin.shutdown(),this.logger.debug(`Shutdown completed for plugin: ${$}`)}catch(G){this.logger.error(`Plugin shutdown failed for ${$}:`,G)}X.status="disabled",this.events.emit("plugin:disabled",$,X.plugin),this.logger.debug(`Disabled plugin: ${$}`)}async enablePlugin($){let X=this.plugins.get($);if(!X){this.logger.warn(`Cannot enable plugin ${$}: not registered`);return}if(X.status!=="disabled"){this.logger.warn(`Cannot enable plugin ${$}: not disabled`);return}this.logger.debug(`Enabling plugin: ${$}`),X.status="initialized";try{await this.daemonRegistry.startPlugin($),this.logger.debug(`Started daemons for plugin: ${$}`)}catch(G){this.logger.error(`Failed to start daemons for plugin: ${$}`,G)}this.events.emit("plugin:enabled",$,X.plugin),this.logger.debug(`Enabled plugin: ${$}`)}}var pZ=B(()=>{I();i6();O8()});class hG{plugins;events;logger;constructor($,X,G){this.plugins=$;this.events=X;this.logger=G.child("DependencyResolver")}async resolveInitializationOrder($){this.logger.debug("Resolving plugin initialization order...");let X=Array.from(this.plugins.keys()),G=new Set,Y=!0;while(Y&&G.size<X.length){Y=!1;for(let H of X){if(G.has(H))continue;if(!this.plugins.get(H))continue;if(this.getUnmetDependencies(H).length===0)try{await $(H),G.add(H),Y=!0}catch(M){let Q=S0(M);this.logger.error(`Failed to initialize plugin ${H}: ${Q}`),G.add(H),Y=!0}}}let J=X.filter((H)=>!G.has(H));if(J.length>0){let H=J.join(", ");this.logger.error(`Failed to initialize plugins due to dependency issues: ${H}`);for(let U of J){let F=this.getUnmetDependencies(U);this.logger.error(`Plugin ${U} has unmet dependencies: ${F.join(", ")}`);let M=this.plugins.get(U);if(M)M.status="error",M.error=new s1(U,`Unmet dependencies: ${F.join(", ")}`);this.events.emit("plugin:error",U,M?.error)}}let W=new Set;for(let[H,U]of this.plugins)if(U.status==="initialized")W.add(H);return this.logger.debug(`Resolved ${W.size} of ${X.length} plugins`),{initialized:W,failed:J}}getUnmetDependencies($){let X=this.plugins.get($);if(!X)return[];let{dependencies:G}=X,Y=[];for(let J of G){let W=this.plugins.get(J);if(!W){Y.push(J);continue}if(W.status!=="initialized")Y.push(J)}return Y}}var uZ=B(()=>{I();i6();O8()});class yG{logger;constructor($){this.logger=$.child("CapabilityRegistrar")}async registerCapabilities($,X,G){if(G.tools.length>0)$.registerTools(X,G.tools),this.logger.debug(`Registered ${G.tools.length} tools from ${X}`);if(G.resources.length>0)$.registerResources(X,G.resources),this.logger.debug(`Registered ${G.resources.length} resources from ${X}`);if(G.instructions)$.registerInstructions(X,G.instructions),this.logger.debug(`Registered instructions from ${X}`)}}import{EventEmitter as dZ}from"events";class K2{static instance=null;plugins=new Map;logger;events=new dZ;daemonRegistry;shell=null;initializedPluginIds=[];pluginLifecycle;dependencyResolver;capabilityRegistrar;static getInstance($,X){return K2.instance??=new K2($,X),K2.instance}static resetInstance(){K2.instance=null}static createFresh($,X){return new K2($,X)}setShell($){this.shell=$}constructor($,X){this.logger=$.child("PluginManager"),this.events=new dZ,this.daemonRegistry=X,this.pluginLifecycle=new bG(this.plugins,this.events,this.daemonRegistry,$),this.dependencyResolver=new hG(this.plugins,this.events,$),this.capabilityRegistrar=new yG($)}registerPlugin($){if(!$.id)throw new s1("unknown","Registration failed: Plugin must have an id");if(this.logger.debug(`Registering plugin: ${$.id} (${$.version})`),this.plugins.has($.id)){let J=this.plugins.get($.id)?.plugin.version;throw new s1($.id,`Registration failed: Plugin is already registered with version ${J}`)}let X=$.dependencies??[],G={plugin:$,status:"registered",dependencies:X};this.plugins.set($.id,G),this.logger.debug(`Registered plugin: ${$.id} (${$.version})`),this.events.emit("plugin:registered",$.id,$)}async initializePlugins($){this.logger.debug("Initializing plugins..."),this.initializedPluginIds=[];let X=await this.dependencyResolver.resolveInitializationOrder(async(G)=>{await this.initializePlugin(G,$)});this.logger.debug(`Initialized ${X.initialized.size} of ${this.plugins.size} plugins`)}async initializePlugin($,X){if(!this.shell)throw new s1($,"Cannot initialize plugin: Shell not set. Call setShell() first.");let G=this.shell,Y=await this.pluginLifecycle.initializePlugin($,G,X);await this.capabilityRegistrar.registerCapabilities(G,$,Y),this.initializedPluginIds.push($)}async readyPlugins(){this.logger.debug("Dispatching plugin ready hooks..."),await Promise.all(this.initializedPluginIds.map(($)=>this.pluginLifecycle.readyPlugin($)))}async startPluginDaemons(){this.logger.debug("Starting plugin daemons..."),await Promise.all(this.initializedPluginIds.map(($)=>this.pluginLifecycle.startPluginDaemons($)))}getPlugin($){return this.plugins.get($)?.plugin}getPluginStatus($){return this.plugins.get($)?.status}hasPlugin($){return this.plugins.has($)}isPluginInitialized($){return this.plugins.get($)?.status==="initialized"}getAllPluginIds(){return Array.from(this.plugins.keys())}getAllPlugins(){return new Map(this.plugins)}getFailedPlugins(){return Array.from(this.plugins.entries()).filter(($)=>$[1].status==="error"&&$[1].error!==void 0).map(([$,X])=>({id:$,error:X.error}))}getPluginPackageName($){return this.plugins.get($)?.plugin.packageName}async disablePlugin($){await this.pluginLifecycle.disablePlugin($)}async enablePlugin($){await this.pluginLifecycle.enablePlugin($)}on($,X){this.events.on($,X)}once($,X){this.events.once($,X)}off($,X){this.events.off($,X)}getEventEmitter(){return this.events}}var lZ=B(()=>{i6();O8();pZ();uZ();i6()});var cZ=B(()=>{lZ();i6()});var Q0=B(()=>{MZ();qZ();_G();NG();ZG();DG();OZ();t3();BG();F8();zG();w3();v1();ZZ();v1();U8();RZ();U5();VZ();NZ();XG();JG();wZ();CZ();jZ();N3();SZ();I();xZ();bZ();d2();mZ();cZ();O8()});var FI,Q1,MI,n6,Z8,a1,R8;var Z5=B(()=>{I();Q0();FI=K.enum(["draft","queued","published"]),Q1=K.object({title:K.string(),slug:K.string().optional(),status:FI,publishedAt:K.string().datetime().optional(),excerpt:K.string(),author:K.string(),coverImageId:K.string().optional(),seriesName:K.string().optional(),seriesIndex:K.number().optional(),ogImage:K.string().url().optional(),ogDescription:K.string().optional(),twitterCard:K.enum(["summary","summary_large_image"]).optional(),canonicalUrl:K.string().url().optional()}),MI=Q1.pick({title:!0,status:!0,publishedAt:!0,seriesName:!0,seriesIndex:!0}).extend({slug:K.string()}),n6=N1.extend({entityType:K.literal("post"),metadata:MI}),Z8=n6.extend({frontmatter:Q1,body:K.string(),coverImageUrl:K.string().optional()}),a1=Z8.extend({url:K.string().optional(),typeLabel:K.string().optional(),listUrl:K.string().optional(),listLabel:K.string().optional(),seriesUrl:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional(),coverImageSrcset:K.string().optional(),coverImageSizes:K.string().optional()}),R8=Z8.extend({url:K.string(),typeLabel:K.string(),listUrl:K.string(),listLabel:K.string(),seriesUrl:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional(),coverImageSrcset:K.string().optional(),coverImageSizes:K.string().optional()})});var rZ={};b8(rZ,{blogPostAdapter:()=>l2,BlogPostAdapter:()=>D$});var D$,l2;var A8=B(()=>{Q0();I();Z5();D$=class D$ extends V1{constructor(){super({entityType:"post",schema:n6,frontmatterSchema:Q1,supportsCoverImage:!0})}toMarkdown($){let X=this.extractBody($.content);try{let G=this.parseFrontMatter($.content,Q1),Y={...G,slug:G.slug??$.metadata.slug};return this.buildMarkdown(X,Y)}catch{return X}}fromMarkdown($){let X=this.parseFrontMatter($,Q1),G=X.slug??f1(X.title);return{content:$,entityType:"post",metadata:{title:X.title,slug:G,status:X.status,publishedAt:X.publishedAt,seriesName:X.seriesName,seriesIndex:X.seriesIndex}}}parsePostFrontmatter($){return this.parseFrontMatter($.content,Q1)}createPostContent($,X){return this.buildMarkdown(X,$)}};l2=new D$});function b1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function TR($){return new Date($).toUTCString()}function S$($,X){let G=$.filter((M)=>{if(X.includeAllPosts)return!0;return M.frontmatter.status==="published"&&M.frontmatter.publishedAt}).sort((M,Q)=>{let q=new Date(M.frontmatter.publishedAt??M.created);return new Date(Q.frontmatter.publishedAt??Q.created).getTime()-q.getTime()}),Y=G.length>0&&G[0]?G[0].frontmatter.publishedAt??G[0].created:new Date().toISOString(),J=G.map((M)=>{let Q=`${X.link}/posts/${M.metadata.slug}`,q=M.frontmatter.publishedAt??M.created,A=M.frontmatter.excerpt,Z=M.frontmatter.author;return` <item>
|
|
173
173
|
<title>${b1(M.frontmatter.title)}</title>
|
|
174
174
|
<link>${b1(Q)}</link>
|
|
175
175
|
<guid isPermaLink="true">${b1(Q)}</guid>
|
|
@@ -787,7 +787,7 @@ The excerpt should be clear, concise, and compelling.`});I();U5();Z5();import{js
|
|
|
787
787
|
Note: This is part of a series called "${G.seriesName}".`:""}`;return $.ai.generate({prompt:Y,templateName:"blog:generation"})}),$.eval.registerHandler("generateExcerpt",async(X)=>{let G=yj.parse(X);return $.ai.generate({prompt:`Title: ${G.title}
|
|
788
788
|
|
|
789
789
|
Content:
|
|
790
|
-
${G.content}`,templateName:"blog:excerpt"})})}var jR={name:"@brains/blog",private:!0,version:"0.2.0-alpha.55",description:"AI-powered blog post generation from existing brain content",type:"module",exports:{".":"./src/index.ts"},scripts:{typecheck:"tsc --noEmit",test:"bun test",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix",eval:"cd evals && bun run brain-eval"},dependencies:{"@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};class xR extends H2{entityType=l2.entityType;schema=n6;adapter=l2;constructor($={}){super("blog",jR,$,fG)}getEntityTypeConfig(){return{weight:2}}createGenerationHandler($){return new gG(this.logger.child("BlogGenerationJobHandler"),$)}getTemplates(){return PR()}getDataSources(){return[new pG(this.logger.child("BlogDataSource"))]}async onRegister($){let{RSSDataSource:X}=await Promise.resolve().then(() => (vR(),kR));$.entities.registerDataSource(new X(this.logger.child("RSSDataSource"))),await LR($,this.logger),CR($,this.logger),ER($,this.logger),IR($),this.logger.info("Blog plugin registered (routes auto-generated at /posts/)")}}Z5();A8();Q0();I();var bR=K.object({id:K.string(),template:K.string(),content:K.unknown().optional(),dataQuery:K.object({entityType:K.string().optional(),template:K.string().optional(),query:K.object({id:K.string().optional(),limit:K.number().optional(),offset:K.number().optional()}).passthrough().optional()}).passthrough().optional(),order:K.number().optional()}),hR=["primary","secondary"],yR=K.object({show:K.boolean().default(!1),label:K.string().optional(),slot:K.enum(hR).default("primary"),priority:K.number().min(0).max(100).default(50)}).optional(),fR=K.object({id:K.string(),path:K.string(),title:K.string().default(""),description:K.string().default(""),sections:K.array(bR).default([]),layout:K.string().default("default"),fullscreen:K.boolean().optional(),pluginId:K.string().optional(),sourceEntityType:K.string().optional(),external:K.boolean().optional(),navigation:yR}),mj=K.object({routes:K.array(fR),pluginId:K.string()}),pj=K.object({paths:K.array(K.string()).optional(),pluginId:K.string().optional()}),uj=K.object({pluginId:K.string().optional()}),dj=K.object({path:K.string()}),k$=K.object({label:K.string(),href:K.string(),priority:K.number()});I();var v$=K.object({heading:K.string().describe("Main CTA heading text"),buttonText:K.string().describe("Call-to-action button text"),buttonLink:K.string().describe("URL or anchor for the CTA button")}),x$=K.object({blurb:K.string().optional().describe("Short italic subtitle under the section title")}),b$=K.object({title:K.string().describe("The site's title"),description:K.string().describe("The site's description"),url:K.string().optional().describe("Canonical site URL"),copyright:K.string().optional().describe("Copyright notice text"),logo:K.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:K.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:K.string().optional().describe("Analytics script HTML"),cta:v$.optional().describe("Call-to-action configuration"),sections:K.record(K.string(),x$).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),lj=K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")}),cj=b$.extend({navigation:K.object({primary:K.array(k$),secondary:K.array(k$)}),copyright:K.string(),socialLinks:K.array(lj).optional().describe("Social media links from profile metadata")});I();var rj=K.string(),ij=K.object({id:K.string().min(1)}).passthrough(),nj=K.object({label:K.string().min(1)}).passthrough(),oj=K.object({layouts:K.record(K.unknown()),plugin:K.function(),routes:K.array(ij),entityDisplay:K.record(nj),staticAssets:K.record(K.string()).optional()}).passthrough(),sj=K.custom(($)=>oj.safeParse($).success);I();Q0();var gR=K.object({}),h$=N1.extend({id:K.literal("site-info"),entityType:K.literal("site-info"),metadata:gR}),E8=v$,J4=b$.omit({url:!0,analyticsScript:!0});Q0();class x5 extends V1{constructor(){super({entityType:"site-info",schema:h$,frontmatterSchema:J4,isSingleton:!0,hasBody:!1})}createSiteInfoContent($){let X=J4.parse($);return this.buildMarkdown("",X)}parseSiteInfoBody($){return this.parseFrontmatter($)}fromMarkdown($){return{content:$,entityType:"site-info"}}extractMetadata($){return{}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}var RX0=new x5;var TX0=new x5;var XS=new x5;async function I8($){let G=(await $.listEntities({entityType:"site-info",options:{limit:1}}))[0];if(!G)throw Error("Site info not found \u2014 create a site-info entity");return XS.parseSiteInfoBody(G.content)}I();var GS=J4.extend({navigation:K.object({primary:K.array(K.object({label:K.string(),href:K.string(),priority:K.number()})),secondary:K.array(K.object({label:K.string(),href:K.string(),priority:K.number()}))}),copyright:K.string(),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")})).optional().describe("Social media links from profile entity")});Q0();var y$=r6,q2=O5.extend(y$.shape);Q0();d2();I();var YS=new m1;class f${postsListUrl;id="personal:homepage";name="Personal Homepage DataSource";description="Fetches profile and blog posts for a personal homepage";constructor($){this.postsListUrl=$}async fetch($,X,G){let Y=G.entityService,[J,W,H]=await Promise.all([q5(Y),Y.listEntities({entityType:"post",options:{limit:20}}),I8(Y)]),U=YS.parseProfileBody(J,q2),F=W.sort(h6).slice(0,6).map(c2);if(!H.cta)throw Error("CTA not configured in site-info");let M={profile:U,posts:F,postsListUrl:this.postsListUrl,cta:H.cta};return X.parse(M)}}Q0();d2();var JS=new m1;class g${id="personal:about";name="About Page DataSource";description="Fetches full profile data for the about page";async fetch($,X,G){let Y=await q5(G.entityService),W={profile:JS.parseProfileBody(Y,q2)};return X.parse(W)}}import{jsxDEV as U0,Fragment as mR}from"preact/jsx-dev-runtime";function WS($){return new Date($).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function HS($){return $.split(/(\*[^*]+\*)/).map((X,G)=>{if(X.startsWith("*")&&X.endsWith("*")&&X.length>2)return U0("em",{className:"font-sans italic font-medium text-theme-inverse tracking-[-0.015em] [font-variation-settings:'opsz'_72]",children:X.slice(1,-1)},G,!1,void 0,this);return X})}var MY=({profile:$,posts:X,postsListUrl:G,cta:Y})=>{let J=$.tagline??$.description,W=$.name.split(" ")[0];return U0(mR,{children:[U0(s0,{title:$.name,description:$.description??J??"Personal site",ogType:"website"},void 0,!1,void 0,this),U0("header",{className:"hero-decor bg-brand text-theme-inverse relative flex flex-col items-center justify-center px-6 md:px-12 pt-32 pb-24 gap-7",children:U0("div",{className:"w-full max-w-[1100px] mx-auto text-center flex flex-col items-center gap-7",children:[J&&U0("h1",{className:"font-heading font-bold text-[clamp(2.5rem,6vw,5rem)] leading-[1.05] tracking-[-0.035em] text-theme-inverse text-balance m-0 [font-variation-settings:'wdth'_90,'opsz'_96]",children:HS(J)},void 0,!1,void 0,this),$.description&&U0("p",{className:"text-[clamp(1.0625rem,1.4vw,1.3125rem)] leading-[1.5] text-theme-inverse opacity-95 max-w-[600px] mx-auto m-0",children:$.description},void 0,!1,void 0,this),U0("div",{className:"flex flex-wrap justify-center gap-3.5 mt-2",children:[U0("a",{href:G,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-theme text-brand border-2 border-theme font-heading font-semibold text-[15px] hover:bg-theme-subtle hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["Read the Blog ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("a",{href:"/about",className:"rounded-full py-3.5 px-7 border-2 border-theme-light text-theme-inverse font-heading font-semibold text-[15px] hover:bg-brand-dark hover:border-theme hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["About ",W]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X.length>0&&U0("section",{className:"flex flex-col py-24 px-6 md:px-12 gap-11 bg-theme-subtle",children:[U0("div",{className:"flex justify-between items-end max-w-layout mx-auto w-full gap-6 flex-wrap",children:[U0("div",{children:[U0("span",{className:"block font-heading font-semibold text-[13px] uppercase tracking-[0.22em] text-brand mb-3 [font-variation-settings:'wdth'_85,'opsz'_12]",children:"The Archive"},void 0,!1,void 0,this),U0("h2",{className:"font-heading font-bold text-[clamp(2.25rem,5vw,3.75rem)] leading-none tracking-[-0.03em] text-heading m-0 [font-variation-settings:'wdth'_92,'opsz'_64]",children:["Recent"," ",U0("em",{className:"font-sans italic font-medium text-brand [font-variation-settings:'opsz'_60]",children:"posts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U0("a",{href:G,className:"font-heading font-semibold text-[15px] text-brand inline-flex items-center gap-1.5 pb-1.5 border-b-2 border-current hover:text-brand-dark transition-colors [font-variation-settings:'wdth'_88,'opsz'_16]",children:["View the whole archive ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U0("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] gap-8 max-w-layout mx-auto w-full",children:X.map((H)=>U0("a",{href:H.url,className:"group flex flex-col bg-theme border border-theme rounded-md overflow-hidden hover:-translate-y-1 hover:border-brand/50 transition-all no-underline shadow-sm hover:shadow-lg",children:[H.coverImageUrl?U0("img",{src:H.coverImageUrl,alt:H.metadata.title,className:"w-full aspect-[16/10] object-cover bg-theme-muted"},void 0,!1,void 0,this):U0("div",{className:"w-full aspect-[16/10] bg-gradient-to-br from-brand to-accent","aria-hidden":"true"},void 0,!1,void 0,this),U0("div",{className:"flex flex-col gap-4 p-7 flex-1",children:[U0("div",{className:"flex flex-wrap items-center gap-3.5 font-heading text-[11px] font-semibold uppercase tracking-[0.18em] text-theme-muted [font-variation-settings:'wdth'_85,'opsz'_11]",children:[H.frontmatter.seriesName&&U0(mR,{children:[U0("span",{className:"text-brand",children:H.frontmatter.seriesName},void 0,!1,void 0,this),U0("span",{className:"w-[3px] h-[3px] rounded-full bg-current opacity-50","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("time",{children:WS(H.metadata.publishedAt??H.created)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("h3",{className:"font-sans font-semibold text-[clamp(1.375rem,1.8vw,1.625rem)] leading-[1.18] tracking-[-0.012em] text-heading m-0 text-balance",children:H.metadata.title},void 0,!1,void 0,this),H.frontmatter.excerpt&&U0("p",{className:"text-base leading-[1.55] text-theme-muted m-0 flex-1",children:H.frontmatter.excerpt},void 0,!1,void 0,this),U0("span",{className:"inline-flex items-center gap-1.5 font-heading font-semibold text-[13px] uppercase tracking-[0.14em] text-brand mt-1 [font-variation-settings:'wdth'_88,'opsz'_14]",children:["Read the post"," ",U0("span",{"aria-hidden":"true",className:"transition-transform group-hover:translate-x-1",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},H.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("section",{className:"cta-decor bg-theme-dark text-theme-on-dark flex-grow flex flex-col items-center justify-center py-24 px-6 md:px-12 gap-5",children:[U0("span",{className:"font-heading font-medium text-xs uppercase tracking-[0.24em] text-accent [font-variation-settings:'wdth'_85,'opsz'_12]",children:"Get in touch"},void 0,!1,void 0,this),U0("h2",{className:"text-center font-heading font-bold text-[clamp(2rem,4vw,3rem)] leading-none tracking-[-0.03em] text-theme-on-dark m-0 [font-variation-settings:'wdth'_90,'opsz'_64]",children:Y.heading},void 0,!1,void 0,this),Y.subtitle&&U0("p",{className:"text-center text-base leading-[1.55] text-theme-on-dark opacity-80 max-w-[480px] m-0",children:Y.subtitle},void 0,!1,void 0,this),U0("a",{href:Y.buttonLink,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-brand text-theme-inverse border-2 border-brand font-heading font-semibold text-[15px] hover:bg-brand-dark hover:-translate-y-0.5 transition-all mt-2 [font-variation-settings:'wdth'_92,'opsz'_18]",children:[Y.buttonText," ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as X1,Fragment as US}from"preact/jsx-dev-runtime";var QY=({profile:$})=>{let X=`About ${$.name}`,G=$.description??$.intro??"About page",Y=Boolean($.email??$.website);return X1(US,{children:[X1(s0,{title:X,description:G,ogType:"profile"},void 0,!1,void 0,this),X1("section",{className:"hero-decor bg-brand text-theme-inverse relative flex flex-col px-6 md:px-12 pt-32 pb-24",children:X1("div",{className:"w-full max-w-3xl mx-auto flex flex-col gap-6",children:[X1("h1",{className:"font-heading font-bold text-[clamp(2.5rem,6vw,4.5rem)] leading-[1.05] tracking-[-0.035em] text-theme-inverse text-balance m-0 [font-variation-settings:'wdth'_90,'opsz'_96]",children:$.name},void 0,!1,void 0,this),$.description&&X1("p",{className:"text-[clamp(1.0625rem,1.4vw,1.25rem)] leading-[1.55] text-theme-inverse opacity-95 max-w-2xl m-0",children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$.story&&X1("section",{className:`py-24 px-6 md:px-12 bg-theme-subtle${Y?"":" flex-grow"}`,children:X1("div",{className:"max-w-3xl mx-auto",children:X1(i2,{markdown:$.story},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&X1("section",{className:"cta-decor bg-theme-dark text-theme-on-dark flex-grow flex flex-col items-center justify-center py-24 px-6 md:px-12 gap-5",children:[X1("span",{className:"font-heading font-medium text-xs uppercase tracking-[0.24em] text-accent [font-variation-settings:'wdth'_85,'opsz'_12]",children:"Get in touch"},void 0,!1,void 0,this),X1("h2",{className:"text-center font-heading font-bold text-[clamp(2rem,4vw,3rem)] leading-none tracking-[-0.03em] text-theme-on-dark m-0 [font-variation-settings:'wdth'_90,'opsz'_64]",children:["Say"," ",X1("em",{className:"font-sans italic font-medium text-accent [font-variation-settings:'opsz'_72]",children:"hi."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X1("div",{className:"flex flex-wrap justify-center gap-3.5 mt-2",children:[$.email&&X1("a",{href:`mailto:${$.email}`,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-brand text-theme-inverse border-2 border-brand font-heading font-semibold text-[15px] hover:bg-brand-dark hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["Get in Touch ",X1("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.website&&X1("a",{href:$.website,className:"rounded-full py-3.5 px-7 border-2 border-theme-light text-theme-on-dark font-heading font-semibold text-[15px] hover:bg-brand-dark hover:border-theme hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:"Website"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var pR={name:"@brains/site-personal",private:!0,version:"0.2.0-alpha.55",description:"Personal site composition package",type:"module",exports:{".":"./src/index.ts"},files:["src"],scripts:{typecheck:"tsc --noEmit",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"},dependencies:{"@brains/blog":"workspace:*","@brains/identity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/site-engine":"workspace:*","@brains/site-info":"workspace:*","@brains/templates":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*",preact:"^10.27.2"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};var FS=K.object({entityDisplay:K.object({post:K.object({label:K.string().default("Post"),pluralName:K.string().optional()}).default({})}).default({})});class qY extends d6{dependencies=["blog"];constructor($={}){super("personal-site",pR,$,FS)}async onRegister($){$.entities.extendFrontmatterSchema("anchor-profile",y$);let X=this.config.entityDisplay.post,G=`/${X.pluralName??X.label.toLowerCase()+"s"}`,Y=new f$(G);$.entities.registerDataSource(Y);let J=new g$;$.entities.registerDataSource(J);let W=K.object({profile:q2,posts:K.array(a1),postsListUrl:K.string(),cta:E8}),H=K.object({profile:q2});$.templates.register({homepage:L0({name:"homepage",description:"Personal homepage with recent blog posts",schema:W,dataSourceId:"personal:homepage",requiredPermission:"public",layout:{component:MY}}),about:L0({name:"about",description:"About page with profile",schema:H,dataSourceId:"personal:about",requiredPermission:"public",layout:{component:QY}})}),this.logger.info("Personal site plugin registered successfully")}async getTools(){return[]}async getResources(){return[]}}function OY($){return new qY($??{})}var ZY=[{id:"home",path:"/",title:"Home",description:"Personal site homepage",layout:"default",navigation:{show:!0,label:"Home",slot:"secondary",priority:10},sections:[{id:"homepage",template:"personal-site:homepage",dataQuery:{}}]},{id:"about",path:"/about",title:"About",description:"About page",layout:"default",navigation:{show:!0,label:"About",slot:"primary",priority:90},sections:[{id:"about",template:"personal-site:about",dataQuery:{}}]}];import{jsxDEV as h1}from"preact/jsx-dev-runtime";function RY({sections:$,siteInfo:X}){let G=[...X.navigation.primary,...X.navigation.secondary].filter((Y)=>Y.label!=="Home");return h1("div",{className:"flex flex-col min-h-screen bg-theme overflow-x-clip",children:[h1(w8,{title:X.title,titleClassName:"font-heading font-bold text-2xl",navigation:X.navigation.primary,showThemeToggle:!0,themeToggleClassName:"bg-theme-toggle text-theme-toggle-icon hover:bg-theme-toggle-hover rounded-[10px]",...X.logo!==void 0?{logo:X.logo}:{}},void 0,!1,void 0,this),h1("main",{className:"flex-grow flex flex-col",children:$},void 0,!1,void 0,this),h1("footer",{className:"bg-footer text-footer border-t border-theme",children:h1("div",{className:"max-w-layout mx-auto flex flex-col md:flex-row justify-between items-center py-8 px-6 md:px-8",children:[h1("div",{className:"flex flex-col gap-1 mb-4 md:mb-0",children:[h1("span",{className:"text-brand font-heading font-bold text-lg",children:X.title},void 0,!1,void 0,this),X.description&&h1("span",{className:"text-theme-muted text-xs",children:X.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h1("nav",{className:"flex flex-wrap justify-center gap-x-6 gap-y-2 mb-4 md:mb-0",children:G.map((Y)=>h1("a",{href:Y.href,className:"text-theme-muted text-[13px] hover:text-brand transition-colors",children:Y.label},Y.href,!1,void 0,this))},void 0,!1,void 0,this),h1("div",{className:"flex items-center gap-4",children:[X.copyright&&h1("span",{className:"text-theme-light text-[11px]",children:X.copyright},void 0,!1,void 0,this),h1(Q2,{variant:"footer",size:"sm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}Q0();I();U5();Q0();I();Q0();I();I();Q0();var MS=K.enum(["draft","queued","published"]),O2=K.object({title:K.string(),slug:K.string().optional(),description:K.string().optional(),author:K.string().optional(),status:MS,publishedAt:K.string().datetime().optional(),event:K.string().optional(),coverImageId:K.string().optional()}),QS=O2.pick({title:!0,description:!0,status:!0,publishedAt:!0,coverImageId:!0}).extend({slug:K.string()}),m$=N1.extend({entityType:K.literal("deck"),metadata:QS}),p$=m$.extend({frontmatter:O2,body:K.string()}),j8=p$.extend({url:K.string().optional(),typeLabel:K.string().optional(),listUrl:K.string().optional(),listLabel:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional()});class AY extends V1{constructor(){super({entityType:"deck",schema:m$,frontmatterSchema:O2,supportsCoverImage:!0})}validateSlideStructure($){if(!/^---$/gm.test($))throw Error("Invalid deck: markdown must contain slide separators (---) to be a valid presentation")}toMarkdown($){let X=this.extractBody($.content);this.validateSlideStructure(X);try{let G=this.parseFrontMatter($.content,O2),Y={...G,slug:G.slug??$.metadata.slug};return this.buildMarkdown(X,Y)}catch{return X}}fromMarkdown($){let X=this.parseFrontmatter($),G=this.extractBody($);this.validateSlideStructure(G);let Y=X.slug??f1(X.title),J=X.status;return{entityType:"deck",content:$,metadata:{slug:Y,title:X.title,description:X.description,status:J,publishedAt:X.publishedAt,coverImageId:X.coverImageId}}}generateTitle($){return $.metadata.title}generateSummary($){if($.metadata.description)return $.metadata.description;return`Presentation: ${$.metadata.title}`}generateFrontMatter($){return this.toMarkdown($)}}var S8=new AY;I();U5();var qS=K.object({markdown:K.string().describe("Markdown content with slide separators (---)")}),BY=L0({name:"deck-detail",description:"Render a presentation deck as Reveal.js slides",schema:qS,dataSourceId:"decks:entities",requiredPermission:"public",layout:{component:cG,fullscreen:!0}});U5();I();var VY=K.object({decks:K.array(p$)}),NY=K.object({decks:K.array(j8),pageTitle:K.string().optional()});import{jsxDEV as wY}from"preact/jsx-dev-runtime";var _Y=({decks:$,pageTitle:X})=>{let G=$.map((Y)=>({id:Y.id,url:Y.url,title:Y.frontmatter.title,date:Y.frontmatter.publishedAt??Y.created,description:Y.frontmatter.description}));return wY("div",{className:"deck-list bg-theme",children:wY("div",{className:"container mx-auto px-6 md:px-12 max-w-4xl py-16 md:py-24",children:wY(D8,{title:X??"Presentations",items:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)};I();class u$ extends i9{constructor(){super(VY,{title:"Deck List",mappings:[{key:"decks",label:"Decks",type:"array",itemType:"object"}]})}}var zY=L0({name:"deck-list",description:"List view of all presentation decks",schema:NY,dataSourceId:"decks:entities",requiredPermission:"public",formatter:new u$,layout:{component:_Y}});I();Q0();var OS=K.object({title:K.string().max(80).describe("A short, punchy title (2-5 words) that's memorable and evocative"),content:K.string().describe("Full slide deck content in markdown format with slide separators (---). Each slide should have a header and focused content."),description:K.string().describe("A concise 1-2 sentence summary that captures the essence of the talk")}),uR=L0({name:"decks:generation",description:"Template for AI to generate complete slide decks from prompts",schema:OS,dataSourceId:"shell:ai-content",requiredPermission:"public",useKnowledgeContext:!0,basePrompt:`You are creating slide decks in a distinctive voice that blends philosophy, technology, and culture.
|
|
790
|
+
${G.content}`,templateName:"blog:excerpt"})})}var jR={name:"@brains/blog",private:!0,version:"0.2.0-alpha.57",description:"AI-powered blog post generation from existing brain content",type:"module",exports:{".":"./src/index.ts"},scripts:{typecheck:"tsc --noEmit",test:"bun test",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix",eval:"cd evals && bun run brain-eval"},dependencies:{"@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};class xR extends H2{entityType=l2.entityType;schema=n6;adapter=l2;constructor($={}){super("blog",jR,$,fG)}getEntityTypeConfig(){return{weight:2}}createGenerationHandler($){return new gG(this.logger.child("BlogGenerationJobHandler"),$)}getTemplates(){return PR()}getDataSources(){return[new pG(this.logger.child("BlogDataSource"))]}async onRegister($){let{RSSDataSource:X}=await Promise.resolve().then(() => (vR(),kR));$.entities.registerDataSource(new X(this.logger.child("RSSDataSource"))),await LR($,this.logger),CR($,this.logger),ER($,this.logger),IR($),this.logger.info("Blog plugin registered (routes auto-generated at /posts/)")}}Z5();A8();Q0();I();var bR=K.object({id:K.string(),template:K.string(),content:K.unknown().optional(),dataQuery:K.object({entityType:K.string().optional(),template:K.string().optional(),query:K.object({id:K.string().optional(),limit:K.number().optional(),offset:K.number().optional()}).passthrough().optional()}).passthrough().optional(),order:K.number().optional()}),hR=["primary","secondary"],yR=K.object({show:K.boolean().default(!1),label:K.string().optional(),slot:K.enum(hR).default("primary"),priority:K.number().min(0).max(100).default(50)}).optional(),fR=K.object({id:K.string(),path:K.string(),title:K.string().default(""),description:K.string().default(""),sections:K.array(bR).default([]),layout:K.string().default("default"),fullscreen:K.boolean().optional(),pluginId:K.string().optional(),sourceEntityType:K.string().optional(),external:K.boolean().optional(),navigation:yR}),mj=K.object({routes:K.array(fR),pluginId:K.string()}),pj=K.object({paths:K.array(K.string()).optional(),pluginId:K.string().optional()}),uj=K.object({pluginId:K.string().optional()}),dj=K.object({path:K.string()}),k$=K.object({label:K.string(),href:K.string(),priority:K.number()});I();var v$=K.object({heading:K.string().describe("Main CTA heading text"),buttonText:K.string().describe("Call-to-action button text"),buttonLink:K.string().describe("URL or anchor for the CTA button")}),x$=K.object({blurb:K.string().optional().describe("Short italic subtitle under the section title")}),b$=K.object({title:K.string().describe("The site's title"),description:K.string().describe("The site's description"),url:K.string().optional().describe("Canonical site URL"),copyright:K.string().optional().describe("Copyright notice text"),logo:K.boolean().optional().describe("Whether to display logo instead of title text in header"),themeMode:K.enum(["light","dark"]).optional().describe("Default theme mode"),analyticsScript:K.string().optional().describe("Analytics script HTML"),cta:v$.optional().describe("Call-to-action configuration"),sections:K.record(K.string(),x$).optional().describe("Optional per-section blurbs, keyed by section id (e.g. 'essays', 'presentations', 'about'). Used by homepage templates that render editorial section headers.")}),lj=K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")}),cj=b$.extend({navigation:K.object({primary:K.array(k$),secondary:K.array(k$)}),copyright:K.string(),socialLinks:K.array(lj).optional().describe("Social media links from profile metadata")});I();var rj=K.string(),ij=K.object({id:K.string().min(1)}).passthrough(),nj=K.object({label:K.string().min(1)}).passthrough(),oj=K.object({layouts:K.record(K.unknown()),plugin:K.function(),routes:K.array(ij),entityDisplay:K.record(nj),staticAssets:K.record(K.string()).optional()}).passthrough(),sj=K.custom(($)=>oj.safeParse($).success);I();Q0();var gR=K.object({}),h$=N1.extend({id:K.literal("site-info"),entityType:K.literal("site-info"),metadata:gR}),E8=v$,J4=b$.omit({url:!0,analyticsScript:!0});Q0();class x5 extends V1{constructor(){super({entityType:"site-info",schema:h$,frontmatterSchema:J4,isSingleton:!0,hasBody:!1})}createSiteInfoContent($){let X=J4.parse($);return this.buildMarkdown("",X)}parseSiteInfoBody($){return this.parseFrontmatter($)}fromMarkdown($){return{content:$,entityType:"site-info"}}extractMetadata($){return{}}generateFrontMatter($){let X=this.parseFrontmatter($.content);return this.buildMarkdown("",X)}}var RX0=new x5;var TX0=new x5;var XS=new x5;async function I8($){let G=(await $.listEntities({entityType:"site-info",options:{limit:1}}))[0];if(!G)throw Error("Site info not found \u2014 create a site-info entity");return XS.parseSiteInfoBody(G.content)}I();var GS=J4.extend({navigation:K.object({primary:K.array(K.object({label:K.string(),href:K.string(),priority:K.number()})),secondary:K.array(K.object({label:K.string(),href:K.string(),priority:K.number()}))}),copyright:K.string(),socialLinks:K.array(K.object({platform:K.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:K.string().describe("Profile or contact URL"),label:K.string().optional().describe("Optional display label")})).optional().describe("Social media links from profile entity")});Q0();var y$=r6,q2=O5.extend(y$.shape);Q0();d2();I();var YS=new m1;class f${postsListUrl;id="personal:homepage";name="Personal Homepage DataSource";description="Fetches profile and blog posts for a personal homepage";constructor($){this.postsListUrl=$}async fetch($,X,G){let Y=G.entityService,[J,W,H]=await Promise.all([q5(Y),Y.listEntities({entityType:"post",options:{limit:20}}),I8(Y)]),U=YS.parseProfileBody(J,q2),F=W.sort(h6).slice(0,6).map(c2);if(!H.cta)throw Error("CTA not configured in site-info");let M={profile:U,posts:F,postsListUrl:this.postsListUrl,cta:H.cta};return X.parse(M)}}Q0();d2();var JS=new m1;class g${id="personal:about";name="About Page DataSource";description="Fetches full profile data for the about page";async fetch($,X,G){let Y=await q5(G.entityService),W={profile:JS.parseProfileBody(Y,q2)};return X.parse(W)}}import{jsxDEV as U0,Fragment as mR}from"preact/jsx-dev-runtime";function WS($){return new Date($).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function HS($){return $.split(/(\*[^*]+\*)/).map((X,G)=>{if(X.startsWith("*")&&X.endsWith("*")&&X.length>2)return U0("em",{className:"font-sans italic font-medium text-theme-inverse tracking-[-0.015em] [font-variation-settings:'opsz'_72]",children:X.slice(1,-1)},G,!1,void 0,this);return X})}var MY=({profile:$,posts:X,postsListUrl:G,cta:Y})=>{let J=$.tagline??$.description,W=$.name.split(" ")[0];return U0(mR,{children:[U0(s0,{title:$.name,description:$.description??J??"Personal site",ogType:"website"},void 0,!1,void 0,this),U0("header",{className:"hero-decor bg-brand text-theme-inverse relative flex flex-col items-center justify-center px-6 md:px-12 pt-32 pb-24 gap-7",children:U0("div",{className:"w-full max-w-[1100px] mx-auto text-center flex flex-col items-center gap-7",children:[J&&U0("h1",{className:"font-heading font-bold text-[clamp(2.5rem,6vw,5rem)] leading-[1.05] tracking-[-0.035em] text-theme-inverse text-balance m-0 [font-variation-settings:'wdth'_90,'opsz'_96]",children:HS(J)},void 0,!1,void 0,this),$.description&&U0("p",{className:"text-[clamp(1.0625rem,1.4vw,1.3125rem)] leading-[1.5] text-theme-inverse opacity-95 max-w-[600px] mx-auto m-0",children:$.description},void 0,!1,void 0,this),U0("div",{className:"flex flex-wrap justify-center gap-3.5 mt-2",children:[U0("a",{href:G,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-theme text-brand border-2 border-theme font-heading font-semibold text-[15px] hover:bg-theme-subtle hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["Read the Blog ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("a",{href:"/about",className:"rounded-full py-3.5 px-7 border-2 border-theme-light text-theme-inverse font-heading font-semibold text-[15px] hover:bg-brand-dark hover:border-theme hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["About ",W]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X.length>0&&U0("section",{className:"flex flex-col py-24 px-6 md:px-12 gap-11 bg-theme-subtle",children:[U0("div",{className:"flex justify-between items-end max-w-layout mx-auto w-full gap-6 flex-wrap",children:[U0("div",{children:[U0("span",{className:"block font-heading font-semibold text-[13px] uppercase tracking-[0.22em] text-brand mb-3 [font-variation-settings:'wdth'_85,'opsz'_12]",children:"The Archive"},void 0,!1,void 0,this),U0("h2",{className:"font-heading font-bold text-[clamp(2.25rem,5vw,3.75rem)] leading-none tracking-[-0.03em] text-heading m-0 [font-variation-settings:'wdth'_92,'opsz'_64]",children:["Recent"," ",U0("em",{className:"font-sans italic font-medium text-brand [font-variation-settings:'opsz'_60]",children:"posts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U0("a",{href:G,className:"font-heading font-semibold text-[15px] text-brand inline-flex items-center gap-1.5 pb-1.5 border-b-2 border-current hover:text-brand-dark transition-colors [font-variation-settings:'wdth'_88,'opsz'_16]",children:["View the whole archive ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U0("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,320px),1fr))] gap-8 max-w-layout mx-auto w-full",children:X.map((H)=>U0("a",{href:H.url,className:"group flex flex-col bg-theme border border-theme rounded-md overflow-hidden hover:-translate-y-1 hover:border-brand/50 transition-all no-underline shadow-sm hover:shadow-lg",children:[H.coverImageUrl?U0("img",{src:H.coverImageUrl,alt:H.metadata.title,className:"w-full aspect-[16/10] object-cover bg-theme-muted"},void 0,!1,void 0,this):U0("div",{className:"w-full aspect-[16/10] bg-gradient-to-br from-brand to-accent","aria-hidden":"true"},void 0,!1,void 0,this),U0("div",{className:"flex flex-col gap-4 p-7 flex-1",children:[U0("div",{className:"flex flex-wrap items-center gap-3.5 font-heading text-[11px] font-semibold uppercase tracking-[0.18em] text-theme-muted [font-variation-settings:'wdth'_85,'opsz'_11]",children:[H.frontmatter.seriesName&&U0(mR,{children:[U0("span",{className:"text-brand",children:H.frontmatter.seriesName},void 0,!1,void 0,this),U0("span",{className:"w-[3px] h-[3px] rounded-full bg-current opacity-50","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("time",{children:WS(H.metadata.publishedAt??H.created)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("h3",{className:"font-sans font-semibold text-[clamp(1.375rem,1.8vw,1.625rem)] leading-[1.18] tracking-[-0.012em] text-heading m-0 text-balance",children:H.metadata.title},void 0,!1,void 0,this),H.frontmatter.excerpt&&U0("p",{className:"text-base leading-[1.55] text-theme-muted m-0 flex-1",children:H.frontmatter.excerpt},void 0,!1,void 0,this),U0("span",{className:"inline-flex items-center gap-1.5 font-heading font-semibold text-[13px] uppercase tracking-[0.14em] text-brand mt-1 [font-variation-settings:'wdth'_88,'opsz'_14]",children:["Read the post"," ",U0("span",{"aria-hidden":"true",className:"transition-transform group-hover:translate-x-1",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},H.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U0("section",{className:"cta-decor bg-theme-dark text-theme-on-dark flex-grow flex flex-col items-center justify-center py-24 px-6 md:px-12 gap-5",children:[U0("span",{className:"font-heading font-medium text-xs uppercase tracking-[0.24em] text-accent [font-variation-settings:'wdth'_85,'opsz'_12]",children:"Get in touch"},void 0,!1,void 0,this),U0("h2",{className:"text-center font-heading font-bold text-[clamp(2rem,4vw,3rem)] leading-none tracking-[-0.03em] text-theme-on-dark m-0 [font-variation-settings:'wdth'_90,'opsz'_64]",children:Y.heading},void 0,!1,void 0,this),Y.subtitle&&U0("p",{className:"text-center text-base leading-[1.55] text-theme-on-dark opacity-80 max-w-[480px] m-0",children:Y.subtitle},void 0,!1,void 0,this),U0("a",{href:Y.buttonLink,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-brand text-theme-inverse border-2 border-brand font-heading font-semibold text-[15px] hover:bg-brand-dark hover:-translate-y-0.5 transition-all mt-2 [font-variation-settings:'wdth'_92,'opsz'_18]",children:[Y.buttonText," ",U0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as X1,Fragment as US}from"preact/jsx-dev-runtime";var QY=({profile:$})=>{let X=`About ${$.name}`,G=$.description??$.intro??"About page",Y=Boolean($.email??$.website);return X1(US,{children:[X1(s0,{title:X,description:G,ogType:"profile"},void 0,!1,void 0,this),X1("section",{className:"hero-decor bg-brand text-theme-inverse relative flex flex-col px-6 md:px-12 pt-32 pb-24",children:X1("div",{className:"w-full max-w-3xl mx-auto flex flex-col gap-6",children:[X1("h1",{className:"font-heading font-bold text-[clamp(2.5rem,6vw,4.5rem)] leading-[1.05] tracking-[-0.035em] text-theme-inverse text-balance m-0 [font-variation-settings:'wdth'_90,'opsz'_96]",children:$.name},void 0,!1,void 0,this),$.description&&X1("p",{className:"text-[clamp(1.0625rem,1.4vw,1.25rem)] leading-[1.55] text-theme-inverse opacity-95 max-w-2xl m-0",children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$.story&&X1("section",{className:`py-24 px-6 md:px-12 bg-theme-subtle${Y?"":" flex-grow"}`,children:X1("div",{className:"max-w-3xl mx-auto",children:X1(i2,{markdown:$.story},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&X1("section",{className:"cta-decor bg-theme-dark text-theme-on-dark flex-grow flex flex-col items-center justify-center py-24 px-6 md:px-12 gap-5",children:[X1("span",{className:"font-heading font-medium text-xs uppercase tracking-[0.24em] text-accent [font-variation-settings:'wdth'_85,'opsz'_12]",children:"Get in touch"},void 0,!1,void 0,this),X1("h2",{className:"text-center font-heading font-bold text-[clamp(2rem,4vw,3rem)] leading-none tracking-[-0.03em] text-theme-on-dark m-0 [font-variation-settings:'wdth'_90,'opsz'_64]",children:["Say"," ",X1("em",{className:"font-sans italic font-medium text-accent [font-variation-settings:'opsz'_72]",children:"hi."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X1("div",{className:"flex flex-wrap justify-center gap-3.5 mt-2",children:[$.email&&X1("a",{href:`mailto:${$.email}`,className:"inline-flex items-center gap-2 rounded-full py-3.5 px-7 bg-brand text-theme-inverse border-2 border-brand font-heading font-semibold text-[15px] hover:bg-brand-dark hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:["Get in Touch ",X1("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.website&&X1("a",{href:$.website,className:"rounded-full py-3.5 px-7 border-2 border-theme-light text-theme-on-dark font-heading font-semibold text-[15px] hover:bg-brand-dark hover:border-theme hover:-translate-y-0.5 transition-all [font-variation-settings:'wdth'_92,'opsz'_18]",children:"Website"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};var pR={name:"@brains/site-personal",private:!0,version:"0.2.0-alpha.57",description:"Personal site composition package",type:"module",exports:{".":"./src/index.ts"},files:["src"],scripts:{typecheck:"tsc --noEmit",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"},dependencies:{"@brains/blog":"workspace:*","@brains/identity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/site-engine":"workspace:*","@brains/site-info":"workspace:*","@brains/templates":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*",preact:"^10.27.2"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};var FS=K.object({entityDisplay:K.object({post:K.object({label:K.string().default("Post"),pluralName:K.string().optional()}).default({})}).default({})});class qY extends d6{dependencies=["blog"];constructor($={}){super("personal-site",pR,$,FS)}async onRegister($){$.entities.extendFrontmatterSchema("anchor-profile",y$);let X=this.config.entityDisplay.post,G=`/${X.pluralName??X.label.toLowerCase()+"s"}`,Y=new f$(G);$.entities.registerDataSource(Y);let J=new g$;$.entities.registerDataSource(J);let W=K.object({profile:q2,posts:K.array(a1),postsListUrl:K.string(),cta:E8}),H=K.object({profile:q2});$.templates.register({homepage:L0({name:"homepage",description:"Personal homepage with recent blog posts",schema:W,dataSourceId:"personal:homepage",requiredPermission:"public",layout:{component:MY}}),about:L0({name:"about",description:"About page with profile",schema:H,dataSourceId:"personal:about",requiredPermission:"public",layout:{component:QY}})}),this.logger.info("Personal site plugin registered successfully")}async getTools(){return[]}async getResources(){return[]}}function OY($){return new qY($??{})}var ZY=[{id:"home",path:"/",title:"Home",description:"Personal site homepage",layout:"default",navigation:{show:!0,label:"Home",slot:"secondary",priority:10},sections:[{id:"homepage",template:"personal-site:homepage",dataQuery:{}}]},{id:"about",path:"/about",title:"About",description:"About page",layout:"default",navigation:{show:!0,label:"About",slot:"primary",priority:90},sections:[{id:"about",template:"personal-site:about",dataQuery:{}}]}];import{jsxDEV as h1}from"preact/jsx-dev-runtime";function RY({sections:$,siteInfo:X}){let G=[...X.navigation.primary,...X.navigation.secondary].filter((Y)=>Y.label!=="Home");return h1("div",{className:"flex flex-col min-h-screen bg-theme overflow-x-clip",children:[h1(w8,{title:X.title,titleClassName:"font-heading font-bold text-2xl",navigation:X.navigation.primary,showThemeToggle:!0,themeToggleClassName:"bg-theme-toggle text-theme-toggle-icon hover:bg-theme-toggle-hover rounded-[10px]",...X.logo!==void 0?{logo:X.logo}:{}},void 0,!1,void 0,this),h1("main",{className:"flex-grow flex flex-col",children:$},void 0,!1,void 0,this),h1("footer",{className:"bg-footer text-footer border-t border-theme",children:h1("div",{className:"max-w-layout mx-auto flex flex-col md:flex-row justify-between items-center py-8 px-6 md:px-8",children:[h1("div",{className:"flex flex-col gap-1 mb-4 md:mb-0",children:[h1("span",{className:"text-brand font-heading font-bold text-lg",children:X.title},void 0,!1,void 0,this),X.description&&h1("span",{className:"text-theme-muted text-xs",children:X.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h1("nav",{className:"flex flex-wrap justify-center gap-x-6 gap-y-2 mb-4 md:mb-0",children:G.map((Y)=>h1("a",{href:Y.href,className:"text-theme-muted text-[13px] hover:text-brand transition-colors",children:Y.label},Y.href,!1,void 0,this))},void 0,!1,void 0,this),h1("div",{className:"flex items-center gap-4",children:[X.copyright&&h1("span",{className:"text-theme-light text-[11px]",children:X.copyright},void 0,!1,void 0,this),h1(Q2,{variant:"footer",size:"sm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}Q0();I();U5();Q0();I();Q0();I();I();Q0();var MS=K.enum(["draft","queued","published"]),O2=K.object({title:K.string(),slug:K.string().optional(),description:K.string().optional(),author:K.string().optional(),status:MS,publishedAt:K.string().datetime().optional(),event:K.string().optional(),coverImageId:K.string().optional()}),QS=O2.pick({title:!0,description:!0,status:!0,publishedAt:!0,coverImageId:!0}).extend({slug:K.string()}),m$=N1.extend({entityType:K.literal("deck"),metadata:QS}),p$=m$.extend({frontmatter:O2,body:K.string()}),j8=p$.extend({url:K.string().optional(),typeLabel:K.string().optional(),listUrl:K.string().optional(),listLabel:K.string().optional(),coverImageUrl:K.string().optional(),coverImageWidth:K.number().optional(),coverImageHeight:K.number().optional()});class AY extends V1{constructor(){super({entityType:"deck",schema:m$,frontmatterSchema:O2,supportsCoverImage:!0})}validateSlideStructure($){if(!/^---$/gm.test($))throw Error("Invalid deck: markdown must contain slide separators (---) to be a valid presentation")}toMarkdown($){let X=this.extractBody($.content);this.validateSlideStructure(X);try{let G=this.parseFrontMatter($.content,O2),Y={...G,slug:G.slug??$.metadata.slug};return this.buildMarkdown(X,Y)}catch{return X}}fromMarkdown($){let X=this.parseFrontmatter($),G=this.extractBody($);this.validateSlideStructure(G);let Y=X.slug??f1(X.title),J=X.status;return{entityType:"deck",content:$,metadata:{slug:Y,title:X.title,description:X.description,status:J,publishedAt:X.publishedAt,coverImageId:X.coverImageId}}}generateTitle($){return $.metadata.title}generateSummary($){if($.metadata.description)return $.metadata.description;return`Presentation: ${$.metadata.title}`}generateFrontMatter($){return this.toMarkdown($)}}var S8=new AY;I();U5();var qS=K.object({markdown:K.string().describe("Markdown content with slide separators (---)")}),BY=L0({name:"deck-detail",description:"Render a presentation deck as Reveal.js slides",schema:qS,dataSourceId:"decks:entities",requiredPermission:"public",layout:{component:cG,fullscreen:!0}});U5();I();var VY=K.object({decks:K.array(p$)}),NY=K.object({decks:K.array(j8),pageTitle:K.string().optional()});import{jsxDEV as wY}from"preact/jsx-dev-runtime";var _Y=({decks:$,pageTitle:X})=>{let G=$.map((Y)=>({id:Y.id,url:Y.url,title:Y.frontmatter.title,date:Y.frontmatter.publishedAt??Y.created,description:Y.frontmatter.description}));return wY("div",{className:"deck-list bg-theme",children:wY("div",{className:"container mx-auto px-6 md:px-12 max-w-4xl py-16 md:py-24",children:wY(D8,{title:X??"Presentations",items:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)};I();class u$ extends i9{constructor(){super(VY,{title:"Deck List",mappings:[{key:"decks",label:"Decks",type:"array",itemType:"object"}]})}}var zY=L0({name:"deck-list",description:"List view of all presentation decks",schema:NY,dataSourceId:"decks:entities",requiredPermission:"public",formatter:new u$,layout:{component:_Y}});I();Q0();var OS=K.object({title:K.string().max(80).describe("A short, punchy title (2-5 words) that's memorable and evocative"),content:K.string().describe("Full slide deck content in markdown format with slide separators (---). Each slide should have a header and focused content."),description:K.string().describe("A concise 1-2 sentence summary that captures the essence of the talk")}),uR=L0({name:"decks:generation",description:"Template for AI to generate complete slide decks from prompts",schema:OS,dataSourceId:"shell:ai-content",requiredPermission:"public",useKnowledgeContext:!0,basePrompt:`You are creating slide decks in a distinctive voice that blends philosophy, technology, and culture.
|
|
791
791
|
|
|
792
792
|
Your task is to generate a complete slide deck based on the user's prompt.
|
|
793
793
|
|
|
@@ -856,12 +856,12 @@ Add your conclusion here`,F=F??`Presentation: ${H}`,await this.reportProgress(X,
|
|
|
856
856
|
Note: This presentation is for "${J}".`:""}`,P=await this.context.ai.generate({prompt:D,templateName:"decks:generation"});H=H??P.title,U=U??P.content,F=F??P.description,await this.reportProgress(X,{progress:50,message:`Generated deck: "${H}"`})}else if(!F)await this.reportProgress(X,{progress:30,message:"Generating description with AI"}),F=(await this.context.ai.generate({prompt:`Title: ${H}
|
|
857
857
|
|
|
858
858
|
Content:
|
|
859
|
-
${U}`,templateName:"decks:description"})).description,await this.reportProgress(X,{progress:50,message:"Description generated"});else await this.reportProgress(X,{progress:50,message:"Using provided content"});if(!H||!U)this.failEarly("Title and content are required");let Q={slug:f1(H),title:H,status:"draft"},q=await q8({entityType:"deck",title:H,deriveId:(_)=>_,regeneratePrompt:"Generate a different presentation deck title on the same topic.",context:this.context});if(q!==H)Q.title=q,Q.slug=f1(q);let A={title:Q.title,status:Q.status,slug:Q.slug,description:F,author:Y,event:J},Z=W2(U,A);return{id:q,content:Z,metadata:Q,title:q,resultExtras:{title:q,slug:Q.slug},createOptions:{deduplicateId:!0}}}summarizeDataForLog($){return{prompt:$.prompt,title:$.title}}}var nR={name:"@brains/decks",private:!0,version:"0.2.0-alpha.
|
|
859
|
+
${U}`,templateName:"decks:description"})).description,await this.reportProgress(X,{progress:50,message:"Description generated"});else await this.reportProgress(X,{progress:50,message:"Using provided content"});if(!H||!U)this.failEarly("Title and content are required");let Q={slug:f1(H),title:H,status:"draft"},q=await q8({entityType:"deck",title:H,deriveId:(_)=>_,regeneratePrompt:"Generate a different presentation deck title on the same topic.",context:this.context});if(q!==H)Q.title=q,Q.slug=f1(q);let A={title:Q.title,status:Q.status,slug:Q.slug,description:F,author:Y,event:J},Z=W2(U,A);return{id:q,content:Z,metadata:Q,title:q,resultExtras:{title:q,slug:Q.slug},createOptions:{deduplicateId:!0}}}summarizeDataForLog($){return{prompt:$.prompt,title:$.title}}}var nR={name:"@brains/decks",private:!0,version:"0.2.0-alpha.57",description:"Presentation decks plugin for creating and viewing slide presentations",type:"module",exports:{".":"./src/index.ts"},scripts:{typecheck:"tsc --noEmit",test:"bun test",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix",eval:"cd evals && bun run brain-eval"},dependencies:{"@brains/image":"workspace:*","@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};class oR extends H2{entityType=S8.entityType;schema=S8.schema;adapter=S8;constructor(){super("decks",nR)}createGenerationHandler($){return new EY(this.logger.child("DeckGenerationJobHandler"),$)}getTemplates(){return{"deck-detail":BY,"deck-list":zY,generation:uR,description:dR}}getDataSources(){return[new TY(this.logger)]}getEntityTypeConfig(){return{weight:1.5}}async onRegister($){await this.registerWithPublishPipeline($),this.subscribeToPublishExecute($),this.registerEvalHandlers($),this.logger.info("Decks plugin registered")}async registerWithPublishPipeline($){await $.messaging.send({type:"publish:register",payload:{entityType:"deck",provider:{name:"internal",publish:async()=>({id:"internal"})}}})}subscribeToPublishExecute($){$.messaging.subscribe("publish:execute",async(X)=>{let{entityType:G,entityId:Y}=X.payload;if(G!=="deck")return{success:!0};try{let J=await $.entityService.getEntity({entityType:"deck",id:Y});if(!J)return await $.messaging.send({type:"publish:report:failure",payload:{entityType:G,entityId:Y,error:`Deck not found: ${Y}`}}),{success:!0};if(J.metadata.status==="published")return{success:!0};let W=new Date().toISOString(),H={...J,metadata:{...J.metadata,status:"published",publishedAt:W}};await $.entityService.updateEntity({entity:{...H,content:this.adapter.toMarkdown(H)}}),await $.messaging.send({type:"publish:report:success",payload:{entityType:G,entityId:Y,result:{id:Y}}})}catch(J){await $.messaging.send({type:"publish:report:failure",payload:{entityType:G,entityId:Y,error:S0(J)}})}return{success:!0}})}registerEvalHandlers($){$.eval.registerHandler("generateDeck",async(X)=>{let G=K.object({prompt:K.string(),event:K.string().optional()}).parse(X);return $.ai.generate({prompt:`${G.prompt}${G.event?`
|
|
860
860
|
|
|
861
861
|
Note: This presentation is for "${G.event}".`:""}`,templateName:"decks:generation"})}),$.eval.registerHandler("generateDescription",async(X)=>{let G=K.object({title:K.string(),content:K.string()}).parse(X);return $.ai.generate({prompt:`Title: ${G.title}
|
|
862
862
|
|
|
863
863
|
Content:
|
|
864
|
-
${G.content}`,templateName:"decks:description"})})}}I();Q0();var c$=r6.extend({expertise:K.array(K.string()).optional().describe("Skills, domains, areas of focus"),currentFocus:K.string().optional().describe("What you're currently working on"),availability:K.string().optional().describe("What you're open to (consulting, speaking, etc.)")}),Z2=O5.extend(c$.shape);Q0();d2();I();var _S=new m1;class r${postsListUrl;decksListUrl;id="professional:homepage-list";name="Homepage List DataSource";description="Fetches profile, blog posts, and presentation decks for homepage";constructor($,X){this.postsListUrl=$;this.decksListUrl=X}async fetch($,X,G){let Y=G.entityService,[J,W,H,U]=await Promise.all([q5(Y),Y.listEntities({entityType:"post",options:{limit:20}}),Y.listEntities({entityType:"deck",options:{limit:20}}),I8(Y)]),F=_S.parseProfileBody(J,Z2),M=W.sort(h6).slice(0,3).map(c2),Q=H.sort(h6).slice(0,3).map(k8);if(!U.cta)throw Error("CTA not configured in site-info");let q={profile:F,posts:M,decks:Q,postsListUrl:this.postsListUrl,decksListUrl:this.decksListUrl,cta:U.cta,sections:U.sections??{}};return X.parse(q)}}Q0();d2();var zS=new m1;class i${id="professional:about";name="About Page DataSource";description="Fetches full profile data for the about page";async fetch($,X,G){let Y=await q5(G.entityService),W={profile:zS.parseProfileBody(Y,Z2)};return X.parse(W)}}import{jsxDEV as C0,Fragment as LS}from"preact/jsx-dev-runtime";var DS="grid md:grid-cols-[14rem_1px_1fr] gap-y-2 gap-x-0 md:gap-16 items-start",PS="border-t md:border-t-0 md:border-l border-rule-strong md:self-stretch",IY=({number:$,title:X,blurb:G,children:Y})=>C0("section",{className:"py-20 border-b border-rule px-6 md:px-12",children:C0("div",{className:"max-w-6xl mx-auto",children:C0("div",{className:DS,children:[C0(XY,{title:X,number:$,blurb:G},void 0,!1,void 0,this),C0("div",{className:PS,"aria-hidden":"true"},void 0,!1,void 0,this),C0("div",{className:"mt-6 md:mt-0",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),jY=({profile:$,posts:X,decks:G,postsListUrl:Y,decksListUrl:J,cta:W,sections:H})=>{let U=$.tagline||$.description,F=X.map((Z)=>({id:Z.id,url:Z.url,title:Z.metadata.title,date:Z.metadata.publishedAt||Z.created,description:Z.frontmatter.excerpt,series:Z.frontmatter.seriesName&&Z.frontmatter.seriesIndex?{name:Z.frontmatter.seriesName,index:Z.frontmatter.seriesIndex}:void 0})),M=G.map((Z)=>({id:Z.id,url:Z.url,title:Z.frontmatter.title||Z.id,date:Z.frontmatter.publishedAt??Z.created,description:Z.frontmatter.description})),Q=$.name||"Home",q=$.intro||$.description||U||"Professional site",A=Boolean($.description)||$.expertise!==void 0&&$.expertise.length>0;return C0(LS,{children:[C0(s0,{title:Q,description:q,ogType:"website"},void 0,!1,void 0,this),C0("div",{className:"homepage-list bg-theme",children:[C0("header",{className:"hero-bg-pattern relative w-full px-6 md:px-12 pt-28 pb-24 md:pt-28 md:pb-24 overflow-hidden border-b border-rule",children:C0("div",{className:"relative z-10 max-w-6xl mx-auto w-full",children:[$.name&&C0("div",{className:"flex items-center gap-[0.6rem] mb-6 font-mono text-[0.7rem] font-medium uppercase tracking-[0.22em] text-accent",children:[C0("span",{className:"w-[18px] h-px bg-accent","aria-hidden":"true"},void 0,!1,void 0,this),C0("span",{children:$.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&C0("h1",{className:"font-heading text-[clamp(2.75rem,6.5vw,5.5rem)] font-normal text-heading leading-[1.02] tracking-[-0.025em] max-w-[18ch] [font-variation-settings:'opsz'_144,'SOFT'_30]",children:I$(U,"italic font-normal text-accent [font-variation-settings:'opsz'_144,'SOFT'_80]")},void 0,!1,void 0,this),$.intro&&C0("p",{className:"font-heading font-light text-[clamp(1.1rem,1.8vw,1.4rem)] leading-[1.5] text-theme-muted max-w-[42ch] mt-8 [font-variation-settings:'opsz'_24]",children:I$($.intro,"italic text-accent")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C0(IY,{number:"01",title:"Essays",blurb:H.essays?.blurb,children:C0(E$,{items:F,viewAllUrl:Y,viewAllLabel:"View all essays"},void 0,!1,void 0,this)},void 0,!1,void 0,this),M.length>0&&C0(IY,{number:"02",title:"Presentations",blurb:H.presentations?.blurb,children:C0(E$,{items:M,viewAllUrl:J,viewAllLabel:"View all presentations"},void 0,!1,void 0,this)},void 0,!1,void 0,this),A&&C0(IY,{number:"03",title:"About",blurb:H.about?.blurb,children:C0("div",{className:"flex flex-col gap-8",children:[$.description&&C0("p",{className:"font-heading font-light text-[1.25rem] leading-[1.55] text-theme max-w-[55ch] [font-variation-settings:'opsz'_24,'SOFT'_50]",children:$.description},void 0,!1,void 0,this),$.expertise&&$.expertise.length>0&&C0(GY,{subjects:$.expertise},void 0,!1,void 0,this),C0("a",{href:"/about",className:"mt-6 inline-flex items-center gap-2 font-mono text-[0.7rem] font-medium uppercase tracking-[0.18em] text-accent pb-1 relative before:content-[''] before:absolute before:left-0 before:right-full before:bottom-0 before:h-px before:bg-accent before:transition-[right] before:duration-300 hover:before:right-0",children:["Learn more",C0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C0(iG,{cta:W,variant:"editorial",socialLinks:$.socialLinks},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as B0,Fragment as CS}from"preact/jsx-dev-runtime";var SY=({profile:$})=>{let X=`About ${$.name||"Me"}`,G=$.description||$.intro||"About page",Y=$.expertise&&$.expertise.length>0||$.currentFocus||$.availability||$.email||$.website||$.socialLinks&&$.socialLinks.length>0;return B0(CS,{children:[B0(s0,{title:X,description:G,ogType:"profile"},void 0,!1,void 0,this),B0("div",{className:"about-page bg-theme",children:[B0("header",{className:"hero-bg-pattern relative w-full py-16 md:py-24 px-6 md:px-12 bg-theme overflow-hidden",children:B0("div",{className:"relative z-10 max-w-4xl mx-auto",children:[B0("h1",{className:"text-5xl md:text-6xl font-semibold mb-6 text-heading",children:["About ",$.name||"Me"]},void 0,!0,void 0,this),$.description&&B0("p",{className:"text-xl md:text-2xl text-theme-muted leading-relaxed",children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),B0("div",{className:"container mx-auto px-6 md:px-12 max-w-4xl py-12 md:py-16",children:[$.story&&B0("section",{className:"content-section-reveal mb-20 md:mb-28",children:B0(i2,{markdown:$.story},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&B0("div",{className:"content-section-reveal grid md:grid-cols-2 gap-x-16 gap-y-12",children:[$.expertise&&$.expertise.length>0&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Expertise"},void 0,!1,void 0,this),B0("ul",{className:"flex flex-wrap gap-3",children:$.expertise.map((J,W)=>B0("li",{className:$Y({variant:"accent",size:"lg"}),children:J},W,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.currentFocus&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Current Focus"},void 0,!1,void 0,this),B0("p",{className:"text-lg text-theme leading-relaxed",children:$.currentFocus},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.availability&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Availability"},void 0,!1,void 0,this),B0("p",{className:"text-lg text-theme leading-relaxed",children:$.availability},void 0,!1,void 0,this)]},void 0,!0,void 0,this),($.email||$.website||$.socialLinks&&$.socialLinks.length>0)&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Contact"},void 0,!1,void 0,this),B0("div",{className:"space-y-4",children:[$.email&&B0("p",{className:"text-lg",children:B0("a",{href:`mailto:${$.email}`,className:"text-brand hover:text-brand-dark transition-colors",children:$.email},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.website&&B0("p",{className:"text-lg",children:B0("a",{href:$.website,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:text-brand-dark transition-colors",children:$.website},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.socialLinks&&$.socialLinks.length>0&&B0("div",{className:"flex flex-wrap gap-4 mt-4",children:$.socialLinks.map((J,W)=>B0(t1,{href:J.url,external:!0,variant:"secondary",size:"md",children:J.label||J.platform},W,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as q1,Fragment as sR}from"preact/jsx-dev-runtime";var kY=()=>{return q1(sR,{children:[q1(s0,{title:"Thanks for subscribing!",description:"You've successfully subscribed to the newsletter."},void 0,!1,void 0,this),q1("div",{className:"min-h-[60vh] flex items-center justify-center px-6",children:q1("div",{className:"text-center max-w-md",children:[q1("div",{className:"text-6xl mb-6",children:"\uD83C\uDF89"},void 0,!1,void 0,this),q1("h1",{className:"text-3xl font-semibold mb-4 text-heading",children:"Thanks for subscribing!"},void 0,!1,void 0,this),q1("p",{className:"text-lg text-theme-muted mb-8",children:"You'll receive a confirmation email shortly. Check your inbox to confirm your subscription."},void 0,!1,void 0,this),q1(t1,{href:"/",variant:"primary",children:"Back to Home"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},vY=()=>{return q1(sR,{children:[q1(s0,{title:"Subscription failed",description:"There was a problem with your subscription."},void 0,!1,void 0,this),q1("div",{className:"min-h-[60vh] flex items-center justify-center px-6",children:q1("div",{className:"text-center max-w-md",children:[q1("div",{className:"text-6xl mb-6",children:"\uD83D\uDE22"},void 0,!1,void 0,this),q1("h1",{className:"text-3xl font-semibold mb-4 text-heading",children:"Something went wrong"},void 0,!1,void 0,this),q1("p",{className:"text-lg text-theme-muted mb-8",children:"We couldn't process your subscription. Please try again or contact us if the problem persists."},void 0,!1,void 0,this),q1(t1,{href:"/",variant:"primary",children:"Back to Home"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};I();var aR=K.object({label:K.string().describe("Display label for entity type (e.g., 'Essay')"),pluralName:K.string().optional().describe("URL path segment (defaults to label.toLowerCase() + 's')")}),tR=K.object({entityDisplay:K.object({post:aR,deck:aR}).describe("Display metadata for post and deck entity types (required for homepage)")});var eR={name:"@brains/site-professional",private:!0,version:"0.2.0-alpha.55",description:"Professional site composition package",type:"module",exports:{".":"./src/index.ts"},files:["src"],scripts:{typecheck:"tsc --noEmit",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"},dependencies:{"@brains/blog":"workspace:*","@brains/decks":"workspace:*","@brains/identity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/site-engine":"workspace:*","@brains/site-info":"workspace:*","@brains/templates":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*",preact:"^10.27.2"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};class xY extends d6{dependencies=["blog","decks"];constructor($){super("professional-site",eR,$,tR)}async onRegister($){$.entities.extendFrontmatterSchema("anchor-profile",c$);let X=this.config.entityDisplay.post,G=this.config.entityDisplay.deck,Y=`/${X.pluralName??X.label.toLowerCase()+"s"}`,J=`/${G.pluralName??G.label.toLowerCase()+"s"}`,W=new r$(Y,J);$.entities.registerDataSource(W);let H=new i$;$.entities.registerDataSource(H);let U=K.object({profile:Z2,posts:K.array(a1),decks:K.array(j8),postsListUrl:K.string(),decksListUrl:K.string(),cta:E8,sections:K.record(K.string(),x$)}),F=K.object({profile:Z2}),M=K.object({});$.templates.register({"homepage-list":L0({name:"homepage-list",description:"Professional homepage with essays and presentations",schema:U,dataSourceId:"professional:homepage-list",requiredPermission:"public",layout:{component:jY}}),about:L0({name:"about",description:"About page with full profile information",schema:F,dataSourceId:"professional:about",requiredPermission:"public",layout:{component:SY}}),"subscribe-thanks":L0({name:"subscribe-thanks",description:"Newsletter subscription success page",schema:M,requiredPermission:"public",layout:{component:kY}}),"subscribe-error":L0({name:"subscribe-error",description:"Newsletter subscription error page",schema:M,requiredPermission:"public",layout:{component:vY}})}),this.logger.info("Professional site plugin registered successfully")}async getTools(){return[]}async getResources(){return[]}}function bY($){return new xY($??{})}var hY=[{id:"home",path:"/",title:"Home",description:"Professional site homepage",layout:"default",navigation:{show:!0,label:"Home",slot:"secondary",priority:10},sections:[{id:"homepage",template:"professional-site:homepage-list",dataQuery:{}}]},{id:"about",path:"/about",title:"About",description:"About page",layout:"default",navigation:{show:!0,label:"About",slot:"primary",priority:90},sections:[{id:"about",template:"professional-site:about",dataQuery:{}}]},{id:"subscribe-thanks",path:"/subscribe/thanks",title:"Thanks for subscribing",description:"Newsletter subscription confirmation",layout:"default",navigation:{show:!1},sections:[{id:"subscribe-thanks",template:"professional-site:subscribe-thanks",dataQuery:{},content:{}}]},{id:"subscribe-error",path:"/subscribe/error",title:"Subscription failed",description:"Newsletter subscription error",layout:"default",navigation:{show:!1},sections:[{id:"subscribe-error",template:"professional-site:subscribe-error",dataQuery:{},content:{}}]}];import{jsxDEV as n$}from"preact/jsx-dev-runtime";function yY({sections:$,siteInfo:X,slots:G,wordmark:Y}){return n$("div",{className:"flex flex-col min-h-screen bg-theme overflow-x-clip",children:[n$(w8,{title:X.title,navigation:X.navigation.primary,showThemeToggle:!0,...X.logo!==void 0?{logo:X.logo}:{},...Y!==void 0?{wordmark:Y}:{}},void 0,!1,void 0,this),n$("main",{className:"flex-grow flex flex-col bg-theme",children:$},void 0,!1,void 0,this),n$(oG,{primaryNavigation:X.navigation.primary,secondaryNavigation:X.navigation.secondary,copyright:X.copyright,socialLinks:X.socialLinks,title:X.title,tagline:X.description,children:G?.getSlot("footer-top").map((J)=>J.render())},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $A($){return{id:$.id,version:$.version,type:$.type,packageName:$.packageName}}var VJ0=RY;function NJ0($){return $A(OY($))}var ES=ZY,wJ0=ES,_J0=yY;function zJ0($){return $A(bY($))}var DJ0=hY;export{ES as routes,zJ0 as professionalSitePlugin,DJ0 as professionalRoutes,NJ0 as personalSitePlugin,wJ0 as personalRoutes,_J0 as ProfessionalLayout,VJ0 as PersonalLayout};
|
|
864
|
+
${G.content}`,templateName:"decks:description"})})}}I();Q0();var c$=r6.extend({expertise:K.array(K.string()).optional().describe("Skills, domains, areas of focus"),currentFocus:K.string().optional().describe("What you're currently working on"),availability:K.string().optional().describe("What you're open to (consulting, speaking, etc.)")}),Z2=O5.extend(c$.shape);Q0();d2();I();var _S=new m1;class r${postsListUrl;decksListUrl;id="professional:homepage-list";name="Homepage List DataSource";description="Fetches profile, blog posts, and presentation decks for homepage";constructor($,X){this.postsListUrl=$;this.decksListUrl=X}async fetch($,X,G){let Y=G.entityService,[J,W,H,U]=await Promise.all([q5(Y),Y.listEntities({entityType:"post",options:{limit:20}}),Y.listEntities({entityType:"deck",options:{limit:20}}),I8(Y)]),F=_S.parseProfileBody(J,Z2),M=W.sort(h6).slice(0,3).map(c2),Q=H.sort(h6).slice(0,3).map(k8);if(!U.cta)throw Error("CTA not configured in site-info");let q={profile:F,posts:M,decks:Q,postsListUrl:this.postsListUrl,decksListUrl:this.decksListUrl,cta:U.cta,sections:U.sections??{}};return X.parse(q)}}Q0();d2();var zS=new m1;class i${id="professional:about";name="About Page DataSource";description="Fetches full profile data for the about page";async fetch($,X,G){let Y=await q5(G.entityService),W={profile:zS.parseProfileBody(Y,Z2)};return X.parse(W)}}import{jsxDEV as C0,Fragment as LS}from"preact/jsx-dev-runtime";var DS="grid md:grid-cols-[14rem_1px_1fr] gap-y-2 gap-x-0 md:gap-16 items-start",PS="border-t md:border-t-0 md:border-l border-rule-strong md:self-stretch",IY=({number:$,title:X,blurb:G,children:Y})=>C0("section",{className:"py-20 border-b border-rule px-6 md:px-12",children:C0("div",{className:"max-w-6xl mx-auto",children:C0("div",{className:DS,children:[C0(XY,{title:X,number:$,blurb:G},void 0,!1,void 0,this),C0("div",{className:PS,"aria-hidden":"true"},void 0,!1,void 0,this),C0("div",{className:"mt-6 md:mt-0",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),jY=({profile:$,posts:X,decks:G,postsListUrl:Y,decksListUrl:J,cta:W,sections:H})=>{let U=$.tagline||$.description,F=X.map((Z)=>({id:Z.id,url:Z.url,title:Z.metadata.title,date:Z.metadata.publishedAt||Z.created,description:Z.frontmatter.excerpt,series:Z.frontmatter.seriesName&&Z.frontmatter.seriesIndex?{name:Z.frontmatter.seriesName,index:Z.frontmatter.seriesIndex}:void 0})),M=G.map((Z)=>({id:Z.id,url:Z.url,title:Z.frontmatter.title||Z.id,date:Z.frontmatter.publishedAt??Z.created,description:Z.frontmatter.description})),Q=$.name||"Home",q=$.intro||$.description||U||"Professional site",A=Boolean($.description)||$.expertise!==void 0&&$.expertise.length>0;return C0(LS,{children:[C0(s0,{title:Q,description:q,ogType:"website"},void 0,!1,void 0,this),C0("div",{className:"homepage-list bg-theme",children:[C0("header",{className:"hero-bg-pattern relative w-full px-6 md:px-12 pt-28 pb-24 md:pt-28 md:pb-24 overflow-hidden border-b border-rule",children:C0("div",{className:"relative z-10 max-w-6xl mx-auto w-full",children:[$.name&&C0("div",{className:"flex items-center gap-[0.6rem] mb-6 font-mono text-[0.7rem] font-medium uppercase tracking-[0.22em] text-accent",children:[C0("span",{className:"w-[18px] h-px bg-accent","aria-hidden":"true"},void 0,!1,void 0,this),C0("span",{children:$.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&C0("h1",{className:"font-heading text-[clamp(2.75rem,6.5vw,5.5rem)] font-normal text-heading leading-[1.02] tracking-[-0.025em] max-w-[18ch] [font-variation-settings:'opsz'_144,'SOFT'_30]",children:I$(U,"italic font-normal text-accent [font-variation-settings:'opsz'_144,'SOFT'_80]")},void 0,!1,void 0,this),$.intro&&C0("p",{className:"font-heading font-light text-[clamp(1.1rem,1.8vw,1.4rem)] leading-[1.5] text-theme-muted max-w-[42ch] mt-8 [font-variation-settings:'opsz'_24]",children:I$($.intro,"italic text-accent")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C0(IY,{number:"01",title:"Essays",blurb:H.essays?.blurb,children:C0(E$,{items:F,viewAllUrl:Y,viewAllLabel:"View all essays"},void 0,!1,void 0,this)},void 0,!1,void 0,this),M.length>0&&C0(IY,{number:"02",title:"Presentations",blurb:H.presentations?.blurb,children:C0(E$,{items:M,viewAllUrl:J,viewAllLabel:"View all presentations"},void 0,!1,void 0,this)},void 0,!1,void 0,this),A&&C0(IY,{number:"03",title:"About",blurb:H.about?.blurb,children:C0("div",{className:"flex flex-col gap-8",children:[$.description&&C0("p",{className:"font-heading font-light text-[1.25rem] leading-[1.55] text-theme max-w-[55ch] [font-variation-settings:'opsz'_24,'SOFT'_50]",children:$.description},void 0,!1,void 0,this),$.expertise&&$.expertise.length>0&&C0(GY,{subjects:$.expertise},void 0,!1,void 0,this),C0("a",{href:"/about",className:"mt-6 inline-flex items-center gap-2 font-mono text-[0.7rem] font-medium uppercase tracking-[0.18em] text-accent pb-1 relative before:content-[''] before:absolute before:left-0 before:right-full before:bottom-0 before:h-px before:bg-accent before:transition-[right] before:duration-300 hover:before:right-0",children:["Learn more",C0("span",{"aria-hidden":"true",children:"\u2192"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),C0(iG,{cta:W,variant:"editorial",socialLinks:$.socialLinks},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as B0,Fragment as CS}from"preact/jsx-dev-runtime";var SY=({profile:$})=>{let X=`About ${$.name||"Me"}`,G=$.description||$.intro||"About page",Y=$.expertise&&$.expertise.length>0||$.currentFocus||$.availability||$.email||$.website||$.socialLinks&&$.socialLinks.length>0;return B0(CS,{children:[B0(s0,{title:X,description:G,ogType:"profile"},void 0,!1,void 0,this),B0("div",{className:"about-page bg-theme",children:[B0("header",{className:"hero-bg-pattern relative w-full py-16 md:py-24 px-6 md:px-12 bg-theme overflow-hidden",children:B0("div",{className:"relative z-10 max-w-4xl mx-auto",children:[B0("h1",{className:"text-5xl md:text-6xl font-semibold mb-6 text-heading",children:["About ",$.name||"Me"]},void 0,!0,void 0,this),$.description&&B0("p",{className:"text-xl md:text-2xl text-theme-muted leading-relaxed",children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),B0("div",{className:"container mx-auto px-6 md:px-12 max-w-4xl py-12 md:py-16",children:[$.story&&B0("section",{className:"content-section-reveal mb-20 md:mb-28",children:B0(i2,{markdown:$.story},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&B0("div",{className:"content-section-reveal grid md:grid-cols-2 gap-x-16 gap-y-12",children:[$.expertise&&$.expertise.length>0&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Expertise"},void 0,!1,void 0,this),B0("ul",{className:"flex flex-wrap gap-3",children:$.expertise.map((J,W)=>B0("li",{className:$Y({variant:"accent",size:"lg"}),children:J},W,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.currentFocus&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Current Focus"},void 0,!1,void 0,this),B0("p",{className:"text-lg text-theme leading-relaxed",children:$.currentFocus},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.availability&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Availability"},void 0,!1,void 0,this),B0("p",{className:"text-lg text-theme leading-relaxed",children:$.availability},void 0,!1,void 0,this)]},void 0,!0,void 0,this),($.email||$.website||$.socialLinks&&$.socialLinks.length>0)&&B0("section",{children:[B0("h2",{className:"text-sm tracking-widest uppercase text-theme-muted mb-6",children:"Contact"},void 0,!1,void 0,this),B0("div",{className:"space-y-4",children:[$.email&&B0("p",{className:"text-lg",children:B0("a",{href:`mailto:${$.email}`,className:"text-brand hover:text-brand-dark transition-colors",children:$.email},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.website&&B0("p",{className:"text-lg",children:B0("a",{href:$.website,target:"_blank",rel:"noopener noreferrer",className:"text-brand hover:text-brand-dark transition-colors",children:$.website},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.socialLinks&&$.socialLinks.length>0&&B0("div",{className:"flex flex-wrap gap-4 mt-4",children:$.socialLinks.map((J,W)=>B0(t1,{href:J.url,external:!0,variant:"secondary",size:"md",children:J.label||J.platform},W,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)};import{jsxDEV as q1,Fragment as sR}from"preact/jsx-dev-runtime";var kY=()=>{return q1(sR,{children:[q1(s0,{title:"Thanks for subscribing!",description:"You've successfully subscribed to the newsletter."},void 0,!1,void 0,this),q1("div",{className:"min-h-[60vh] flex items-center justify-center px-6",children:q1("div",{className:"text-center max-w-md",children:[q1("div",{className:"text-6xl mb-6",children:"\uD83C\uDF89"},void 0,!1,void 0,this),q1("h1",{className:"text-3xl font-semibold mb-4 text-heading",children:"Thanks for subscribing!"},void 0,!1,void 0,this),q1("p",{className:"text-lg text-theme-muted mb-8",children:"You'll receive a confirmation email shortly. Check your inbox to confirm your subscription."},void 0,!1,void 0,this),q1(t1,{href:"/",variant:"primary",children:"Back to Home"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},vY=()=>{return q1(sR,{children:[q1(s0,{title:"Subscription failed",description:"There was a problem with your subscription."},void 0,!1,void 0,this),q1("div",{className:"min-h-[60vh] flex items-center justify-center px-6",children:q1("div",{className:"text-center max-w-md",children:[q1("div",{className:"text-6xl mb-6",children:"\uD83D\uDE22"},void 0,!1,void 0,this),q1("h1",{className:"text-3xl font-semibold mb-4 text-heading",children:"Something went wrong"},void 0,!1,void 0,this),q1("p",{className:"text-lg text-theme-muted mb-8",children:"We couldn't process your subscription. Please try again or contact us if the problem persists."},void 0,!1,void 0,this),q1(t1,{href:"/",variant:"primary",children:"Back to Home"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};I();var aR=K.object({label:K.string().describe("Display label for entity type (e.g., 'Essay')"),pluralName:K.string().optional().describe("URL path segment (defaults to label.toLowerCase() + 's')")}),tR=K.object({entityDisplay:K.object({post:aR,deck:aR}).describe("Display metadata for post and deck entity types (required for homepage)")});var eR={name:"@brains/site-professional",private:!0,version:"0.2.0-alpha.57",description:"Professional site composition package",type:"module",exports:{".":"./src/index.ts"},files:["src"],scripts:{typecheck:"tsc --noEmit",lint:"eslint . --ext .ts","lint:fix":"eslint . --ext .ts --fix"},dependencies:{"@brains/blog":"workspace:*","@brains/decks":"workspace:*","@brains/identity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/site-engine":"workspace:*","@brains/site-info":"workspace:*","@brains/templates":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*",preact:"^10.27.2"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"latest","bun-types":"latest",eslint:"^8.56.0",typescript:"^5.3.3"}};class xY extends d6{dependencies=["blog","decks"];constructor($){super("professional-site",eR,$,tR)}async onRegister($){$.entities.extendFrontmatterSchema("anchor-profile",c$);let X=this.config.entityDisplay.post,G=this.config.entityDisplay.deck,Y=`/${X.pluralName??X.label.toLowerCase()+"s"}`,J=`/${G.pluralName??G.label.toLowerCase()+"s"}`,W=new r$(Y,J);$.entities.registerDataSource(W);let H=new i$;$.entities.registerDataSource(H);let U=K.object({profile:Z2,posts:K.array(a1),decks:K.array(j8),postsListUrl:K.string(),decksListUrl:K.string(),cta:E8,sections:K.record(K.string(),x$)}),F=K.object({profile:Z2}),M=K.object({});$.templates.register({"homepage-list":L0({name:"homepage-list",description:"Professional homepage with essays and presentations",schema:U,dataSourceId:"professional:homepage-list",requiredPermission:"public",layout:{component:jY}}),about:L0({name:"about",description:"About page with full profile information",schema:F,dataSourceId:"professional:about",requiredPermission:"public",layout:{component:SY}}),"subscribe-thanks":L0({name:"subscribe-thanks",description:"Newsletter subscription success page",schema:M,requiredPermission:"public",layout:{component:kY}}),"subscribe-error":L0({name:"subscribe-error",description:"Newsletter subscription error page",schema:M,requiredPermission:"public",layout:{component:vY}})}),this.logger.info("Professional site plugin registered successfully")}async getTools(){return[]}async getResources(){return[]}}function bY($){return new xY($??{})}var hY=[{id:"home",path:"/",title:"Home",description:"Professional site homepage",layout:"default",navigation:{show:!0,label:"Home",slot:"secondary",priority:10},sections:[{id:"homepage",template:"professional-site:homepage-list",dataQuery:{}}]},{id:"about",path:"/about",title:"About",description:"About page",layout:"default",navigation:{show:!0,label:"About",slot:"primary",priority:90},sections:[{id:"about",template:"professional-site:about",dataQuery:{}}]},{id:"subscribe-thanks",path:"/subscribe/thanks",title:"Thanks for subscribing",description:"Newsletter subscription confirmation",layout:"default",navigation:{show:!1},sections:[{id:"subscribe-thanks",template:"professional-site:subscribe-thanks",dataQuery:{},content:{}}]},{id:"subscribe-error",path:"/subscribe/error",title:"Subscription failed",description:"Newsletter subscription error",layout:"default",navigation:{show:!1},sections:[{id:"subscribe-error",template:"professional-site:subscribe-error",dataQuery:{},content:{}}]}];import{jsxDEV as n$}from"preact/jsx-dev-runtime";function yY({sections:$,siteInfo:X,slots:G,wordmark:Y}){return n$("div",{className:"flex flex-col min-h-screen bg-theme overflow-x-clip",children:[n$(w8,{title:X.title,navigation:X.navigation.primary,showThemeToggle:!0,...X.logo!==void 0?{logo:X.logo}:{},...Y!==void 0?{wordmark:Y}:{}},void 0,!1,void 0,this),n$("main",{className:"flex-grow flex flex-col bg-theme",children:$},void 0,!1,void 0,this),n$(oG,{primaryNavigation:X.navigation.primary,secondaryNavigation:X.navigation.secondary,copyright:X.copyright,socialLinks:X.socialLinks,title:X.title,tagline:X.description,children:G?.getSlot("footer-top").map((J)=>J.render())},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $A($){return{id:$.id,version:$.version,type:$.type,packageName:$.packageName}}var VJ0=RY;function NJ0($){return $A(OY($))}var ES=ZY,wJ0=ES,_J0=yY;function zJ0($){return $A(bY($))}var DJ0=hY;export{ES as routes,zJ0 as professionalSitePlugin,DJ0 as professionalRoutes,NJ0 as personalSitePlugin,wJ0 as personalRoutes,_J0 as ProfessionalLayout,VJ0 as PersonalLayout};
|
|
865
865
|
|
|
866
|
-
//# debugId=
|
|
866
|
+
//# debugId=911FEC2B11D44A3164756E2164756E21
|
|
867
867
|
//# sourceMappingURL=site.js.map
|