@rizom/brain 0.2.0-alpha.258 → 0.2.0-alpha.259

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{R as a,S as b}from"./index-5pqw6emc.js";import"./index-jhx8t2fb.js";import"./index-q7vxqhw0.js";import"./index-7ytt9vvj.js";import"./index-7rpsxmkw.js";import"./index-b321g3dq.js";import"./index-x1z91h8f.js";import"./index-fd1gxz8a.js";import"./index-ra0ektdg.js";import"./index-b8fr3719.js";import"./index-gq8ts1j6.js";import"./index-sam9qxh9.js";import"./index-8p1j80d4.js";import"./index-88hscfqt.js";export{a as STARTUP_CHECK_API_KEY,b as App};
2
+ import{R as a,S as b}from"./index-vm8e7ddv.js";import"./index-jhx8t2fb.js";import"./index-q7vxqhw0.js";import"./index-7ytt9vvj.js";import"./index-7rpsxmkw.js";import"./index-b321g3dq.js";import"./index-x1z91h8f.js";import"./index-fd1gxz8a.js";import"./index-ra0ektdg.js";import"./index-b8fr3719.js";import"./index-gq8ts1j6.js";import"./index-sam9qxh9.js";import"./index-8p1j80d4.js";import"./index-88hscfqt.js";export{a as STARTUP_CHECK_API_KEY,b as App};
3
3
 
4
4
  //# debugId=E3A871CBB33DE0A064756E2164756E21
