@vpxa/aikit 0.1.161 → 0.1.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpxa/aikit",
3
- "version": "0.1.161",
3
+ "version": "0.1.163",
4
4
  "type": "module",
5
5
  "description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
6
6
  "license": "MIT",
@@ -1579,7 +1579,7 @@ html[data-theme='dark'] .aikit-theme-toggle-icon--moon {
1579
1579
  }
1580
1580
  `,_t={actions:m,cards:ee,chart:te,checklist:ne,code:re,comparison:ae,"component-detail":fe,"data-table-schema":_e,"docs-browser":ye,"docs-hub":Ce,finding:Te,graph:De,heading:Oe,"lifecycle-flow":Ie,markdown:Ve,mermaid:He,metrics:We,paragraph:Ge,progress:qe,prompt:Ye,separator:Xe,"status-board":Qe,table:tt,tags:rt,text:it,timeline:at,tree:ot};function vt(e,t){let r={...e,value:o(e.value)},i=_t[r.type],a=i?i(r,t):bt(r);return r.title&&![`heading`,`finding`].includes(r.type)?`<section class="bk-section bk-section--${n(r.type)}"><h3 class="bk-section-title">${n(r.title)}</h3>${a}</section>`:a}function yt(e,t){return e.map(e=>vt(e,t)).join(`
1581
1581
  `)}function bt(e){if(e.value===void 0||e.value===null)return``;if(typeof e.value==`string`)return`<p class="bk-paragraph">${n(e.value)}</p>`;try{return`<pre class="bk-fallback">${n(JSON.stringify(e.value,null,2))}</pre>`}catch{return`<pre class="bk-fallback">${n(String(e.value))}</pre>`}}var xt=class{templates=new Map;register(e){this.templates.set(e.id,e)}get(e){let t=this.templates.get(e);if(t)return t;let n=e.includes(`@`)?e:`${e}@`,r,i=-1;for(let[e,t]of this.templates){if(!e.startsWith(n))continue;let a=Number.parseInt(e.split(`@`)[1]??`0`,10);a>i&&(i=a,r=t)}return r}has(e){return this.get(e)!==void 0}list(){return[...this.templates.values()]}};const St=[`mcp-app`,`browser`];function k(e){return typeof e==`object`&&!!e}function Ct(e){return Array.isArray(e)?e.flatMap(e=>!k(e)||typeof e.label!=`string`?[]:[{label:e.label,checked:!!e.checked}]):[]}const A={id:`checklist@1`,label:`Checklist`,description:`Checklist with optional title and form hydration metadata.`,inputSchema:{type:`object`,properties:{title:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`label`,`checked`],properties:{label:{type:`string`},checked:{type:`boolean`}},additionalProperties:!1}}},required:[`items`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=[],n=k(e)&&typeof e.title==`string`?e.title:void 0,r=k(e)?Ct(e.items):[];return n&&t.push({type:`heading`,value:n}),t.push({type:`checklist`,value:r}),t},hydration:[`form`],supportedTransports:St},wt=[`mcp-app`,`browser`,`export`];function j(e){return typeof e==`object`&&!!e}function Tt(e){return j(e)&&typeof e.label==`string`&&(typeof e.value==`string`||typeof e.value==`number`)}function Et(e){return j(e)&&typeof e.key==`string`&&typeof e.label==`string`}function Dt(e){return Array.isArray(e)?e.filter(j):[]}function Ot(e,t){if(Array.isArray(e)){let t=e.filter(Et);if(t.length>0)return t}return Object.keys(t[0]??{}).map(e=>({key:e,label:e}))}const M={id:`data-table@1`,label:`Data Table`,description:`Static data table with optional metrics and sortable table hydration.`,inputSchema:{type:`object`,properties:{columns:{type:`array`,items:{type:`object`,required:[`key`,`label`],properties:{key:{type:`string`},label:{type:`string`}},additionalProperties:!1}},rows:{type:`array`,items:{type:`object`}},stats:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{label:{type:`string`},value:{type:[`string`,`number`]},trend:{type:[`string`,`number`]},status:{type:`string`}},additionalProperties:!1}}},required:[`rows`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=j(e)?Dt(e.rows):[],n=j(e)?Ot(e.columns,t):[],r=n.map(e=>e.label),i=t.map(e=>n.map(t=>e[t.key])),a=[];if(j(e)&&Array.isArray(e.stats)){let t=e.stats.filter(Tt);t.length>0&&a.push({type:`metrics`,value:t})}return a.push({type:`table`,columns:n,headers:r,rows:i,value:{headers:r,rows:i}}),a},hydration:[`table`],supportedTransports:wt},kt=[`mcp-app`,`browser`,`export`];function N(e){return typeof e==`object`&&!!e}function At(e){return Array.isArray(e)?e.flatMap(e=>!N(e)||typeof e.type!=`string`||typeof e.content!=`string`?[]:[{type:e.type,content:e.content}]):[]}function jt(e){return Array.isArray(e)?e.flatMap(e=>!N(e)||typeof e.header!=`string`?[]:[{header:e.header,changes:At(e.changes)}]):[]}function Mt(e){return!N(e)||!Array.isArray(e.files)?[]:e.files.flatMap(e=>!N(e)||typeof e.path!=`string`||typeof e.status!=`string`?[]:[{path:e.path,status:e.status,additions:typeof e.additions==`number`?e.additions:0,deletions:typeof e.deletions==`number`?e.deletions:0,hunks:jt(e.hunks)}])}function Nt(e){return e===`add`?`+`:e===`delete`?`-`:` `}function Pt(e){let t=e.hunks.flatMap(e=>[e.header,...e.changes.map(e=>`${Nt(e.type)}${e.content}`)]).join(`
