module.exports=[45919,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let n=r.default.join(process.cwd(),"data","org-skills"),i=r.default.join(process.cwd(),"data","org","skill-assignments.json"),a=/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;function l(e){let t=e.match(a);if(!t)return{fm:{},body:e};let r={};for(let e of t[1].split("\n")){let t=e.match(/^([a-zA-Z_]+):\s*(.+)$/);if(!t)continue;let n=t[1],i=t[2].trim();if(i.startsWith("[")&&i.endsWith("]")){let e=i.slice(1,-1).trim();r[n]=e?e.split(",").map(e=>e.trim().replace(/^['"]|['"]$/g,"")):[];continue}r[n]=i.replace(/^['"]|['"]$/g,"")}return{fm:r,body:t[2]?.trim()??""}}function o(e){let i=r.default.join(n,c(e),"SKILL.md");try{let r=t.default.readFileSync(i,"utf8"),{fm:n,body:a}=l(r);return{id:f(n.id)||e,label:f(n.label)||e,description:f(n.description),triggers:m(n.triggers),body:a}}catch{return null}}function s(){try{return t.default.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>o(e.name)).filter(e=>!!e).sort((e,t)=>e.label.localeCompare(t.label))}catch{return[]}}function u(e){var i;let a=c(e.id.trim().toLowerCase());if(!a)throw Error("skill id is required");let l={id:a,label:e.label.trim()||a,description:e.description.trim(),triggers:e.triggers.map(e=>e.trim()).filter(Boolean),body:e.body.trim()},o=r.default.join(n,a);return t.default.mkdirSync(o,{recursive:!0}),t.default.writeFileSync(r.default.join(o,"SKILL.md"),(i=l,`---
id: ${i.id}
label: ${i.label}
description: ${i.description}
triggers: [${i.triggers.join(", ")}]
---

${i.body.replace(/\s+$/,"")}
`),"utf8"),l}function d(e){return e.replace(/\.md$/i,"").replace(/^skill$/i,"").replace(/[-_]+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())}function c(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_")}function f(e){return"string"==typeof e?e:""}function m(e){return Array.isArray(e)?e:"string"==typeof e&&e?[e]:[]}function p(e){return new Set((e.toLowerCase().match(/[\p{L}\p{N}_-]{2,}/gu)??[]).filter(e=>!g.has(e)))}let g=new Set(["the","and","for","that","this","with","you","are","was","were","what","how","של","על","עם","את","זה","מה","איך"]);function h(){try{return JSON.parse(t.default.readFileSync(i,"utf8"))}catch{return{}}}e.s(["formatOrgSkillsBlock",0,function(e){if(0===e.length)return"";let t=e.map(({skill:e})=>`## ${e.label} (${e.id})

${e.body}`).join("\n\n---\n\n");return`# Relevant organization skills

These are organization-level playbooks assigned to this employee. Use them to
shape how work is performed. They do not override hard boundaries, approval
policy, or the employee's profile files.

${t}`},"getAssignedOrgSkillIdsForEmployee",0,function(e,t=[]){return h()[e]??t},"importOrgSkillMarkdown",0,function(e){let t,{fm:r,body:n}=l(e.content),i=(t=n.match(/^#\s+(.+)$/m),t?.[1]?.trim()??""),a=f(r.label)||d(f(r.name))||i||d(e.filename.replace(/\.md$/i,"")),o=f(r.id)||f(r.name)||a||e.filename.replace(/\.md$/i,""),s=f(r.description),c=m(r.triggers).length>0?m(r.triggers):function(...e){return Array.from(new Set(e.join(" ").toLowerCase().match(/[\p{L}\p{N}_-]{3,}/gu)??[])).filter(e=>!g.has(e)).slice(0,8)}(o,a,s);return u({id:o,label:a,description:s,triggers:c,body:n.trim()||e.content.trim()})},"listOrgSkills",0,s,"readOrgSkill",0,o,"selectOrgSkillsForRun",0,function(e,t,r=3){var n;let i=(n=e,h()[n.id]??n.orgSkillIds).map(o).filter(e=>!!e);if(0===i.length)return[];let a=i.map(e=>({skill:e,score:function(e,t){let r=p(t);if(0===r.size)return 0;let n=0,i=p([e.id,e.label,e.description,e.triggers.join(" ")].join(" ").toLowerCase());for(let e of r)i.has(e)&&(n+=1);for(let r of e.triggers)t.toLowerCase().includes(r.toLowerCase())&&(n+=2);return n}(e,t)})).sort((e,t)=>t.score-e.score),l=a.filter(e=>e.score>0);return(l.length>0?l:a).slice(0,r)},"setAssignedOrgSkillIds",0,function(e,n){var a;let l=new Set(s().map(e=>e.id)),o=Array.from(new Set(n.map(e=>c(e)).filter(e=>l.has(e)))),u=h();return u[e]=o,a=u,t.default.mkdirSync(r.default.dirname(i),{recursive:!0}),t.default.writeFileSync(i,JSON.stringify(a,null,2),"utf8"),o},"writeOrgSkill",0,u])},13427,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let n=r.default.join(process.cwd(),"data","org-brain"),i=r.default.join(n,"nodes"),a=/^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/,l=/\[\[([a-zA-Z0-9_-]+)(?:#[^\]|]+)?(?:\|[^\]]+)?\]\]/g,o=["document","decision","incident","policy","customer","product","process","note"];function s(e){return e.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function u(e){return"string"==typeof e?e:""}function d(e){return Array.isArray(e)?e:"string"==typeof e&&e?[e]:[]}function c(e){let t=e.toLowerCase();return o.includes(t)?t:"note"}function f(e){let n=s(e),o=r.default.join(i,`${n}.md`);try{let e=t.default.readFileSync(o,"utf8"),{fm:r,body:i}=function(e){let t=e.match(a);if(!t)return{fm:{},body:e};let r={};for(let e of t[1].split("\n")){let t=e.match(/^([a-zA-Z_]+):\s*(.+)$/);if(!t)continue;let n=t[1],i=t[2].trim();if(i.startsWith("[")&&i.endsWith("]")){let e=i.slice(1,-1).trim();r[n]=e?e.split(",").map(e=>e.trim().replace(/^['"]|['"]$/g,"")):[];continue}r[n]=i.replace(/^['"]|['"]$/g,"")}return{fm:r,body:t[2]?.trim()??""}}(e),s=d(r.linked_nodes),f=function(e){let t=new Set;for(let r of e.matchAll(l))t.add(r[1]);return Array.from(t)}(i),m=Array.from(new Set([...s,...f]));return{slug:u(r.slug)||n,label:u(r.label)||n,type:c(u(r.type)||"note"),description:u(r.description),triggers:d(r.triggers),sources:d(r.sources),linkedNodes:m,lastUpdated:u(r.last_updated),body:i}}catch{return null}}function m(){try{return t.default.readdirSync(i,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".md")).map(e=>f(e.name.replace(/\.md$/,""))).filter(e=>!!e).sort((e,t)=>e.label.localeCompare(t.label))}catch{return[]}}let p=new Set(["the","and","for","that","this","with","you","are","was","were","what","how","who","why","when","from","can","our","your","של","על","עם","את","זה","מה","איך","מי","למה","מתי"]);function g(e){return new Set((e.toLowerCase().match(/[\p{L}\p{N}_-]{2,}/gu)??[]).filter(e=>!p.has(e)))}e.s(["deleteOrgBrainNode",0,function(e){let n=s(e),a=r.default.join(i,`${n}.md`);try{return t.default.unlinkSync(a),!0}catch{return!1}},"formatOrgBrainBlock",0,function(e){if(0===e.length)return"";let t=e.map(({node:e})=>{let t=[e.type?`type: ${e.type}`:"",e.sources.length?`sources: ${e.sources.join(", ")}`:"",e.lastUpdated?`updated: ${e.lastUpdated.slice(0,10)}`:""].filter(Boolean).join(" · ");return`## ${e.label} \`[[${e.slug}]]\`
${t?`_${t}_
`:""}
${e.body}`}).join("\n\n---\n\n");return`# Relevant company knowledge (Org Brain)

These are organization-wide facts and documents — shared across every twin in
the company. Treat them as ground truth about the company itself (decisions,
policies, customers, incidents, products). They do NOT override your personal
profile, hard boundaries, or the user's direction.

${t}`},"listOrgBrainNodes",0,m,"readOrgBrainNode",0,f,"selectOrgBrainNodesForRun",0,function(e,t=4){let r=m();if(0===r.length)return[];let n=r.map(t=>({node:t,score:function(e,t){let r=g(t);if(0===r.size)return 0;let n=0,i=g([e.slug,e.label,e.description,e.triggers.join(" ")].join(" ").toLowerCase());for(let e of r)i.has(e)&&(n+=1);for(let r of e.triggers)r&&t.toLowerCase().includes(r.toLowerCase())&&(n+=3);return e.label.length>=4&&t.toLowerCase().includes(e.label.toLowerCase())&&(n+=2),n}(t,e)})).sort((e,t)=>t.score-e.score).filter(e=>e.score>0);return 0===n.length?[]:n.slice(0,t)},"writeOrgBrainNode",0,function(e){var n;let a=s(e.slug);if(!a)throw Error("node slug is required");let l={slug:a,label:e.label.trim()||a,type:c(e.type??"note"),description:(e.description??"").trim(),triggers:(e.triggers??[]).map(e=>e.trim()).filter(Boolean),sources:(e.sources??[]).map(e=>e.trim()).filter(Boolean),linkedNodes:(e.linkedNodes??[]).map(e=>s(e)).filter(Boolean),lastUpdated:new Date().toISOString(),body:e.body.trim()};return t.default.mkdirSync(i,{recursive:!0}),t.default.writeFileSync(r.default.join(i,`${a}.md`),(n=l,`---
slug: ${n.slug}
label: ${n.label}
type: ${n.type}
description: ${n.description}
triggers: [${n.triggers.join(", ")}]
sources: [${n.sources.join(", ")}]
linked_nodes: [${n.linkedNodes.join(", ")}]
last_updated: ${n.lastUpdated}
---

${n.body.replace(/\s+$/,"")}
`),"utf8"),l}])},81040,e=>{"use strict";var t=e.i(22734),r=e.i(14747);let n=new Map,i=r.default.join(process.cwd(),"data","meetings"),a=!1;1;a=!0;try{t.default.existsSync(i)&&t.default.rmSync(i,{recursive:!0,force:!0})}catch(e){console.warn("[meeting-store] cold-start wipe failed:",e)}function l(e){let t=r.default.basename(e||"").trim().replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[._-]+|[._-]+$/g,"");return t?t.slice(0,120):"file"}let o={".csv":"text/csv",".json":"application/json",".md":"text/markdown",".txt":"text/plain",".html":"text/html",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".tsv":"text/tab-separated-values"};function s(e){return r.default.join(i,e,"shared")}e.s(["SHARED_FILE_MAX_BYTES",0,0x1900000,"appendTurn",0,function(e,t){let r=n.get(e);r&&(r.transcript.push(t),r.updatedAt=Date.now())},"getMeeting",0,function(e){return n.get(e)},"getOrCreateMeeting",0,function(e,t){let r,i;if(e){let t=n.get(e);if(t)return t}return r=Date.now(),i={id:`mtg_${r}_${Math.random().toString(36).slice(2,8)}`,participantIds:t,transcript:[],sharedFiles:[],createdAt:r,updatedAt:r},n.set(i.id,i),i},"listSharedFiles",0,function(e){return n.get(e)?.sharedFiles??[]},"readSharedFile",0,function(e,i){let a=n.get(e);if(!a)return{status:"not_found"};let o=l(i),u=a.sharedFiles.find(e=>e.filename===o);if(!u)return{status:"not_found"};if("text"!==u.kind)return{status:"binary",entry:u};try{let n=r.default.join(s(e),u.filename),i=t.default.readFileSync(n,"utf8");return{status:"text",content:i,entry:u}}catch{return{status:"not_found"}}},"readSharedFileBytes",0,function(e,i){let a=n.get(e);if(!a)return{found:!1};let o=l(i),u=a.sharedFiles.find(e=>e.filename===o);if(!u)return{found:!1};try{let n=r.default.join(s(e),u.filename),i=t.default.readFileSync(n);return{found:!0,bytes:i,entry:u}}catch{return{found:!1}}},"recordSharedFile",0,function(e,i){let a=n.get(e);if(!a)throw Error(`meeting ${e} not found`);let u="image"===i.kind,d=u?i.bytes.length:Buffer.byteLength(i.content,"utf8");if(d>0x1900000)throw Error(`file is ${d} bytes, exceeds 26214400-byte limit`);let c=function(e,t){let i=n.get(e),a=new Set((i?.sharedFiles??[]).map(e=>e.filename));if(!a.has(t))return t;let l=r.default.extname(t),o=t.slice(0,t.length-l.length);for(let e=2;e<1e3;e++){let t=`${o}_${e}${l}`;if(!a.has(t))return t}return`${o}_${Date.now()}${l}`}(e,l(i.filename)),f=s(e);t.default.mkdirSync(f,{recursive:!0});let m=r.default.join(f,c);u?t.default.writeFileSync(m,i.bytes):t.default.writeFileSync(m,i.content,"utf8");let p={id:`sf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,filename:c,summary:i.summary.trim(),sharedById:i.sharedById,sharedByName:i.sharedByName,sharedAt:Date.now(),sizeBytes:d,contentType:u?i.contentType:o[r.default.extname(c).toLowerCase()]??"text/plain",kind:u?"image":"text"};return a.sharedFiles.push(p),a.updatedAt=Date.now(),p},"renderSharedFilesForPrompt",0,function(e){return 0===e.length?"":e.map(e=>{let t=Math.max(0,Math.floor((Date.now()-e.sharedAt)/1e3)),r=t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)} min ago`:`${Math.floor(t/3600)} h ago`,n=Math.max(1,Math.round(e.sizeBytes/1024)),i="image"===e.kind?`image, ${e.contentType} — visible to the CEO in the chat; you cannot read its bytes`:"text — readable via read_meeting_file";return`- \`${e.filename}\` — ${e.summary}
  (shared by ${e.sharedByName}, ${r}, ${n} KB, ${i})`}).join("\n")},"renderTranscriptForPrompt",0,function(e){return 0===e.length?"(meeting just started — no prior turns)":e.map(e=>"ceo"===e.kind?`CEO: ${e.text}`:`${e.employeeName}${e.delegatedFromName?` (called in by ${e.delegatedFromName})`:""}: ${e.text}`).join("\n\n")}])},11540,e=>{"use strict";let t=new Map,r=0;if("u">typeof globalThis){let e=globalThis;e.__approvalSweep||(e.__approvalSweep=setInterval(()=>{let e=Date.now();for(let[r,n]of t.entries())e-n.request.createdAt>6e5&&(t.delete(r),n.resolve({action:"deny",message:"Approval timed out — no human response within 10 minutes."}))},6e4))}e.s(["listPendingApprovals",0,function(e){let r=Array.from(t.values()).map(e=>e.request);return e?.surface?r.filter(t=>t.surface===e.surface):r},"registerApproval",0,function(e){let n,i=(r++,`apr_${Date.now().toString(36)}_${r}`),a=new Promise(e=>{n=e});return t.set(i,{request:{...e,surface:e.surface??"chat",approvalId:i,createdAt:Date.now()},resolve:n}),{approvalId:i,promise:a}},"resolveApproval",0,function(e,r){let n=t.get(e);return!!n&&(t.delete(e),n.resolve(r),!0)}])},88947,(e,t,r)=>{t.exports=e.x("stream",()=>require("stream"))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0o6mut~._.js.map