5
- //# sourceMappingURL=app-s3fzd792.js.map
5
+ //# sourceMappingURL=app-28ft6g6m.js.map
@@ -954,7 +954,7 @@ Default "index" lookups for the main are deprecated for ES modules.`,"Deprecatio
954
954
  });
955
955
  });
956
956
  })();
957
- `;if(l==="inline")return Wl("div",{className:W0(W2({variant:l}),"max-w-full sm:max-w-xs",u),children:[Wl("form",{action:n,method:"POST",className:"newsletter-signup-form",children:[Wl("span",{className:"text-[10px] font-mono font-bold uppercase tracking-[0.16em] text-brand opacity-60 block mb-5",children:w},void 0,!1,void 0,this),Wl("div",{className:"flex w-full min-w-0",children:[Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"flex-1 min-w-0 px-3 py-2 font-mono text-[13px] bg-transparent border border-theme text-theme placeholder-theme-muted focus:outline-none focus:border-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",className:"shrink-0 whitespace-nowrap font-mono text-xs font-bold uppercase tracking-[0.08em] border border-l-0 border-brand bg-brand text-theme-inverse hover:bg-transparent hover:text-brand px-4",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(l==="section")return Wl("div",{className:W0(W2({variant:l}),u),children:[Wl("div",{className:"max-w-xl mx-auto px-6",children:[w&&Wl("h2",{className:"text-3xl font-bold text-heading mb-3",children:w},void 0,!1,void 0,this),v&&Wl("p",{className:"text-theme-muted text-lg mb-8",children:v},void 0,!1,void 0,this),Wl("form",{action:n,method:"POST",className:"newsletter-signup-form flex flex-col sm:flex-row gap-3 justify-center",children:[t&&Wl("input",{type:"text",name:"name",placeholder:"Your name",className:"px-4 py-3 text-base rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"flex-1 max-w-sm px-4 py-3 text-base rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",size:"lg",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return Wl("div",{className:W0(W2({variant:l}),u),children:[w&&Wl("h3",{className:"text-lg font-semibold text-heading mb-2",children:w},void 0,!1,void 0,this),v&&Wl("p",{className:"text-theme-muted text-sm mb-4",children:v},void 0,!1,void 0,this),Wl("form",{action:n,method:"POST",className:"newsletter-signup-form flex flex-col gap-3",children:[t&&Wl("input",{type:"text",name:"name",placeholder:"Your name",className:"px-3 py-2 text-sm rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"px-3 py-2 text-sm rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as ts}from"preact/jsx-dev-runtime";import{useState as hs}from"preact/hooks";import{jsxDEV as $s}from"preact/jsx-dev-runtime";var vs=W.record(W.string(),W.unknown()),ks=W.record(W.string(),W.unknown());import{jsxDEV as As}from"preact/jsx-dev-runtime";var Kw=W.object({id:W.string(),type:W.string().optional(),name:W.string().optional(),count:W.number().optional(),priority:W.string().optional(),status:W.string().optional()}),ds=W.object({jobs:W.array(Kw).optional(),batches:W.array(Kw).optional(),items:W.array(Kw).optional()});import{jsxDEV as Os}from"preact/jsx-dev-runtime";var Ws=W.record(W.string(),W.unknown());import{useState as Ys}from"preact/hooks";import{jsxDEV as Gs}from"preact/jsx-dev-runtime";var cB=W.object({id:W.string(),title:W.string(),type:W.string(),status:W.enum(["draft","queued","published","failed"]),scheduledFor:W.string().optional(),retryInfo:W.string().optional()}),Hs=W.object({summary:W.object({draft:W.number(),queued:W.number(),published:W.number(),failed:W.number()}),items:W.array(cB)});import{jsxDEV as Vs}from"preact/jsx-dev-runtime";var Ls=W.object({name:W.string(),role:W.string(),purpose:W.string(),values:W.array(W.string())});import{jsxDEV as qs}from"preact/jsx-dev-runtime";var Ms=W.object({name:W.string(),description:W.string().optional(),links:W.array(W.object({label:W.string(),url:W.string()})).optional()});import{jsxDEV as Es}from"preact/jsx-dev-runtime";var Ss=W.object({version:W.string(),plugins:W.string(),rendered:W.string(),links:W.array(W.object({label:W.string(),url:W.string()})).optional()});var Km={name:"@brains/style-guide",license:"AGPL-3.0-only",version:"0.2.0-alpha.258",description:"Singleton style guide for content and image generation",dependencies:{"@brains/contracts":"workspace:*","@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var zm=W.object({audiences:W.array(W.string()).optional(),positioning:W.string().optional()}),Wm=W.object({summary:W.string().optional(),traits:W.array(W.string()).optional(),principles:W.array(W.string()).optional(),preferredTerms:W.array(W.string()).optional(),avoid:W.array(W.string()).optional()}),Zm=W.object({artDirection:W.string().optional(),palette:W.array(W.string()).optional(),composition:W.string().optional(),mood:W.string().optional(),preferred:W.array(W.string()).optional(),avoid:W.array(W.string()).optional()}),fn=W.object({name:W.string().describe("Style guide name"),messaging:zm.optional(),voice:Wm.optional(),visual:Zm.optional()}),YB=W.object({}),tn=Ii.extend({id:W.literal("style-guide"),entityType:W.literal("style-guide"),metadata:YB});class zw extends qi{constructor(){super({entityType:"style-guide",purpose:"Singleton messaging, voice, and visual guidance for generated artifacts.",schema:tn,frontmatterSchema:fn,isSingleton:!0,hasBody:!0})}createStyleGuideContent(l,r=""){return this.buildMarkdown(r,fn.parse(l))}parseStyleGuide(l){let r=Zl(l,fn);return{...r.metadata,guidance:r.content}}fromMarkdown(l){return{content:l,entityType:"style-guide"}}extractMetadata(l){return{}}}var _i=new zw;class Ww extends nf{entityType="style-guide";schema=tn;adapter=_i;constructor(){super("style-guide",Km,{},Di)}getEntityTypeConfig(){return{embeddable:!1}}async onRegister(l){l.messaging.subscribe(Z2.initialCompleted,async()=>{if(await l.entityService.getEntity({entityType:"style-guide",id:"style-guide"}))return{success:!0};return await l.entityService.createEntity({entity:{id:"style-guide",entityType:"style-guide",content:_i.createStyleGuideContent({name:"Default style guide"}),metadata:{}}}),{success:!0}})}}function JB(){return new Ww}var am={name:"Default style guide",guidance:""};async function B1(l){let r=await l.getEntity({entityType:"style-guide",id:"style-guide"});return r?.id==="style-guide"?_i.parseStyleGuide(r.content):am}function uf(l,r,f){if(f&&f.length>0)l.push(`${r}: ${f.join(", ")}`)}function QB(l){let r=[],{messaging:f,voice:i}=l;if(uf(r,"Audiences",f?.audiences),f?.positioning)r.push(`Positioning: ${f.positioning}`);if(i?.summary)r.push(`Voice: ${i.summary}`);return uf(r,"Voice traits",i?.traits),uf(r,"Voice principles",i?.principles),uf(r,"Preferred terms",i?.preferredTerms),uf(r,"Avoid",i?.avoid),r.join(`
957
+ `;if(l==="inline")return Wl("div",{className:W0(W2({variant:l}),"max-w-full sm:max-w-xs",u),children:[Wl("form",{action:n,method:"POST",className:"newsletter-signup-form",children:[Wl("span",{className:"text-[10px] font-mono font-bold uppercase tracking-[0.16em] text-brand opacity-60 block mb-5",children:w},void 0,!1,void 0,this),Wl("div",{className:"flex w-full min-w-0",children:[Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"flex-1 min-w-0 px-3 py-2 font-mono text-[13px] bg-transparent border border-theme text-theme placeholder-theme-muted focus:outline-none focus:border-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",className:"shrink-0 whitespace-nowrap font-mono text-xs font-bold uppercase tracking-[0.08em] border border-l-0 border-brand bg-brand text-theme-inverse hover:bg-transparent hover:text-brand px-4",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(l==="section")return Wl("div",{className:W0(W2({variant:l}),u),children:[Wl("div",{className:"max-w-xl mx-auto px-6",children:[w&&Wl("h2",{className:"text-3xl font-bold text-heading mb-3",children:w},void 0,!1,void 0,this),v&&Wl("p",{className:"text-theme-muted text-lg mb-8",children:v},void 0,!1,void 0,this),Wl("form",{action:n,method:"POST",className:"newsletter-signup-form flex flex-col sm:flex-row gap-3 justify-center",children:[t&&Wl("input",{type:"text",name:"name",placeholder:"Your name",className:"px-4 py-3 text-base rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"flex-1 max-w-sm px-4 py-3 text-base rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",size:"lg",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return Wl("div",{className:W0(W2({variant:l}),u),children:[w&&Wl("h3",{className:"text-lg font-semibold text-heading mb-2",children:w},void 0,!1,void 0,this),v&&Wl("p",{className:"text-theme-muted text-sm mb-4",children:v},void 0,!1,void 0,this),Wl("form",{action:n,method:"POST",className:"newsletter-signup-form flex flex-col gap-3",children:[t&&Wl("input",{type:"text",name:"name",placeholder:"Your name",className:"px-3 py-2 text-sm rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl("input",{type:"email",name:"email",placeholder:"your@email.com",required:!0,className:"px-3 py-2 text-sm rounded-lg border border-theme bg-theme text-theme placeholder:text-theme-muted focus:outline-none focus:ring-2 focus:ring-brand"},void 0,!1,void 0,this),Wl(Ff,{type:"submit",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Wl("script",{dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as ts}from"preact/jsx-dev-runtime";import{useState as hs}from"preact/hooks";import{jsxDEV as $s}from"preact/jsx-dev-runtime";var vs=W.record(W.string(),W.unknown()),ks=W.record(W.string(),W.unknown());import{jsxDEV as As}from"preact/jsx-dev-runtime";var Kw=W.object({id:W.string(),type:W.string().optional(),name:W.string().optional(),count:W.number().optional(),priority:W.string().optional(),status:W.string().optional()}),ds=W.object({jobs:W.array(Kw).optional(),batches:W.array(Kw).optional(),items:W.array(Kw).optional()});import{jsxDEV as Os}from"preact/jsx-dev-runtime";var Ws=W.record(W.string(),W.unknown());import{useState as Ys}from"preact/hooks";import{jsxDEV as Gs}from"preact/jsx-dev-runtime";var cB=W.object({id:W.string(),title:W.string(),type:W.string(),status:W.enum(["draft","queued","published","failed"]),scheduledFor:W.string().optional(),retryInfo:W.string().optional()}),Hs=W.object({summary:W.object({draft:W.number(),queued:W.number(),published:W.number(),failed:W.number()}),items:W.array(cB)});import{jsxDEV as Vs}from"preact/jsx-dev-runtime";var Ls=W.object({name:W.string(),role:W.string(),purpose:W.string(),values:W.array(W.string())});import{jsxDEV as qs}from"preact/jsx-dev-runtime";var Ms=W.object({name:W.string(),description:W.string().optional(),links:W.array(W.object({label:W.string(),url:W.string()})).optional()});import{jsxDEV as Es}from"preact/jsx-dev-runtime";var Ss=W.object({version:W.string(),plugins:W.string(),rendered:W.string(),links:W.array(W.object({label:W.string(),url:W.string()})).optional()});var Km={name:"@brains/style-guide",license:"AGPL-3.0-only",version:"0.2.0-alpha.259",description:"Singleton style guide for content and image generation",dependencies:{"@brains/contracts":"workspace:*","@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var zm=W.object({audiences:W.array(W.string()).optional(),positioning:W.string().optional()}),Wm=W.object({summary:W.string().optional(),traits:W.array(W.string()).optional(),principles:W.array(W.string()).optional(),preferredTerms:W.array(W.string()).optional(),avoid:W.array(W.string()).optional()}),Zm=W.object({artDirection:W.string().optional(),palette:W.array(W.string()).optional(),composition:W.string().optional(),mood:W.string().optional(),preferred:W.array(W.string()).optional(),avoid:W.array(W.string()).optional()}),fn=W.object({name:W.string().describe("Style guide name"),messaging:zm.optional(),voice:Wm.optional(),visual:Zm.optional()}),YB=W.object({}),tn=Ii.extend({id:W.literal("style-guide"),entityType:W.literal("style-guide"),metadata:YB});class zw extends qi{constructor(){super({entityType:"style-guide",purpose:"Singleton messaging, voice, and visual guidance for generated artifacts.",schema:tn,frontmatterSchema:fn,isSingleton:!0,hasBody:!0})}createStyleGuideContent(l,r=""){return this.buildMarkdown(r,fn.parse(l))}parseStyleGuide(l){let r=Zl(l,fn);return{...r.metadata,guidance:r.content}}fromMarkdown(l){return{content:l,entityType:"style-guide"}}extractMetadata(l){return{}}}var _i=new zw;class Ww extends nf{entityType="style-guide";schema=tn;adapter=_i;constructor(){super("style-guide",Km,{},Di)}getEntityTypeConfig(){return{embeddable:!1}}async onRegister(l){l.messaging.subscribe(Z2.initialCompleted,async()=>{if(await l.entityService.getEntity({entityType:"style-guide",id:"style-guide"}))return{success:!0};return await l.entityService.createEntity({entity:{id:"style-guide",entityType:"style-guide",content:_i.createStyleGuideContent({name:"Default style guide"}),metadata:{}}}),{success:!0}})}}function JB(){return new Ww}var am={name:"Default style guide",guidance:""};async function B1(l){let r=await l.getEntity({entityType:"style-guide",id:"style-guide"});return r?.id==="style-guide"?_i.parseStyleGuide(r.content):am}function uf(l,r,f){if(f&&f.length>0)l.push(`${r}: ${f.join(", ")}`)}function QB(l){let r=[],{messaging:f,voice:i}=l;if(uf(r,"Audiences",f?.audiences),f?.positioning)r.push(`Positioning: ${f.positioning}`);if(i?.summary)r.push(`Voice: ${i.summary}`);return uf(r,"Voice traits",i?.traits),uf(r,"Voice principles",i?.principles),uf(r,"Preferred terms",i?.preferredTerms),uf(r,"Avoid",i?.avoid),r.join(`
958
958
  `)}function HB(l){let r=[],{visual:f}=l;if(f?.artDirection)r.push(`Art direction: ${f.artDirection}`);if(uf(r,"Palette",f?.palette),f?.composition)r.push(`Composition: ${f.composition}`);if(f?.mood)r.push(`Mood: ${f.mood}`);return uf(r,"Prefer",f?.preferred),uf(r,"Avoid",f?.avoid),r.join(`
959
959
  `)}function Om(l,r){return[l,r].filter(Boolean).join(`
960
960
  `)}function Zw(l,r){let f=r==="voice"||r==="both"?QB(l):"",i=r==="visual"||r==="both"?HB(l):"";if(l.guidance)if(r==="voice"||r==="both")f=Om(f,l.guidance);else i=Om(i,l.guidance);return{...f&&{voice:f},...i&&{visual:i}}}function G1(l){return Zw(l,"voice").voice??""}function BB(l){return Zw(l,"visual").visual??""}var Ul=W.string().nullable().default(null),O2=W.number().nullable().default(null),GB=W.union([W.enum(["public","shared","restricted"]),W.literal("private")]).optional().transform((l)=>{if(l===void 0)return"public";if(l==="private")return"restricted";return l}),UB=W.object({title:W.string(),status:Ow,publishedAt:Ul,seriesName:Ul,seriesIndex:O2,slug:W.string(),error:Ul}),FB=W.object({title:W.string(),slug:Ul,status:Ow,publishedAt:Ul,excerpt:W.string(),author:W.string(),coverImageId:Ul,ogImageId:Ul,seriesName:Ul,seriesIndex:O2,ogImage:Ul,ogDescription:Ul,twitterCard:W.enum(["summary","summary_large_image"]).nullable().default(null),canonicalUrl:Ul,atprotoUri:Ul}),yr=W.object({id:W.string(),entityType:W.literal("post"),content:W.string(),created:W.string(),updated:W.string(),visibility:GB,metadata:UB,contentHash:W.string(),frontmatter:FB,body:W.string(),url:Ul,typeLabel:Ul,listUrl:Ul,listLabel:Ul,seriesUrl:Ul,coverImageUrl:Ul,ogImageUrl:Ul,coverImageWidth:O2,coverImageHeight:O2,coverImageSrcset:Ul,coverImageSizes:Ul});var Xm={register:"publish-assets:register"};var Ym={lexicon:1,id:"ai.rizom.brain.card",defs:{main:{type:"record",description:"Public discovery card for a Rizom brain. The operational A2A Agent Card is conventionally served at /.well-known/agent-card.json under siteUrl.",key:"literal:self",record:{type:"object",required:["siteUrl","brain","anchor","skills","model","version","createdAt"],properties:{siteUrl:{type:"string",format:"uri",description:"Public site URL. Consumers derive the A2A Agent Card URL from this base."},brain:{type:"ref",ref:"#brain",description:"Brain identity described by this discovery card."},anchor:{type:"ref",ref:"#anchor",description:"Minimal Anchor snapshot for discovery grouping and display."},skills:{type:"array",description:"User-facing skills this brain advertises for discovery.",items:{type:"ref",ref:"#skill"},maxLength:100},model:{type:"string",description:"Rizom brain model identifier."},version:{type:"string",description:"Brain runtime/model implementation version."},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}},brain:{type:"object",description:"Brain identity described by this discovery card.",required:["did","name","role","purpose","values"],properties:{did:{type:"string",description:"Public DID for the brain identity."},name:{type:"string",maxLength:200,description:"Human-readable brain name."},role:{type:"string",maxLength:500,description:"Brain role or persona."},purpose:{type:"string",maxLength:2000,description:"Short public description of what this brain is for."},values:{type:"array",description:"Public values or principles for this brain.",items:{type:"string",maxLength:200},maxLength:50}}},anchor:{type:"object",description:"Minimal Anchor snapshot for discovery grouping and display.",required:["did","name","category","kind"],properties:{did:{type:"string",description:"Public DID for the Anchor identity."},name:{type:"string",maxLength:200,description:"Human-readable anchor name."},category:{type:"string",knownValues:["person","team","organization"],description:"Stable structural category for discovery and grouping."},kind:{type:"string",maxLength:200,description:"Open semantic profile kind selected by the publishing brain."}}},skill:{type:"object",description:"User-facing skill this brain advertises for discovery.",required:["id","name","description"],properties:{id:{type:"string",maxLength:200},name:{type:"string",maxLength:200},description:{type:"string",maxLength:2000},tags:{type:"array",items:{type:"string"},maxLength:50},examples:{type:"array",items:{type:"string"},maxLength:20}}}}};var Jm={lexicon:1,id:"ai.rizom.brain.deck",defs:{main:{type:"record",description:"Public presentation deck from a Rizom brain.",key:"any",record:{type:"object",required:["title","body","createdAt"],properties:{title:{type:"string",maxLength:300},slug:{type:"string"},description:{type:"string",maxLength:2000},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},author:{type:"string"},event:{type:"string"},publishedAt:{type:"string",format:"datetime"},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Qm={lexicon:1,id:"ai.rizom.brain.link",defs:{main:{type:"record",description:"Public curated link from a Rizom brain.",key:"any",record:{type:"object",required:["title","url","createdAt"],properties:{title:{type:"string",maxLength:500},url:{type:"string",format:"uri"},description:{type:"string",maxLength:2000},summary:{type:"string",maxLength:1e5},domain:{type:"string"},capturedAt:{type:"string",format:"datetime"},source:{type:"ref",ref:"#source"},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}},source:{type:"object",description:"Attribution for where this link was captured.",required:["ref","label"],properties:{ref:{type:"string"},label:{type:"string"}}}}};var Hm={lexicon:1,id:"ai.rizom.brain.note",defs:{main:{type:"record",description:"Public knowledge note from a Rizom brain.",key:"any",record:{type:"object",required:["title","body","createdAt"],properties:{title:{type:"string",maxLength:300},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Bm={lexicon:1,id:"ai.rizom.brain.post",defs:{main:{type:"record",description:"Markdown blog post distributed by a Rizom brain.",key:"any",record:{type:"object",required:["title","body","createdAt"],properties:{title:{type:"string",maxLength:300},summary:{type:"string",maxLength:2000},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},brainDid:{type:"string"},anchorDid:{type:"string"},canonicalUrl:{type:"string",format:"uri"},topics:{type:"array",items:{type:"string"},maxLength:50},coverImage:{type:"ref",ref:"#coverImage"},series:{type:"string",maxLength:200},seriesIndex:{type:"integer"},sourceEntityType:{type:"string",knownValues:["post"]},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},publishedAt:{type:"string",format:"datetime"}}}},coverImage:{type:"object",description:"Cover image attached to the post.",required:["blob"],properties:{blob:{type:"blob"},alt:{type:"string",maxLength:1000},width:{type:"integer"},height:{type:"integer"}}}}};var Gm={lexicon:1,id:"ai.rizom.brain.project",defs:{main:{type:"record",description:"Public project or case study from a Rizom brain.",key:"any",record:{type:"object",required:["title","body","year","createdAt"],properties:{title:{type:"string",maxLength:300},slug:{type:"string"},description:{type:"string",maxLength:2000},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},year:{type:"integer"},url:{type:"string",format:"uri"},publishedAt:{type:"string",format:"datetime"},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Um={lexicon:1,id:"ai.rizom.brain.series",defs:{main:{type:"record",description:"Public content series from a Rizom brain.",key:"any",record:{type:"object",required:["title","createdAt"],properties:{title:{type:"string",maxLength:300},slug:{type:"string"},description:{type:"string",maxLength:1e4},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Fm={lexicon:1,id:"ai.rizom.brain.socialPost",defs:{main:{type:"record",description:"Semantic local social-post entity from a Rizom brain; not a Bluesky feed post.",key:"any",record:{type:"object",required:["title","platform","body","createdAt"],properties:{title:{type:"string",maxLength:300},platform:{type:"string"},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},status:{type:"string"},publishedAt:{type:"string",format:"datetime"},platformPostId:{type:"string"},sourceLocalEntityType:{type:"string"},sourceLocalEntityId:{type:"string"},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Nm={lexicon:1,id:"ai.rizom.brain.topic",defs:{main:{type:"record",description:"Public topic page from a Rizom brain.",key:"any",record:{type:"object",required:["title","body","createdAt"],properties:{title:{type:"string",maxLength:300},body:{type:"string",maxLength:1e5},format:{type:"string",knownValues:["text/markdown"]},brainDid:{type:"string"},anchorDid:{type:"string"},sourceEntityType:{type:"string"},sourceEntityId:{type:"string"},createdAt:{type:"string",format:"datetime"},updatedAt:{type:"string",format:"datetime"}}}}}};var Lm=W.object({type:W.string()}).catchall(W.unknown()),qB=W.object({type:W.literal("object"),description:W.string().optional(),required:W.array(W.string()).optional(),properties:W.record(W.string(),Lm)}),_B=W.object({lexicon:W.literal(1),id:W.string(),defs:W.object({main:W.object({type:W.literal("record"),key:W.string().min(1),description:W.string().optional(),record:W.object({type:W.literal("object"),required:W.array(W.string()).optional(),properties:W.record(W.string(),Lm)})})}).catchall(qB)});function m1(l){return _B.parse(l)}var _l={"ai.rizom.brain.card":m1(Ym),"ai.rizom.brain.deck":m1(Jm),"ai.rizom.brain.link":m1(Qm),"ai.rizom.brain.note":m1(Hm),"ai.rizom.brain.post":m1(Bm),"ai.rizom.brain.project":m1(Gm),"ai.rizom.brain.series":m1(Um),"ai.rizom.brain.socialPost":m1(Fm),"ai.rizom.brain.topic":m1(Nm)},DB="Additive optional fields are compatible; required-field, type, or constraint changes require a migration plan or new NSID.";function U1(l){return{status:"approved",version:"1.0.0",revision:1,owner:"Rizom",steward:"Rizom protocol registry",projectionPackage:l,compatibility:DB}}var Rm={"ai.rizom.brain.card":U1("@brains/atproto"),"ai.rizom.brain.deck":U1("@brains/decks"),"ai.rizom.brain.link":U1("@brains/link"),"ai.rizom.brain.note":U1("@brains/note"),"ai.rizom.brain.post":U1("@brains/blog"),"ai.rizom.brain.project":U1("@brains/portfolio"),"ai.rizom.brain.series":U1("@brains/series"),"ai.rizom.brain.socialPost":U1("@brains/social-media"),"ai.rizom.brain.topic":U1("@brains/topics")};function jB(){return Object.values(_l)}function SB(l){if(!(l in _l))return;return _l[l]}function xB(){return Object.entries(Rm).map(([l,r])=>({id:l,...r}))}function a2(l){return typeof l==="object"&&l!==null&&!Array.isArray(l)}var EB=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function sB(l){let r=W.string(),f=l.maxLength!==void 0?r.max(l.maxLength):r;if(l.knownValues)f=f.refine((i)=>l.knownValues?.includes(i),{message:`expected one of ${l.knownValues.join(", ")}`});if(l.format==="datetime")f=f.refine((i)=>EB.test(i)&&!Number.isNaN(Date.parse(i)),{message:"expected datetime"});if(l.format==="uri")f=f.refine((i)=>{try{return new URL(i),!0}catch{return!1}},{message:"expected uri"});return f}function CB(l,r){if(typeof l!=="string"||!l.startsWith("#"))return;let f=r[l.slice(1)];return f?.type==="object"?f:void 0}function Tm(l,r){switch(l.type){case"string":return sB(l);case"integer":return W.number().int();case"boolean":return W.boolean();case"array":{let f=l.items?Tm(l.items,r):W.unknown(),i=W.array(f);if(l.maxLength!==void 0)i=i.max(l.maxLength);return i}case"object":return Vm(l,r);case"ref":{let f=CB(l.ref,r);if(!f)return W.custom(()=>!1,{message:`unresolvable lexicon ref ${String(l.ref)}`});return W.lazy(()=>Vm(f,r))}case"blob":return W.custom(a2,{message:"expected blob"});default:return W.unknown()}}function pm(l,r){let f=new Set(l.required??[]),i={};for(let[t,n]of Object.entries(l.properties??{})){let u=Tm(n,r);i[t]=f.has(t)?u:u.optional()}return i}function Vm(l,r){return W.object(pm(l,r)).passthrough()}function aw(l,r,f,i=[]){let t=Object.keys(l).filter((n)=>!r.has(n));if(t.length===0)return;f.addIssue({code:W.ZodIssueCode.custom,path:i,message:`unrecognized field(s): ${t.join(", ")}`})}function eB(l,r){if(aw(l,new Set(["$type","siteUrl","brain","anchor","skills","model","version","createdAt","updatedAt"]),r),a2(l.brain))aw(l.brain,new Set(["did","name","role","purpose","values"]),r,["brain"]);if(a2(l.anchor))aw(l.anchor,new Set(["did","name","category","kind"]),r,["anchor"])}function Pr(l){let r=W.object({...pm(l.defs.main.record,l.defs),$type:W.literal(l.id).optional()}).passthrough();return l.id==="ai.rizom.brain.card"?r.superRefine(eB):r}var Xw={"ai.rizom.brain.card":Pr(_l["ai.rizom.brain.card"]),"ai.rizom.brain.deck":Pr(_l["ai.rizom.brain.deck"]),"ai.rizom.brain.link":Pr(_l["ai.rizom.brain.link"]),"ai.rizom.brain.note":Pr(_l["ai.rizom.brain.note"]),"ai.rizom.brain.post":Pr(_l["ai.rizom.brain.post"]),"ai.rizom.brain.project":Pr(_l["ai.rizom.brain.project"]),"ai.rizom.brain.series":Pr(_l["ai.rizom.brain.series"]),"ai.rizom.brain.socialPost":Pr(_l["ai.rizom.brain.socialPost"]),"ai.rizom.brain.topic":Pr(_l["ai.rizom.brain.topic"])};function lG(l,r){let f=l;for(let i of r){if(typeof i==="symbol")return;if(Array.isArray(f)){f=f[Number(i)];continue}if(!a2(f))return;f=f[String(i)]}return f}function rG(l,r,f){let i=f.path.join(".");if(i==="$type")return`AT Protocol record $type must match lexicon id: ${String(r.$type)} !== ${l.id}`;if(f.code==="invalid_type"&&lG(r,f.path)===void 0)return`Missing required AT Protocol record field: ${i}`;if(f.code==="invalid_type")return`Invalid AT Protocol record field ${i}: expected ${f.expected}`;if(f.code==="too_big")return`Invalid AT Protocol record field ${i}: exceeds maxLength ${f.maximum}`;if(f.code==="custom")return`Invalid AT Protocol record field ${i}: ${f.message}`;if(f.code==="unrecognized_keys")return`Unrecognized AT Protocol record field(s): ${f.keys.join(", ")}`;return`Invalid AT Protocol record field ${i}: ${f.message}`}function fG(l,r){let f=Pr(l).safeParse(r);if(f.success)return;let i=f.error.issues[0];if(!i)throw f.error;throw Error(rG(l,r,i))}var iG="atproto:brain-card-discovered",tG="atproto:brain-discovered",nG="atproto:brain-card-refreshed",uG="atproto:brain-card-unavailable",hG="atproto:brain-card-conflict",oG="atproto:jetstream-gap",wG=W.custom((l)=>Xw["ai.rizom.brain.card"].safeParse(l).success),vG=W.object({repoDid:W.string().min(1),uri:W.string().min(1),cid:W.string().min(1),record:wG}).strict(),kG=W.object({agentId:W.string().min(1),name:W.string().min(1),url:W.string().url(),status:W.enum(["discovered","approved","archived"]),repoDid:W.string().min(1).optional(),brainDid:W.string().min(1).optional(),anchorDid:W.string().min(1).optional(),cardUri:W.string().min(1).optional(),cardCid:W.string().min(1).optional()}).strict(),mG=W.object({repoDid:W.string().startsWith("did:plc:"),observedAt:W.string().datetime(),staleAfter:W.string().datetime().optional(),reason:W.enum(["deleted","refresh-failed"]),error:W.string().min(1).optional()}).strict(),$G=W.object({domain:W.string().min(1),existingRepoDid:W.string().min(1).optional(),candidateRepoDid:W.string().startsWith("did:plc:"),observedAt:W.string().datetime(),reason:W.string().min(1)}).strict(),bG=W.object({previousCursorTimeUs:W.number().int().nonnegative(),clampedCursorTimeUs:W.number().int().nonnegative(),observedAt:W.string().datetime()}).strict();class hf{static instance;projections=new Map;static getInstance(){return this.instance??=new hf,this.instance}static createFresh(){return new hf}static resetInstance(){this.instance=void 0}register(l){this.validateProjection(l);let r=this.get(l.entityType);if(r&&!this.isEquivalentProjection(r,l))throw Error(`AT Protocol projection already registered for entity type ${l.entityType}`);let f=this.projections.get(l.entityType)??[];return f.push(l),this.projections.set(l.entityType,f),this.createUnregister(l.entityType,l)}get(l){let r=this.projections.get(l);return r?.[r.length-1]}has(l){return this.get(l)!==void 0}list(){let l=[];for(let r of this.projections.keys()){let f=this.get(r);if(f)l.push(f)}return l}listLexicons(){return this.list().map((l)=>l.lexicon)}createUnregister(l,r){let f=!0;return()=>{if(!f)return;f=!1;let i=this.projections.get(l);if(!i)return;let t=i.lastIndexOf(r);if(t!==-1)i.splice(t,1);if(i.length===0)this.projections.delete(l)}}isEquivalentProjection(l,r){return l.entityType===r.entityType&&l.collection===r.collection&&l.lexicon.id===r.lexicon.id&&l.validate===r.validate}validateProjection(l){if(l.collection!==l.lexicon.id)throw Error(`AT Protocol projection collection must match lexicon id: ${l.collection} !== ${l.lexicon.id}`);if(!l.lexicon.defs.main.key)throw Error(`AT Protocol projection lexicon must define a record key: ${l.collection}`)}}var Yw=W.object({defaultPrompt:W.string().default("Write a blog post about my recent work and insights"),paginate:W.boolean().default(!0),pageSize:W.number().default(10)});var yG=W.object({prompt:W.string().optional(),title:W.string().optional(),content:W.string().optional(),excerpt:W.string().optional(),coverImageId:W.string().optional(),seriesName:W.string().optional(),seriesIndex:W.number().optional(),skipAi:W.boolean().optional()}),W00=X2.extend({title:W.string().optional(),slug:W.string().optional()});class Jw extends Y2{constructor(l,r){super(l,r,{schema:yG,jobTypeName:"blog-generation",entityType:"post"})}async generate(l,r){let{prompt:f,coverImageId:i,seriesName:t,seriesIndex:n,skipAi:u}=l,{title:o,content:w,excerpt:v}=l;if(u){if(!o)this.failEarly("Title is required when skipAi is true");w=w??`## Introduction
@@ -1384,7 +1384,7 @@ ${l.map((n)=>({url:`${r}${n.path}`,lastmod:f,changefreq:n.path==="/"?"daily":"we
1384
1384
  letter-spacing: 0.02em;
1385
1385
  }
1386
1386
  .printable-footer a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
1387
- `}},void 0,!1,void 0,this),lr("header",{className:"printable-hero",children:[lr("div",{className:"printable-masthead",children:r.brandLabel&&lr("p",{className:"printable-kicker",children:r.brandLabel},void 0,!1,void 0,this)},void 0,!1,void 0,this),lr("div",{children:[lr("h1",{className:"printable-title",children:r.title},void 0,!1,void 0,this),r.excerpt&&lr("p",{className:"printable-excerpt",children:r.excerpt},void 0,!1,void 0,this),lr("div",{className:"printable-meta",children:[r.author&&lr("span",{children:["By ",r.author]},void 0,!0,void 0,this),f&&lr("span",{children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.coverImageUrl&&lr("figure",{className:"printable-cover-wrap",children:lr("img",{className:"printable-cover",src:r.coverImageUrl,alt:""},void 0,!1,void 0,this)},void 0,!1,void 0,this),lr(rn,{markdown:r.body,className:"printable-body"},void 0,!1,void 0,this),(Boolean(r.canonicalUrl)||Boolean(r.brandLabel))&&lr("footer",{className:"printable-footer",children:[lr("span",{children:r.brandLabel??"Printable PDF"},void 0,!1,void 0,this),r.canonicalUrl&&lr("a",{href:r.canonicalUrl,children:r.canonicalUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var SK=p6({sourceEntityType:"post",attachmentType:Dh,template:jK,themeMode:"light",buildContent:async(l,r)=>{let{frontmatter:f,content:i}=zf(l.content),t=kr.parse(f),n=await r.resolveImageDataUrl(t.coverImageId);return{title:t.title,body:i,...t.excerpt?{excerpt:t.excerpt}:{},...t.author?{author:t.author}:{},...t.publishedAt?{publishedAt:t.publishedAt}:{},...t.canonicalUrl?{canonicalUrl:t.canonicalUrl}:{},...n?{coverImageUrl:n}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});import{jsxDEV as Xq}from"preact/jsx-dev-runtime";var Sn="og-image",Zq="blog:og-image",xK=W.object({title:W.string().min(1),excerpt:W.string().optional(),author:W.string().optional(),publishedAt:W.string().optional(),brandLabel:W.string().optional(),coverImageUrl:W.string().optional()}),EK={name:Zq,pluginId:"blog",schema:xK,renderers:{image:aq}};function Oq(l){if(!l)return;let r=new Date(l);if(Number.isNaN(r.getTime()))return;return fr(r,{style:"medium"})}function aq(l){let r=xK.parse(l);return Xq(Et,{brandLabel:r.brandLabel??r.title,eyebrow:"Journal",title:r.title,subtitle:r.excerpt,meta:[r.author],tag:Oq(r.publishedAt)},void 0,!1,void 0,this)}var sK=jn({sourceEntityType:"post",attachmentType:Sn,template:EK,themeMode:"light",buildContent:async(l,r)=>{let{frontmatter:f}=zf(l.content),i=kr.parse(f),t=await r.resolveImageDataUrl(i.coverImageId);return{title:i.title,...i.excerpt?{excerpt:i.excerpt}:{},...i.author?{author:i.author}:{},...i.publishedAt?{publishedAt:i.publishedAt}:{},...t?{coverImageUrl:t}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});var CK={name:"@brains/blog",license:"AGPL-3.0-only",version:"0.2.0-alpha.258",description:"AI-powered blog post generation from existing brain content",dependencies:{"@brains/atproto-contracts":"workspace:*","@brains/contracts":"workspace:*","@brains/media-page-composer":"workspace:*","@brains/plugins":"workspace:*","@brains/style-guide":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{eval:"cd evals && bun run brain-eval",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};class M6 extends nf{entityType=of.entityType;schema=P6;adapter=of;unregisterAtprotoProjection;unregisterPrintableAttachmentProvider;unregisterOgImageAttachmentProvider;constructor(l={}){super("blog",CK,l,Yw)}getEntityTypeConfig(){return{weight:2,projectionSourceRole:"primary",publish:{publishStatuses:["queued","published"]}}}createGenerationHandler(l){return new Jw(this.logger.child("BlogGenerationJobHandler"),l)}getTemplates(){return Dm()}getDataSources(){return[new Gw(this.logger.child("BlogDataSource"))]}async onRegister(l){let{RSSDataSource:r}=await import("./rss-datasource-hbtj9tz9.js");l.entities.registerDataSource(new r(this.logger.child("RSSDataSource"))),jm(l,this.logger),Sm(l,this.logger),sm(l,this.logger),Cm(l),this.unregisterPrintableAttachmentProvider=l.attachments.register("post",Dh,SK(l)),this.unregisterOgImageAttachmentProvider=l.attachments.register("post",Sn,sK(l)),this.deferPublishAssetRegistration(l),this.unregisterAtprotoProjection=hf.getInstance().register(Nw()),this.logger.info("Blog plugin registered (routes auto-generated at /posts/)")}deferPublishAssetRegistration(l){l.messaging.subscribe(F1.pluginsRegistered,async()=>{return await l.messaging.send({type:Xm.register,payload:{entityType:"post",attachmentType:Sn,mediaEntityType:"image",targetEntityField:{location:"frontmatter",field:"ogImageId"},requiredWhen:{status:"published"},autoGenerate:!0,jobType:"image:image-render-source"}}),{success:!0}})}async onShutdown(){this.unregisterPrintableAttachmentProvider?.(),this.unregisterPrintableAttachmentProvider=void 0,this.unregisterOgImageAttachmentProvider?.(),this.unregisterOgImageAttachmentProvider=void 0,this.unregisterAtprotoProjection?.(),this.unregisterAtprotoProjection=void 0}}function Jq(l={}){return new M6(l)}var lz=W.object({}),xn=Ii.extend({id:W.literal("site-info"),entityType:W.literal("site-info"),metadata:lz});var Qq=eK.omit({url:!0,analyticsScript:!0}),kt=Qq.extend({title:W.string().optional().describe("Optional site title override"),description:W.string().optional().describe("Optional site description override")});var Hq=W.record(W.string(),W.unknown());class g1 extends qi{constructor(){super({entityType:"site-info",purpose:"Singleton configuration describing the published site.",schema:xn,frontmatterSchema:kt,isSingleton:!0,hasBody:!1})}createSiteInfoContent(l){let r=kt.parse(l);return this.buildMarkdown("",r)}parseSiteInfoBody(l){return this.parseFrontmatter(l)}fromMarkdown(l){return{content:l,entityType:"site-info"}}extractMetadata(l){return{}}generateFrontMatter(l){let r=this.parseFrontmatter(l.content);return this.buildMarkdown("",Hq.parse(r))}}var Bq={getBrain:()=>({name:"Brain",role:"Knowledge assistant",purpose:"A knowledge management system",values:[]}),getAnchor:()=>({name:"Brain",description:"A knowledge management system"})};class En{logger;entityService;adapter;defaultSiteInfo;identitySource;static getDefaultSiteInfo(){return{represents:"anchor",title:"Brain",description:"A knowledge management system"}}static createFresh(l,r,f,i){return new En(l,r,f,i)}constructor(l,r,f,i=Bq){this.entityService=l,this.logger=r.child("SiteInfoService"),this.adapter=new g1,this.identitySource=i,this.defaultSiteInfo={represents:"anchor",...f}}async initialize(){try{if(!await this.entityService.getEntity({entityType:"site-info",id:"site-info"})){if(await this.entityService.getEntity({entityType:"site-info",id:"site-info"}))return;this.logger.info("No site info found, creating default site info");let f=this.adapter.createSiteInfoContent(this.defaultSiteInfo);await this.entityService.createEntity({entity:{id:"site-info",entityType:"site-info",content:f,metadata:{}}}),this.logger.info("Default site info created successfully")}}catch(l){this.logger.error("Failed to initialize site info",{error:l})}}async getSiteInfo(){try{let l=await this.entityService.getEntity({entityType:"site-info",id:"site-info"});if(l)return this.resolveIdentityFallbacks(this.adapter.parseSiteInfoBody(l.content))}catch(l){this.logger.debug("Site info not found, using defaults",{error:l})}return this.resolveIdentityFallbacks(this.defaultSiteInfo)}resolveIdentityFallbacks(l){if(l.represents==="brain"){let f=this.identitySource.getBrain();return{...l,title:l.title??f.name,description:l.description??f.purpose}}let r=this.identitySource.getAnchor();return{...l,title:l.title??r.name,description:l.description??r.description??`The public site for ${r.name}`}}}var Gq=new g1;class jh{logger;id="site-info:entities";name="Site Info DataSource";description="Provides website channel metadata such as title, description, and CTA";constructor(l){this.logger=l}async fetch(l,r,f){let{entityService:i}=f,t;try{let u=await i.getEntity({entityType:"site-info",id:"site-info"});t=u?Gq.parseSiteInfoBody(u.content):{represents:"anchor",title:"Brain",description:"A knowledge management system"}}catch{t={represents:"anchor",title:"Brain",description:"A knowledge management system"}}let n={...t,title:t.title??"Brain",description:t.description??"A knowledge management system",copyright:t.copyright??"Powered by Rizom"};return this.logger.debug("SiteInfoDataSource returning",{title:n.title}),r.parse(n)}}var rz={name:"@brains/site-info",license:"AGPL-3.0-only",version:"0.2.0-alpha.258",description:"Site info entity \u2014 site metadata, title, description, CTA",dependencies:{"@brains/contracts":"workspace:*","@brains/entity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var Fq=new g1,Nq="site-info";class I6 extends nf{entityType=Nq;schema=xn;adapter=Fq;defaultSiteInfo;constructor(l){super("site-info",rz,{},Di);this.defaultSiteInfo=l?.siteInfo??{}}getEntityTypeConfig(){return{embeddable:!1,projectionSource:!1,projectionSourceRole:"excluded"}}getDataSources(){return[new jh(this.logger.child("SiteInfoDataSource"))]}async onRegister(l){let r=En.createFresh(l.entityService,this.logger,this.defaultSiteInfo,{getBrain:l.identity.get,getAnchor:l.identity.getProfile});l.messaging.subscribeExecution(iz,async()=>{return{success:!0,data:await r.getSiteInfo()}}),l.messaging.subscribe(fz.updated,async(f)=>{if(f.payload.entityType==="site-info"){let t=await r.getSiteInfo();await l.messaging.send({type:tz,payload:t,broadcast:!0})}return{success:!0}}),l.messaging.subscribe(Z2.initialCompleted,async()=>{return await r.initialize(),{success:!0}})}}function Lq(l){return new I6(l)}var Rq=new g1;async function q6(l){let f=(await l.listEntities({entityType:"site-info",options:{limit:1}}))[0];if(!f)throw Error("Site info not found \u2014 create a site-info entity");return Rq.parseSiteInfoBody(f.content)}function nz(l,r){let f=l.metadata.publishedAt??l.created,i=r.metadata.publishedAt??r.created;return new Date(i).getTime()-new Date(f).getTime()}async function Vq(l,r){return(await l.listEntities({entityType:r.entityType,options:{limit:20}})).sort(nz).slice(0,r.count).map(r.parse)}function Tq(l){if(!l)throw Error("CTA not configured in site-info");return l}var uz=W.object({label:W.string(),href:W.string(),priority:W.number()}),pq=W.object({primary:W.array(uz),secondary:W.array(uz)}),Pq=W.object({platform:W.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:W.string().describe("Profile or contact URL"),label:W.string().optional().describe("Optional display label")}),Mq=kt.extend({title:W.string(),description:W.string(),navigation:pq,copyright:W.string(),socialLinks:W.array(Pq).optional().describe("Social media links composed by a site integration")});var sn=W.enum(["generating","draft","queued","published","failed"]),hz="publishedAt is required when deck status is published",oz=(l)=>l.status==="published"&&!l.publishedAt,_6=(l)=>{if(oz(l))throw Error(hz)},Cr=W.object({title:W.string(),slug:W.string().optional(),description:W.string().optional(),author:W.string().optional(),status:sn,publishedAt:W.string().datetime().optional(),event:W.string().optional(),coverImageId:W.string().optional(),ogImageId:W.string().optional()}),Iq=W.object({title:W.string(),description:W.string().optional(),status:sn,publishedAt:W.string().datetime().optional(),coverImageId:W.string().optional(),slug:W.string(),error:W.string().optional()}).superRefine((l,r)=>{if(!oz(l))return;r.addIssue({code:W.ZodIssueCode.custom,path:["publishedAt"],message:hz})}),mt=Ii.extend({entityType:W.literal("deck"),metadata:Iq}),Sh=mt.extend({frontmatter:Cr,body:W.string(),ogImageUrl:W.string().optional()}),qq=Sh.extend({url:W.string().optional(),typeLabel:W.string().optional(),listUrl:W.string().optional(),listLabel:W.string().optional(),coverImageUrl:W.string().optional(),ogImageUrl:W.string().optional(),coverImageWidth:W.number().optional(),coverImageHeight:W.number().optional()});var _q=W.union([W.enum(["public","shared","restricted"]),W.literal("private")]).optional().transform((l)=>{if(l===void 0)return"public";if(l==="private")return"restricted";return l}),Dq=W.object({title:W.string(),slug:W.string().nullable().default(null),description:W.string().nullable().default(null),author:W.string().nullable().default(null),status:sn,publishedAt:W.string().nullable().default(null),event:W.string().nullable().default(null),coverImageId:W.string().nullable().default(null),ogImageId:W.string().nullable().default(null)}),jq=W.object({title:W.string(),description:W.string().nullable().default(null),status:sn,publishedAt:W.string().nullable().default(null),coverImageId:W.string().nullable().default(null),slug:W.string(),error:W.string().nullable().default(null)}),wi=W.object({id:W.string(),entityType:W.literal("deck"),content:W.string(),created:W.string(),updated:W.string(),visibility:_q,metadata:jq,contentHash:W.string(),frontmatter:Dq,body:W.string(),url:W.string().nullable().default(null),typeLabel:W.string().nullable().default(null),listUrl:W.string().nullable().default(null),listLabel:W.string().nullable().default(null),coverImageUrl:W.string().nullable().default(null),ogImageUrl:W.string().nullable().default(null),coverImageWidth:W.number().nullable().default(null),coverImageHeight:W.number().nullable().default(null)});class D6 extends qi{constructor(){super({entityType:"deck",purpose:"A slide-deck presentation.",schema:mt,frontmatterSchema:Cr,supportsCoverImage:!0})}validateSlideStructure(l){if(!/^---$/gm.test(l))throw Error("Invalid deck: markdown must contain slide separators (---) to be a valid presentation")}toMarkdown(l){let r=this.extractBody(l.content);this.validateSlideStructure(r);let f=this.parseFrontMatter(l.content,Cr);_6(f);let i={...f,slug:f.slug??l.metadata.slug};return this.buildMarkdown(r,i)}fromMarkdown(l){let r=this.parseFrontmatter(l),f=this.extractBody(l);_6(r),this.validateSlideStructure(f);let i=r.slug??Mr(r.title),t=r.status;return{entityType:"deck",content:l,metadata:{slug:i,title:r.title,description:r.description,status:t,publishedAt:r.publishedAt,coverImageId:r.coverImageId}}}generateTitle(l){return l.metadata.title}generateSummary(l){if(l.metadata.description)return l.metadata.description;return`Presentation: ${l.metadata.title}`}generateFrontMatter(l){return this.toMarkdown(l)}buildStub(l){let r={title:l.title,slug:l.id,status:"generating"};return{content:this.buildMarkdown(`---
1387
+ `}},void 0,!1,void 0,this),lr("header",{className:"printable-hero",children:[lr("div",{className:"printable-masthead",children:r.brandLabel&&lr("p",{className:"printable-kicker",children:r.brandLabel},void 0,!1,void 0,this)},void 0,!1,void 0,this),lr("div",{children:[lr("h1",{className:"printable-title",children:r.title},void 0,!1,void 0,this),r.excerpt&&lr("p",{className:"printable-excerpt",children:r.excerpt},void 0,!1,void 0,this),lr("div",{className:"printable-meta",children:[r.author&&lr("span",{children:["By ",r.author]},void 0,!0,void 0,this),f&&lr("span",{children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.coverImageUrl&&lr("figure",{className:"printable-cover-wrap",children:lr("img",{className:"printable-cover",src:r.coverImageUrl,alt:""},void 0,!1,void 0,this)},void 0,!1,void 0,this),lr(rn,{markdown:r.body,className:"printable-body"},void 0,!1,void 0,this),(Boolean(r.canonicalUrl)||Boolean(r.brandLabel))&&lr("footer",{className:"printable-footer",children:[lr("span",{children:r.brandLabel??"Printable PDF"},void 0,!1,void 0,this),r.canonicalUrl&&lr("a",{href:r.canonicalUrl,children:r.canonicalUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var SK=p6({sourceEntityType:"post",attachmentType:Dh,template:jK,themeMode:"light",buildContent:async(l,r)=>{let{frontmatter:f,content:i}=zf(l.content),t=kr.parse(f),n=await r.resolveImageDataUrl(t.coverImageId);return{title:t.title,body:i,...t.excerpt?{excerpt:t.excerpt}:{},...t.author?{author:t.author}:{},...t.publishedAt?{publishedAt:t.publishedAt}:{},...t.canonicalUrl?{canonicalUrl:t.canonicalUrl}:{},...n?{coverImageUrl:n}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});import{jsxDEV as Xq}from"preact/jsx-dev-runtime";var Sn="og-image",Zq="blog:og-image",xK=W.object({title:W.string().min(1),excerpt:W.string().optional(),author:W.string().optional(),publishedAt:W.string().optional(),brandLabel:W.string().optional(),coverImageUrl:W.string().optional()}),EK={name:Zq,pluginId:"blog",schema:xK,renderers:{image:aq}};function Oq(l){if(!l)return;let r=new Date(l);if(Number.isNaN(r.getTime()))return;return fr(r,{style:"medium"})}function aq(l){let r=xK.parse(l);return Xq(Et,{brandLabel:r.brandLabel??r.title,eyebrow:"Journal",title:r.title,subtitle:r.excerpt,meta:[r.author],tag:Oq(r.publishedAt)},void 0,!1,void 0,this)}var sK=jn({sourceEntityType:"post",attachmentType:Sn,template:EK,themeMode:"light",buildContent:async(l,r)=>{let{frontmatter:f}=zf(l.content),i=kr.parse(f),t=await r.resolveImageDataUrl(i.coverImageId);return{title:i.title,...i.excerpt?{excerpt:i.excerpt}:{},...i.author?{author:i.author}:{},...i.publishedAt?{publishedAt:i.publishedAt}:{},...t?{coverImageUrl:t}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});var CK={name:"@brains/blog",license:"AGPL-3.0-only",version:"0.2.0-alpha.259",description:"AI-powered blog post generation from existing brain content",dependencies:{"@brains/atproto-contracts":"workspace:*","@brains/contracts":"workspace:*","@brains/media-page-composer":"workspace:*","@brains/plugins":"workspace:*","@brains/style-guide":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{eval:"cd evals && bun run brain-eval",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};class M6 extends nf{entityType=of.entityType;schema=P6;adapter=of;unregisterAtprotoProjection;unregisterPrintableAttachmentProvider;unregisterOgImageAttachmentProvider;constructor(l={}){super("blog",CK,l,Yw)}getEntityTypeConfig(){return{weight:2,projectionSourceRole:"primary",publish:{publishStatuses:["queued","published"]}}}createGenerationHandler(l){return new Jw(this.logger.child("BlogGenerationJobHandler"),l)}getTemplates(){return Dm()}getDataSources(){return[new Gw(this.logger.child("BlogDataSource"))]}async onRegister(l){let{RSSDataSource:r}=await import("./rss-datasource-hbtj9tz9.js");l.entities.registerDataSource(new r(this.logger.child("RSSDataSource"))),jm(l,this.logger),Sm(l,this.logger),sm(l,this.logger),Cm(l),this.unregisterPrintableAttachmentProvider=l.attachments.register("post",Dh,SK(l)),this.unregisterOgImageAttachmentProvider=l.attachments.register("post",Sn,sK(l)),this.deferPublishAssetRegistration(l),this.unregisterAtprotoProjection=hf.getInstance().register(Nw()),this.logger.info("Blog plugin registered (routes auto-generated at /posts/)")}deferPublishAssetRegistration(l){l.messaging.subscribe(F1.pluginsRegistered,async()=>{return await l.messaging.send({type:Xm.register,payload:{entityType:"post",attachmentType:Sn,mediaEntityType:"image",targetEntityField:{location:"frontmatter",field:"ogImageId"},requiredWhen:{status:"published"},autoGenerate:!0,jobType:"image:image-render-source"}}),{success:!0}})}async onShutdown(){this.unregisterPrintableAttachmentProvider?.(),this.unregisterPrintableAttachmentProvider=void 0,this.unregisterOgImageAttachmentProvider?.(),this.unregisterOgImageAttachmentProvider=void 0,this.unregisterAtprotoProjection?.(),this.unregisterAtprotoProjection=void 0}}function Jq(l={}){return new M6(l)}var lz=W.object({}),xn=Ii.extend({id:W.literal("site-info"),entityType:W.literal("site-info"),metadata:lz});var Qq=eK.omit({url:!0,analyticsScript:!0}),kt=Qq.extend({title:W.string().optional().describe("Optional site title override"),description:W.string().optional().describe("Optional site description override")});var Hq=W.record(W.string(),W.unknown());class g1 extends qi{constructor(){super({entityType:"site-info",purpose:"Singleton configuration describing the published site.",schema:xn,frontmatterSchema:kt,isSingleton:!0,hasBody:!1})}createSiteInfoContent(l){let r=kt.parse(l);return this.buildMarkdown("",r)}parseSiteInfoBody(l){return this.parseFrontmatter(l)}fromMarkdown(l){return{content:l,entityType:"site-info"}}extractMetadata(l){return{}}generateFrontMatter(l){let r=this.parseFrontmatter(l.content);return this.buildMarkdown("",Hq.parse(r))}}var Bq={getBrain:()=>({name:"Brain",role:"Knowledge assistant",purpose:"A knowledge management system",values:[]}),getAnchor:()=>({name:"Brain",description:"A knowledge management system"})};class En{logger;entityService;adapter;defaultSiteInfo;identitySource;static getDefaultSiteInfo(){return{represents:"anchor",title:"Brain",description:"A knowledge management system"}}static createFresh(l,r,f,i){return new En(l,r,f,i)}constructor(l,r,f,i=Bq){this.entityService=l,this.logger=r.child("SiteInfoService"),this.adapter=new g1,this.identitySource=i,this.defaultSiteInfo={represents:"anchor",...f}}async initialize(){try{if(!await this.entityService.getEntity({entityType:"site-info",id:"site-info"})){if(await this.entityService.getEntity({entityType:"site-info",id:"site-info"}))return;this.logger.info("No site info found, creating default site info");let f=this.adapter.createSiteInfoContent(this.defaultSiteInfo);await this.entityService.createEntity({entity:{id:"site-info",entityType:"site-info",content:f,metadata:{}}}),this.logger.info("Default site info created successfully")}}catch(l){this.logger.error("Failed to initialize site info",{error:l})}}async getSiteInfo(){try{let l=await this.entityService.getEntity({entityType:"site-info",id:"site-info"});if(l)return this.resolveIdentityFallbacks(this.adapter.parseSiteInfoBody(l.content))}catch(l){this.logger.debug("Site info not found, using defaults",{error:l})}return this.resolveIdentityFallbacks(this.defaultSiteInfo)}resolveIdentityFallbacks(l){if(l.represents==="brain"){let f=this.identitySource.getBrain();return{...l,title:l.title??f.name,description:l.description??f.purpose}}let r=this.identitySource.getAnchor();return{...l,title:l.title??r.name,description:l.description??r.description??`The public site for ${r.name}`}}}var Gq=new g1;class jh{logger;id="site-info:entities";name="Site Info DataSource";description="Provides website channel metadata such as title, description, and CTA";constructor(l){this.logger=l}async fetch(l,r,f){let{entityService:i}=f,t;try{let u=await i.getEntity({entityType:"site-info",id:"site-info"});t=u?Gq.parseSiteInfoBody(u.content):{represents:"anchor",title:"Brain",description:"A knowledge management system"}}catch{t={represents:"anchor",title:"Brain",description:"A knowledge management system"}}let n={...t,title:t.title??"Brain",description:t.description??"A knowledge management system",copyright:t.copyright??"Powered by Rizom"};return this.logger.debug("SiteInfoDataSource returning",{title:n.title}),r.parse(n)}}var rz={name:"@brains/site-info",license:"AGPL-3.0-only",version:"0.2.0-alpha.259",description:"Site info entity \u2014 site metadata, title, description, CTA",dependencies:{"@brains/contracts":"workspace:*","@brains/entity-service":"workspace:*","@brains/plugins":"workspace:*","@brains/site-composition":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var Fq=new g1,Nq="site-info";class I6 extends nf{entityType=Nq;schema=xn;adapter=Fq;defaultSiteInfo;constructor(l){super("site-info",rz,{},Di);this.defaultSiteInfo=l?.siteInfo??{}}getEntityTypeConfig(){return{embeddable:!1,projectionSource:!1,projectionSourceRole:"excluded"}}getDataSources(){return[new jh(this.logger.child("SiteInfoDataSource"))]}async onRegister(l){let r=En.createFresh(l.entityService,this.logger,this.defaultSiteInfo,{getBrain:l.identity.get,getAnchor:l.identity.getProfile});l.messaging.subscribeExecution(iz,async()=>{return{success:!0,data:await r.getSiteInfo()}}),l.messaging.subscribe(fz.updated,async(f)=>{if(f.payload.entityType==="site-info"){let t=await r.getSiteInfo();await l.messaging.send({type:tz,payload:t,broadcast:!0})}return{success:!0}}),l.messaging.subscribe(Z2.initialCompleted,async()=>{return await r.initialize(),{success:!0}})}}function Lq(l){return new I6(l)}var Rq=new g1;async function q6(l){let f=(await l.listEntities({entityType:"site-info",options:{limit:1}}))[0];if(!f)throw Error("Site info not found \u2014 create a site-info entity");return Rq.parseSiteInfoBody(f.content)}function nz(l,r){let f=l.metadata.publishedAt??l.created,i=r.metadata.publishedAt??r.created;return new Date(i).getTime()-new Date(f).getTime()}async function Vq(l,r){return(await l.listEntities({entityType:r.entityType,options:{limit:20}})).sort(nz).slice(0,r.count).map(r.parse)}function Tq(l){if(!l)throw Error("CTA not configured in site-info");return l}var uz=W.object({label:W.string(),href:W.string(),priority:W.number()}),pq=W.object({primary:W.array(uz),secondary:W.array(uz)}),Pq=W.object({platform:W.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:W.string().describe("Profile or contact URL"),label:W.string().optional().describe("Optional display label")}),Mq=kt.extend({title:W.string(),description:W.string(),navigation:pq,copyright:W.string(),socialLinks:W.array(Pq).optional().describe("Social media links composed by a site integration")});var sn=W.enum(["generating","draft","queued","published","failed"]),hz="publishedAt is required when deck status is published",oz=(l)=>l.status==="published"&&!l.publishedAt,_6=(l)=>{if(oz(l))throw Error(hz)},Cr=W.object({title:W.string(),slug:W.string().optional(),description:W.string().optional(),author:W.string().optional(),status:sn,publishedAt:W.string().datetime().optional(),event:W.string().optional(),coverImageId:W.string().optional(),ogImageId:W.string().optional()}),Iq=W.object({title:W.string(),description:W.string().optional(),status:sn,publishedAt:W.string().datetime().optional(),coverImageId:W.string().optional(),slug:W.string(),error:W.string().optional()}).superRefine((l,r)=>{if(!oz(l))return;r.addIssue({code:W.ZodIssueCode.custom,path:["publishedAt"],message:hz})}),mt=Ii.extend({entityType:W.literal("deck"),metadata:Iq}),Sh=mt.extend({frontmatter:Cr,body:W.string(),ogImageUrl:W.string().optional()}),qq=Sh.extend({url:W.string().optional(),typeLabel:W.string().optional(),listUrl:W.string().optional(),listLabel:W.string().optional(),coverImageUrl:W.string().optional(),ogImageUrl:W.string().optional(),coverImageWidth:W.number().optional(),coverImageHeight:W.number().optional()});var _q=W.union([W.enum(["public","shared","restricted"]),W.literal("private")]).optional().transform((l)=>{if(l===void 0)return"public";if(l==="private")return"restricted";return l}),Dq=W.object({title:W.string(),slug:W.string().nullable().default(null),description:W.string().nullable().default(null),author:W.string().nullable().default(null),status:sn,publishedAt:W.string().nullable().default(null),event:W.string().nullable().default(null),coverImageId:W.string().nullable().default(null),ogImageId:W.string().nullable().default(null)}),jq=W.object({title:W.string(),description:W.string().nullable().default(null),status:sn,publishedAt:W.string().nullable().default(null),coverImageId:W.string().nullable().default(null),slug:W.string(),error:W.string().nullable().default(null)}),wi=W.object({id:W.string(),entityType:W.literal("deck"),content:W.string(),created:W.string(),updated:W.string(),visibility:_q,metadata:jq,contentHash:W.string(),frontmatter:Dq,body:W.string(),url:W.string().nullable().default(null),typeLabel:W.string().nullable().default(null),listUrl:W.string().nullable().default(null),listLabel:W.string().nullable().default(null),coverImageUrl:W.string().nullable().default(null),ogImageUrl:W.string().nullable().default(null),coverImageWidth:W.number().nullable().default(null),coverImageHeight:W.number().nullable().default(null)});class D6 extends qi{constructor(){super({entityType:"deck",purpose:"A slide-deck presentation.",schema:mt,frontmatterSchema:Cr,supportsCoverImage:!0})}validateSlideStructure(l){if(!/^---$/gm.test(l))throw Error("Invalid deck: markdown must contain slide separators (---) to be a valid presentation")}toMarkdown(l){let r=this.extractBody(l.content);this.validateSlideStructure(r);let f=this.parseFrontMatter(l.content,Cr);_6(f);let i={...f,slug:f.slug??l.metadata.slug};return this.buildMarkdown(r,i)}fromMarkdown(l){let r=this.parseFrontmatter(l),f=this.extractBody(l);_6(r),this.validateSlideStructure(f);let i=r.slug??Mr(r.title),t=r.status;return{entityType:"deck",content:l,metadata:{slug:i,title:r.title,description:r.description,status:t,publishedAt:r.publishedAt,coverImageId:r.coverImageId}}}generateTitle(l){return l.metadata.title}generateSummary(l){if(l.metadata.description)return l.metadata.description;return`Presentation: ${l.metadata.title}`}generateFrontMatter(l){return this.toMarkdown(l)}buildStub(l){let r={title:l.title,slug:l.id,status:"generating"};return{content:this.buildMarkdown(`---
1388
1388
  `,r),metadata:{title:l.title,slug:l.id,status:"generating"}}}}var Cn=new D6;var Sq=W.object({markdown:W.string().describe("Markdown content with slide separators (---)"),deck:wi.nullable().default(null)}),j6=xl({name:"deck-detail",description:"Render a presentation deck as Reveal.js slides",schema:Sq,dataSourceId:"decks:entities",requiredPermission:"public",layout:{component:nw,fullscreen:!0}});var S6=W.object({decks:W.array(Sh)}),x6=W.object({decks:W.array(wi),pageTitle:W.string().nullable().default(null),pageLabel:W.string().nullable().default(null)});import{jsxDEV as E6}from"preact/jsx-dev-runtime";var xq="Presentations",s6=({decks:l,pageLabel:r})=>{let f=l.map((t)=>({id:t.id,url:t.url,title:t.frontmatter.title,date:t.frontmatter.publishedAt??t.created,...t.frontmatter.description?{description:t.frontmatter.description}:{}}));return E6("div",{className:"deck-list bg-theme",children:E6("div",{className:"container mx-auto max-w-[1100px] px-6 py-16 md:px-12 md:py-24",children:E6(st,{label:r&&r!=="Decks"?r:xq,items:f},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)};class xh extends wz{constructor(){super(S6,{title:"Deck List",mappings:[{key:"decks",label:"Decks",type:"array",itemType:"object"}]})}}var C6=xl({name:"deck-list",description:"List view of all presentation decks",schema:x6,dataSourceId:"decks:entities",requiredPermission:"public",formatter:new xh,layout:{component:s6}});var Eq=W.object({title:W.string().max(80).describe("A short, punchy title (2-5 words) that's memorable and evocative"),content:W.string().describe("Full slide deck content in markdown format with slide separators (---). Each slide should have a header and focused content."),description:W.string().describe("A concise 1-2 sentence summary that captures the essence of the talk")}),vz=xl({name:"decks:generation",description:"Template for AI to generate complete slide decks from prompts",schema:Eq,dataSourceId:"shell:ai-content",requiredPermission:"public",useKnowledgeContext:!0,basePrompt:`Generate a complete slide deck based on the user's prompt.
1389
1389
 
1390
1390
  Content requirements:
@@ -1688,12 +1688,12 @@ ${o}`,templateName:"decks:description",representedIdentity:"none"})).description
1688
1688
  color: var(--carousel-accent);
1689
1689
  font-weight: 600;
1690
1690
  }
1691
- `}},void 0,!1,void 0,this),t.map((v,m)=>ur("section",{className:`deck-carousel-slide${m===0?" is-cover":""}`,children:[ur("header",{className:"deck-carousel-header",children:ur("span",{className:"deck-carousel-wordmark","aria-label":f??r,children:[ur("span",{className:"wm-primary",children:n.primary},void 0,!1,void 0,this),n.secondary!==void 0&&ur(f_,{children:[ur("span",{className:"wm-dot",children:"."},void 0,!1,void 0,this),ur("span",{className:"wm-secondary",children:n.secondary},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),ur("div",{className:"deck-carousel-body",children:ur("div",{className:"deck-carousel-content",dangerouslySetInnerHTML:{__html:w(v.markdown)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),ur("footer",{className:"deck-carousel-footer",children:[ur("span",{className:"deck-carousel-footer-meta",children:i??r},void 0,!1,void 0,this),ur("span",{className:"deck-carousel-counter","aria-label":`Slide ${m+1} of ${u}`,children:[ur("span",{className:"deck-carousel-counter-current",children:String(m+1).padStart(2,"0")},void 0,!1,void 0,this)," / ",ur("span",{children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},m,!0,void 0,this))]},void 0,!0,void 0,this)}var gz=20;class f4{metadata={outputEntityType:"document"};context;renderPdf;getThemeMode;constructor(l,r={}){this.context=l,this.renderPdf=r.renderPdf,this.getThemeMode=r.getThemeMode??(async()=>"dark")}async resolve(l){if(l.sourceEntityType!=="deck")return;let r=await this.context.entityService.getEntity({entityType:"deck",id:l.sourceEntityId});if(!r)return;let{brandLabel:f}=_h(this.context),i=i_(r,{brandLabel:f});if(i.slides.length>gz)throw Error(`Refusing to render carousel with ${i.slides.length} slides; maxSlides=${gz}`);return{type:"document",data:await Dn({mediaPath:`/_media/carousel/${r.id}`,template:yz,content:i,title:i.title,themeMode:await this.getThemeMode(),themeCSS:this.context.themeCSS,tmpPrefix:"brain-deck-carousel-",...this.renderPdf?{renderPdf:this.renderPdf}:{}}),mimeType:"application/pdf",filename:`${I1(r.metadata.slug,r.metadata.title)}-carousel.pdf`}}}function i_(l,r={}){let{frontmatter:f,content:i}=zf(l.content),t=typeof f.title==="string"?f.title:l.metadata.title,n=typeof f.event==="string"&&f.event.length>0?f.event:void 0,u=i.split(/^---$/gm).map((o)=>o.trim()).filter((o)=>o.length>0).map((o)=>({markdown:o}));return{title:t,slides:u,...r.brandLabel?{brandLabel:r.brandLabel}:{},...n?{eyebrow:n}:{}}}import{jsxDEV as u_}from"preact/jsx-dev-runtime";var Eh="og-image",t_="decks:og-image",dz=W.object({title:W.string().min(1),description:W.string().optional(),event:W.string().optional(),brandLabel:W.string().optional(),slideCount:W.number().int().positive().optional(),coverImageUrl:W.string().optional()}),cz={name:t_,pluginId:"decks",schema:dz,renderers:{image:n_}};function n_(l){let r=dz.parse(l),f=r.slideCount?`${r.slideCount} slide${r.slideCount===1?"":"s"}`:void 0;return u_(Et,{brandLabel:r.brandLabel??r.title,eyebrow:"Deck",title:r.title,subtitle:r.description,meta:[r.event],tag:f},void 0,!1,void 0,this)}var Az=jn({sourceEntityType:"deck",attachmentType:Eh,template:cz,themeMode:"dark",buildContent:async(l,r)=>{let{frontmatter:f,content:i}=zf(l.content),t=Cr.parse(f),n=h_(i),u=await r.resolveImageDataUrl(t.coverImageId);return{title:t.title,...t.description?{description:t.description}:{},...t.event?{event:t.event}:{},...n?{slideCount:n}:{},...u?{coverImageUrl:u}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});function h_(l){return l.split(/^---$/gm).map((r)=>r.trim()).filter((r)=>r.length>0).length}async function Kz({entity:l,config:r}){let f=mt.parse(l),i=Zl(f.content,Cr),t=i.metadata;return{$type:"ai.rizom.brain.deck",title:t.title,...t.slug&&{slug:t.slug},...t.description&&{description:t.description},body:i.content,format:"text/markdown",...t.author&&{author:t.author},...t.event&&{event:t.event},...t.publishedAt&&{publishedAt:t.publishedAt},...r.brainDid&&{brainDid:r.brainDid},...r.anchorDid&&{anchorDid:r.anchorDid},sourceEntityType:"deck",sourceEntityId:f.id,createdAt:f.created,...f.updated&&{updatedAt:f.updated}}}function i4(){return{entityType:"deck",collection:"ai.rizom.brain.deck",lexicon:_l["ai.rizom.brain.deck"],validate:!1,buildRecord:Kz}}var zz={name:"@brains/decks",license:"AGPL-3.0-only",version:"0.2.0-alpha.258",description:"Presentation decks plugin for creating and viewing slide presentations",dependencies:{"@brains/atproto-contracts":"workspace:*","@brains/content-formatters":"workspace:*","@brains/contracts":"workspace:*","@brains/image":"workspace:*","@brains/media-page-composer":"workspace:*","@brains/plugins":"workspace:*","@brains/site-info":"workspace:*","@brains/style-guide":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{eval:"cd evals && bun run brain-eval",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var w_=W.object({prompt:W.string(),event:W.string().optional()}),v_=W.object({title:W.string(),content:W.string()});class t4 extends nf{deps;entityType=Cn.entityType;schema=Cn.schema;adapter=Cn;unregisterCarouselAttachmentProvider;unregisterOgImageAttachmentProvider;unregisterAtprotoProjection;constructor(l={}){super("decks",zz,{},Di);this.deps=l}createGenerationHandler(l){return new r4(this.logger.child("DeckGenerationJobHandler"),l)}getTemplates(){return{"deck-detail":j6,"deck-list":C6,generation:vz,description:kz}}getDataSources(){return[new l4(this.logger)]}getEntityTypeConfig(){return{weight:1.5,projectionSourceRole:"primary"}}async onRegister(l){this.deferPublishRegistration(l),this.subscribeToPublishExecute(l),this.registerCarouselAttachmentProvider(l),this.registerOgImageAttachmentProvider(l),this.registerEvalHandlers(l),this.unregisterAtprotoProjection=hf.getInstance().register(i4()),this.logger.info("Decks plugin registered")}async onShutdown(){this.unregisterCarouselAttachmentProvider?.(),this.unregisterCarouselAttachmentProvider=void 0,this.unregisterOgImageAttachmentProvider?.(),this.unregisterOgImageAttachmentProvider=void 0,this.unregisterAtprotoProjection?.(),this.unregisterAtprotoProjection=void 0}deferPublishRegistration(l){l.messaging.subscribe(F1.pluginsRegistered,async()=>{return await l.messaging.send({type:Fr.register,payload:{entityType:"deck",provider:{name:"internal",publish:async()=>({id:"internal"})},config:{executionMode:"provider"}}}),{success:!0}})}subscribeToPublishExecute(l){l.messaging.subscribe(Fr.execute,async(r)=>{let{entityType:f,entityId:i}=r.payload;if(f!=="deck")return{success:!0};try{let t=await l.entityService.getEntity({entityType:"deck",id:i});if(!t)return await l.messaging.send({type:Fr.reportFailure,payload:{entityType:f,entityId:i,error:`Deck not found: ${i}`}}),{success:!0};if(t.metadata.status==="published")return{success:!0};let n=new Date().toISOString(),u={...t,metadata:{...t.metadata,status:"published",publishedAt:n}};await l.entityService.updateEntity({entity:{...u,content:this.adapter.toMarkdown(u)}}),await l.messaging.send({type:Fr.reportSuccess,payload:{entityType:f,entityId:i,result:{id:i}}})}catch(t){await l.messaging.send({type:Fr.reportFailure,payload:{entityType:f,entityId:i,error:mr(t)}})}return{success:!0}})}registerCarouselAttachmentProvider(l){let r={...this.deps,getThemeMode:this.deps.getThemeMode??(async()=>{try{return(await q6(l.entityService)).themeMode??"dark"}catch{return"dark"}})};this.unregisterCarouselAttachmentProvider=l.attachments.register("deck",$z,new f4(l,r))}registerOgImageAttachmentProvider(l){this.unregisterOgImageAttachmentProvider=l.attachments.register("deck",Eh,Az(l))}registerEvalHandlers(l){l.eval.registerHandler("generateDeck",async(r)=>{let f=w_.parse(r),i=G1(await B1(l.entityService));return l.ai.generate({prompt:`${f.prompt}${f.event?`
1691
+ `}},void 0,!1,void 0,this),t.map((v,m)=>ur("section",{className:`deck-carousel-slide${m===0?" is-cover":""}`,children:[ur("header",{className:"deck-carousel-header",children:ur("span",{className:"deck-carousel-wordmark","aria-label":f??r,children:[ur("span",{className:"wm-primary",children:n.primary},void 0,!1,void 0,this),n.secondary!==void 0&&ur(f_,{children:[ur("span",{className:"wm-dot",children:"."},void 0,!1,void 0,this),ur("span",{className:"wm-secondary",children:n.secondary},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),ur("div",{className:"deck-carousel-body",children:ur("div",{className:"deck-carousel-content",dangerouslySetInnerHTML:{__html:w(v.markdown)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),ur("footer",{className:"deck-carousel-footer",children:[ur("span",{className:"deck-carousel-footer-meta",children:i??r},void 0,!1,void 0,this),ur("span",{className:"deck-carousel-counter","aria-label":`Slide ${m+1} of ${u}`,children:[ur("span",{className:"deck-carousel-counter-current",children:String(m+1).padStart(2,"0")},void 0,!1,void 0,this)," / ",ur("span",{children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},m,!0,void 0,this))]},void 0,!0,void 0,this)}var gz=20;class f4{metadata={outputEntityType:"document"};context;renderPdf;getThemeMode;constructor(l,r={}){this.context=l,this.renderPdf=r.renderPdf,this.getThemeMode=r.getThemeMode??(async()=>"dark")}async resolve(l){if(l.sourceEntityType!=="deck")return;let r=await this.context.entityService.getEntity({entityType:"deck",id:l.sourceEntityId});if(!r)return;let{brandLabel:f}=_h(this.context),i=i_(r,{brandLabel:f});if(i.slides.length>gz)throw Error(`Refusing to render carousel with ${i.slides.length} slides; maxSlides=${gz}`);return{type:"document",data:await Dn({mediaPath:`/_media/carousel/${r.id}`,template:yz,content:i,title:i.title,themeMode:await this.getThemeMode(),themeCSS:this.context.themeCSS,tmpPrefix:"brain-deck-carousel-",...this.renderPdf?{renderPdf:this.renderPdf}:{}}),mimeType:"application/pdf",filename:`${I1(r.metadata.slug,r.metadata.title)}-carousel.pdf`}}}function i_(l,r={}){let{frontmatter:f,content:i}=zf(l.content),t=typeof f.title==="string"?f.title:l.metadata.title,n=typeof f.event==="string"&&f.event.length>0?f.event:void 0,u=i.split(/^---$/gm).map((o)=>o.trim()).filter((o)=>o.length>0).map((o)=>({markdown:o}));return{title:t,slides:u,...r.brandLabel?{brandLabel:r.brandLabel}:{},...n?{eyebrow:n}:{}}}import{jsxDEV as u_}from"preact/jsx-dev-runtime";var Eh="og-image",t_="decks:og-image",dz=W.object({title:W.string().min(1),description:W.string().optional(),event:W.string().optional(),brandLabel:W.string().optional(),slideCount:W.number().int().positive().optional(),coverImageUrl:W.string().optional()}),cz={name:t_,pluginId:"decks",schema:dz,renderers:{image:n_}};function n_(l){let r=dz.parse(l),f=r.slideCount?`${r.slideCount} slide${r.slideCount===1?"":"s"}`:void 0;return u_(Et,{brandLabel:r.brandLabel??r.title,eyebrow:"Deck",title:r.title,subtitle:r.description,meta:[r.event],tag:f},void 0,!1,void 0,this)}var Az=jn({sourceEntityType:"deck",attachmentType:Eh,template:cz,themeMode:"dark",buildContent:async(l,r)=>{let{frontmatter:f,content:i}=zf(l.content),t=Cr.parse(f),n=h_(i),u=await r.resolveImageDataUrl(t.coverImageId);return{title:t.title,...t.description?{description:t.description}:{},...t.event?{event:t.event}:{},...n?{slideCount:n}:{},...u?{coverImageUrl:u}:{},...r.brandLabel?{brandLabel:r.brandLabel}:{}}},pageTitle:(l)=>l.title,slug:(l)=>I1(l.metadata.slug,l.metadata.title)});function h_(l){return l.split(/^---$/gm).map((r)=>r.trim()).filter((r)=>r.length>0).length}async function Kz({entity:l,config:r}){let f=mt.parse(l),i=Zl(f.content,Cr),t=i.metadata;return{$type:"ai.rizom.brain.deck",title:t.title,...t.slug&&{slug:t.slug},...t.description&&{description:t.description},body:i.content,format:"text/markdown",...t.author&&{author:t.author},...t.event&&{event:t.event},...t.publishedAt&&{publishedAt:t.publishedAt},...r.brainDid&&{brainDid:r.brainDid},...r.anchorDid&&{anchorDid:r.anchorDid},sourceEntityType:"deck",sourceEntityId:f.id,createdAt:f.created,...f.updated&&{updatedAt:f.updated}}}function i4(){return{entityType:"deck",collection:"ai.rizom.brain.deck",lexicon:_l["ai.rizom.brain.deck"],validate:!1,buildRecord:Kz}}var zz={name:"@brains/decks",license:"AGPL-3.0-only",version:"0.2.0-alpha.259",description:"Presentation decks plugin for creating and viewing slide presentations",dependencies:{"@brains/atproto-contracts":"workspace:*","@brains/content-formatters":"workspace:*","@brains/contracts":"workspace:*","@brains/image":"workspace:*","@brains/media-page-composer":"workspace:*","@brains/plugins":"workspace:*","@brains/site-info":"workspace:*","@brains/style-guide":"workspace:*","@brains/ui-library":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/app":"workspace:*","@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{eval:"cd evals && bun run brain-eval",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var w_=W.object({prompt:W.string(),event:W.string().optional()}),v_=W.object({title:W.string(),content:W.string()});class t4 extends nf{deps;entityType=Cn.entityType;schema=Cn.schema;adapter=Cn;unregisterCarouselAttachmentProvider;unregisterOgImageAttachmentProvider;unregisterAtprotoProjection;constructor(l={}){super("decks",zz,{},Di);this.deps=l}createGenerationHandler(l){return new r4(this.logger.child("DeckGenerationJobHandler"),l)}getTemplates(){return{"deck-detail":j6,"deck-list":C6,generation:vz,description:kz}}getDataSources(){return[new l4(this.logger)]}getEntityTypeConfig(){return{weight:1.5,projectionSourceRole:"primary"}}async onRegister(l){this.deferPublishRegistration(l),this.subscribeToPublishExecute(l),this.registerCarouselAttachmentProvider(l),this.registerOgImageAttachmentProvider(l),this.registerEvalHandlers(l),this.unregisterAtprotoProjection=hf.getInstance().register(i4()),this.logger.info("Decks plugin registered")}async onShutdown(){this.unregisterCarouselAttachmentProvider?.(),this.unregisterCarouselAttachmentProvider=void 0,this.unregisterOgImageAttachmentProvider?.(),this.unregisterOgImageAttachmentProvider=void 0,this.unregisterAtprotoProjection?.(),this.unregisterAtprotoProjection=void 0}deferPublishRegistration(l){l.messaging.subscribe(F1.pluginsRegistered,async()=>{return await l.messaging.send({type:Fr.register,payload:{entityType:"deck",provider:{name:"internal",publish:async()=>({id:"internal"})},config:{executionMode:"provider"}}}),{success:!0}})}subscribeToPublishExecute(l){l.messaging.subscribe(Fr.execute,async(r)=>{let{entityType:f,entityId:i}=r.payload;if(f!=="deck")return{success:!0};try{let t=await l.entityService.getEntity({entityType:"deck",id:i});if(!t)return await l.messaging.send({type:Fr.reportFailure,payload:{entityType:f,entityId:i,error:`Deck not found: ${i}`}}),{success:!0};if(t.metadata.status==="published")return{success:!0};let n=new Date().toISOString(),u={...t,metadata:{...t.metadata,status:"published",publishedAt:n}};await l.entityService.updateEntity({entity:{...u,content:this.adapter.toMarkdown(u)}}),await l.messaging.send({type:Fr.reportSuccess,payload:{entityType:f,entityId:i,result:{id:i}}})}catch(t){await l.messaging.send({type:Fr.reportFailure,payload:{entityType:f,entityId:i,error:mr(t)}})}return{success:!0}})}registerCarouselAttachmentProvider(l){let r={...this.deps,getThemeMode:this.deps.getThemeMode??(async()=>{try{return(await q6(l.entityService)).themeMode??"dark"}catch{return"dark"}})};this.unregisterCarouselAttachmentProvider=l.attachments.register("deck",$z,new f4(l,r))}registerOgImageAttachmentProvider(l){this.unregisterOgImageAttachmentProvider=l.attachments.register("deck",Eh,Az(l))}registerEvalHandlers(l){l.eval.registerHandler("generateDeck",async(r)=>{let f=w_.parse(r),i=G1(await B1(l.entityService));return l.ai.generate({prompt:`${f.prompt}${f.event?`
1692
1692
 
1693
1693
  Note: This presentation is for "${f.event}".`:""}`,templateName:"decks:generation",representedIdentity:"anchor",...i&&{styleGuide:{voice:i}}})}),l.eval.registerHandler("generateDescription",async(r)=>{let f=v_.parse(r);return l.ai.generate({prompt:`Title: ${f.title}
1694
1694
 
1695
1695
  Content:
1696
- ${f.content}`,templateName:"decks:description",representedIdentity:"none"})})}}function k_(){return new t4}var Wz={name:"@brains/profile",license:"AGPL-3.0-only",version:"0.2.0-alpha.258",description:"Anchor-profile extensions and context-generated starter identity lifecycle",dependencies:{"@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var Wf=W.object({tagline:W.string().optional().describe("Short public profile tagline"),intro:W.string().optional().describe("Longer public profile introduction"),story:W.string().optional().describe("Extended profile narrative sourced from the markdown body"),audience:W.string().optional().describe("Primary audience or community served")}),sh=W.object({tagline:Wf.shape.tagline,intro:Wf.shape.intro,audience:Wf.shape.audience}),Ch=W.object({role:W.string().optional().describe("Professional role or working identity"),expertise:W.array(W.string()).optional().describe("Skills, domains, and areas of focus"),currentFocus:W.string().optional().describe("What the professional is currently working on"),availability:W.string().optional().describe("Work, speaking, or collaboration availability")}),Zz=Wf.extend(Ch.shape),n4=W.object({purpose:W.string().optional().describe("Team purpose"),focusAreas:W.array(W.string()).optional().describe("Team focus areas"),capabilities:W.array(W.string()).optional().describe("Team capabilities"),workingPrinciples:W.array(W.string()).optional().describe("Principles guiding how the team works")}),Oz=Wf.extend(n4.shape),u4=W.object({mission:W.string().optional().describe("Organization mission"),focusAreas:W.array(W.string()).optional().describe("Organization focus areas"),offerings:W.array(W.string()).optional().describe("Organization products, services, or programs"),values:W.array(W.string()).optional().describe("Organization values")}),az=Wf.extend(u4.shape),$_=$t.extend(Zz.shape).strict(),b_=$t.extend(Oz.shape).strict(),y_=$t.extend(az.shape).strict(),Xz=$t.extend(Wf.shape).loose(),g_=Xz.extend(Ch.shape).loose();var h4=[{kind:"professional",category:"person",fields:Ch,labels:{singular:"Professional",plural:"Professionals"}},{kind:"team",category:"team",fields:n4,labels:{singular:"Team",plural:"Teams"}},{kind:"organization",category:"organization",fields:u4,labels:{singular:"Organization",plural:"Organizations"}}],d_=W.record(W.string(),W.unknown()),c_={person:"person",professional:"person",team:"team",organization:"organization",collective:"organization"};function A_(l,r){if(l===void 0)return;if(typeof l!=="string")throw Error("anchor-profile transitional kind must be a string");let f=c_[l];if(!f)throw Error(`Unknown transitional anchor-profile kind: ${l}`);if(r&&f!==r.category)throw Error(`anchor-profile content kind category ${f} does not match configured category ${r.category}`)}function o4(l,r){let{metadata:f}=Zl(l,d_);if(Object.hasOwn(f,"story"))throw Error("anchor-profile story must be stored in the markdown body, not frontmatter");A_(f.kind,r);let{kind:i,...t}=f,n=r?.fields.shape??{};$t.extend(sh.shape).extend(n).strict().parse(t)}var K_=50,Yz=12,z_=12,W_=160,Z_=/\b(?:ranger|relay|rover)\b/iu,O_=W.record(W.string(),W.unknown()),a_=["title","name","summary","description","topic","tagline"],X_=[["name"],["description"],["tagline"],["intro"],["role"],["purpose"],["mission"],["audience"],["expertise"],["currentFocus"],["focusAreas"],["capabilities"],["offerings"],["values"],["workingPrinciples"]],Y_=[["messaging","audiences"],["messaging","positioning"],["voice","summary"],["voice","traits"],["voice","principles"],["voice","preferredTerms"],["voice","avoid"]],J_=new Set(["anchor-profile","brain-character","conversation","image","site-info","style-guide"]),Q_=W.string().trim().min(3).max(80).refine((l)=>l.split(/\s+/u).length>=2&&l.split(/\s+/u).length<=6,"Role must contain between two and six words").refine((l)=>!/[.!?]$/u.test(l),"Role must be a phrase"),H_=W.string().trim().min(12).max(240).refine((l)=>!/[\r\n]/u.test(l),"Purpose must be one line"),B_=W.string().trim().min(2).max(60).refine((l)=>l.split(/\s+/u).length<=5,"Values must contain at most five words"),w4=W.object({role:Q_,purpose:H_,values:W.array(B_).length(3)}).refine(({values:l})=>new Set(l.map((r)=>r.toLowerCase())).size===l.length,{message:"Values must be distinct",path:["values"]});function Hz(l){return l.replace(/\s+/gu," ").trim().slice(0,W_)}function k4(l){if(typeof l==="string"){let r=Hz(l);return r?[r]:[]}if(Array.isArray(l))return l.flatMap((r)=>typeof r==="string"?k4(r):[]);return[]}function v4(l){try{return Zl(l,O_).metadata}catch{return null}}function G_(l){return l!==null&&typeof l==="object"&&!Array.isArray(l)}function U_(l,r){let f=l;for(let i of r){if(!G_(f))return;f=f[i]}return f}function Jz(l,r){let f=[];for(let i of r)for(let t of k4(U_(l,i)))if(f.push(`${i.join(".")}: ${t}`),f.length>=z_)return f;return f}function F_(l){let r=v4(l.content);if(!r)return null;let f=[];for(let t of a_){let n=k4(r[t]);if(n.length>0)f.push(`${t}: ${n.join(", ")}`);if(f.length>=2)break}return Hz(f.join(" \u2014 "))||null}function Qz(l){if(l==="topic")return 0;if(l==="summary")return 1;return 2}async function N_(l,r){let f=[...r.entries()].filter(([t,n])=>n>0&&!J_.has(t)).sort(([t,n],[u,o])=>Qz(t)-Qz(u)||o-n||t.localeCompare(u)),i=[];for(let[t]of f){let n=await l.listEntities({entityType:t,options:{limit:Yz,sortFields:[{field:"updated",direction:"desc"}],filter:{visibilityScope:"restricted"}}});for(let u of n){let o=F_(u);if(!o||Z_.test(o))continue;if(i.push({entityType:t,label:o}),i.length>=Yz)return i}}return i}async function m4(l){let{entityService:r,profileKind:f,profileCategory:i,anchorEntity:t,includeAnchor:n}=l,u=await r.getEntityCounts("restricted"),o=new Map(u.map(({entityType:c,count:a})=>[c,a])),w=r.getEntityTypes().sort((c,a)=>c.localeCompare(a)).slice(0,K_).map((c)=>({entityType:c,count:o.get(c)??0})),v=n&&t?v4(t.content):null,m=v?Jz(v,X_):[],$=await r.getEntity({entityType:"style-guide",id:"style-guide",visibilityScope:"restricted"}),b=$?v4($.content):null,d=b?Jz(b,Y_):[];return{...f&&{profileKind:f},...i&&{profileCategory:i},capabilities:w,anchorSignals:m,styleSignals:d,contentSignals:await N_(r,o)}}function Bz(l){return`Create a durable starter character for a software agent from the factual brief below.
1696
+ ${f.content}`,templateName:"decks:description",representedIdentity:"none"})})}}function k_(){return new t4}var Wz={name:"@brains/profile",license:"AGPL-3.0-only",version:"0.2.0-alpha.259",description:"Anchor-profile extensions and context-generated starter identity lifecycle",dependencies:{"@brains/plugins":"workspace:*","@brains/utils":"workspace:*"},devDependencies:{"@brains/eslint-config":"workspace:*","@brains/typescript-config":"workspace:*","@types/bun":"^1.3.14","bun-types":"^1.3.14",eslint:"^10.5.0",typescript:"^7.0.2"},exports:{".":"./src/index.ts"},private:!0,scripts:{lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",test:"bun test",typecheck:"tsc --noEmit"},type:"module"};var Wf=W.object({tagline:W.string().optional().describe("Short public profile tagline"),intro:W.string().optional().describe("Longer public profile introduction"),story:W.string().optional().describe("Extended profile narrative sourced from the markdown body"),audience:W.string().optional().describe("Primary audience or community served")}),sh=W.object({tagline:Wf.shape.tagline,intro:Wf.shape.intro,audience:Wf.shape.audience}),Ch=W.object({role:W.string().optional().describe("Professional role or working identity"),expertise:W.array(W.string()).optional().describe("Skills, domains, and areas of focus"),currentFocus:W.string().optional().describe("What the professional is currently working on"),availability:W.string().optional().describe("Work, speaking, or collaboration availability")}),Zz=Wf.extend(Ch.shape),n4=W.object({purpose:W.string().optional().describe("Team purpose"),focusAreas:W.array(W.string()).optional().describe("Team focus areas"),capabilities:W.array(W.string()).optional().describe("Team capabilities"),workingPrinciples:W.array(W.string()).optional().describe("Principles guiding how the team works")}),Oz=Wf.extend(n4.shape),u4=W.object({mission:W.string().optional().describe("Organization mission"),focusAreas:W.array(W.string()).optional().describe("Organization focus areas"),offerings:W.array(W.string()).optional().describe("Organization products, services, or programs"),values:W.array(W.string()).optional().describe("Organization values")}),az=Wf.extend(u4.shape),$_=$t.extend(Zz.shape).strict(),b_=$t.extend(Oz.shape).strict(),y_=$t.extend(az.shape).strict(),Xz=$t.extend(Wf.shape).loose(),g_=Xz.extend(Ch.shape).loose();var h4=[{kind:"professional",category:"person",fields:Ch,labels:{singular:"Professional",plural:"Professionals"}},{kind:"team",category:"team",fields:n4,labels:{singular:"Team",plural:"Teams"}},{kind:"organization",category:"organization",fields:u4,labels:{singular:"Organization",plural:"Organizations"}}],d_=W.record(W.string(),W.unknown()),c_={person:"person",professional:"person",team:"team",organization:"organization",collective:"organization"};function A_(l,r){if(l===void 0)return;if(typeof l!=="string")throw Error("anchor-profile transitional kind must be a string");let f=c_[l];if(!f)throw Error(`Unknown transitional anchor-profile kind: ${l}`);if(r&&f!==r.category)throw Error(`anchor-profile content kind category ${f} does not match configured category ${r.category}`)}function o4(l,r){let{metadata:f}=Zl(l,d_);if(Object.hasOwn(f,"story"))throw Error("anchor-profile story must be stored in the markdown body, not frontmatter");A_(f.kind,r);let{kind:i,...t}=f,n=r?.fields.shape??{};$t.extend(sh.shape).extend(n).strict().parse(t)}var K_=50,Yz=12,z_=12,W_=160,Z_=/\b(?:ranger|relay|rover)\b/iu,O_=W.record(W.string(),W.unknown()),a_=["title","name","summary","description","topic","tagline"],X_=[["name"],["description"],["tagline"],["intro"],["role"],["purpose"],["mission"],["audience"],["expertise"],["currentFocus"],["focusAreas"],["capabilities"],["offerings"],["values"],["workingPrinciples"]],Y_=[["messaging","audiences"],["messaging","positioning"],["voice","summary"],["voice","traits"],["voice","principles"],["voice","preferredTerms"],["voice","avoid"]],J_=new Set(["anchor-profile","brain-character","conversation","image","site-info","style-guide"]),Q_=W.string().trim().min(3).max(80).refine((l)=>l.split(/\s+/u).length>=2&&l.split(/\s+/u).length<=6,"Role must contain between two and six words").refine((l)=>!/[.!?]$/u.test(l),"Role must be a phrase"),H_=W.string().trim().min(12).max(240).refine((l)=>!/[\r\n]/u.test(l),"Purpose must be one line"),B_=W.string().trim().min(2).max(60).refine((l)=>l.split(/\s+/u).length<=5,"Values must contain at most five words"),w4=W.object({role:Q_,purpose:H_,values:W.array(B_).length(3)}).refine(({values:l})=>new Set(l.map((r)=>r.toLowerCase())).size===l.length,{message:"Values must be distinct",path:["values"]});function Hz(l){return l.replace(/\s+/gu," ").trim().slice(0,W_)}function k4(l){if(typeof l==="string"){let r=Hz(l);return r?[r]:[]}if(Array.isArray(l))return l.flatMap((r)=>typeof r==="string"?k4(r):[]);return[]}function v4(l){try{return Zl(l,O_).metadata}catch{return null}}function G_(l){return l!==null&&typeof l==="object"&&!Array.isArray(l)}function U_(l,r){let f=l;for(let i of r){if(!G_(f))return;f=f[i]}return f}function Jz(l,r){let f=[];for(let i of r)for(let t of k4(U_(l,i)))if(f.push(`${i.join(".")}: ${t}`),f.length>=z_)return f;return f}function F_(l){let r=v4(l.content);if(!r)return null;let f=[];for(let t of a_){let n=k4(r[t]);if(n.length>0)f.push(`${t}: ${n.join(", ")}`);if(f.length>=2)break}return Hz(f.join(" \u2014 "))||null}function Qz(l){if(l==="topic")return 0;if(l==="summary")return 1;return 2}async function N_(l,r){let f=[...r.entries()].filter(([t,n])=>n>0&&!J_.has(t)).sort(([t,n],[u,o])=>Qz(t)-Qz(u)||o-n||t.localeCompare(u)),i=[];for(let[t]of f){let n=await l.listEntities({entityType:t,options:{limit:Yz,sortFields:[{field:"updated",direction:"desc"}],filter:{visibilityScope:"restricted"}}});for(let u of n){let o=F_(u);if(!o||Z_.test(o))continue;if(i.push({entityType:t,label:o}),i.length>=Yz)return i}}return i}async function m4(l){let{entityService:r,profileKind:f,profileCategory:i,anchorEntity:t,includeAnchor:n}=l,u=await r.getEntityCounts("restricted"),o=new Map(u.map(({entityType:c,count:a})=>[c,a])),w=r.getEntityTypes().sort((c,a)=>c.localeCompare(a)).slice(0,K_).map((c)=>({entityType:c,count:o.get(c)??0})),v=n&&t?v4(t.content):null,m=v?Jz(v,X_):[],$=await r.getEntity({entityType:"style-guide",id:"style-guide",visibilityScope:"restricted"}),b=$?v4($.content):null,d=b?Jz(b,Y_):[];return{...f&&{profileKind:f},...i&&{profileCategory:i},capabilities:w,anchorSignals:m,styleSignals:d,contentSignals:await N_(r,o)}}function Bz(l){return`Create a durable starter character for a software agent from the factual brief below.
1697
1697
 
1698
1698
  Return only the requested structured fields.
1699
1699
 
@@ -1710,5 +1710,5 @@ Requirements:
1710
1710
  Factual brief:
1711
1711
  ${JSON.stringify(l,null,2)}`}async function $4(l,r){let f=await l.generateObject(Bz(r),w4);return w4.parse(f.object)}import{createHash as L_}from"crypto";var R_=W.record(W.string(),W.unknown()),b4={first:["Arcane","Astonishing","Bold","Cosmic","Daring","Deep","Dynamic","Electric","Endless","Fearless","Hidden","Infinite","Keen","Lucky","Midnight","Mighty","Mystic","Noble","Phantom","Profound","Quiet","Radiant","Silent","Solar","Sonic","Supreme","Swift","Thunderous","Uncommon","Vivid"],second:["Architect","Cipher","Diplomat","Dreamer","Explorer","Genius","Guide","Herald","Inventor","Luminary","Magician","Mastermind","Navigator","Observer","Operator","Oracle","Pioneer","Sage","Scholar","Scribe","Seeker","Specialist","Strategist","Thinker","Voyager","Watcher","Weaver","Wizard"]},V_=[{id:"brain-v2",character:{name:"Brain",role:"Knowledge assistant",purpose:"Help organize, understand, and retrieve information from your knowledge base",values:["clarity","accuracy","helpfulness"]}},{id:"personal-brain-v1",character:{name:"Personal Brain",role:"Personal knowledge assistant",purpose:"Help organize, understand, and retrieve information from your personal knowledge base",values:["clarity","accuracy","helpfulness"]}}],T_=[{id:"unknown-person-v1",name:"Unknown",kind:"person"}];function Fz(l){let r=l.trim().toLowerCase();if(!r)return null;let f;try{f=new URL(/^[a-z][a-z\d+.-]*:\/\//u.test(r)?r:`https://${r}`).host}catch{return null}return f.replace(/\.$/u,"")||null}function p_(l){let r=l.trim().toLowerCase();if(!r.startsWith("did:web:"))return null;let f=r.slice(8).split(":");if(f.length!==1||!f[0])return null;try{return Fz(decodeURIComponent(f[0]))}catch{return null}}function c4(l){let r=l.domain?Fz(l.domain):l.didWeb?p_(l.didWeb):null;return r?`domain:${r}`:null}function P_(l){return L_("sha256").update(l).digest()}function Gz(l,r,f){let i=r[f]??0,t=l[i%l.length];if(t===void 0)throw Error("Starter identity register is empty");return t}function Nz(l){let r=P_(`starter-alias:v1:${l}`);return{name:`${Gz(b4.first,r,0)} ${Gz(b4.second,r,1)}`}}function A4(l){try{let r=Zl(l,R_);return{metadata:r.metadata,body:r.content.trim()}}catch{return null}}function y4(l,r){let f=Object.keys(l).sort(),i=[...r].sort();return f.length===i.length&&f.every((t,n)=>t===i[n])}function Lz(l){let r=A4(l);if(!r||r.body||!y4(r.metadata,["name","role","purpose","values"]))return!1;let f=d4.safeParse(r.metadata);if(!f.success)return!1;return V_.some(({character:i})=>Boolean(f.data.name===i.name&&f.data.role===i.role&&f.data.purpose===i.purpose&&f.data.values.length===i.values.length&&f.data.values.every((t,n)=>t===i.values[n])))}function g4(l){let r=A4(l);if(!r||r.body)return!1;if(y4(r.metadata,["name"])&&r.metadata.name==="Unknown")return!0;if(!y4(r.metadata,["name","kind"]))return!1;return T_.some((f)=>r.metadata.name===f.name&&r.metadata.kind===f.kind)}function M_(l){if(!l)return null;let f=A4(l.content)?.metadata.name;return typeof f==="string"&&f.trim()?f:null}function Rz(l){return en("",l)}function Vz(l,r){let f=r??"anchor";return en(`This brain picked **${l}** as its starter name. Replace this placeholder with the ${f} identity the brain represents.`,{name:`Anchor for ${l}`,description:`Starter ${f} profile; configuration is still needed.`,intro:"This is a generated placeholder, not an invented real-world identity."})}async function Uz(l,r,f,i){if(r)return await l.updateEntity({entity:{...r,content:i}}),"migrated";return await l.createEntity({entity:{id:f,entityType:f,content:i,metadata:{}}}),"created"}async function K4(l){let{entityService:r,identifier:f,profileKind:i,profileCategory:t,generateBrainCharacter:n,logger:u}=l,[o,w]=await Promise.all([r.getEntity({entityType:"brain-character",id:"brain-character",visibilityScope:"restricted"}),r.getEntity({entityType:"anchor-profile",id:"anchor-profile",visibilityScope:"restricted"})]),v=Nz(f),m=!o||Lz(o.content),$=Boolean(w&&!g4(w.content)),b=null;if(m){let L=await n({starterName:v.name,...i&&{profileKind:i},...t&&{profileCategory:t},anchorEntity:w,anchorIsAuthored:$});b={name:v.name,...L},d4.parse(b)}let d="unchanged";if(b)d=await Uz(r,o,"brain-character",Rz(b));let c=b?b.name:M_(o)??v.name,a="unchanged";if(!w||g4(w.content))a=await Uz(r,w,"anchor-profile",Vz(c,t));let Y={brainCharacter:d,anchorProfile:a,starterName:v.name};if(d!=="unchanged"||a!=="unchanged")u?.info("Seeded or migrated starter identity",Y);return Y}var I_=W.object({enabled:W.boolean().default(!0)}),q_=W.object({starterIdentity:I_.default({enabled:!0})});class z4 extends Tz{constructor(l={}){super("profile",Wz,l,q_)}async generateCharacter(l,r){return $4(l.ai,r)}async onRegister(l){for(let u of h4)l.profileKinds.register(u);if(!this.config.starterIdentity.enabled)return;let r=!1,f=!1,i,t=async()=>{let u=c4({domain:l.domain});if(!u){this.logger.warn("Starter identity deferred: configure a canonical brain domain");return}let o=l.profileKinds.getResolved();try{await K4({entityService:l.entityService,identifier:u,...o&&{profileKind:o.kind,profileCategory:o.category},generateBrainCharacter:async({profileKind:w,profileCategory:v,anchorEntity:m,anchorIsAuthored:$})=>{let b=await m4({entityService:l.entityService,...w&&{profileKind:w},...v&&{profileCategory:v},anchorEntity:m,includeAnchor:$});return this.generateCharacter(l,b)},logger:this.logger})}catch(w){this.logger.warn("Starter character generation deferred",{error:mr(w)})}},n=async()=>{if(!r||!f)return;if(i){await i;return}i=t();try{await i}finally{i=void 0}};l.messaging.subscribe(F1.initialSyncCompleted,async(u)=>{if(u.payload.success===!0)r=!0,await n();return{success:!0}}),l.messaging.subscribe(F1.shellReady,async()=>{return f=!0,await n(),{success:!0}})}async onRegistrationComplete(l){l.entities.extendFrontmatterSchema("anchor-profile",sh);let r=l.profileKinds.getResolved(),f=l.profileKinds.getSelectedDefinition();if(r&&!f)throw Error(`Selected profile kind "${r.kind}" has no field definition`);if(f)l.entities.extendFrontmatterSchema("anchor-profile",f.fields);l.entities.registerPersistValidator("anchor-profile",async(i)=>{o4(i.content,r&&f?{category:r.category,fields:f.fields}:void 0)})}}function __(l={}){return new z4(l)}async function pz(l){let f=(await l.listEntities({entityType:"anchor-profile",options:{limit:1}}))[0];if(!f)throw Error("Profile not found \u2014 create an anchor-profile entity");return f.content}async function D_(l,r){let f=await pz(l),{metadata:i,content:t}=Zl(f,W.record(W.string(),W.unknown()));return r.parse(t?{...i,story:t}:i)}export{_l as W,jB as X,SB as Y,xB as Z,fG as _,iG as $,tG as aa,nG as ba,uG as ca,hG as da,oG as ea,vG as fa,kG as ga,mG as ha,$G as ia,hf as ja,DZ as ka,zi as la,Ai as ma,Ho as na,z1 as oa,Oi as pa,Z1 as qa,bv as ra,Pv as sa,iw as ta,FH as ua,MZ as va,_Z as wa,Et as xa,VH as ya,TH as za,ow as Aa,PH as Ba,MH as Ca,qH as Da,_H as Ea,fr as Fa,$w as Ga,DH as Ha,jH as Ia,SH as Ja,xH as Ka,sH as La,nB as Ma,hB as Na,wB as Oa,kB as Pa,rn as Qa,yB as Ra,gB as Sa,dB as Ta,_i as Ua,JB as Va,B1 as Wa,G1 as Xa,BB as Ya,Hw as Za,yr as _a,gK as $a,dK as ab,Rh as bb,Z6 as cb,ph as db,a6 as eb,aK as fb,UI as gb,YK as hb,Ph as ib,LI as jb,FK as kb,LK as lb,RI as mb,VI as nb,TI as ob,PI as pb,V6 as qb,I1 as rb,jn as sb,p6 as tb,Jq as ub,Lq as vb,q6 as wb,Vq as xb,Tq as yb,wi as zb,e6 as Ab,k_ as Bb,__ as Cb,D_ as Db};
1712
1712
 
1713
- //# debugId=D815FC5EB1237D1564756E2164756E21
1714
- //# sourceMappingURL=index-ga7bq62s.js.map
1713
+ //# debugId=0B64B5289CAECD1664756E2164756E21
1714
+ //# sourceMappingURL=index-0sdv84f7.js.map