1582
- `);return[{type:`heading`,value:e.path},{type:`paragraph`,value:`${e.status} | +${e.additions} / -${e.deletions}`},{type:`code`,language:`diff`,value:t}]}const P={id:`diff-view@1`,label:`Diff View`,description:`Static diff summary rendered as per-file diff code blocks.`,inputSchema:{type:`object`,properties:{files:{type:`array`,items:{type:`object`,required:[`path`,`status`,`additions`,`deletions`,`hunks`],properties:{path:{type:`string`},status:{type:`string`},additions:{type:`number`},deletions:{type:`number`},hunks:{type:`array`,items:{type:`object`,required:[`header`,`changes`],properties:{header:{type:`string`},changes:{type:`array`,items:{type:`object`,required:[`type`,`content`],properties:{type:{type:`string`},content:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`files`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>Mt(e).flatMap(Pt),hydration:[],supportedTransports:kt},Ft=[`mcp-app`,`browser`,`export`];function F(e){return typeof e==`object`&&!!e}function It(e){return F(e)&&typeof e.type==`string`}function Lt(e){return Array.isArray(e)&&e.every(It)}function Rt(e){if(!F(e))return{sections:[]};let t=Array.isArray(e.sections)?e.sections.flatMap(e=>{if(!F(e)||typeof e.heading!=`string`)return[];let t=typeof e.content==`string`||Lt(e.content)?e.content:``;return[{heading:e.heading,content:t}]}):[];return{title:typeof e.title==`string`?e.title:void 0,sections:t}}function zt(e){let t=[{type:`heading`,value:e.heading}];return typeof e.content==`string`?(t.push({type:`paragraph`,value:e.content}),t):(t.push(...e.content),t)}const I={id:`document@1`,label:`Document`,description:`Structured document with optional title and section content blocks.`,inputSchema:{type:`object`,properties:{title:{type:`string`},sections:{type:`array`,items:{type:`object`,additionalProperties:!1,required:[`heading`,`content`],properties:{heading:{type:`string`},content:{oneOf:[{type:`string`},{type:`array`,items:{type:`object`}}]}}}}},required:[`sections`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=Rt(e),n=[];t.title&&n.push({type:`heading`,value:t.title});for(let e of t.sections)n.push(...zt(e));return n},hydration:[],supportedTransports:Ft},Bt=[`mcp-app`,`browser`,`export`];function Vt(e){return typeof e==`object`&&!!e}function Ht(e){return Vt(e)?{code:typeof e.code==`string`?e.code:`ERROR`,message:typeof e.message==`string`?e.message:`Unknown error`,details:typeof e.details==`string`?e.details:void 0,stack:typeof e.stack==`string`?e.stack:void 0}:{code:`ERROR`,message:`Unknown error`}}const L={id:`error@1`,label:`Error`,description:`Static error view with message and optional stack trace.`,inputSchema:{type:`object`,properties:{code:{type:`string`},message:{type:`string`},details:{type:`string`},stack:{type:`string`}},required:[`code`,`message`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=Ht(e),n=[{type:`heading`,value:`Error`},{type:`code`,title:t.code,language:`text`,value:t.details?`${t.message}\n\n${t.details}`:t.message}];return t.stack&&n.push({type:`code`,title:`Stack Trace`,language:`text`,value:t.stack}),n},hydration:[],supportedTransports:Bt};function R(e){return typeof e==`object`&&!!e}function Ut(e){return Array.isArray(e)?e.flatMap(e=>!R(e)||typeof e.name!=`string`||typeof e.label!=`string`?[]:[{name:e.name,label:e.label,type:typeof e.type==`string`?e.type:void 0,required:typeof e.required==`boolean`?e.required:void 0,placeholder:typeof e.placeholder==`string`?e.placeholder:void 0,default:typeof e.default==`string`?e.default:void 0,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`):void 0,value:typeof e.value==`string`?e.value:void 0}]):[]}const z={id:`form@1`,label:`Form`,description:`Browser-only form template rendered as a heading and table of field metadata.`,inputSchema:{type:`object`,properties:{title:{type:`string`},fields:{type:`array`,items:{type:`object`,required:[`name`,`label`],properties:{name:{type:`string`},label:{type:`string`},type:{type:`string`},required:{type:`boolean`},placeholder:{type:`string`},default:{type:`string`},options:{type:`array`,items:{type:`string`}},value:{type:`string`}},additionalProperties:!1}}},required:[`fields`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t={title:R(e)&&typeof e.title==`string`?e.title:`Form`,fields:R(e)?Ut(e.fields):[]};return[{type:`heading`,value:t.title},{type:`table`,value:{headers:[`Label`,`Name`,`Type`,`Required`,`Default/Placeholder`],rows:t.fields.map(e=>[e.label||e.name,e.name,e.type||`text`,e.required?`Yes`:`No`,e.placeholder||e.default||``])}}]},hydration:[`form`],supportedTransports:[`browser`]},Wt=[`mcp-app`,`browser`];function B(e){return typeof e==`object`&&!!e}function Gt(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>!B(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}]);return t.length>0?t:void 0}function Kt(e){return Array.isArray(e)?e.flatMap(e=>!B(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label,category:typeof e.category==`string`?e.category:void 0,tags:Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):void 0}]):[]}function qt(e){return B(e)?{categories:Gt(e.categories),items:Kt(e.items)}:{items:[]}}function V(e){return{title:e.label,body:e.id,description:e.tags&&e.tags.length>0?e.tags.join(`, `):void 0}}function H(e,t){return t.length===0?[]:[{type:`heading`,value:e},{type:`cards`,value:t.map(V)}]}const U={id:`picker@1`,label:`Picker`,description:`Grouped item picker rendered as cards with picker hydration metadata.`,inputSchema:{type:`object`,properties:{categories:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`}},additionalProperties:!1}},items:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`},category:{type:`string`},tags:{type:`array`,items:{type:`string`}}},additionalProperties:!1}}},required:[`items`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=qt(e),n=[];if(t.categories&&t.categories.length>0){let e=new Set(t.categories.map(e=>e.id)),r=[];for(let e of t.categories){let n=H(e.label,t.items.filter(t=>t.category===e.id));n.length>0&&r.push(n)}let i=H(`Other`,t.items.filter(t=>!t.category||!e.has(t.category)));return i.length>0&&r.push(i),n.push(...r.flatMap((e,t)=>t>0?[{type:`separator`},...e]:e)),n}return t.items.length>0&&n.push({type:`cards`,value:t.items.map(V)}),n},hydration:[`picker`],supportedTransports:Wt},Jt=[`mcp-app`,`browser`,`export`];function W(e){return typeof e==`object`&&!!e}function Yt(e){return W(e)&&typeof e.type==`string`}function Xt(e){return Array.isArray(e)&&e.every(Yt)}function Zt(e){return W(e)&&typeof e.label==`string`&&(typeof e.value==`string`||typeof e.value==`number`)}function Qt(e){return Array.isArray(e)?e.flatMap(e=>{if(!W(e)||typeof e.heading!=`string`)return[];let t=typeof e.content==`string`||Xt(e.content)?e.content:``;return[{heading:e.heading,content:t}]}):[]}function $t(e){return Array.isArray(e)?e.flatMap(e=>W(e)?[{title:typeof e.title==`string`?e.title:void 0,value:e.value,headers:Array.isArray(e.headers)?e.headers.filter(e=>typeof e==`string`):void 0,rows:Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):void 0}]:[]):[]}function en(e){let t=[{type:`heading`,value:e.heading}];return typeof e.content==`string`?(t.push({type:`paragraph`,value:e.content}),t):(t.push(...e.content),t)}function tn(e){let t={type:`table`};return e.title&&(t.title=e.title),e.value!==void 0&&(t.value=e.value),e.headers&&(t.headers=e.headers),e.rows&&(t.rows=e.rows),t}const nn={id:`report@1`,label:`Report`,description:`Static report with title, optional metrics, narrative sections, and tables.`,inputSchema:{type:`object`,properties:{title:{type:`string`},metrics:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{label:{type:`string`},value:{type:[`string`,`number`]},trend:{type:[`string`,`number`]},status:{type:`string`}},additionalProperties:!1}},sections:{type:`array`,items:{type:`object`,required:[`heading`,`content`],properties:{heading:{type:`string`},content:{oneOf:[{type:`string`},{type:`array`,items:{type:`object`}}]}},additionalProperties:!1}},tables:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},value:{},headers:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{}}}},additionalProperties:!1}}},required:[`title`,`sections`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t={title:W(e)&&typeof e.title==`string`?e.title:`Report`,metrics:W(e)&&Array.isArray(e.metrics)?e.metrics.filter(Zt):void 0,sections:W(e)?Qt(e.sections):[],tables:W(e)?$t(e.tables):void 0},n=[{type:`heading`,value:t.title}];t.metrics&&t.metrics.length>0&&n.push({type:`metrics`,value:t.metrics});for(let e of t.sections)n.push(...en(e));for(let e of t.tables??[])n.push(tn(e));return n},hydration:[],supportedTransports:Jt},rn=[`mcp-app`,`browser`,`export`];function G(e){return typeof e==`object`&&!!e}function an(e){return Array.isArray(e)?e.flatMap(e=>{if(!G(e)||typeof e.category!=`string`||!Array.isArray(e.items))return[];let t=e.items.flatMap(e=>!G(e)||typeof e.label!=`string`||typeof e.status!=`string`?[]:[{label:e.label,status:e.status,badge:typeof e.badge==`string`?e.badge:void 0}]);return[{category:e.category,items:t}]}):[]}function on(e){return e.map(e=>({title:e.label,status:e.status,badge:e.badge}))}const K={id:`status-board@1`,label:`Status Board`,description:`Static status board grouped into category headings and card collections.`,inputSchema:{type:`object`,properties:{categories:{type:`array`,items:{type:`object`,required:[`category`,`items`],properties:{category:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`label`,`status`],properties:{label:{type:`string`},status:{type:`string`},badge:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`categories`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=G(e)?an(e.categories):[],n=[];for(let e of t)n.push({type:`heading`,value:e.category}),n.push({type:`cards`,value:on(e.items)});return n},hydration:[],supportedTransports:rn},sn=[`mcp-app`,`browser`,`export`];function q(e){return typeof e==`object`&&!!e}function cn(e){return Array.isArray(e)?e.flatMap(e=>!q(e)||typeof e.title!=`string`?[]:[{title:e.title,description:typeof e.description==`string`?e.description:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:void 0,status:typeof e.status==`string`?e.status:void 0}]):[]}function ln(e){return Array.isArray(e)?{entries:cn(e)}:q(e)?{entries:cn(e.entries??e.events??e.items),title:typeof e.title==`string`?e.title:void 0}:{entries:[]}}const J={type:`array`,items:{type:`object`,required:[`title`],properties:{title:{type:`string`},description:{type:`string`},timestamp:{type:`string`},status:{type:`string`}},additionalProperties:!1}},un={id:`timeline@1`,label:`Timeline`,description:`Static timeline events rendered as a timeline block.`,inputSchema:{oneOf:[J,{type:`object`,properties:{title:{type:`string`},entries:J,events:J,items:J},anyOf:[{required:[`entries`]},{required:[`events`]},{required:[`items`]}],additionalProperties:!1}]},defaultLayout:{},blocksFromData:e=>{let{entries:t,title:n}=ln(e),r=[];return n&&r.push({type:`heading`,value:n}),r.push({type:`timeline`,value:t}),r},hydration:[],supportedTransports:sn},dn=[`mcp-app`,`browser`,`export`];function Y(e){return typeof e==`object`&&!!e}function X(e){return Y(e)&&typeof e.label==`string`}function fn(e){return{name:e.label,children:Array.isArray(e.children)?e.children.filter(X).map(fn):[]}}function pn(e){if(!Y(e))return{};let t=e.root;return X(t)?fn(t):Y(t)?t:e}const mn={id:`tree@1`,label:`Tree`,description:`Static tree view data with optional tree hydration metadata.`,inputSchema:{oneOf:[{type:`object`,properties:{root:{type:`object`}},required:[`root`],additionalProperties:!0},{type:`object`,additionalProperties:!0}]},defaultLayout:{},blocksFromData:e=>[{type:`tree`,value:pn(e)}],hydration:[`tree`],supportedTransports:dn},Z=new xt;Z.register(A),Z.register(P),Z.register(I),Z.register(U),Z.register(nn),Z.register(un),Z.register(mn),Z.register(M),Z.register(L),Z.register(z),Z.register(K);let Q=0;function hn(){return Q=(Q+1)%(2**53-1),`${Date.now().toString(16).padStart(12,`0`).slice(-12)}${Q.toString(16).padStart(4,`0`).slice(-4)}${Array.from({length:8},()=>Math.floor(Math.random()*256).toString(16).padStart(2,`0`)).join(``)}`}function gn(e){return{id:e,version:1,entry:`@aikit/blocks-interactive/dist/islands/${e}.js`,selector:`[data-island="${e}"]`,needsData:!0}}function _n(e,t){let n=new TextEncoder;return n.encode(e).byteLength+t.reduce((e,t)=>e+n.encode(t).byteLength,0)}function vn(e,t){let n=[],r=t.registry??Z,i={colorScheme:e.colorScheme??t.colorScheme??`auto`,transport:t.transport,lang:e.lang,dir:e.dir},a=[...e.blocks??[]],o=[...a],s=[],c=[...e.actions??[]];if(e.template){let t=r.get(e.template);if(t)try{o=t.blocksFromData(e.data,i),t.actionsFromData&&(c=[...c,...t.actionsFromData(e.data)]),s=t.hydration.map(e=>gn(e))}catch(t){let r=t instanceof Error?t.message:String(t);n.push({level:`error`,message:`Template ${e.template} failed: ${r}`}),o=a.length===0?L.blocksFromData({code:`TEMPLATE_RENDER_ERROR`,message:`Failed to render template ${e.template}`,details:r},i):[...a]}else n.push({level:`warn`,message:`Template not found: ${e.template}`})}let l=yt(o,i),u=[S(o.map(e=>e.type))],d=t.nonce??hn(),f=e.metadata?.surfaceId??`surface-${d}`,p=s.length>0?JSON.stringify({data:e.data,blocks:o}):void 0,m=t.blockVendorScripts?[...new Set(o.flatMap(e=>t.blockVendorScripts?.[e.type]??[]))]:void 0;return{surfaceId:f,nonce:d,html:l,css:u,vendorScripts:m&&m.length>0?m:void 0,islands:s,actions:c,payload:p,estimatedBytes:_n(l,u),exportPolicy:s.length>0?`local-interactive`:`static-only`,diagnostics:n.length>0?n:void 0}}function yn(e){return e===`up`||e===`down`||e===`neutral`}function $(e){return typeof e==`object`&&!!e}function bn(e){return!$(e)||!Array.isArray(e.metrics)?{metrics:[]}:{metrics:e.metrics.flatMap(e=>{if(!$(e)||typeof e.label!=`string`||typeof e.value!=`string`&&typeof e.value!=`number`)return[];let t=$(e.trend)&&typeof e.trend.value==`string`&&yn(e.trend.direction)?{value:e.trend.value,direction:e.trend.direction}:void 0,n=Array.isArray(e.items)?e.items.flatMap(e=>!$(e)||typeof e.label!=`string`||typeof e.value!=`string`?[]:[{label:e.label,value:e.value}]):void 0;return[{id:typeof e.id==`string`?e.id:void 0,label:e.label,value:e.value,trend:t,status:e.status===`success`||e.status===`warning`||e.status===`error`||e.status===`info`?e.status:void 0,type:e.type===`progress`||e.type===`list`||e.type===`stat`?e.type:void 0,progress:typeof e.progress==`number`?On(e.progress):void 0,items:n}]})}}function xn(e){let t=e.type===`progress`&&typeof e.progress==`number`?`${e.progress}%`:void 0;return{label:e.label,value:e.value,trend:e.trend?.value??t,status:e.status}}function Sn(e){return e.type!==`progress`||typeof e.progress!=`number`?null:{label:e.label,value:On(e.progress),max:100}}function Cn(e){return $(e)?{columns:Array.isArray(e.columns)?e.columns.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}]):[],cards:Array.isArray(e.cards)?e.cards.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.title!=`string`||typeof e.column!=`string`?[]:[{id:e.id,title:e.title,description:typeof e.description==`string`?e.description:void 0,column:e.column,tags:Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):void 0,priority:e.priority===`high`||e.priority===`medium`||e.priority===`low`?e.priority:void 0}]):[]}:{columns:[],cards:[]}}function wn(e){return{title:e.title,description:e.description,badge:e.priority,body:e.tags?.join(`, `),status:e.priority}}function Tn(e){return!$(e)||!Array.isArray(e.items)?[]:e.items.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}])}function En(e){return $(e)?{name:typeof e.name==`string`?e.name:``,total:typeof e.total==`number`?e.total:typeof e.value==`number`?e.value:0,self:typeof e.self==`number`?e.self:void 0,children:Array.isArray(e.children)?e.children.map(e=>En(e)):[]}:{name:``,total:0,children:[]}}function Dn(e){return{name:e.self==null?`${e.name} (${e.total})`:`${e.name} (${e.total} total / ${e.self} self)`,children:(e.children??[]).map(Dn)}}function On(e){return Math.max(0,Math.min(100,e))}function kn(e){let t=bn(e),n=[];t.metrics.length>0&&n.push({type:`metrics`,value:t.metrics.map(xn)});let r=t.metrics.map(Sn).filter(e=>e!==null);r.length>0&&n.push({type:`progress`,value:r});for(let e of t.metrics)e.type===`list`&&e.items&&e.items.length>0&&(n.push({type:`heading`,value:e.label}),n.push({type:`table`,value:e.items}));return n}function An(e){let t=Cn(e),n=[];for(let e of t.columns){let r=t.cards.filter(t=>t.column===e.id);n.push({type:`heading`,value:e.label}),n.push({type:`cards`,value:r.map(wn)})}return n}function jn(e){let t=Tn(e);return t.length===0?[]:[{type:`cards`,value:t.map((e,t)=>({title:e.label,body:e.id,badge:`#${t+1}`}))}]}function Mn(e){return!$(e)||!$(e.profile)?[]:[{type:`tree`,value:Dn(En(e.profile))}]}const Nn={id:`dashboard@1`,label:`Dashboard`,description:`Metric cards grid with optional charts.`,inputSchema:{type:`object`,properties:{metrics:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{id:{type:`string`},label:{type:`string`},value:{type:[`string`,`number`]},trend:{type:`object`,properties:{value:{type:`string`},direction:{enum:[`up`,`down`,`neutral`]}},required:[`value`,`direction`],additionalProperties:!1},status:{enum:[`success`,`warning`,`error`,`info`]},type:{enum:[`stat`,`progress`,`list`]},progress:{type:`number`},items:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{label:{type:`string`},value:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`metrics`],additionalProperties:!1},defaultLayout:{maxWidth:`1200px`},blocksFromData:e=>kn(e),hydration:[],supportedTransports:[`mcp-app`,`browser`]},Pn={id:`kanban@1`,label:`Kanban`,description:`Drag-and-drop task board grouped by columns.`,inputSchema:{type:`object`,properties:{columns:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`},color:{type:`string`}},additionalProperties:!1}},cards:{type:`array`,items:{type:`object`,required:[`id`,`title`,`column`],properties:{id:{type:`string`},title:{type:`string`},description:{type:`string`},column:{type:`string`},tags:{type:`array`,items:{type:`string`}},priority:{enum:[`high`,`medium`,`low`]}},additionalProperties:!1}}},required:[`columns`,`cards`],additionalProperties:!1},defaultLayout:{maxWidth:`1400px`},blocksFromData:e=>An(e),hydration:[],supportedTransports:[`browser`]},Fn={id:`list-sort@1`,label:`Sortable List`,description:`Reorderable list of items with browser drag-and-drop interactions.`,inputSchema:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`}},additionalProperties:!1}}},required:[`items`],additionalProperties:!1},defaultLayout:{maxWidth:`720px`},blocksFromData:e=>jn(e),hydration:[],supportedTransports:[`browser`]},In={id:`flame-graph@1`,label:`Flame Graph`,description:`Hierarchical performance profile with interactive zoom state.`,inputSchema:{type:`object`,properties:{profile:{type:`object`}},required:[`profile`],additionalProperties:!1},defaultLayout:{maxWidth:`1200px`},blocksFromData:e=>Mn(e),hydration:[],supportedTransports:[`browser`]};function Ln(e){return e.replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/&/g,`\\u0026`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}function Rn(e,t){let n=[`
1582
+ `);return[{type:`heading`,value:e.path},{type:`paragraph`,value:`${e.status} | +${e.additions} / -${e.deletions}`},{type:`code`,language:`diff`,value:t}]}const P={id:`diff-view@1`,label:`Diff View`,description:`Static diff summary rendered as per-file diff code blocks.`,inputSchema:{type:`object`,properties:{files:{type:`array`,items:{type:`object`,required:[`path`,`status`,`additions`,`deletions`,`hunks`],properties:{path:{type:`string`},status:{type:`string`},additions:{type:`number`},deletions:{type:`number`},hunks:{type:`array`,items:{type:`object`,required:[`header`,`changes`],properties:{header:{type:`string`},changes:{type:`array`,items:{type:`object`,required:[`type`,`content`],properties:{type:{type:`string`},content:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`files`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>Mt(e).flatMap(Pt),hydration:[],supportedTransports:kt},Ft=[`mcp-app`,`browser`,`export`];function F(e){return typeof e==`object`&&!!e}function It(e){return F(e)&&typeof e.type==`string`}function Lt(e){return Array.isArray(e)&&e.every(It)}function Rt(e){if(!F(e))return{sections:[]};let t=Array.isArray(e.sections)?e.sections.flatMap(e=>{if(!F(e)||typeof e.heading!=`string`)return[];let t=typeof e.content==`string`||Lt(e.content)?e.content:``;return[{heading:e.heading,content:t}]}):[];return{title:typeof e.title==`string`?e.title:void 0,sections:t}}function zt(e){let t=[{type:`heading`,value:e.heading}];return typeof e.content==`string`?(t.push({type:`paragraph`,value:e.content}),t):(t.push(...e.content),t)}const I={id:`document@1`,label:`Document`,description:`Structured document with optional title and section content blocks.`,inputSchema:{type:`object`,properties:{title:{type:`string`},sections:{type:`array`,items:{type:`object`,additionalProperties:!1,required:[`heading`,`content`],properties:{heading:{type:`string`},content:{oneOf:[{type:`string`},{type:`array`,items:{type:`object`}}]}}}}},required:[`sections`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=Rt(e),n=[];t.title&&n.push({type:`heading`,value:t.title});for(let e of t.sections)n.push(...zt(e));return n},hydration:[],supportedTransports:Ft},Bt=[`mcp-app`,`browser`,`export`];function Vt(e){return typeof e==`object`&&!!e}function Ht(e){return Vt(e)?{code:typeof e.code==`string`?e.code:`ERROR`,message:typeof e.message==`string`?e.message:`Unknown error`,details:typeof e.details==`string`?e.details:void 0,stack:typeof e.stack==`string`?e.stack:void 0}:{code:`ERROR`,message:`Unknown error`}}const L={id:`error@1`,label:`Error`,description:`Static error view with message and optional stack trace.`,inputSchema:{type:`object`,properties:{code:{type:`string`},message:{type:`string`},details:{type:`string`},stack:{type:`string`}},required:[`code`,`message`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=Ht(e),n=[{type:`heading`,value:`Error`},{type:`code`,title:t.code,language:`text`,value:t.details?`${t.message}\n\n${t.details}`:t.message}];return t.stack&&n.push({type:`code`,title:`Stack Trace`,language:`text`,value:t.stack}),n},hydration:[],supportedTransports:Bt};function R(e){return typeof e==`object`&&!!e}function Ut(e){return Array.isArray(e)?e.flatMap(e=>!R(e)||typeof e.name!=`string`||typeof e.label!=`string`?[]:[{name:e.name,label:e.label,type:typeof e.type==`string`?e.type:void 0,required:typeof e.required==`boolean`?e.required:void 0,placeholder:typeof e.placeholder==`string`?e.placeholder:void 0,default:typeof e.default==`string`?e.default:void 0,options:Array.isArray(e.options)?e.options.filter(e=>typeof e==`string`):void 0,value:typeof e.value==`string`?e.value:void 0}]):[]}const z={id:`form@1`,label:`Form`,description:`Browser-only form template rendered as a heading and table of field metadata.`,inputSchema:{type:`object`,properties:{title:{type:`string`},fields:{type:`array`,items:{type:`object`,required:[`name`,`label`],properties:{name:{type:`string`},label:{type:`string`},type:{type:`string`},required:{type:`boolean`},placeholder:{type:`string`},default:{type:`string`},options:{type:`array`,items:{type:`string`}},value:{type:`string`}},additionalProperties:!1}}},required:[`fields`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t={title:R(e)&&typeof e.title==`string`?e.title:`Form`,fields:R(e)?Ut(e.fields):[]};return[{type:`heading`,value:t.title},{type:`table`,value:{headers:[`Label`,`Name`,`Type`,`Required`,`Default/Placeholder`],rows:t.fields.map(e=>[e.label||e.name,e.name,e.type||`text`,e.required?`Yes`:`No`,e.placeholder||e.default||``])}}]},hydration:[`form`],supportedTransports:[`browser`]},Wt=[`mcp-app`,`browser`];function B(e){return typeof e==`object`&&!!e}function Gt(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>!B(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}]);return t.length>0?t:void 0}function Kt(e){return Array.isArray(e)?e.flatMap(e=>!B(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label,category:typeof e.category==`string`?e.category:void 0,tags:Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):void 0}]):[]}function qt(e){return B(e)?{categories:Gt(e.categories),items:Kt(e.items)}:{items:[]}}function V(e){return{title:e.label,body:e.id,description:e.tags&&e.tags.length>0?e.tags.join(`, `):void 0}}function H(e,t){return t.length===0?[]:[{type:`heading`,value:e},{type:`cards`,value:t.map(V)}]}const U={id:`picker@1`,label:`Picker`,description:`Grouped item picker rendered as cards with picker hydration metadata.`,inputSchema:{type:`object`,properties:{categories:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`}},additionalProperties:!1}},items:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`},category:{type:`string`},tags:{type:`array`,items:{type:`string`}}},additionalProperties:!1}}},required:[`items`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=qt(e),n=[];if(t.categories&&t.categories.length>0){let e=new Set(t.categories.map(e=>e.id)),r=[];for(let e of t.categories){let n=H(e.label,t.items.filter(t=>t.category===e.id));n.length>0&&r.push(n)}let i=H(`Other`,t.items.filter(t=>!t.category||!e.has(t.category)));return i.length>0&&r.push(i),n.push(...r.flatMap((e,t)=>t>0?[{type:`separator`},...e]:e)),n}return t.items.length>0&&n.push({type:`cards`,value:t.items.map(V)}),n},hydration:[`picker`],supportedTransports:Wt},Jt=[`mcp-app`,`browser`,`export`];function W(e){return typeof e==`object`&&!!e}function Yt(e){return W(e)&&typeof e.type==`string`}function Xt(e){return Array.isArray(e)&&e.every(Yt)}function Zt(e){return W(e)&&typeof e.label==`string`&&(typeof e.value==`string`||typeof e.value==`number`)}function Qt(e){return Array.isArray(e)?e.flatMap(e=>{if(!W(e)||typeof e.heading!=`string`)return[];let t=typeof e.content==`string`||Xt(e.content)?e.content:``;return[{heading:e.heading,content:t}]}):[]}function $t(e){return Array.isArray(e)?e.flatMap(e=>W(e)?[{title:typeof e.title==`string`?e.title:void 0,value:e.value,headers:Array.isArray(e.headers)?e.headers.filter(e=>typeof e==`string`):void 0,rows:Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):void 0}]:[]):[]}function en(e){let t=[{type:`heading`,value:e.heading}];return typeof e.content==`string`?(t.push({type:`paragraph`,value:e.content}),t):(t.push(...e.content),t)}function tn(e){let t={type:`table`};return e.title&&(t.title=e.title),e.value!==void 0&&(t.value=e.value),e.headers&&(t.headers=e.headers),e.rows&&(t.rows=e.rows),t}const nn={id:`report@1`,label:`Report`,description:`Static report with title, optional metrics, narrative sections, and tables.`,inputSchema:{type:`object`,properties:{title:{type:`string`},metrics:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{label:{type:`string`},value:{type:[`string`,`number`]},trend:{type:[`string`,`number`]},status:{type:`string`}},additionalProperties:!1}},sections:{type:`array`,items:{type:`object`,required:[`heading`,`content`],properties:{heading:{type:`string`},content:{oneOf:[{type:`string`},{type:`array`,items:{type:`object`}}]}},additionalProperties:!1}},tables:{type:`array`,items:{type:`object`,properties:{title:{type:`string`},value:{},headers:{type:`array`,items:{type:`string`}},rows:{type:`array`,items:{type:`array`,items:{}}}},additionalProperties:!1}}},required:[`title`,`sections`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t={title:W(e)&&typeof e.title==`string`?e.title:`Report`,metrics:W(e)&&Array.isArray(e.metrics)?e.metrics.filter(Zt):void 0,sections:W(e)?Qt(e.sections):[],tables:W(e)?$t(e.tables):void 0},n=[{type:`heading`,value:t.title}];t.metrics&&t.metrics.length>0&&n.push({type:`metrics`,value:t.metrics});for(let e of t.sections)n.push(...en(e));for(let e of t.tables??[])n.push(tn(e));return n},hydration:[],supportedTransports:Jt},rn=[`mcp-app`,`browser`,`export`];function G(e){return typeof e==`object`&&!!e}function an(e){return Array.isArray(e)?e.flatMap(e=>{if(!G(e)||typeof e.category!=`string`||!Array.isArray(e.items))return[];let t=e.items.flatMap(e=>!G(e)||typeof e.label!=`string`||typeof e.status!=`string`?[]:[{label:e.label,status:e.status,badge:typeof e.badge==`string`?e.badge:void 0}]);return[{category:e.category,items:t}]}):[]}function on(e){return e.map(e=>({title:e.label,status:e.status,badge:e.badge}))}const K={id:`status-board@1`,label:`Status Board`,description:`Static status board grouped into category headings and card collections.`,inputSchema:{type:`object`,properties:{categories:{type:`array`,items:{type:`object`,required:[`category`,`items`],properties:{category:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`label`,`status`],properties:{label:{type:`string`},status:{type:`string`},badge:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`categories`],additionalProperties:!1},defaultLayout:{},blocksFromData:e=>{let t=G(e)?an(e.categories):[],n=[];for(let e of t)n.push({type:`heading`,value:e.category}),n.push({type:`cards`,value:on(e.items)});return n},hydration:[],supportedTransports:rn},sn=[`mcp-app`,`browser`,`export`];function q(e){return typeof e==`object`&&!!e}function cn(e){return Array.isArray(e)?e.flatMap(e=>!q(e)||typeof e.title!=`string`?[]:[{title:e.title,description:typeof e.description==`string`?e.description:void 0,timestamp:typeof e.timestamp==`string`?e.timestamp:void 0,status:typeof e.status==`string`?e.status:void 0}]):[]}function ln(e){return Array.isArray(e)?{entries:cn(e)}:q(e)?{entries:cn(e.entries??e.events??e.items),title:typeof e.title==`string`?e.title:void 0}:{entries:[]}}const J={type:`array`,items:{type:`object`,required:[`title`],properties:{title:{type:`string`},description:{type:`string`},timestamp:{type:`string`},status:{type:`string`}},additionalProperties:!1}},un={id:`timeline@1`,label:`Timeline`,description:`Static timeline events rendered as a timeline block.`,inputSchema:{oneOf:[J,{type:`object`,properties:{title:{type:`string`},entries:J,events:J,items:J},anyOf:[{required:[`entries`]},{required:[`events`]},{required:[`items`]}],additionalProperties:!1}]},defaultLayout:{},blocksFromData:e=>{let{entries:t,title:n}=ln(e),r=[];return n&&r.push({type:`heading`,value:n}),r.push({type:`timeline`,value:t}),r},hydration:[],supportedTransports:sn},dn=[`mcp-app`,`browser`,`export`];function Y(e){return typeof e==`object`&&!!e}function X(e){return Y(e)&&typeof e.label==`string`}function fn(e){return{name:e.label,children:Array.isArray(e.children)?e.children.filter(X).map(fn):[]}}function pn(e){if(!Y(e))return{};let t=e.root;return X(t)?fn(t):Y(t)?t:e}const mn={id:`tree@1`,label:`Tree`,description:`Static tree view data with optional tree hydration metadata.`,inputSchema:{oneOf:[{type:`object`,properties:{root:{type:`object`}},required:[`root`],additionalProperties:!0},{type:`object`,additionalProperties:!0}]},defaultLayout:{},blocksFromData:e=>[{type:`tree`,value:pn(e)}],hydration:[`tree`],supportedTransports:dn},Z=new xt;Z.register(A),Z.register(P),Z.register(I),Z.register(U),Z.register(nn),Z.register(un),Z.register(mn),Z.register(M),Z.register(L),Z.register(z),Z.register(K);let Q=0;function hn(){return Q=(Q+1)%(2**53-1),`${Date.now().toString(16).padStart(12,`0`).slice(-12)}${Q.toString(16).padStart(4,`0`).slice(-4)}${Array.from({length:8},()=>Math.floor(Math.random()*256).toString(16).padStart(2,`0`)).join(``)}`}function gn(e){return{id:e,version:1,entry:`@aikit/blocks-interactive/dist/islands/${e}.js`,selector:`[data-island="${e}"]`,needsData:!0}}function _n(e,t){let n=new TextEncoder;return n.encode(e).byteLength+t.reduce((e,t)=>e+n.encode(t).byteLength,0)}function vn(e,t){let n=[],r=t.registry??Z,i={colorScheme:e.colorScheme??t.colorScheme??`auto`,transport:t.transport,lang:e.lang,dir:e.dir},a=[...e.blocks??[]],o=[...a],s=[],c=[...e.actions??[]];if(e.template){let t=r.get(e.template);if(t)try{o=t.blocksFromData(e.data,i),t.actionsFromData&&(c=[...c,...t.actionsFromData(e.data)]),s=t.hydration.map(e=>gn(e))}catch(t){let r=t instanceof Error?t.message:String(t);n.push({level:`error`,message:`Template ${e.template} failed: ${r}`}),o=a.length===0?L.blocksFromData({code:`TEMPLATE_RENDER_ERROR`,message:`Failed to render template ${e.template}`,details:r},i):[...a]}else n.push({level:`warn`,message:`Template not found: ${e.template}`})}let l=yt(o,i),u=[S(o.map(e=>e.type))],d=t.nonce??hn(),f=e.metadata?.surfaceId??`surface-${d}`,p=s.length>0?JSON.stringify({data:e.data,blocks:o}):void 0,m=t.blockVendorScripts?[...new Set(o.flatMap(e=>t.blockVendorScripts?.[e.type]??[]))]:void 0;return{surfaceId:f,nonce:d,html:l,css:u,vendorScripts:m&&m.length>0?m:void 0,islands:s,actions:c,payload:p,estimatedBytes:_n(l,u),exportPolicy:s.length>0?`local-interactive`:`static-only`,diagnostics:n.length>0?n:void 0}}function yn(e){return e===`up`||e===`down`||e===`neutral`}function $(e){return typeof e==`object`&&!!e}function bn(e){return!$(e)||!Array.isArray(e.metrics)?{metrics:[]}:{metrics:e.metrics.flatMap(e=>{if(!$(e)||typeof e.label!=`string`||typeof e.value!=`string`&&typeof e.value!=`number`)return[];let t=$(e.trend)&&typeof e.trend.value==`string`&&yn(e.trend.direction)?{value:e.trend.value,direction:e.trend.direction}:void 0,n=Array.isArray(e.items)?e.items.flatMap(e=>!$(e)||typeof e.label!=`string`||typeof e.value!=`string`?[]:[{label:e.label,value:e.value}]):void 0;return[{id:typeof e.id==`string`?e.id:void 0,label:e.label,value:e.value,trend:t,status:e.status===`success`||e.status===`warning`||e.status===`error`||e.status===`info`?e.status:void 0,type:e.type===`progress`||e.type===`list`||e.type===`stat`?e.type:void 0,progress:typeof e.progress==`number`?On(e.progress):void 0,items:n}]})}}function xn(e){let t=e.type===`progress`&&typeof e.progress==`number`?`${e.progress}%`:void 0;return{label:e.label,value:e.value,trend:e.trend?.value??t,status:e.status}}function Sn(e){return e.type!==`progress`||typeof e.progress!=`number`?null:{label:e.label,value:On(e.progress),max:100}}function Cn(e){return $(e)?{columns:Array.isArray(e.columns)?e.columns.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}]):[],cards:Array.isArray(e.cards)?e.cards.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.title!=`string`||typeof e.column!=`string`?[]:[{id:e.id,title:e.title,description:typeof e.description==`string`?e.description:void 0,column:e.column,tags:Array.isArray(e.tags)?e.tags.filter(e=>typeof e==`string`):void 0,priority:e.priority===`high`||e.priority===`medium`||e.priority===`low`?e.priority:void 0}]):[]}:{columns:[],cards:[]}}function wn(e){return{title:e.title,description:e.description,badge:e.priority,body:e.tags?.join(`, `),status:e.priority}}function Tn(e){return!$(e)||!Array.isArray(e.items)?[]:e.items.flatMap(e=>!$(e)||typeof e.id!=`string`||typeof e.label!=`string`?[]:[{id:e.id,label:e.label}])}function En(e){return $(e)?{name:typeof e.name==`string`?e.name:``,total:typeof e.total==`number`?e.total:typeof e.value==`number`?e.value:0,self:typeof e.self==`number`?e.self:void 0,children:Array.isArray(e.children)?e.children.map(e=>En(e)):[]}:{name:``,total:0,children:[]}}function Dn(e){return{name:e.self==null?`${e.name} (${e.total})`:`${e.name} (${e.total} total / ${e.self} self)`,children:(e.children??[]).map(Dn)}}function On(e){return Math.max(0,Math.min(100,e))}function kn(e){let t=bn(e),n=[];t.metrics.length>0&&n.push({type:`metrics`,value:t.metrics.map(xn)});let r=t.metrics.map(Sn).filter(e=>e!==null);r.length>0&&n.push({type:`progress`,value:r});for(let e of t.metrics)e.type===`list`&&e.items&&e.items.length>0&&(n.push({type:`heading`,value:e.label}),n.push({type:`table`,value:e.items}));return n}function An(e){let t=Cn(e),n=[];return t.columns.forEach((e,r)=>{r>0&&n.push({type:`separator`,value:``});let i=t.cards.filter(t=>t.column===e.id);n.push({type:`heading`,value:e.label}),n.push({type:`cards`,value:i.map(wn)})}),n}function jn(e){let t=Tn(e);return t.length===0?[]:[{type:`cards`,value:t.map((e,t)=>({title:e.label,body:e.id,badge:`#${t+1}`}))}]}function Mn(e){return!$(e)||!$(e.profile)?[]:[{type:`tree`,value:Dn(En(e.profile))}]}const Nn={id:`dashboard@1`,label:`Dashboard`,description:`Metric cards grid with optional charts.`,inputSchema:{type:`object`,properties:{metrics:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{id:{type:`string`},label:{type:`string`},value:{type:[`string`,`number`]},trend:{type:`object`,properties:{value:{type:`string`},direction:{enum:[`up`,`down`,`neutral`]}},required:[`value`,`direction`],additionalProperties:!1},status:{enum:[`success`,`warning`,`error`,`info`]},type:{enum:[`stat`,`progress`,`list`]},progress:{type:`number`},items:{type:`array`,items:{type:`object`,required:[`label`,`value`],properties:{label:{type:`string`},value:{type:`string`}},additionalProperties:!1}}},additionalProperties:!1}}},required:[`metrics`],additionalProperties:!1},defaultLayout:{maxWidth:`1200px`},blocksFromData:e=>kn(e),hydration:[],supportedTransports:[`mcp-app`,`browser`]},Pn={id:`kanban@1`,label:`Kanban`,description:`Drag-and-drop task board grouped by columns.`,inputSchema:{type:`object`,properties:{columns:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`},color:{type:`string`}},additionalProperties:!1}},cards:{type:`array`,items:{type:`object`,required:[`id`,`title`,`column`],properties:{id:{type:`string`},title:{type:`string`},description:{type:`string`},column:{type:`string`},tags:{type:`array`,items:{type:`string`}},priority:{enum:[`high`,`medium`,`low`]}},additionalProperties:!1}}},required:[`columns`,`cards`],additionalProperties:!1},defaultLayout:{maxWidth:`1400px`},blocksFromData:e=>An(e),hydration:[],supportedTransports:[`browser`]},Fn={id:`list-sort@1`,label:`Sortable List`,description:`Reorderable list of items with browser drag-and-drop interactions.`,inputSchema:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,required:[`id`,`label`],properties:{id:{type:`string`},label:{type:`string`}},additionalProperties:!1}}},required:[`items`],additionalProperties:!1},defaultLayout:{maxWidth:`720px`},blocksFromData:e=>jn(e),hydration:[],supportedTransports:[`browser`]},In={id:`flame-graph@1`,label:`Flame Graph`,description:`Hierarchical performance profile with interactive zoom state.`,inputSchema:{type:`object`,properties:{profile:{type:`object`}},required:[`profile`],additionalProperties:!1},defaultLayout:{maxWidth:`1200px`},blocksFromData:e=>Mn(e),hydration:[],supportedTransports:[`browser`]};function Ln(e){return e.replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/&/g,`\\u0026`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}function Rn(e,t){let n=[`
1583
1583
  * {
1584
1584
  box-sizing: border-box;
1585
1585
  }
@@ -1603,6 +1603,9 @@ main {
1603
1603
  width: 100%;
1604
1604
  max-width: 100%;
1605
1605
  padding: var(--dt-space-8) var(--dt-space-4);
1606
+ display: flex;
1607
+ flex-direction: column;
1608
+ gap: var(--dt-space-6);
1606
1609
  }
1607
1610
  `,O,...(Array.isArray(t)?t:typeof t==`string`?[t]:[]).filter(e=>e.trim().length>0)].join(`
1608
1611
  `);return[` <style>${e}</style>`,` <style>${n}</style>`].join(`
@@ -1611,7 +1614,7 @@ main {
1611
1614
  color-scheme: light;
1612
1615
  }`,`html[data-theme="dark"] {\n color-scheme: dark;\n${t}\n}`,`@media (prefers-color-scheme: dark) {\n html:not([data-theme]) {\n color-scheme: dark;\n${t}\n }\n}`].join(`
1613
1616
 
1614
- `)}function Bn(e){return e.length===0?``:e.map(e=>{let t=e.initScript?` <script>\n${e.initScript}\n <\/script>\n`:``;if(e.inlineSource){let n=e.onload?`\n;${e.onload}`:``;return`${t} <script>${e.inlineSource}${n}<\/script>`}if(!e.src)return t.trimEnd();let r=e.onload?` onload="${e.onload}"`:``;if(!e.fallback)return`${t} <script src="${n(e.src)}"${r}><\/script>`;let i=e.onload?`f.onload=function(){${e.onload}};`:``;return`${t} <script src="${n(e.src)}"${r} onerror="(function(el){var f=document.createElement('script');f.src='${n(e.fallback)}';${i}document.head.appendChild(f);el.remove()})(this)"><\/script>`}).join(`
1617
+ `)}function Bn(e){return e.length===0?``:e.map(e=>{let t=e.initScript?` <script>\n${e.initScript}\n <\/script>\n`:``;if(e.inlineSource)return`${t} <script>${e.inlineSource.replace(/<\/script/gi,`<\\/script`)}${e.onload?`\n;${e.onload}`:``}<\/script>`;if(!e.src)return t.trimEnd();let r=e.onload?` onload="${e.onload}"`:``;if(!e.fallback)return`${t} <script src="${n(e.src)}"${r}><\/script>`;let i=e.onload?`f.onload=function(){${e.onload}};`:``;return`${t} <script src="${n(e.src)}"${r} onerror="(function(el){var f=document.createElement('script');f.src='${n(e.fallback)}';${i}document.head.appendChild(f);el.remove()})(this)"><\/script>`}).join(`
1615
1618
  `)}function Vn(e){return[` <script>`,` (() => {`,` const preferredTheme = ${JSON.stringify(e)};`,` const storageKey = "aikit-theme-mode";`,` const html = document.documentElement;`,` const toolbox = {`,` container: () => document.querySelector(".aikit-toolbox"),`,` button: () => document.querySelector(".aikit-toolbox-toggle"),`,` menu: () => document.querySelector(".aikit-toolbox-menu"),`,` firstItem: () => document.querySelector(".aikit-toolbox-item"),`,` };`,` const systemTheme = () =>`,` window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches`,` ? "dark"`,` : "light";`,` const readStoredTheme = () => {`,` try {`,` const stored = localStorage.getItem("aikit-theme-mode");`,` return stored === "light" || stored === "dark" ? stored : null;`,` } catch (_error) {`,` return null;`,` }`,` };`,` const resolvedTheme = () => html.getAttribute("data-theme") || readStoredTheme() || systemTheme();`,` const setToolboxOpen = (open, options = {}) => {`,` const button = toolbox.button();`,` const menu = toolbox.menu();`,` if (!button || !menu) return;`,` menu.hidden = !open;`,` button.setAttribute("aria-expanded", String(open));`,` if (open) {`,` if (options.focusItem) toolbox.firstItem()?.focus();`,` } else if (options.restoreFocus) {`,` button.focus();`,` }`,` };`,` const inlineComputedStyles = (source, clone) => {`,` if (!(source instanceof Element) || !(clone instanceof Element)) return;`,` const computed = window.getComputedStyle(source);`,` const cssText = Array.from(computed)`,` .map((name) => {`,` const value = computed.getPropertyValue(name);`,` const priority = computed.getPropertyPriority(name);`,' return `${name}:${value}${priority ? " !important" : ""};`;',` })`,` .join("");`,` clone.setAttribute("style", cssText);`,` for (let index = 0; index < source.children.length; index += 1) {`,` inlineComputedStyles(source.children[index], clone.children[index]);`,` }`,` };`,` const captureDocumentAsPng = async () => {`,` const width = Math.max(`,` document.documentElement.scrollWidth,`,` document.documentElement.clientWidth,`,` document.body ? document.body.scrollWidth : 0,`,` );`,` const height = Math.max(`,` document.documentElement.scrollHeight,`,` document.documentElement.clientHeight,`,` document.body ? document.body.scrollHeight : 0,`,` );`,` const scale = window.devicePixelRatio || 1;`,` const canvas = document.createElement("canvas");`,` canvas.width = Math.max(1, Math.ceil(width * scale));`,` canvas.height = Math.max(1, Math.ceil(height * scale));`,` const context = canvas.getContext("2d");`,` if (!context) throw new Error("Canvas context unavailable");`,` context.scale(scale, scale);`,` const clone = document.documentElement.cloneNode(true);`,` if (!(clone instanceof Element)) throw new Error("Document clone failed");`,` clone.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");`,` clone.querySelectorAll("script").forEach((node) => node.remove());`,` inlineComputedStyles(document.documentElement, clone);`,' const svgMarkup = [`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">`, `<foreignObject width="100%" height="100%">${new XMLSerializer().serializeToString(clone)}</foreignObject>`, "</svg>"].join("");',` const svgBlob = new Blob([svgMarkup], { type: "image/svg+xml;charset=utf-8" });`,` const objectUrl = URL.createObjectURL(svgBlob);`,` try {`,` await new Promise((resolve, reject) => {`,` const image = new Image();`,` image.onload = () => {`,` context.drawImage(image, 0, 0, width, height);`,` resolve(undefined);`,` };`,` image.onerror = () => reject(new Error("ForeignObject render failed"));`,` image.src = objectUrl;`,` });`,` } finally {`,` URL.revokeObjectURL(objectUrl);`,` }`,` const blob = await new Promise((resolve) => canvas.toBlob(resolve, "image/png"));`,` if (!blob) throw new Error("PNG export failed");`,` const downloadUrl = URL.createObjectURL(blob);`,` const link = document.createElement("a");`,` const timestamp = new Date().toISOString().replace(/[.:]/g, "-");`,` link.href = downloadUrl;`," link.download = `aikit-screenshot-${timestamp}.png`;",` document.body.appendChild(link);`,` link.click();`,` link.remove();`,` URL.revokeObjectURL(downloadUrl);`,` };`,` const updateToggle = (theme) => {`,` const button = document.querySelector(".aikit-theme-toggle");`,` const nextTheme = theme === "dark" ? "light" : "dark";`,` if (button) {`,` button.setAttribute("aria-label", "Switch to " + nextTheme + " theme");`,` button.setAttribute("aria-pressed", String(theme === "dark"));`,` }`,` };`,` const applyTheme = (theme, persist = true) => {`,` html.setAttribute("data-theme", theme);`,` if (persist) {`,` try {`,` localStorage.setItem("aikit-theme-mode", theme);`,` } catch (_error) {`,` // Ignore storage failures.`,` }`,` }`,` updateToggle(theme);`,` };`,` if (preferredTheme === "light" || preferredTheme === "dark") {`,` applyTheme(preferredTheme, false);`,` } else {`,` applyTheme(readStoredTheme() || systemTheme(), false);`,` }`,` window.toggleTheme = () => {`,` applyTheme(resolvedTheme() === "dark" ? "light" : "dark");`,` };`,` window.toggleToolbox = () => {`,` const menu = toolbox.menu();`,` setToolboxOpen(Boolean(menu?.hidden), { focusItem: Boolean(menu?.hidden) });`,` };`,` window.screenshotPage = async () => {`,` const scrollX = window.scrollX;`,` const scrollY = window.scrollY;`,` setToolboxOpen(false);`,` window.scrollTo(0, 0);`,` await new Promise((resolve) => window.requestAnimationFrame(() => resolve(undefined)));`,` try {`,` await captureDocumentAsPng();`,` } catch (_error) {`,` window.print();`,` } finally {`,` window.scrollTo(scrollX, scrollY);`,` }`,` };`,` document.addEventListener("click", (event) => {`,` const container = toolbox.container();`,` if (!container) return;`,` const target = event.target;`,` if (target instanceof Node && container.contains(target)) return;`,` setToolboxOpen(false);`,` });`,` document.addEventListener("keydown", (event) => {`,` if (event.key === "Escape") {`,` setToolboxOpen(false, { restoreFocus: true });`,` return;`,` }`,` if ((event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") && event.target === toolbox.button()) {`,` event.preventDefault();`,` setToolboxOpen(true, { focusItem: true });`,` }`,` });`,` if (preferredTheme === "auto" && window.matchMedia) {`,` const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");`,` mediaQuery.addEventListener("change", () => {`,` if (readStoredTheme()) return;`,` applyTheme(systemTheme(), false);`,` });`,` }`,` })();`,` <\/script>`].join(`
1616
1619
  `)}function Hn(e,t){if(t!==`local-interactive`)return``;let r=new Set,i=[];for(let t of e)r.has(t.entry)||(r.add(t.entry),i.push(` <script type="module" src="${n(t.entry)}"><\/script>`));return i.join(`
1617
1620
  `)}function Un(e){let t=n(e.lang??`en`),r=n(e.dir??`ltr`),i=e.colorScheme??`auto`,a=e.generatedAt??new Date().toISOString(),o=[`lang="${t}"`,`dir="${r}"`];i!==`auto`&&o.push(`data-theme="${i}"`);let s=zn(e.tokenCss??mt(`light`)),c=Bn(e.headScripts??[]),l=e.islands.length>0&&e.payload?` <script type="application/json" id="surface-payload">${Ln(e.payload)}<\/script>`:``,u=Hn(e.islands,e.exportPolicy),d=[Vn(i),l,u].filter(Boolean).join(`
@@ -1 +1 @@
1
- import{t as e}from"./curated-manager-BkSgtNC2.js";import{readFileSync as t}from"node:fs";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i,pathToFileURL as a}from"node:url";import{parseArgs as o}from"node:util";import{createLogger as s,serializeError as c}from"../../core/dist/index.js";const l=n(i(import.meta.url)),u=(()=>{try{let e=r(l,`..`,`..`,`..`,`package.json`);return JSON.parse(t(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}})(),d=s(`server`);function f(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}const{values:p}=(()=>{let e=process.argv[1];if(!e)return!1;try{return import.meta.url===a(e).href}catch{return!1}})()?o({allowPositionals:!0,options:{transport:{type:`string`,default:f()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}):{values:{transport:f(),port:process.env.AIKIT_PORT??`3210`}};async function m(){if(process.on(`unhandledRejection`,e=>{d.error(`Unhandled rejection`,c(e))}),process.on(`uncaughtException`,e=>{d.error(`Uncaught exception — exiting`,c(e)),process.exit(1)}),d.info(`Starting MCP AI Kit server`,{version:u}),p.transport===`http`){let[{default:e},{loadConfig:t,resolveIndexMode:n},{registerDashboardRoutes:r,resolveDashboardDir:i},{registerSettingsRoutes:a,resolveSettingsDir:o},{createSettingsRouter:s}]=await Promise.all([import(`express`),import(`./config-D4z6-EcI.js`),import(`./dashboard-static-BfIe0Si1.js`),import(`./settings-static-BosGZSPf.js`),import(`./routes-gbC5Wmr9.js`)]),l=t();d.info(`Config loaded`,{sourceCount:l.sources.length,storePath:l.store.path});let u=e();u.use(e.json());let f=Number(p.port);u.use((e,t,n)=>{if(t.setHeader(`Access-Control-Allow-Origin`,process.env.AIKIT_CORS_ORIGIN??`http://localhost:${f}`),t.setHeader(`Access-Control-Allow-Methods`,`GET, POST, PUT, PATCH, DELETE, OPTIONS`),t.setHeader(`Access-Control-Allow-Headers`,`Content-Type, Authorization`),e.method===`OPTIONS`){t.status(204).end();return}n()}),r(u,i(),d);let m=new Date().toISOString();u.use(`/settings/api`,s({log:d,mcpInfo:()=>({transport:`http`,port:f,pid:process.pid,startedAt:m})})),a(u,o(),d),u.get(`/health`,(e,t)=>{t.json({status:`ok`})});let h=!1,g=null,_=null,v=null,y=Promise.resolve();u.post(`/mcp`,async(e,t)=>{if(!h||!_||!v){t.status(503).json({jsonrpc:`2.0`,error:{code:-32603,message:`Server initializing — please retry in a few seconds`},id:null});return}let n=y,r;y=new Promise(e=>{r=e}),await n;try{let n=new v({sessionIdGenerator:void 0});await _.connect(n),await n.handleRequest(e,t,e.body),n.close()}catch(e){if(d.error(`MCP handler error`,c(e)),!t.headersSent){let n=e instanceof Error?e.message:String(e),r=n.includes(`Not Acceptable`);t.status(r?406:500).json({jsonrpc:`2.0`,error:{code:r?-32e3:-32603,message:r?n:`Internal server error`},id:null})}}finally{r()}}),u.get(`/mcp`,(e,t)=>{t.writeHead(405).end(JSON.stringify({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null}))}),u.delete(`/mcp`,(e,t)=>{t.writeHead(405).end(JSON.stringify({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null}))});let b=u.listen(f,`127.0.0.1`,()=>{d.info(`MCP server listening`,{url:`http://127.0.0.1:${f}/mcp`,port:f}),setTimeout(async()=>{try{let[{createLazyServer:e,ALL_TOOL_NAMES:t},{StreamableHTTPServerTransport:r},{checkForUpdates:i,autoUpgradeScaffold:a}]=await Promise.all([import(`./server--D-DJ9_g.js`),import(`@modelcontextprotocol/sdk/server/streamableHttp.js`),import(`./version-check-Bj07vc5x.js`)]);i(),a();let o=n(l),s=e(l,o);_=s.server,v=r,h=!0,d.info(`MCP server configured (lazy — AI Kit initializing in background)`,{toolCount:t.length,resourceCount:2}),s.startInit(),o===`auto`?s.ready.then(async()=>{try{let e=l.sources.map(e=>e.path).join(`, `);d.info(`Running initial index`,{sourcePaths:e}),await s.runInitialIndex(),d.info(`Initial index complete`)}catch(e){d.error(`Initial index failed; will retry on aikit_reindex`,c(e))}}).catch(e=>d.error(`AI Kit init or indexing failed`,c(e))):o===`smart`?s.ready.then(async()=>{try{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(s.aikit.indexer,l,s.aikit.store),n=s.aikit.store;g=t,t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),s.setSmartScheduler(t),d.info(`Smart index scheduler started (HTTP mode)`)}catch(e){d.error(`Failed to start smart index scheduler`,c(e))}}).catch(e=>d.error(`AI Kit initialization failed`,c(e))):(s.ready.catch(e=>d.error(`AI Kit initialization failed`,c(e))),d.info(`Initial full indexing skipped in HTTP mode`,{indexMode:o}))}catch(e){d.error(`Failed to load server modules`,c(e))}},100)}),x=async e=>{d.info(`Shutdown signal received`,{signal:e}),g?.stop(),b.close(),_&&await _.close(),process.exit(0)};process.on(`SIGINT`,()=>x(`SIGINT`)),process.on(`SIGTERM`,()=>x(`SIGTERM`))}else{let[{loadConfig:e,reconfigureForWorkspace:t,resolveIndexMode:n},{createLazyServer:r},{checkForUpdates:a,autoUpgradeScaffold:o},{RootsListChangedNotificationSchema:s}]=await Promise.all([import(`./config-D4z6-EcI.js`),import(`./server--D-DJ9_g.js`),import(`./version-check-Bj07vc5x.js`),import(`@modelcontextprotocol/sdk/types.js`)]),l=e();d.info(`Config loaded`,{sourceCount:l.sources.length,storePath:l.store.path}),a(),o();let u=n(l),f=r(l,u),{server:p,startInit:m,ready:h,runInitialIndex:g}=f,{StdioServerTransport:_}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),v=new _;await p.connect(v),d.info(`MCP server started`,{transport:`stdio`});let y=e=>{if(e.length===0)return!1;let n=e[0].uri,r=n.startsWith(`file://`)?i(n):n;return d.info(`MCP roots resolved`,{rootUri:n,rootPath:r,rootCount:e.length}),t(l,r),l.allRoots=e.map(e=>{let t=e.uri;return t.startsWith(`file://`)?i(t):t}),!0},b=!1;try{b=y((await p.server.listRoots()).roots),b||d.info(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(e){d.warn(`MCP roots/list not supported by client; using cwd fallback`,{cwd:process.cwd(),...c(e)}),b=!0}b||=await new Promise(e=>{let t=setTimeout(()=>{d.warn(`Timed out waiting for MCP roots/list_changed; using cwd fallback`,{cwd:process.cwd()}),e(!1)},5e3);p.server.setNotificationHandler(s,async()=>{clearTimeout(t);try{e(y((await p.server.listRoots()).roots))}catch(t){d.warn(`roots/list retry failed after notification`,c(t)),e(!1)}})}),m();let x=null,S=()=>{x&&clearTimeout(x),x=setTimeout(async()=>{d.info(`Auto-shutdown: no activity for 30 minutes — shutting down gracefully`);try{let e=f.aikit;e&&await Promise.all([e.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),e.graphStore.close().catch(()=>{}),e.store.close().catch(()=>{})])}catch{}process.exit(0)},18e5),x.unref&&x.unref()};S(),process.stdin.on(`data`,()=>S()),h.catch(e=>{d.error(`Initialization failed — server will continue with limited tools`,c(e))}),u===`auto`?g().catch(e=>d.error(`Initial index failed`,c(e))):u===`smart`?h.then(async()=>{try{if(!f.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(f.aikit.indexer,l,f.aikit.store),n=f.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),f.setSmartScheduler(t),d.info(`Smart index scheduler started (stdio mode)`)}catch(e){d.error(`Failed to start smart index scheduler`,c(e))}}).catch(e=>d.error(`AI Kit init failed for smart scheduler`,c(e))):d.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:u})}}m().catch(e=>{d.error(`Fatal error`,c(e)),process.exit(1)});export{e as CuratedKnowledgeManager};
1
+ import{t as e}from"./curated-manager-BkSgtNC2.js";import{readFileSync as t}from"node:fs";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i,pathToFileURL as a}from"node:url";import{parseArgs as o}from"node:util";import{createLogger as s,serializeError as c}from"../../core/dist/index.js";const l=n(i(import.meta.url)),u=(()=>{try{let e=r(l,`..`,`..`,`..`,`package.json`);return JSON.parse(t(e,`utf-8`)).version??`0.0.0`}catch{return`0.0.0`}})(),d=s(`server`);function f(){return process.env.AIKIT_TRANSPORT?process.env.AIKIT_TRANSPORT:process.stdin.isTTY?`http`:`stdio`}const{values:p}=(()=>{let e=process.argv[1];if(!e)return!1;try{return import.meta.url===a(e).href}catch{return!1}})()?o({allowPositionals:!0,options:{transport:{type:`string`,default:f()},port:{type:`string`,default:process.env.AIKIT_PORT??`3210`}}}):{values:{transport:f(),port:process.env.AIKIT_PORT??`3210`}};async function m(){if(process.on(`unhandledRejection`,e=>{d.error(`Unhandled rejection`,c(e))}),process.on(`uncaughtException`,e=>{d.error(`Uncaught exception — exiting`,c(e)),process.exit(1)}),d.info(`Starting MCP AI Kit server`,{version:u}),p.transport===`http`){let[{default:e},{loadConfig:t,resolveIndexMode:n},{registerDashboardRoutes:r,resolveDashboardDir:i},{registerSettingsRoutes:a,resolveSettingsDir:o},{createSettingsRouter:s}]=await Promise.all([import(`express`),import(`./config-D4z6-EcI.js`),import(`./dashboard-static-BfIe0Si1.js`),import(`./settings-static-BosGZSPf.js`),import(`./routes-gbC5Wmr9.js`)]),l=t();d.info(`Config loaded`,{sourceCount:l.sources.length,storePath:l.store.path});let u=e();u.use(e.json());let f=Number(p.port);u.use((e,t,n)=>{if(t.setHeader(`Access-Control-Allow-Origin`,process.env.AIKIT_CORS_ORIGIN??`http://localhost:${f}`),t.setHeader(`Access-Control-Allow-Methods`,`GET, POST, PUT, PATCH, DELETE, OPTIONS`),t.setHeader(`Access-Control-Allow-Headers`,`Content-Type, Authorization`),e.method===`OPTIONS`){t.status(204).end();return}n()}),r(u,i(),d);let m=new Date().toISOString();u.use(`/settings/api`,s({log:d,mcpInfo:()=>({transport:`http`,port:f,pid:process.pid,startedAt:m})})),a(u,o(),d),u.get(`/health`,(e,t)=>{t.json({status:`ok`})});let h=!1,g=null,_=null,v=null,y=Promise.resolve();u.post(`/mcp`,async(e,t)=>{if(!h||!_||!v){t.status(503).json({jsonrpc:`2.0`,error:{code:-32603,message:`Server initializing — please retry in a few seconds`},id:null});return}let n=y,r;y=new Promise(e=>{r=e}),await n;try{let n=new v({sessionIdGenerator:void 0});await _.connect(n),await n.handleRequest(e,t,e.body),n.close()}catch(e){if(d.error(`MCP handler error`,c(e)),!t.headersSent){let n=e instanceof Error?e.message:String(e),r=n.includes(`Not Acceptable`);t.status(r?406:500).json({jsonrpc:`2.0`,error:{code:r?-32e3:-32603,message:r?n:`Internal server error`},id:null})}}finally{r()}}),u.get(`/mcp`,(e,t)=>{t.writeHead(405).end(JSON.stringify({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null}))}),u.delete(`/mcp`,(e,t)=>{t.writeHead(405).end(JSON.stringify({jsonrpc:`2.0`,error:{code:-32e3,message:`Method not allowed.`},id:null}))});let b=u.listen(f,`127.0.0.1`,()=>{d.info(`MCP server listening`,{url:`http://127.0.0.1:${f}/mcp`,port:f}),setTimeout(async()=>{try{let[{createLazyServer:e,ALL_TOOL_NAMES:t},{StreamableHTTPServerTransport:r},{checkForUpdates:i,autoUpgradeScaffold:a}]=await Promise.all([import(`./server-DLkC-unR.js`),import(`@modelcontextprotocol/sdk/server/streamableHttp.js`),import(`./version-check-Bj07vc5x.js`)]);i(),a();let o=n(l),s=e(l,o);_=s.server,v=r,h=!0,d.info(`MCP server configured (lazy — AI Kit initializing in background)`,{toolCount:t.length,resourceCount:2}),s.startInit(),o===`auto`?s.ready.then(async()=>{try{let e=l.sources.map(e=>e.path).join(`, `);d.info(`Running initial index`,{sourcePaths:e}),await s.runInitialIndex(),d.info(`Initial index complete`)}catch(e){d.error(`Initial index failed; will retry on aikit_reindex`,c(e))}}).catch(e=>d.error(`AI Kit init or indexing failed`,c(e))):o===`smart`?s.ready.then(async()=>{try{if(!s.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(s.aikit.indexer,l,s.aikit.store),n=s.aikit.store;g=t,t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),s.setSmartScheduler(t),d.info(`Smart index scheduler started (HTTP mode)`)}catch(e){d.error(`Failed to start smart index scheduler`,c(e))}}).catch(e=>d.error(`AI Kit initialization failed`,c(e))):(s.ready.catch(e=>d.error(`AI Kit initialization failed`,c(e))),d.info(`Initial full indexing skipped in HTTP mode`,{indexMode:o}))}catch(e){d.error(`Failed to load server modules`,c(e))}},100)}),x=async e=>{d.info(`Shutdown signal received`,{signal:e}),g?.stop(),b.close(),_&&await _.close(),process.exit(0)};process.on(`SIGINT`,()=>x(`SIGINT`)),process.on(`SIGTERM`,()=>x(`SIGTERM`))}else{let[{loadConfig:e,reconfigureForWorkspace:t,resolveIndexMode:n},{createLazyServer:r},{checkForUpdates:a,autoUpgradeScaffold:o},{RootsListChangedNotificationSchema:s}]=await Promise.all([import(`./config-D4z6-EcI.js`),import(`./server-DLkC-unR.js`),import(`./version-check-Bj07vc5x.js`),import(`@modelcontextprotocol/sdk/types.js`)]),l=e();d.info(`Config loaded`,{sourceCount:l.sources.length,storePath:l.store.path}),a(),o();let u=n(l),f=r(l,u),{server:p,startInit:m,ready:h,runInitialIndex:g}=f,{StdioServerTransport:_}=await import(`@modelcontextprotocol/sdk/server/stdio.js`),v=new _;await p.connect(v),d.info(`MCP server started`,{transport:`stdio`});let y=e=>{if(e.length===0)return!1;let n=e[0].uri,r=n.startsWith(`file://`)?i(n):n;return d.info(`MCP roots resolved`,{rootUri:n,rootPath:r,rootCount:e.length}),t(l,r),l.allRoots=e.map(e=>{let t=e.uri;return t.startsWith(`file://`)?i(t):t}),!0},b=!1;try{b=y((await p.server.listRoots()).roots),b||d.info(`No MCP roots yet; waiting for roots/list_changed notification`)}catch(e){d.warn(`MCP roots/list not supported by client; using cwd fallback`,{cwd:process.cwd(),...c(e)}),b=!0}b||=await new Promise(e=>{let t=setTimeout(()=>{d.warn(`Timed out waiting for MCP roots/list_changed; using cwd fallback`,{cwd:process.cwd()}),e(!1)},5e3);p.server.setNotificationHandler(s,async()=>{clearTimeout(t);try{e(y((await p.server.listRoots()).roots))}catch(t){d.warn(`roots/list retry failed after notification`,c(t)),e(!1)}})}),m();let x=null,S=()=>{x&&clearTimeout(x),x=setTimeout(async()=>{d.info(`Auto-shutdown: no activity for 30 minutes — shutting down gracefully`);try{let e=f.aikit;e&&await Promise.all([e.embedder.shutdown?.().catch(()=>{})??Promise.resolve(),e.graphStore.close().catch(()=>{}),e.store.close().catch(()=>{})])}catch{}process.exit(0)},18e5),x.unref&&x.unref()};S(),process.stdin.on(`data`,()=>S()),h.catch(e=>{d.error(`Initialization failed — server will continue with limited tools`,c(e))}),u===`auto`?g().catch(e=>d.error(`Initial index failed`,c(e))):u===`smart`?h.then(async()=>{try{if(!f.aikit)throw Error(`AI Kit components are not available after initialization`);let{SmartIndexScheduler:e}=await import(`../../indexer/dist/index.js`),t=new e(f.aikit.indexer,l,f.aikit.store),n=f.aikit.store;t.start(),n.onBeforeClose&&n.onBeforeClose(()=>t.stop()),f.setSmartScheduler(t),d.info(`Smart index scheduler started (stdio mode)`)}catch(e){d.error(`Failed to start smart index scheduler`,c(e))}}).catch(e=>d.error(`AI Kit init failed for smart scheduler`,c(e))):d.warn(`Initial full indexing skipped; use aikit_reindex to index manually`,{indexMode:u})}}m().catch(e=>{d.error(`Fatal error`,c(e)),process.exit(1)});export{e as CuratedKnowledgeManager};
@@ -238,7 +238,7 @@ Complements: \`symbol\` (single lookup), \`trace\` (call-chain AST), \`blast_rad
238
238
  { path: 'docs/api.md', title: 'API Reference', status: 'stale' },
239
239
  ],
240
240
  },
241
- }`},{type:`text`,category:`content`,description:`Plain text content rendered through the markdown parser.`,valueShape:`string`},{type:`heading`,category:`content`,description:`Single heading with configurable level from h1 to h6.`,valueShape:`string`},{type:`paragraph`,category:`content`,description:`Single paragraph rendered inside a p tag.`,valueShape:`string`},{type:`separator`,category:`layout`,description:`Horizontal rule used to separate adjacent blocks.`,valueShape:`undefined`},{type:`actions`,category:`layout`,description:`Action bar containing button and select action definitions.`,valueShape:`Array<{ type: string; id: string; label: string; variant?: string; options?: Array<string | { label: string; value: string }> }>`}].map(e=>[e.type,{...e}]));function Pl(){let e={};for(let[t,n]of Nl)n.vendorScripts?.length&&(e[t]=n.vendorScripts);return e}const Fl=1024,Il=new Set([`user-closed`,`host-dismissed`,`replaced`]);function Ll(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t,n){let r={code:e,message:t};return n!==void 0&&(r.details=n),{kind:`error`,error:r}}function J(e,t,n,r){e.writeHead(t,{"Content-Type":`application/json`,"Access-Control-Allow-Origin":r??`null`}),e.end(JSON.stringify(n))}async function Rl(e){return await new Promise((t,n)=>{let r=[],i=0;e.on(`data`,t=>{if(i+=t.length,i>65536){n(Error(`Callback payload exceeds 64KB limit`)),e.destroy();return}r.push(t)}),e.on(`end`,()=>t(Buffer.concat(r).toString(`utf8`))),e.on(`error`,n)})}function zl(e,t){if(typeof e!=`string`||e.length!==t.length)return!1;let n=Buffer.from(e,`utf8`),r=Buffer.from(t,`utf8`);return n.length===r.length?oe(n,r):!1}function Bl(e,t){let n=e.headers.origin;if(n!=null)return n===t;let r=e.headers.referer;return r==null?!1:r.startsWith(t)}function Vl(e){return(e.headers[`content-type`]??``).startsWith(`application/json`)}function Hl(e){for(let[t,n]of Object.entries(e)){let e=typeof n==`string`?n:JSON.stringify(n);if(Buffer.byteLength(e,`utf8`)>8192)return`Form field "${t}" exceeds 8KB limit`}return null}function Ul(e){return Array.isArray(e)&&e.length>Fl?`Selection exceeds ${Fl} items (got ${e.length})`:null}function Wl(e,t,n){let r=typeof e.actionId==`string`?e.actionId:``,i=n.find(e=>e.id===r);if(!i)return q(`INVALID_ACTION`,`Unknown actionId: ${r||`(missing)`}`);let a=typeof e.selection==`string`||Array.isArray(e.selection)?e.selection:void 0,o=Ll(e.formData)?e.formData:void 0,s={surfaceId:t,actionId:i.id,actionType:i.type,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),sourceTransport:`browser`};return e.value!==void 0&&(s.value=e.value),a!==void 0&&(s.selection=a),o!==void 0&&(s.formData=o),typeof e.label==`string`?s.label=e.label:i.label&&(s.label=i.label),{kind:`result`,result:s}}function Gl(e,t){let n=ie(16).toString(`hex`),r=!1,i=!1,a,o,s=new Promise(e=>{o=e}),c=e=>r?a??e:(r=!0,a=e,o?.(e),e);return{nonce:n,promise:s,settleTimeout(e){return c({kind:`timeout`,waitedMs:e})},settleCancelled(e){return c({kind:`cancelled`,reason:e})},settleError(e,t,n){return c(q(e,t,n))},async handle(r,a,o){if(!Vl(r)){let e=c(q(`INVALID_CONTENT_TYPE`,`Content-Type must be application/json`));return J(a,415,{ok:!1,error:`unsupported-media-type`},o),e}if(!Bl(r,o)){let e=c(q(`INVALID_ORIGIN`,`Unexpected callback origin: ${r.headers.origin??r.headers.referer??`(missing)`}`));return J(a,403,{ok:!1,error:`invalid-origin`},o),e}let s=``;try{s=await Rl(r)}catch(e){let t=c(q(`INVALID_PAYLOAD`,e instanceof Error?e.message:`Unable to read callback payload`));return J(a,413,{ok:!1,error:`payload-too-large`},o),t}let l;try{let e=JSON.parse(s);if(!Ll(e))throw Error(`Callback payload must be an object`);l=e}catch(e){let t=c(q(`INVALID_PAYLOAD`,e instanceof Error?e.message:`Malformed callback payload`));return J(a,400,{ok:!1,error:`invalid-json`},o),t}if(i){let e=q(`NONCE_CONSUMED`,`Nonce has already been used`);return J(a,403,{ok:!1,error:`nonce-consumed`},o),e}if(!zl(typeof l.nonce==`string`?l.nonce:``,n)){let e=c(q(`INVALID_NONCE`,`Callback nonce did not match`));return J(a,403,{ok:!1,error:`invalid-nonce`},o),e}i=!0;let u=Ul(l.selection);if(u){let e=c(q(`SELECTION_TOO_LARGE`,u));return J(a,413,{ok:!1,error:`selection-too-large`},o),e}if(Ll(l.formData)){let e=Hl(l.formData);if(e){let t=c(q(`PAYLOAD_FIELD_TOO_LARGE`,e));return J(a,413,{ok:!1,error:`field-too-large`},o),t}}if(l.kind===`cancelled`){let e=typeof l.reason==`string`?l.reason:``;if(!Il.has(e)){let t=c(q(`INVALID_CANCEL_REASON`,`Unsupported cancel reason: ${e||`(missing)`}`));return J(a,400,{ok:!1,error:`invalid-cancel-reason`},o),t}let t=c({kind:`cancelled`,reason:e});return J(a,200,{ok:!0,kind:`cancelled`},o),t}let d=c(Wl(l,e,t));return J(a,d.kind===`error`?400:200,{ok:d.kind!==`error`,kind:d.kind},o),d}}}const Kl=new Map;function ql(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`)}function Jl(e){let t=`(?=[^>]*\\bid=['"]${ql(e)}['"])`;return RegExp(`(<script\\b(?=[^>]*\\btype=['"]application\\/json['"])${t}[^>]*>)[\\s\\S]*?(<\/script>)`,`i`)}function Yl(e){Kl.has(e.id)&&console.warn(`[viewer-registry] Overwriting viewer template "${e.id}"`),Kl.set(e.id,e)}function Xl(e){return Kl.get(e)}function Zl(e){return typeof e==`string`&&Kl.has(e)}function Ql(){return[...Kl.values()]}function $l(e,t,n,r){let i=Jl(n);if(!i.test(e))throw Error(`No <script type="application/json" id="${n}"> found in template`);let a=r?r(t):t,o=JSON.stringify(a??null).replace(/<\/script/gi,`<\\/script`);return e.replace(i,`$1\n${o}\n$2`)}const Y=import.meta.dirname??h(x(import.meta.url)),eu={type:`object`,properties:{title:{type:`string`},description:{type:`string`},layout:{type:`object`,properties:{direction:{type:`string`},spacing:{type:`number`},layerSpacing:{type:`number`}}},nodes:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},type:{type:`string`,enum:[`person`,`system`,`container`,`component`,`database`,`queue`,`external`,`boundary`]},label:{type:`string`},technology:{type:`string`},icon:{type:`string`},description:{type:`string`}},required:[`id`,`type`,`label`]}},edges:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`},label:{type:`string`},style:{type:`string`,enum:[`sync`,`async`,`dashed`,`dotted`,`solid`]}},required:[`source`,`target`]},default:[]}},required:[`nodes`]},tu={type:`object`,properties:{nodes:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},label:{type:`string`},type:{type:`string`,enum:[`start-end`,`manual`,`automated`,`integration`,`decision`,`prerequisite`]},description:{type:`string`}},required:[`id`,`label`]}},edges:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`},label:{type:`string`},type:{type:`string`,enum:[`standard`,`loop-back`,`exception`]}},required:[`source`,`target`]}}},required:[`nodes`]},nu={type:`object`,properties:{title:{type:`string`},description:{type:`string`},phases:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},label:{type:`string`},outcome:{type:`string`},batches:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},order:{type:`number`},parallel:{type:`boolean`},label:{type:`string`},tasks:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},title:{type:`string`},agent:{type:`string`},files:{type:`array`,items:{type:`string`},default:[]},status:{type:`string`,enum:[`pending`,`in-progress`,`done`,`blocked`]},dependsOn:{type:`array`,items:{type:`string`},default:[]}},required:[`id`,`title`]},default:[]}},required:[`id`,`tasks`]},default:[]}},required:[`id`,`label`,`batches`]}}},required:[`phases`]};function ru(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iu(e,t){return ru(t)?{...t,kind:e}:{kind:e}}function au(e){let t=[...e===`canvas.html`?[_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`canvas`,`index.html`),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`canvas`,`index.html`)]:[],_(Y,`..`,`..`,`..`,`viewers`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`static`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`dist`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,e),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,`dist`,e),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,e),_(Y,`..`,`viewers`,`dist`,e),_(Y,`..`,`viewers`,e)];for(let e of t)try{return c(e,`utf8`)}catch{}throw Error(`Viewer HTML not found: ${e}. Searched: ${t.join(`, `)}`)}let ou,su,cu,lu,uu,du;function fu(){return ou??=au(`c4-viewer.html`),ou}function pu(){return su??=au(`tour-viewer.html`),su}function mu(){return cu??=au(`canvas.html`),cu}function hu(){return lu??=au(`architecture-static.html`),lu}function gu(){return uu??=au(`process-flow-static.html`),uu}function _u(){return du??=au(`task-plan-static.html`),du}function vu(){Yl({id:`c4@1`,label:`C4 Architecture Diagram`,description:`Interactive C4 architecture diagram with zoom, pan, and ELK auto-layout`,inputSchema:eu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:fu}),Yl({id:`c4-static@1`,label:`C4 Architecture Diagram (Static)`,description:`Static SVG architecture diagram for inline rendering`,inputSchema:eu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:hu}),Yl({id:`tour@1`,label:`Code Tour Viewer`,description:`Interactive code tour with step navigation and dependency graph`,inputSchema:{type:`object`,properties:{title:{type:`string`},description:{type:`string`},estimatedTime:{type:`string`},steps:{type:`array`,items:{type:`object`,properties:{stepNumber:{type:`number`},id:{type:`string`},title:{type:`string`},file:{type:`string`},explanation:{type:`string`},description:{type:`string`},learnsConcept:{type:`string`},duration:{type:`string`},line:{type:`number`},code:{type:`string`}},required:[`id`,`title`]}},dependencies:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`}},required:[`source`,`target`]},default:[]}},required:[`steps`]},injectId:`tour-data`,supportedTransports:[`browser`],resolveHtml:pu}),Yl({id:`process-flow-static@1`,label:`Process Flow Diagram (Static)`,description:`Static SVG process flow diagram for inline rendering`,inputSchema:tu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:gu}),Yl({id:`task-plan-static@1`,label:`Task Execution Plan (Static)`,description:`Static SVG task execution plan for inline rendering`,inputSchema:nu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:_u}),Yl({id:`task-plan@1`,label:`Task Execution Plan (Interactive)`,description:`Interactive task execution plan with ReactFlow, phase grouping, and dependency edges`,inputSchema:nu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:mu,transformData:e=>iu(`task-plan`,e)}),Yl({id:`process-flow@1`,label:`Process Flow Diagram (Interactive)`,description:`Interactive process flow diagram with ReactFlow`,inputSchema:tu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:mu,transformData:e=>iu(`process-flow`,e)})}function yu(){let e=new zn;for(let t of Hn.list())e.register(t);return e.register(Vn),e.register(Kn),e.register(qn),e.register(Un),e}function bu(e,t){return e?.supportedTransports.includes(t)??!1}const xu=yu();function Su(e){if(e.template)return xu.get(e.template)}function Cu(e){if((e.actions?.length??0)>0)return!0;if(e.template&&Zl(e.template)){let t=Xl(e.template);return t?.supportedTransports.includes(`browser`)===!0&&!t.supportedTransports.includes(`mcp-app`)}let t=Su(e);return bu(t,`browser`)&&!bu(t,`mcp-app`)}vu();function wu(){let e;return()=>{if(e!==void 0)return e;try{e=c(a(import.meta.url).resolve(`mermaid/dist/mermaid.min.js`),`utf-8`)}catch{e=``}return e}}const Tu={id:`mermaid`,cdn:`https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js`,initScript:`window.__aikit_initMermaid = function() {
241
+ }`},{type:`text`,category:`content`,description:`Plain text content rendered through the markdown parser.`,valueShape:`string`},{type:`heading`,category:`content`,description:`Single heading with configurable level from h1 to h6.`,valueShape:`string`},{type:`paragraph`,category:`content`,description:`Single paragraph rendered inside a p tag.`,valueShape:`string`},{type:`separator`,category:`layout`,description:`Horizontal rule used to separate adjacent blocks.`,valueShape:`undefined`},{type:`actions`,category:`layout`,description:`Action bar containing button and select action definitions.`,valueShape:`Array<{ type: string; id: string; label: string; variant?: string; options?: Array<string | { label: string; value: string }> }>`}].map(e=>[e.type,{...e}]));function Pl(){let e={};for(let[t,n]of Nl)n.vendorScripts?.length&&(e[t]=n.vendorScripts);return e}const Fl=1024,Il=new Set([`user-closed`,`host-dismissed`,`replaced`]);function Ll(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t,n){let r={code:e,message:t};return n!==void 0&&(r.details=n),{kind:`error`,error:r}}function J(e,t,n,r){e.writeHead(t,{"Content-Type":`application/json`,"Access-Control-Allow-Origin":r??`null`}),e.end(JSON.stringify(n))}async function Rl(e){return await new Promise((t,n)=>{let r=[],i=0;e.on(`data`,t=>{if(i+=t.length,i>65536){n(Error(`Callback payload exceeds 64KB limit`)),e.destroy();return}r.push(t)}),e.on(`end`,()=>t(Buffer.concat(r).toString(`utf8`))),e.on(`error`,n)})}function zl(e,t){if(typeof e!=`string`||e.length!==t.length)return!1;let n=Buffer.from(e,`utf8`),r=Buffer.from(t,`utf8`);return n.length===r.length?oe(n,r):!1}function Bl(e,t){let n=e.headers.origin;if(n!=null)return n===t;let r=e.headers.referer;return r==null?!1:r.startsWith(t)}function Vl(e){return(e.headers[`content-type`]??``).startsWith(`application/json`)}function Hl(e){for(let[t,n]of Object.entries(e)){let e=typeof n==`string`?n:JSON.stringify(n);if(Buffer.byteLength(e,`utf8`)>8192)return`Form field "${t}" exceeds 8KB limit`}return null}function Ul(e){return Array.isArray(e)&&e.length>Fl?`Selection exceeds ${Fl} items (got ${e.length})`:null}function Wl(e,t,n){let r=typeof e.actionId==`string`?e.actionId:``,i=n.find(e=>e.id===r);if(!i)return q(`INVALID_ACTION`,`Unknown actionId: ${r||`(missing)`}`);let a=typeof e.selection==`string`||Array.isArray(e.selection)?e.selection:void 0,o=Ll(e.formData)?e.formData:void 0,s={surfaceId:t,actionId:i.id,actionType:i.type,timestamp:typeof e.timestamp==`string`?e.timestamp:new Date().toISOString(),sourceTransport:`browser`};return e.value!==void 0&&(s.value=e.value),a!==void 0&&(s.selection=a),o!==void 0&&(s.formData=o),typeof e.label==`string`?s.label=e.label:i.label&&(s.label=i.label),{kind:`result`,result:s}}function Gl(e,t){let n=ie(16).toString(`hex`),r=!1,i=!1,a,o,s=new Promise(e=>{o=e}),c=e=>r?a??e:(r=!0,a=e,o?.(e),e);return{nonce:n,promise:s,settleTimeout(e){return c({kind:`timeout`,waitedMs:e})},settleCancelled(e){return c({kind:`cancelled`,reason:e})},settleError(e,t,n){return c(q(e,t,n))},async handle(r,a,o){if(!Vl(r)){let e=c(q(`INVALID_CONTENT_TYPE`,`Content-Type must be application/json`));return J(a,415,{ok:!1,error:`unsupported-media-type`},o),e}if(!Bl(r,o)){let e=c(q(`INVALID_ORIGIN`,`Unexpected callback origin: ${r.headers.origin??r.headers.referer??`(missing)`}`));return J(a,403,{ok:!1,error:`invalid-origin`},o),e}let s=``;try{s=await Rl(r)}catch(e){let t=c(q(`INVALID_PAYLOAD`,e instanceof Error?e.message:`Unable to read callback payload`));return J(a,413,{ok:!1,error:`payload-too-large`},o),t}let l;try{let e=JSON.parse(s);if(!Ll(e))throw Error(`Callback payload must be an object`);l=e}catch(e){let t=c(q(`INVALID_PAYLOAD`,e instanceof Error?e.message:`Malformed callback payload`));return J(a,400,{ok:!1,error:`invalid-json`},o),t}if(i){let e=q(`NONCE_CONSUMED`,`Nonce has already been used`);return J(a,403,{ok:!1,error:`nonce-consumed`},o),e}if(!zl(typeof l.nonce==`string`?l.nonce:``,n)){let e=c(q(`INVALID_NONCE`,`Callback nonce did not match`));return J(a,403,{ok:!1,error:`invalid-nonce`},o),e}i=!0;let u=Ul(l.selection);if(u){let e=c(q(`SELECTION_TOO_LARGE`,u));return J(a,413,{ok:!1,error:`selection-too-large`},o),e}if(Ll(l.formData)){let e=Hl(l.formData);if(e){let t=c(q(`PAYLOAD_FIELD_TOO_LARGE`,e));return J(a,413,{ok:!1,error:`field-too-large`},o),t}}if(l.kind===`cancelled`){let e=typeof l.reason==`string`?l.reason:``;if(!Il.has(e)){let t=c(q(`INVALID_CANCEL_REASON`,`Unsupported cancel reason: ${e||`(missing)`}`));return J(a,400,{ok:!1,error:`invalid-cancel-reason`},o),t}let t=c({kind:`cancelled`,reason:e});return J(a,200,{ok:!0,kind:`cancelled`},o),t}let d=c(Wl(l,e,t));return J(a,d.kind===`error`?400:200,{ok:d.kind!==`error`,kind:d.kind},o),d}}}const Kl=new Map;function ql(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`)}function Jl(e){let t=`(?=[^>]*\\bid=['"]${ql(e)}['"])`;return RegExp(`(<script\\b(?=[^>]*\\btype=['"]application\\/json['"])${t}[^>]*>)[\\s\\S]*?(<\/script>)`,`i`)}function Yl(e){Kl.has(e.id)&&console.warn(`[viewer-registry] Overwriting viewer template "${e.id}"`),Kl.set(e.id,e)}function Xl(e){return Kl.get(e)}function Zl(e){return typeof e==`string`&&Kl.has(e)}function Ql(){return[...Kl.values()]}function $l(e,t,n,r){let i=Jl(n);if(!i.test(e))throw Error(`No <script type="application/json" id="${n}"> found in template`);let a=r?r(t):t,o=JSON.stringify(a??null).replace(/<\/script/gi,`<\\/script`).replace(/<script/gi,`\\u003Cscript`).replace(/-->/g,`--\\u003E`).replace(/<!--/g,`\\u003C!--`);return e.replace(i,`$1\n${o}\n$2`)}const Y=import.meta.dirname??h(x(import.meta.url)),eu={type:`object`,properties:{title:{type:`string`},description:{type:`string`},layout:{type:`object`,properties:{direction:{type:`string`},spacing:{type:`number`},layerSpacing:{type:`number`}}},nodes:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},type:{type:`string`,enum:[`person`,`system`,`container`,`component`,`database`,`queue`,`external`,`boundary`]},label:{type:`string`},technology:{type:`string`},icon:{type:`string`},description:{type:`string`}},required:[`id`,`type`,`label`]}},edges:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`},label:{type:`string`},style:{type:`string`,enum:[`sync`,`async`,`dashed`,`dotted`,`solid`]}},required:[`source`,`target`]},default:[]}},required:[`nodes`]},tu={type:`object`,properties:{nodes:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},label:{type:`string`},type:{type:`string`,enum:[`start-end`,`manual`,`automated`,`integration`,`decision`,`prerequisite`]},description:{type:`string`}},required:[`id`,`label`]}},edges:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`},label:{type:`string`},type:{type:`string`,enum:[`standard`,`loop-back`,`exception`]}},required:[`source`,`target`]}}},required:[`nodes`]},nu={type:`object`,properties:{title:{type:`string`},description:{type:`string`},phases:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},label:{type:`string`},outcome:{type:`string`},batches:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},order:{type:`number`},parallel:{type:`boolean`},label:{type:`string`},tasks:{type:`array`,items:{type:`object`,properties:{id:{type:`string`},title:{type:`string`},agent:{type:`string`},files:{type:`array`,items:{type:`string`},default:[]},status:{type:`string`,enum:[`pending`,`in-progress`,`done`,`blocked`]},dependsOn:{type:`array`,items:{type:`string`},default:[]}},required:[`id`,`title`]},default:[]}},required:[`id`,`tasks`]},default:[]}},required:[`id`,`label`,`batches`]}}},required:[`phases`]};function ru(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iu(e,t){return ru(t)?{...t,kind:e}:{kind:e}}function au(e){let t=[...e===`canvas.html`?[_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`canvas`,`index.html`),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`canvas`,`index.html`)]:[],_(Y,`..`,`..`,`..`,`viewers`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`src`,`static`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,`dist`,e),_(Y,`..`,`..`,`..`,`..`,`..`,`scaffold`,`general`,`viewers`,e),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,`dist`,e),_(Y,`..`,`..`,`scaffold`,`general`,`viewers`,e),_(Y,`..`,`viewers`,`dist`,e),_(Y,`..`,`viewers`,e)];for(let e of t)try{return c(e,`utf8`)}catch{}throw Error(`Viewer HTML not found: ${e}. Searched: ${t.join(`, `)}`)}let ou,su,cu,lu,uu,du;function fu(){return ou??=au(`c4-viewer.html`),ou}function pu(){return su??=au(`tour-viewer.html`),su}function mu(){return cu??=au(`canvas.html`),cu}function hu(){return lu??=au(`architecture-static.html`),lu}function gu(){return uu??=au(`process-flow-static.html`),uu}function _u(){return du??=au(`task-plan-static.html`),du}function vu(){Yl({id:`c4@1`,label:`C4 Architecture Diagram`,description:`Interactive C4 architecture diagram with zoom, pan, and ELK auto-layout`,inputSchema:eu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:fu}),Yl({id:`c4-static@1`,label:`C4 Architecture Diagram (Static)`,description:`Static SVG architecture diagram for inline rendering`,inputSchema:eu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:hu}),Yl({id:`tour@1`,label:`Code Tour Viewer`,description:`Interactive code tour with step navigation and dependency graph`,inputSchema:{type:`object`,properties:{title:{type:`string`},description:{type:`string`},estimatedTime:{type:`string`},steps:{type:`array`,items:{type:`object`,properties:{stepNumber:{type:`number`},id:{type:`string`},title:{type:`string`},file:{type:`string`},explanation:{type:`string`},description:{type:`string`},learnsConcept:{type:`string`},duration:{type:`string`},line:{type:`number`},code:{type:`string`}},required:[`id`,`title`]}},dependencies:{type:`array`,items:{type:`object`,properties:{source:{type:`string`},target:{type:`string`}},required:[`source`,`target`]},default:[]}},required:[`steps`]},injectId:`tour-data`,supportedTransports:[`browser`],resolveHtml:pu}),Yl({id:`process-flow-static@1`,label:`Process Flow Diagram (Static)`,description:`Static SVG process flow diagram for inline rendering`,inputSchema:tu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:gu}),Yl({id:`task-plan-static@1`,label:`Task Execution Plan (Static)`,description:`Static SVG task execution plan for inline rendering`,inputSchema:nu,injectId:`diagram-data`,supportedTransports:[`mcp-app`],resolveHtml:_u}),Yl({id:`task-plan@1`,label:`Task Execution Plan (Interactive)`,description:`Interactive task execution plan with ReactFlow, phase grouping, and dependency edges`,inputSchema:nu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:mu,transformData:e=>iu(`task-plan`,e)}),Yl({id:`process-flow@1`,label:`Process Flow Diagram (Interactive)`,description:`Interactive process flow diagram with ReactFlow`,inputSchema:tu,injectId:`diagram-data`,supportedTransports:[`browser`],resolveHtml:mu,transformData:e=>iu(`process-flow`,e)})}function yu(){let e=new zn;for(let t of Hn.list())e.register(t);return e.register(Vn),e.register(Kn),e.register(qn),e.register(Un),e}function bu(e,t){return e?.supportedTransports.includes(t)??!1}const xu=yu();function Su(e){if(e.template)return xu.get(e.template)}function Cu(e){if((e.actions?.length??0)>0)return!0;if(e.template&&Zl(e.template)){let t=Xl(e.template);return t?.supportedTransports.includes(`browser`)===!0&&!t.supportedTransports.includes(`mcp-app`)}let t=Su(e);return bu(t,`browser`)&&!bu(t,`mcp-app`)}vu();function wu(){let e;return()=>{if(e!==void 0)return e;try{e=c(a(import.meta.url).resolve(`mermaid/dist/mermaid.min.js`),`utf-8`)}catch{e=``}return e}}const Tu={id:`mermaid`,cdn:`https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js`,initScript:`window.__aikit_initMermaid = function() {
242
242
  if (typeof mermaid === 'undefined') return;
243
243
  if (document.readyState === 'loading') {
244
244
  document.addEventListener('DOMContentLoaded', window.__aikit_initMermaid);
@@ -34,7 +34,7 @@
34
34
  --dt-text-primary: #0f172a;
35
35
  --dt-text-secondary: #64748b;
36
36
  --dt-border: #e2e8f0;
37
- --dt-grid: #f1f5f9;
37
+ --dt-grid: rgba(148, 163, 184, 0.12);
38
38
  --dt-shadow: rgba(148, 163, 184, 0.24);
39
39
  --dt-toolbar-bg: rgba(255, 255, 255, 0.88);
40
40
  --dt-button-bg: rgba(248, 250, 252, 0.96);
@@ -52,7 +52,7 @@
52
52
  --dt-text-primary: #0f172a;
53
53
  --dt-text-secondary: #64748b;
54
54
  --dt-border: #e2e8f0;
55
- --dt-grid: #f1f5f9;
55
+ --dt-grid: rgba(148, 163, 184, 0.12);
56
56
  --dt-shadow: rgba(148, 163, 184, 0.24);
57
57
  --dt-toolbar-bg: rgba(255, 255, 255, 0.88);
58
58
  --dt-button-bg: rgba(248, 250, 252, 0.96);
@@ -149,7 +149,11 @@
149
149
  min-height: calc(100vh - 5.5rem);
150
150
  border: 1px solid var(--dt-border);
151
151
  border-radius: 24px;
152
- background: var(--dt-panel-bg);
152
+ background:
153
+ linear-gradient(var(--dt-grid) 1px, transparent 1px),
154
+ linear-gradient(90deg, var(--dt-grid) 1px, transparent 1px),
155
+ var(--dt-panel-bg);
156
+ background-size: 40px 40px, 40px 40px, 100% 100%;
153
157
  overflow: hidden;
154
158
  box-shadow: 0 24px 60px var(--dt-shadow);
155
159
  }
@@ -554,19 +558,6 @@
554
558
 
555
559
  function renderDefs() {
556
560
  const defs = node('defs');
557
- const pattern = node('pattern', {
558
- id: 'grid',
559
- width: 40,
560
- height: 40,
561
- patternUnits: 'userSpaceOnUse',
562
- });
563
- pattern.appendChild(node('path', {
564
- d: 'M 40 0 L 0 0 0 40',
565
- fill: 'none',
566
- stroke: cssValue('--dt-grid'),
567
- 'stroke-width': 1,
568
- }));
569
- defs.appendChild(pattern);
570
561
 
571
562
  const marker = node('marker', {
572
563
  id: 'arrow',
@@ -813,7 +804,6 @@
813
804
  svg.setAttribute('aria-label', (raw.title || 'Architecture diagram') + ' with ' + model.nodes.length + ' nodes');
814
805
 
815
806
  svg.appendChild(renderDefs());
816
- svg.appendChild(node('rect', { x: 0, y: 0, width, height, fill: 'url(#grid)' }));
817
807
 
818
808
  const title = node('title', { id: 'diagram-title' }, raw.title || 'Architecture diagram');
819
809
  const description = node('desc', { id: 'diagram-description' }, raw.description || 'Static architecture diagram rendered with SVG');
@@ -42,7 +42,7 @@
42
42
  --dt-text-primary: #0f172a;
43
43
  --dt-text-secondary: #64748b;
44
44
  --dt-border: #e2e8f0;
45
- --dt-grid: #f1f5f9;
45
+ --dt-grid: rgba(148, 163, 184, 0.12);
46
46
  --dt-shadow: rgba(148, 163, 184, 0.24);
47
47
  --dt-toolbar-bg: rgba(255, 255, 255, 0.88);
48
48
  --dt-button-bg: rgba(248, 250, 252, 0.96);
@@ -59,7 +59,7 @@
59
59
  --dt-text-primary: #0f172a;
60
60
  --dt-text-secondary: #64748b;
61
61
  --dt-border: #e2e8f0;
62
- --dt-grid: #f1f5f9;
62
+ --dt-grid: rgba(148, 163, 184, 0.12);
63
63
  --dt-shadow: rgba(148, 163, 184, 0.24);
64
64
  --dt-toolbar-bg: rgba(255, 255, 255, 0.88);
65
65
  --dt-button-bg: rgba(248, 250, 252, 0.96);
@@ -155,7 +155,11 @@
155
155
  min-height: calc(100vh - 5.5rem);
156
156
  border: 1px solid var(--dt-border);
157
157
  border-radius: 24px;
158
- background: var(--dt-panel-bg);
158
+ background:
159
+ linear-gradient(var(--dt-grid) 1px, transparent 1px),
160
+ linear-gradient(90deg, var(--dt-grid) 1px, transparent 1px),
161
+ var(--dt-panel-bg);
162
+ background-size: 40px 40px, 40px 40px, 100% 100%;
159
163
  overflow: hidden;
160
164
  box-shadow: 0 24px 60px var(--dt-shadow);
161
165
  }
@@ -163,8 +167,8 @@
163
167
  svg {
164
168
  display: block;
165
169
  width: 100%;
166
- height: min(78vh, 980px);
167
- min-height: 480px;
170
+ height: auto;
171
+ min-height: 600px;
168
172
  }
169
173
 
170
174
  .empty-state {
@@ -231,7 +235,7 @@
231
235
  }
232
236
 
233
237
  svg {
234
- min-height: 420px;
238
+ min-height: 500px;
235
239
  }
236
240
  }
237
241
  </style>
@@ -267,17 +271,17 @@
267
271
  const themeButton = document.getElementById('theme-button');
268
272
  const themes = ['auto', 'dark', 'light'];
269
273
  const monoFont = '"JetBrains Mono", "SFMono-Regular", Consolas, ui-monospace, monospace';
270
- const phaseGap = 260;
271
- const batchGap = 100;
272
- const taskGap = 80;
273
- const sequentialTaskGap = 112;
274
- const taskWidth = 200;
275
- const taskHeight = 72;
276
- const phaseHeaderHeight = 60;
277
- const canvasPadding = 64;
278
- const phasePaddingX = 28;
279
- const phasePaddingBottom = 34;
280
- const batchLabelHeight = 26;
274
+ const phaseGap = 300;
275
+ const batchGap = 120;
276
+ const taskGap = 100;
277
+ const sequentialTaskGap = 140;
278
+ const taskWidth = 260;
279
+ const taskHeight = 88;
280
+ const phaseHeaderHeight = 72;
281
+ const canvasPadding = 80;
282
+ const phasePaddingX = 36;
283
+ const phasePaddingBottom = 44;
284
+ const batchLabelHeight = 32;
281
285
  const phasePalette = [
282
286
  '--dt-cyan',
283
287
  '--tp-indigo',
@@ -527,9 +531,9 @@
527
531
  }
528
532
 
529
533
  function measureTask(task) {
530
- const titleLines = wrapText(task.title || task.id, 22, 2);
531
- const agentLines = wrapText(task.agent || 'Unassigned', 18, 1);
532
- const height = taskHeight + Math.max(0, titleLines.length - 1) * 18;
534
+ const titleLines = wrapText(task.title || task.id, 28, 2);
535
+ const agentLines = wrapText(task.agent || 'Unassigned', 24, 1);
536
+ const height = taskHeight + Math.max(0, titleLines.length - 1) * 20;
533
537
  return {
534
538
  width: taskWidth,
535
539
  height,
@@ -575,59 +579,61 @@
575
579
  function layout(model) {
576
580
  const phaseLayouts = [];
577
581
  const taskBoxes = new Map();
578
- let currentX = canvasPadding;
579
- let maxBottom = 0;
582
+ let currentY = canvasPadding;
583
+ let maxWidth = 0;
580
584
 
581
585
  model.phases.forEach((phase, phaseIndex) => {
582
- const phaseX = currentX;
583
- const phaseY = canvasPadding;
584
- let batchX = phaseX + phasePaddingX;
585
- let batchY = phaseY + phaseHeaderHeight + 18;
586
+ const phaseX = canvasPadding;
587
+ const phaseY = currentY;
588
+ let batchCursorX = phaseX + phasePaddingX;
589
+ const batchBaseY = phaseY + phaseHeaderHeight + 18;
586
590
  let rightEdge = phaseX + 320;
591
+ let maxBatchBottom = batchBaseY;
587
592
  const batchLayouts = [];
588
593
 
589
594
  phase.batches.forEach((batch) => {
590
- const batchLayout = layoutBatch(batch, batchX, batchY);
595
+ const batchLayout = layoutBatch(batch, batchCursorX, batchBaseY);
591
596
  batchLayout.boxes.forEach((box) => {
592
597
  taskBoxes.set(box.task.id, box);
593
598
  });
594
599
  batchLayouts.push({
595
600
  batch,
596
- x: batchX,
597
- y: batchY,
601
+ x: batchCursorX,
602
+ y: batchBaseY,
598
603
  width: batchLayout.width,
599
604
  height: batchLayout.height,
600
605
  boxes: batchLayout.boxes,
601
606
  });
602
- rightEdge = Math.max(rightEdge, batchX + batchLayout.width + phasePaddingX);
603
- batchY += batchLayout.height + batchGap;
604
- batchX += Math.max(taskWidth, batchLayout.width) + 108;
607
+ rightEdge = Math.max(rightEdge, batchCursorX + batchLayout.width + phasePaddingX);
608
+ maxBatchBottom = Math.max(maxBatchBottom, batchBaseY + batchLayout.height);
609
+ batchCursorX += Math.max(taskWidth, batchLayout.width) + batchGap;
605
610
  });
606
611
 
612
+ const phaseWidth = Math.max(600, rightEdge - phaseX);
607
613
  const phaseHeight = Math.max(
608
614
  phaseHeaderHeight + 120,
609
- batchY - phaseY - batchGap + phasePaddingBottom,
615
+ maxBatchBottom - phaseY + phasePaddingBottom,
610
616
  );
611
617
 
612
618
  phaseLayouts.push({
613
619
  phase,
614
620
  x: phaseX,
615
621
  y: phaseY,
616
- width: Math.max(360, rightEdge - phaseX),
622
+ width: phaseWidth,
617
623
  height: phaseHeight,
618
624
  color: phaseColor(phaseIndex),
619
625
  batches: batchLayouts,
620
626
  });
621
627
 
622
- currentX += Math.max(360, rightEdge - phaseX) + phaseGap;
623
- maxBottom = Math.max(maxBottom, phaseY + phaseHeight);
628
+ maxWidth = Math.max(maxWidth, phaseX + phaseWidth + canvasPadding);
629
+ currentY += phaseHeight + phaseGap;
624
630
  });
625
631
 
626
632
  return {
627
633
  phases: phaseLayouts,
628
634
  taskBoxes,
629
- width: Math.max(1160, currentX - phaseGap + canvasPadding),
630
- height: Math.max(700, maxBottom + canvasPadding),
635
+ width: Math.max(1200, maxWidth),
636
+ height: Math.max(600, currentY - phaseGap + canvasPadding),
631
637
  };
632
638
  }
633
639
 
@@ -659,20 +665,6 @@
659
665
  function renderDefs() {
660
666
  const defs = node('defs');
661
667
 
662
- const pattern = node('pattern', {
663
- id: 'grid',
664
- width: 40,
665
- height: 40,
666
- patternUnits: 'userSpaceOnUse',
667
- });
668
- pattern.appendChild(node('path', {
669
- d: 'M 40 0 L 0 0 0 40',
670
- fill: 'none',
671
- stroke: cssValue('--dt-grid'),
672
- 'stroke-width': 1,
673
- }));
674
- defs.appendChild(pattern);
675
-
676
668
  const marker = node('marker', {
677
669
  id: 'arrow',
678
670
  viewBox: '0 0 10 10',
@@ -1018,9 +1010,9 @@
1018
1010
  const layoutResult = layout(model);
1019
1011
  svg.innerHTML = '';
1020
1012
  svg.setAttribute('viewBox', '0 0 ' + layoutResult.width + ' ' + layoutResult.height);
1013
+ svg.style.height = layoutResult.height + 'px';
1021
1014
  svg.setAttribute('aria-label', model.title + ' with ' + totalTasks + ' tasks');
1022
1015
  svg.appendChild(renderDefs());
1023
- svg.appendChild(node('rect', { x: 0, y: 0, width: layoutResult.width, height: layoutResult.height, fill: 'url(#grid)' }));
1024
1016
  svg.appendChild(node('title', { id: 'diagram-title' }, model.title || 'Task execution plan'));
1025
1017
  svg.appendChild(node('desc', { id: 'diagram-description' }, model.description || 'Static task execution plan rendered with SVG'));
1026
1018