@inkeep/open-knowledge 0.77.0-beta.4 → 0.77.0

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.
Files changed (39) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-39tdKa_g.mjs +1 -0
  3. package/dist/index.mjs +1 -1
  4. package/dist/init-Cpn1GbxG.mjs +1 -0
  5. package/dist/{init-Cuw6M3ez.mjs → init-Ph4Fpm4I.mjs} +2 -2
  6. package/dist/{launch-json-removal-CX0BxrBg.mjs → launch-json-removal-vxRM0QmE.mjs} +1 -1
  7. package/dist/loader-BQ-GQCW6.mjs +1 -0
  8. package/dist/{loader-DDluoWkF.mjs → loader-BhmX8i0i.mjs} +1 -1
  9. package/dist/preview-BjKaOkAI.mjs +1 -0
  10. package/dist/{preview-ZhG30yAN.mjs → preview-QAut6Bq_.mjs} +1 -1
  11. package/dist/public/assets/FeedbackForm-BgBv8L6L.js +1 -0
  12. package/dist/public/assets/{SessionsHost-CxAK4Xfa.js → SessionsHost-BqMXhrkE.js} +2 -2
  13. package/dist/public/assets/{TerminalWindowApp-B5c2WpBb.js → TerminalWindowApp-DPNQngga.js} +1 -1
  14. package/dist/public/assets/{ThreadView-dTldxmzz.js → ThreadView-CW2Mu5K7.js} +1 -1
  15. package/dist/public/assets/{globals-BEhdRa7F.css → globals-7nCZAq2S.css} +1 -1
  16. package/dist/public/assets/{index-B_8dBtGF.js → index-fqaD_llj.js} +5 -5
  17. package/dist/public/assets/preferred-session-events-IPaSpBGU.js +1 -0
  18. package/dist/public/assets/{progress-Cn9au8tg.js → progress-Du7pDICl.js} +1 -1
  19. package/dist/public/assets/{uninstall-CcaUy8Sj.js → uninstall-DCh_yZKQ.js} +1 -1
  20. package/dist/public/index.html +5 -5
  21. package/dist/public/uninstall.html +3 -3
  22. package/dist/{registry-probes-CpizlLKe.mjs → registry-probes-Dg6Rlguw.mjs} +1 -1
  23. package/dist/{removal-file-path-DlMMvvl3.mjs → removal-file-path-CLaLzDEp.mjs} +1 -1
  24. package/dist/{repair-launch-json-irGbbbq_.mjs → repair-launch-json-CbwNg2jY.mjs} +1 -1
  25. package/dist/{repair-mcp-configs-ooUrwLkV.mjs → repair-mcp-configs-Gjm7_lnK.mjs} +1 -1
  26. package/dist/{src-C7TYDpda.mjs → src-Cb_QH2h4.mjs} +1 -1
  27. package/dist/src-n4yFU_CJ.mjs +1 -0
  28. package/dist/start-CvrXNS2z.mjs +1 -0
  29. package/dist/{start-Dd8Kjf4r.mjs → start-kpsB4vCt.mjs} +2 -2
  30. package/package.json +4 -4
  31. package/dist/constants-CmQdCHUX.mjs +0 -1
  32. package/dist/init-DgSN-Zb-.mjs +0 -1
  33. package/dist/loader-BTYq6qei.mjs +0 -1
  34. package/dist/preview-B_YbsrcL.mjs +0 -1
  35. package/dist/public/assets/FeedbackForm-D5uyPeTD.js +0 -1
  36. package/dist/public/assets/preferred-session-events-BH6Z6Mzm.js +0 -1
  37. package/dist/src-D4Ieb2-e.mjs +0 -1
  38. package/dist/start-UUHoS8aS.mjs +0 -1
  39. /package/dist/public/assets/{globals-buvkHKE-.js → globals-D1RUz7O8.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Es as t,Gc as n,Hd as r,Ls as i,Mn as a,Nn as o,To as s,Vn as c,Wc as l,ju as u,qc as d,xc as ee}from"./md-manager-BGnqyqi1-DKflYxqj.mjs";import{Ao as f,Jn as te,Qn as p,Rn as m,Tt as h,Ur as g,Yr as _,bi as v,dr as y,ea as b,jo as x,ko as S,m as C,ni as w,ri as T,ro as E,ti as D,yi as O}from"./dist-C9m6GTCy.mjs";import{t as k}from"./yazl-BBz29IQN.mjs";import{St as A,at as j,ot as M}from"./init-Cuw6M3ez.mjs";import{b as N,l as ne}from"./registry-probes-CpizlLKe.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as re}from"./constants-CmQdCHUX.mjs";import"./loader-DDluoWkF.mjs";import"./preview-ZhG30yAN.mjs";import{execSync as ie,spawnSync as I}from"node:child_process";import{basename as L,dirname as R,isAbsolute as ae,join as z,relative as oe,resolve as B,sep as V}from"node:path";import{closeSync as se,cpSync as ce,createWriteStream as le,existsSync as H,lstatSync as ue,mkdirSync as U,mkdtempSync as de,openSync as fe,readFileSync as W,readSync as pe,readdirSync as G,rmSync as K,rmdirSync as me,statSync as he,writeFileSync as q}from"node:fs";import{arch as ge,freemem as _e,homedir as J,hostname as ve,platform as ye,release as be,tmpdir as xe,totalmem as Se,type as Ce,uptime as we}from"node:os";import"node:fs/promises";import{createHash as Te}from"node:crypto";const Ee=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function De(e,t,n=p){if(e!==void 0&&!Ee.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Oe=null;function ke(e){Oe=e}function Ae(){return Oe??process.cwd()}const je=`Open Knowledge`;function Me(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return j(t).join(M({...e,platformName:t}),n)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=j(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`@inkeepopen-knowledge-desktop-updater`)}function Pe(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function Fe(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Pe(n)??[]}function Ie(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Pe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Le=8192;function Re(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Be=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Ve(e){return e.replace(Be,`$1"[REDACTED-DEVICE-ID]"`)}function He(e){return Ve(ze(e))}const Ue=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function We(e){if(typeof e!=`string`)return null;let t=Ue.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Ge(e){let t=fe(e,`r`);try{let e=Buffer.alloc(Le),n=0,r=!1;for(;n<Le;){let i=pe(t,e,n,Le-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{se(t)}}function Ke(e){try{let t=Ge(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:We(a)}}catch{return{kind:`unreadable`}}}function qe(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Je(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=he(n).mtimeMs}catch{continue}if(r<i)continue;let c=Ke(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!qe(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function Y(){return z(J(),`.ok`,`bug-reports`)}function Ye(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function Xe(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?Te(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function Ze(){let e={timestamp:new Date().toISOString(),platform:ye(),osType:Ce(),osRelease:be(),hostname:`[redacted]`,uptime:we(),freeMem:_e(),totalMem:Se(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,E({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const Qe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function $e(e){let t=L(e);return Qe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function et(e,t){return it(e,t).files}const tt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function nt(e,t=ne){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return tt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>z(n,e.entry)))}function rt(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-a.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function it(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter($e),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!$e(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function at(e){let t=z(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,l].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function ot(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function st(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Te(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function ct(e){let n=e.revealDocNames?e.content:st(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=t(n);e.zipfile.addBuffer(Buffer.from(r,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}else e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);ct({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?He(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function lt(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,s=t.userLogsDir??z(J(),`.ok`,`logs`),l=t.projectDir?Xe(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:l},`gathering diagnostic data`);let u=Ze();u.desktop=t.desktop??null,u.language=t.language??null;let{files:d,excludedByProjectSlug:ee}=it(l,s),{files:f}=t.projectDir?at(t.projectDir):{files:[]},{files:te}=t.projectDir?ot(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:ee,lockFileCount:f.length,localSinkFileCount:te.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...d,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:f,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:te,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:o,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;v.addBuffer(t,n),g.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ct({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${L(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Re(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${L(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${o}/${L(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!$e(e)&&!T.has(e)):[],A=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...k.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...O.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${c.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
1
+ import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Es as t,Gc as n,Hd as r,Ls as i,Mn as a,Nn as o,To as s,Vn as c,Wc as l,ju as u,qc as d,xc as ee}from"./md-manager-BGnqyqi1-DKflYxqj.mjs";import{Ao as f,Jn as te,Qn as p,Rn as m,Tt as h,Ur as g,Yr as _,bi as v,dr as y,ea as b,jo as x,ko as S,m as C,ni as w,ri as T,ro as E,ti as D,yi as O}from"./dist-C9m6GTCy.mjs";import{t as k}from"./yazl-BBz29IQN.mjs";import{St as A,at as j,ot as M}from"./init-Ph4Fpm4I.mjs";import{b as N,l as ne}from"./registry-probes-Dg6Rlguw.mjs";import{c as P}from"./colors-r_owlCuY.mjs";import{t as F}from"./is-object-BGze3w87.mjs";import{n as re}from"./constants-39tdKa_g.mjs";import"./loader-BhmX8i0i.mjs";import"./preview-QAut6Bq_.mjs";import{execSync as ie,spawnSync as I}from"node:child_process";import{basename as L,dirname as R,isAbsolute as ae,join as z,relative as oe,resolve as B,sep as V}from"node:path";import{closeSync as se,cpSync as ce,createWriteStream as le,existsSync as H,lstatSync as ue,mkdirSync as U,mkdtempSync as de,openSync as fe,readFileSync as W,readSync as pe,readdirSync as G,rmSync as K,rmdirSync as me,statSync as he,writeFileSync as q}from"node:fs";import{arch as ge,freemem as _e,homedir as J,hostname as ve,platform as ye,release as be,tmpdir as xe,totalmem as Se,type as Ce,uptime as we}from"node:os";import"node:fs/promises";import{createHash as Te}from"node:crypto";const Ee=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function De(e,t,n=p){if(e!==void 0&&!Ee.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Oe=null;function ke(e){Oe=e}function Ae(){return Oe??process.cwd()}const je=`Open Knowledge`;function Me(e={}){let t=e.platformName??process.platform,n=e.productName??`OpenKnowledge`;return j(t).join(M({...e,platformName:t}),n)}function Ne(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=j(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`@inkeepopen-knowledge-desktop-updater`)}function Pe(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function Fe(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Pe(n)??[]}function Ie(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Pe(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Le=8192;function Re(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Be=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Ve(e){return e.replace(Be,`$1"[REDACTED-DEVICE-ID]"`)}function He(e){return Ve(ze(e))}const Ue=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function We(e){if(typeof e!=`string`)return null;let t=Ue.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function Ge(e){let t=fe(e,`r`);try{let e=Buffer.alloc(Le),n=0,r=!1;for(;n<Le;){let i=pe(t,e,n,Le-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{se(t)}}function Ke(e){try{let t=Ge(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:We(a)}}catch{return{kind:`unreadable`}}}function qe(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Je(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=he(n).mtimeMs}catch{continue}if(r<i)continue;let c=Ke(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!qe(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function Y(){return z(J(),`.ok`,`bug-reports`)}function Ye(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function Xe(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?Te(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function Ze(){let e={timestamp:new Date().toISOString(),platform:ye(),osType:Ce(),osRelease:be(),hostname:`[redacted]`,uptime:we(),freeMem:_e(),totalMem:Se(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ie(`sw_vers -productVersion 2>/dev/null`,E({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const Qe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function $e(e){let t=L(e);return Qe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function et(e,t){return it(e,t).files}const tt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function nt(e,t=ne){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return tt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>z(n,e.entry)))}function rt(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-a.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function it(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter($e),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!$e(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function at(e){let t=z(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,`last-spawn-error.log`,l].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function ot(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function st(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Te(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function ct(e){let n=e.revealDocNames?e.content:st(e.content).text;if(e.redact){let{redacted:r,patterns:i,lineCount:a}=t(n);e.zipfile.addBuffer(Buffer.from(r,`utf8`),e.name),e.bundleFiles.push(e.name),i.length>0&&e.redactions.push({file:e.name,lineCount:a,patterns:i})}else e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name)}function X(e){for(let t of e.files)try{let n=W(t,`utf8`);ct({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?He(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function lt(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,s=t.userLogsDir??z(J(),`.ok`,`logs`),l=t.projectDir?Xe(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:l},`gathering diagnostic data`);let u=Ze();u.desktop=t.desktop??null,u.language=t.language??null;let{files:d,excludedByProjectSlug:ee}=it(l,s),{files:f}=t.projectDir?at(t.projectDir):{files:[]},{files:te}=t.projectDir?ot(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:ee,lockFileCount:f.length,localSinkFileCount:te.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...d,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:f,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:te,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:o,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;v.addBuffer(t,n),g.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&ct({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${L(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Re(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let S=JSON.stringify(u,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:l,files:g,redactions:h,sysinfo:u};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${L(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${o}/${L(e)}`)),O=g.filter(e=>D.has(e)),k=l?g.filter(e=>e.startsWith(`logs/`)&&!$e(e)&&!T.has(e)):[],A=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],j=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],M=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${l??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...k.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...O.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${c.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:j].join(`
2
2
  `);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=le(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:l,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var ut=u(),dt=e(k(),1),Z=e(P(),1);function ft(e){let t=x(`user`,e,e);return S({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function pt({home:e=J(),env:t=process.env}={}){let n=ft(e),{override:r,preferenceList:a}=f(t),{locale:o,source:s}=i({override:r,storedPreference:n,supportedLocales:d,preferenceList:a,autoDetectableLocales:ee});return{preference:n,locale:o,source:s,systemLanguages:a}}function mt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function ht(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function gt(e,t){if(typeof e==`string`)return mt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>gt(e,t));if(!ht(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=gt(i,t);return n}function _t(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
3
  `),i=n.split(`
4
4
  `),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=gt(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
@@ -0,0 +1 @@
1
+ import"./md-manager-BGnqyqi1-DKflYxqj.mjs";import"./init-Ph4Fpm4I.mjs";import"./registry-probes-Dg6Rlguw.mjs";import"./src-Cb_QH2h4.mjs";import"./start-kpsB4vCt.mjs";import{n as e}from"./loader-BhmX8i0i.mjs";import"./preview-QAut6Bq_.mjs";import"./cli.mjs";import"./repair-mcp-configs-Gjm7_lnK.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{S as e,m as t,p as n,r}from"./start-kpsB4vCt.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
@@ -1,5 +1,5 @@
1
- import{Fc as e,Fs as t,Hu as n,Md as r,No as i,Rs as a,_t as o,da as s}from"./md-manager-BGnqyqi1-DKflYxqj.mjs";import{Ho as c,Wr as ee,ai as l,jo as u,k as d,ko as f,ti as p,vi as m}from"./dist-C9m6GTCy.mjs";import{Ct as h,I as g,R as _,St as v,Y as y,b,lt as x,wt as S,y as C}from"./init-Cuw6M3ez.mjs";import{a as w,c as T,d as E,f as D,i as te,n as O,o as k,p as A,r as j,s as M,t as ne,u as N,v as P}from"./registry-probes-CpizlLKe.mjs";import{n as re}from"./constants-CmQdCHUX.mjs";import{execFileSync as F,spawn as I}from"node:child_process";import{basename as L,dirname as R,join as ie,resolve as z}from"node:path";import{existsSync as B,realpathSync as ae}from"node:fs";import{homedir as oe,tmpdir as se}from"node:os";import{rm as ce}from"node:fs/promises";import{setTimeout as le}from"node:timers/promises";const ue=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],de={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function V(e,t={}){let{login:n}=t,r=t._exec??F,i=H(t._fileExists??B),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...ue.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,de).toString().trim();if(t.length>0)return t}catch{}}function fe(e,t={}){let n=t._exec??F,r=H(t._fileExists??B),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=pe(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=ve(o);if(e.length>0)return e}}function W(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function pe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=W(W(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=W(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const me=/Logged in to \S+ account (\S+) \(/,he=/(?:Failed to log in to|Timeout trying to log in to) \S+/,ge=/^\s*-\s*Active account:\s*true\s*$/,_e=/\u001b\[[0-9;]*m/g;function ve(e){let t=[],n;for(let r of e.split(`
2
- `)){let e=r.replace(_e,``),i=me.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(he.test(e)){n=void 0;continue}n&&ge.test(e)&&(n.active=!0)}return t}const ye={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){c(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function be(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function xe(e,t,n,r,i){let a=y[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),be(o.kind)}catch(i){return c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function Se(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return xe(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Ce(e,t,n){let i=r[e];if(i===null)return K();let a=ie(t.cwd,i);if(n===`absent`)return xe(e,t.cwd,t.home,a,t.env);let o=C(y[e],t.cwd,ye,void 0,a);switch(o.action){case`written`:case`overwritten`:return{action:o.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function we(e,t,n){let r=t.home??oe();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=w(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function Te(e,t,n){if(n===`absent`){let n=g(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=_(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Ee(e){return t=>{if(t.pathId===void 0)return J();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return J();switch(r.kind){case`editor-user-config`:return Se(r.editor,e,t.desired);case`editor-project-config`:return Ce(r.editor,e,t.desired);case`editor-project-skill-root`:return Te(r.editor,e,t.desired);case`editor-user-skill-root`:return we(r.editor,e,t.desired)}}}function De(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Oe(e){if(e===`server`)return e;throw new h(`--only must be 'server'`)}function ke(e=B){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)].find(t=>e(t))}function Ae(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function je(t){if(t===`off`)return`off`;if(!e.test(t))throw new h(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return t}function Me(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ne(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Pe(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Me(e.host))&&e.isTTY}function Fe(e,t){let n;try{n=new URL(t)}catch{throw new h(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new h(`${e} must be an http(s) origin (got: ${t})`);return t}function Ie(e){return Fe(`--external-url`,e)}function Le(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${d}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??se,r=t.realpathFn??ae,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Re(e,t,n=e=>ce(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${d}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function ze(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:c,dirname:u,resolve:d}=await import(`node:path`),{bootServer:f,createEphemeralProjectDir:p,getLogger:h,resolveContentDir:g,resolveLockDir:_,seedEphemeralProjectDir:v,waitForServerLockDrain:y}=await import(`./dist-Bm7UNIQ7.mjs`),b=e.log??h(`start`),S=e.singleFile!==void 0,C=S?m(e.singleFile).canonicalFilePath:void 0,w=C?u(C):void 0,E=C?c(C):void 0,D,k=!1;if(w!==void 0){if(e.projectDir!==void 0){if(D=e.projectDir,!Z(D))throw new X(D);o(d(D,`.ok`,`config.yml`))||v(D,w)}else D=p(w),k=!0}let A=async()=>{if(!(!k||D===void 0)){if(!Z(D)){b.warn({ephemeralProjectDir:D},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ce(D,{recursive:!0,force:!0})}catch(e){b.warn({err:e,ephemeralProjectDir:D},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},j=D;if(!S){if(!i&&!ee(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?b.debug({event:e},`[start] reclaim sweep event`):b.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-ooUrwLkV.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&b.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){b.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-irGbbbq_.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){b.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let N=w??g(t,n);!S&&!o(N)&&(s(N,{recursive:!0}),b.info({contentDir:N},`Created content directory`));let re=P(),F=l(),I;try{{let e=_(D??n),t=Date.now(),r=await y(e);r!==`no-drain`&&b.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}I=await f({config:t,contentDir:N,projectDir:D??n,contentRoot:S?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:fe,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:x(),...S?{ephemeral:!0,singleDocRelPath:E,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:D??n,home:oe(),env:process.env};return{probe:ne(e),execute:Ee(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Q(j===void 0?n:Re(n,j),{log:b,exit:e.idleExit})},log:b,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}})}catch(e){throw await A(),e}let L=I.destroy,R=k?async()=>{try{await L()}finally{await A()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:N,port:I.port,ready:I.ready,degraded:I.degraded}}function Be(e,t,n=()=>f({absPath:u(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Ve(e){if(e===`browser`||e===`app`)return e;throw new h(`--mode must be 'browser' or 'app'`)}function He(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ue(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function We(e,n){let r=Be(e,n.singleFile),c=He(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:ee}=await import(`./banner-kywHhVaC.mjs`),{accent:l,dim:u,error:d,warning:f}=await import(`./colors-SgU3JHQu.mjs`),p=process.cwd();process.title=Le(p);let m;try{m=t(process.env)}catch(e){throw e instanceof o&&(console.error(d(e.message)),process.exit(78)),e}for(let e of m.diagnostics)console.warn(f(`[config] ${e.message}`));let h=s(r,m.layer),g=m.overrides.some(e=>e.envVar===`OK_BIND`),_=n.bind!==void 0&&n.bind.length>0?n.bind:void 0,v=process.env.HOST,y=v!==void 0&&v.trim()!==``?v:void 0,b=a(h),x=_??(g||y===void 0?[...b.bind]:[y]);Ne({flagBindSet:_!==void 0,okBindSet:g,hostEnvSet:y!==void 0,fileBindCount:b.bind.length})&&console.warn(f(`[config] HOST=${y} overrides server.bind — dropping the file-configured addresses (${b.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let S=x[0]??`127.0.0.1`,C=x,w=n.externalUrl,T=a(s(h,{server:{bind:C,...w===void 0?{}:{externalUrl:w}}}));if(T.allowExternal&&(!T.loopbackOnly||T.externalUrl)){let e=T.externalUrl??T.bind.join(`, `);console.warn(f([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
1
+ import{Fc as e,Fs as t,Hu as n,Md as r,No as i,Rs as a,_t as o,da as s}from"./md-manager-BGnqyqi1-DKflYxqj.mjs";import{Ho as c,Wr as ee,ai as l,jo as u,k as d,ko as f,ti as p,vi as m}from"./dist-C9m6GTCy.mjs";import{Ct as h,I as g,R as _,St as v,Y as y,b,lt as x,wt as S,y as C}from"./init-Ph4Fpm4I.mjs";import{a as w,c as T,d as E,f as D,i as te,n as O,o as k,p as A,r as j,s as M,t as ne,u as N,v as P}from"./registry-probes-Dg6Rlguw.mjs";import{n as re}from"./constants-39tdKa_g.mjs";import{execFileSync as F,spawn as I}from"node:child_process";import{basename as L,dirname as R,join as ie,resolve as z}from"node:path";import{existsSync as B,realpathSync as ae}from"node:fs";import{homedir as oe,tmpdir as se}from"node:os";import{rm as ce}from"node:fs/promises";import{setTimeout as le}from"node:timers/promises";const ue=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],de={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function V(e,t={}){let{login:n}=t,r=t._exec??F,i=H(t._fileExists??B),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...ue.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,de).toString().trim();if(t.length>0)return t}catch{}}function fe(e,t={}){let n=t._exec??F,r=H(t._fileExists??B),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=pe(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=ve(o);if(e.length>0)return e}}function W(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function pe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=W(W(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=W(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const me=/Logged in to \S+ account (\S+) \(/,he=/(?:Failed to log in to|Timeout trying to log in to) \S+/,ge=/^\s*-\s*Active account:\s*true\s*$/,_e=/\u001b\[[0-9;]*m/g;function ve(e){let t=[],n;for(let r of e.split(`
2
+ `)){let e=r.replace(_e,``),i=me.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(he.test(e)){n=void 0;continue}n&&ge.test(e)&&(n.active=!0)}return t}const ye={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){c(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function be(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function xe(e,t,n,r,i){let a=y[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),be(o.kind)}catch(i){return c(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function Se(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return xe(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Ce(e,t,n){let i=r[e];if(i===null)return K();let a=ie(t.cwd,i);if(n===`absent`)return xe(e,t.cwd,t.home,a,t.env);let o=C(y[e],t.cwd,ye,void 0,a);switch(o.action){case`written`:case`overwritten`:return{action:o.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function we(e,t,n){let r=t.home??oe();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=w(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function Te(e,t,n){if(n===`absent`){let n=g(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=_(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Ee(e){return t=>{if(t.pathId===void 0)return J();let r=n(t.pathId);if(r===null||r.kind===`central-skill-store`)return J();switch(r.kind){case`editor-user-config`:return Se(r.editor,e,t.desired);case`editor-project-config`:return Ce(r.editor,e,t.desired);case`editor-project-skill-root`:return Te(r.editor,e,t.desired);case`editor-user-skill-root`:return we(r.editor,e,t.desired)}}}function De(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Oe(e){if(e===`server`)return e;throw new h(`--only must be 'server'`)}function ke(e=B){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)].find(t=>e(t))}function Ae(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function je(t){if(t===`off`)return`off`;if(!e.test(t))throw new h(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return t}function Me(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ne(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Pe(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Me(e.host))&&e.isTTY}function Fe(e,t){let n;try{n=new URL(t)}catch{throw new h(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new h(`${e} must be an http(s) origin (got: ${t})`);return t}function Ie(e){return Fe(`--external-url`,e)}function Le(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${d}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??se,r=t.realpathFn??ae,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Re(e,t,n=e=>ce(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${d}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Q(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function ze(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:c,dirname:u,resolve:d}=await import(`node:path`),{bootServer:f,createEphemeralProjectDir:p,getLogger:h,resolveContentDir:g,resolveLockDir:_,seedEphemeralProjectDir:v,waitForServerLockDrain:y}=await import(`./dist-Bm7UNIQ7.mjs`),b=e.log??h(`start`),S=e.singleFile!==void 0,C=S?m(e.singleFile).canonicalFilePath:void 0,w=C?u(C):void 0,E=C?c(C):void 0,D,k=!1;if(w!==void 0){if(e.projectDir!==void 0){if(D=e.projectDir,!Z(D))throw new X(D);o(d(D,`.ok`,`config.yml`))||v(D,w)}else D=p(w),k=!0}let A=async()=>{if(!(!k||D===void 0)){if(!Z(D)){b.warn({ephemeralProjectDir:D},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ce(D,{recursive:!0,force:!0})}catch(e){b.warn({err:e,ephemeralProjectDir:D},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},j=D;if(!S){if(!i&&!ee(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?b.debug({event:e},`[start] reclaim sweep event`):b.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-Gjm7_lnK.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&b.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){b.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-CbwNg2jY.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){b.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let N=w??g(t,n);!S&&!o(N)&&(s(N,{recursive:!0}),b.info({contentDir:N},`Created content directory`));let re=P(),F=l(),I;try{{let e=_(D??n),t=Date.now(),r=await y(e);r!==`no-drain`&&b.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}I=await f({config:t,contentDir:N,projectDir:D??n,contentRoot:S?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:fe,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:x(),...S?{ephemeral:!0,singleDocRelPath:E,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:D??n,home:oe(),env:process.env};return{probe:ne(e),execute:Ee(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Q(j===void 0?n:Re(n,j),{log:b,exit:e.idleExit})},log:b,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}})}catch(e){throw await A(),e}let L=I.destroy,R=k?async()=>{try{await L()}finally{await A()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:N,port:I.port,ready:I.ready,degraded:I.degraded}}function Be(e,t,n=()=>f({absPath:u(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Ve(e){if(e===`browser`||e===`app`)return e;throw new h(`--mode must be 'browser' or 'app'`)}function He(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ue(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function We(e,n){let r=Be(e,n.singleFile),c=He(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:ee}=await import(`./banner-kywHhVaC.mjs`),{accent:l,dim:u,error:d,warning:f}=await import(`./colors-SgU3JHQu.mjs`),p=process.cwd();process.title=Le(p);let m;try{m=t(process.env)}catch(e){throw e instanceof o&&(console.error(d(e.message)),process.exit(78)),e}for(let e of m.diagnostics)console.warn(f(`[config] ${e.message}`));let h=s(r,m.layer),g=m.overrides.some(e=>e.envVar===`OK_BIND`),_=n.bind!==void 0&&n.bind.length>0?n.bind:void 0,v=process.env.HOST,y=v!==void 0&&v.trim()!==``?v:void 0,b=a(h),x=_??(g||y===void 0?[...b.bind]:[y]);Ne({flagBindSet:_!==void 0,okBindSet:g,hostEnvSet:y!==void 0,fileBindCount:b.bind.length})&&console.warn(f(`[config] HOST=${y} overrides server.bind — dropping the file-configured addresses (${b.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let S=x[0]??`127.0.0.1`,C=x,w=n.externalUrl,T=a(s(h,{server:{bind:C,...w===void 0?{}:{externalUrl:w}}}));if(T.allowExternal&&(!T.loopbackOnly||T.externalUrl)){let e=T.externalUrl??T.bind.join(`, `);console.warn(f([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
3
3
  `)))}let E=n.port===void 0?void 0:Number(n.port),D=m.overrides.find(e=>e.envVar===`PORT`)?.value,te=E??D??r.server?.port,O=Ae({explicitDir:n.reactShellDistDir,only:n.only,findBundledDir:ke}),k=O.dir;O.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let A;try{A=await ze({config:r,cwd:p,host:S,port:te,bind:C,...n.serveContentAssets===void 0?{}:{serveContentAssets:n.serveContentAssets},...k?{reactShellDistDir:k}:{},idleThresholdMs:i(n.idleShutdown??T.idleShutdown),serverRuntime:T,...n.singleFile?{singleFile:n.singleFile}:{},...n.projectDir?{projectDir:n.projectDir}:{}})}catch(e){e instanceof Y&&(console.error(d(e.message)),process.exit(1)),e instanceof X&&(console.error(d(e.message)),process.exit(1));let t=await import(`./dist-Bm7UNIQ7.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(d(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(d(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(d(e.message)),process.exit(1)),qe(e,t)){let e=t.resolveLockDir(p),n=null;try{n=await Ge({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>le(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ke(n);console.log(l(e));for(let e of t)console.log(u(e));process.exit(0)}}let n=$(e,p,t);n!==null&&(console.error(d(n)),process.exit(1)),console.error(`${d(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let j=!1,M=async e=>{if(j)return;j=!0;let[t,...n]=Ue(e);console.log(l(`\n${t}`));for(let e of n)console.log(u(` ${e}`));try{await A.destroy(`external-signal`)}catch(e){console.error(`${d(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{M(`SIGINT`)}),process.once(`SIGTERM`,()=>{M(`SIGTERM`)});let ne=`http://${S.includes(`:`)&&!S.startsWith(`[`)?`[${S}]`:S}:${A.port}`,N=S===`0.0.0.0`||S===`::`?`http://0.0.0.0:${A.port}`:void 0,P=ne;console.log(ee({name:`open-knowledge`,version:re,localUrl:P,networkUrl:N,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let F={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};A.ready.then(async()=>{if(A.degraded.length>0){console.log();for(let e of A.degraded){let t=F[e]??`${e} (check server logs for details)`;console.warn(` ${f(`⚠`)} ${f(e)}: ${u(t)}`)}console.log()}if(Pe({openBrowser:n.openBrowser!==!1&&T.openBrowser,explicitOn:n.openBrowser!==!1&&h.server?.openBrowser===!0,host:S,isTTY:process.stdout.isTTY===!0,ephemeral:n.singleFile!==void 0,only:n.only,servesUi:k!==void 0})){let{openBrowser:e}=await import(`./open-browser-OpHQJzqy.mjs`);e(P)}}).catch(e=>{console.error(` ${d(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function Ge(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:p(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ke(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function qe(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function $(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Je(e){return new v(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,Oe).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,je).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Ve).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new S(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new S(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Ie).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
4
4
  `),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
5
5
  `),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=E(N());if(n.available){D({spawn:I},n);return}console.error(A(n.reason)),process.exit(1)}await We(n,t)})}export{$ as C,fe as D,V as E,Je as S,Q as T,He as _,Ke as a,Pe as b,Z as c,je as d,Oe as f,Be as g,Ge as h,Le as i,qe as l,De as m,Y as n,Ue as o,ke as p,ze as r,Me as s,X as t,Ie as u,Ae as v,Re as w,Ne as x,We as y};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/open-knowledge",
3
- "version": "0.77.0-beta.4",
3
+ "version": "0.77.0",
4
4
  "description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
5
5
  "keywords": [
6
6
  "knowledge-base",
@@ -72,10 +72,10 @@
72
72
  "ajv-formats": "^3.0.1",
73
73
  "tsdown": "^0.22.14",
74
74
  "typescript": "~7.0.2",
75
- "@inkeep/open-knowledge-app": "0.77.0-beta.4",
76
- "@inkeep/open-knowledge-server": "0.77.0-beta.4",
75
+ "@inkeep/open-knowledge-app": "0.77.0",
76
+ "@inkeep/open-knowledge-core": "0.77.0",
77
77
  "@inkeep/open-knowledge-native-config": "0.0.0",
78
- "@inkeep/open-knowledge-core": "0.77.0-beta.4"
78
+ "@inkeep/open-knowledge-server": "0.77.0"
79
79
  },
80
80
  "scripts": {
81
81
  "build:cli": "rm -rf dist && tsdown",
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-DKflYxqj.mjs";var e=`0.77.0-beta.4`;const t=`config.yml`,n=e;export{n,t};
@@ -1 +0,0 @@
1
- import"./dist-C9m6GTCy.mjs";import{_ as e}from"./init-Cuw6M3ez.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-DDluoWkF.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-ZhG30yAN.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1 +0,0 @@
1
- import{t as e}from"./index-B_8dBtGF.js";export{e as FeedbackForm};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./overlay-layers-Bj-TVfKw.js";import{r as c,t as l}from"./button-HKX9wT1K.js";import{t as u}from"./dist-BHv-mziD.js";import{i as d,n as f,t as p}from"./tooltip-BnyyQDRs.js";import"./separator-CcvvqzEJ.js";import{t as m}from"./RegisteredAgentIcon-C299I100.js";import{gr as h}from"./dist-DOFOMv5X.js";import{_ as g,b as _}from"./use-settings-route-CBhyzk7L.js";import{c as v,r as y,s as b}from"./local-menu-action-bus-DaoT7_kL.js";import{h as x}from"./terminal-launch-events-BD-q8533.js";import{t as S}from"./OpenInAgentMenuItem-VFY-Baek.js";import{t as C}from"./createLucideIcon-B6ULg5PN.js";import{t as w}from"./arrow-up-right-B3B9a7te.js";import{t as T}from"./check-BzfGb3KU.js";import{t as ee}from"./chevron-down-Dloks0wp.js";import{a as E,i as D,m as O,o as k,r as A,t as te,u as j}from"./dropdown-menu-DjQ8GtwR.js";import"./input-f41fkc3m.js";import{r as M}from"./DeleteConfirmationDialog-D_u8hFpe.js";import{n as ne}from"./agent-launcher-labels-C68Xjdk5.js";import"./skeleton-BJMacgN3.js";import{_ as N,f as P,l as F}from"./sortable.esm-BqXWcrem.js";var I=e(n(),1),L=new Map,R=null,z=new Set;function B(){return L.get(`agents`)??L.get(`terminal`)??null}function V(e,t){return e===null||t===null?e===t:e.id!==t.id||e.kind!==t.kind||e.label!==t.label?!1:e.kind===`thread`&&t.kind===`thread`?e.agentId===t.agentId&&e.iconUrl===t.iconUrl:e.kind===`terminal`&&t.kind===`terminal`?e.cli===t.cli:!1}function H(e,t){if(L.has(e)&&V(L.get(e)??null,t))return;L.set(e,t);let n=B();if(!V(R,n)){R=n;for(let e of z)e()}}function U(){return R}function W(e){return z.add(e),()=>{z.delete(e)}}function G(){return(0,I.useSyncExternalStore)(W,U,K)}function K(){return null}var q=C(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),J=C(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),re=C(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Y={},X=new Set;function ie(){return Y}function ae(e){Y={...Y,...e};for(let e of X)e()}function oe(e){return X.add(e),()=>{X.delete(e)}}function se(){return(0,I.useSyncExternalStore)(oe,ie,ie)}var Z={terminal:`ok-dock-session-order-v1`,agents:`ok-agent-session-order-v1`};function ce(e){let t=Array.isArray(e.order)?e.order.filter(e=>typeof e==`string`):[],n=typeof e.activeKey==`string`?e.activeKey:null,r=typeof e.agentPanelVisible==`boolean`?e.agentPanelVisible:void 0;return r===void 0?{order:t,activeKey:n}:{order:t,activeKey:n,agentPanelVisible:r}}function le(e){if(typeof window>`u`)return{status:`absent`};let t;try{t=window.localStorage.getItem(Z[e])}catch(t){return console.warn(`[dock-session-persistence] reading ${Z[e]} failed: ${String(t)}`),{status:`blocked`}}if(t===null)return{status:`absent`};try{return{status:`parsed`,record:ce(JSON.parse(t))}}catch(t){return console.warn(`[dock-session-persistence] stored ${Z[e]} record was not valid JSON; ignoring it: ${String(t)}`),{status:`corrupt`}}}function ue(e){let t=le(`agents`);if(t.status===`blocked`)return console.warn(`[dock-session-persistence] ${Z.agents} could not be read; withholding this write rather than overwriting the unread record`),null;let n=t.status===`parsed`?t.record:null,r=[...e.order??n?.order??[]],i=e.activeKey===void 0?n?.activeKey??null:e.activeKey,a=e.agentPanelVisible??n?.agentPanelVisible;return a===void 0?{order:r,activeKey:i}:{order:r,activeKey:i,agentPanelVisible:a}}function de(e){let t=le(e);return t.status===`parsed`?t.record:null}function fe(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(Z[e],JSON.stringify(t))}catch(t){console.warn(`[dock-session-persistence] writing ${Z[e]} failed: ${String(t)}`)}}function pe(e,t){if(e?.terminal!=null)return;let n=ue({agentPanelVisible:t});n!==null&&fe(`agents`,n)}async function me(e,t){if(typeof e?.terminal?.getDockState==`function`)try{let n=await e.terminal.getDockState(),r=n[t];if(r==null)return{sessionOrder:null,terminalSnapshot:n.terminalSnapshot,failed:!1};let{order:i,activeKey:a}=ce(r);return{sessionOrder:i.length===0&&a===null?null:{order:i,activeKey:a},terminalSnapshot:n.terminalSnapshot,failed:!1}}catch(e){return console.warn(`[dock-session-persistence] getDockState failed; cold-starting: ${String(e)}`),{sessionOrder:null,terminalSnapshot:void 0,failed:!0}}return{sessionOrder:e?.terminal==null?de(t):null,terminalSnapshot:void 0,failed:!1}}function he(e,t,n,r={tabs:[],activeOrdinal:null}){if(typeof e?.terminal?.setDockState==`function`){let i={order:[...n.order],activeKey:n.activeKey},a=t===`terminal`?e.terminal.setDockState({surface:`terminal`,...i,terminalSnapshot:r}):e.terminal.setDockState({surface:`agents`,...i});Promise.resolve(a).then(e=>{e?.ok===!1&&(e.reason===`ipc-unavailable`?console.warn(`[dock-session-persistence] setDockState skipped during window teardown`):console.error(`[dock-session-persistence] setDockState failed: ${e.reason}`))}).catch(e=>{console.error(`[dock-session-persistence] setDockState rejected: ${e instanceof Error?e.stack??e.message:String(e)}`)});return}if(e?.terminal==null){if(t===`agents`){let e=ue({order:n.order,activeKey:n.activeKey});if(e===null)return;fe(`agents`,e);return}fe(t,n)}}var ge=5e3,Q=a(),$=t();function _e(e){let t=(0,Q.c)(64),{primary:n,onPrimary:a,primaryDisabled:s,enabledTargets:c,selectedTargetId:u,onSelectTarget:d,threadAgents:f,onOpenSettings:p,terminal:h,terminals:g,menuEmptyState:_,menuLeading:v,onMenuOpenChange:b,menuAlign:C,menuAttributes:N,className:P,primaryClassName:F,primaryAriaLabel:I,threadAgentsFooter:L,triggerAriaLabel:R,testIds:z}=e,B=s===void 0?!1:s,V=C===void 0?`end`:C,{_:H}=i(),U=c.length>0,W=g&&g.length>0?g:null,G=W!=null||h!=null,K=U||G,q=f!==void 0&&f.length>0,J;t[0]===z?J=t[1]:(J=e=>typeof z.terminal==`function`?z.terminal(e):z.terminal,t[0]=z,t[1]=J);let re=J,Y;t[2]===F?Y=t[3]:(Y=o(`gap-1.5`,F),t[2]=F,t[3]=Y);let X;t[4]!==a||t[5]!==n||t[6]!==I||t[7]!==B||t[8]!==Y||t[9]!==z.primary?(X=(0,$.jsx)(l,{type:`button`,variant:`outline`,className:Y,disabled:B,"aria-label":I,onClick:a,"data-testid":z.primary,children:n}),t[4]=a,t[5]=n,t[6]=I,t[7]=B,t[8]=Y,t[9]=z.primary,t[10]=X):X=t[10];let ie;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(ee,{"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`}),t[11]=ie):ie=t[11];let ae;t[12]!==z.trigger||t[13]!==R?(ae=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(l,{type:`button`,variant:`outline`,size:`icon`,"aria-label":R,"data-testid":z.trigger,children:ie})}),t[12]=z.trigger,t[13]=R,t[14]=ae):ae=t[14];let oe;t[15]!==K||t[16]!==v||t[17]!==q?(oe=v?(0,$.jsxs)($.Fragment,{children:[v,q||K?(0,$.jsx)(j,{}):null]}):null,t[15]=K,t[16]=v,t[17]=q,t[18]=oe):oe=t[18];let se;t[19]!==H||t[20]!==K||t[21]!==q||t[22]!==z||t[23]!==f||t[24]!==L?(se=q?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(D,{"aria-label":H({id:`RXEbZy`}),children:[(0,$.jsx)(k,{children:(0,$.jsx)(r,{id:`RXEbZy`})}),f?.map(e=>(0,$.jsxs)(E,{onSelect:e.onSelect,disabled:e.disabled,"data-testid":z.threadAgent?.(e.key),"aria-current":e.selected?`true`:void 0,children:[(0,$.jsx)(m,{agentId:e.id,iconUrl:e.iconUrl,className:`size-4`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),e.selected?(0,$.jsx)(T,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.key)),L]}),K?(0,$.jsx)(j,{}):null]}):null,t[19]=H,t[20]=K,t[21]=q,t[22]=z,t[23]=f,t[24]=L,t[25]=se):se=t[25];let Z;t[26]!==H||t[27]!==W||t[28]!==c||t[29]!==K||t[30]!==d||t[31]!==u||t[32]!==U||t[33]!==G||t[34]!==h||t[35]!==re||t[36]!==z?(Z=K?(0,$.jsxs)($.Fragment,{children:[G?(0,$.jsxs)(D,{"aria-label":H({id:`ALhMYW`}),children:[(0,$.jsx)(k,{children:(0,$.jsx)(r,{id:`ALhMYW`})}),W?.map(e=>(0,$.jsxs)(E,{onSelect:e.onSelect,"data-testid":re(e.cli),"aria-label":e.ariaLabel,children:[(0,$.jsx)(S,{id:M(e.cli),className:`size-4`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:e.label}),e.selected?(0,$.jsx)(T,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.cli)),h?(0,$.jsxs)(E,{onSelect:h.onSelect,"data-testid":h.testId??re(`claude`),"aria-label":h.ariaLabel??H({id:`AcK_r0`}),children:[h.icon??(0,$.jsx)(S,{id:M(`claude`),className:`size-4`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:h.label??(0,$.jsx)(r,{id:`fcgvCA`})}),h.selected?(0,$.jsx)(T,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]}):null]}):null,U?(0,$.jsxs)($.Fragment,{children:[G?(0,$.jsx)(j,{}):null,(0,$.jsxs)(D,{"aria-label":H({id:`BwKH4d`}),children:[(0,$.jsxs)(k,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(r,{id:`BwKH4d`}),(0,$.jsx)(w,{"aria-hidden":`true`,className:`size-3`})]}),c.map(e=>(0,$.jsxs)(E,{onSelect:()=>d(e),"data-testid":z.option(e.id),children:[(0,$.jsx)(S,{id:e.id,"aria-hidden":`true`,className:`size-4`}),(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(ne,{displayName:e.displayName})}),u===e.id?(0,$.jsx)(T,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e.id))]})]}):null]}):null,t[26]=H,t[27]=W,t[28]=c,t[29]=K,t[30]=d,t[31]=u,t[32]=U,t[33]=G,t[34]=h,t[35]=re,t[36]=z,t[37]=Z):Z=t[37];let ce=!q&&!K?_:null,le;t[38]!==K||t[39]!==q?(le=q||K?(0,$.jsx)(j,{}):null,t[38]=K,t[39]=q,t[40]=le):le=t[40];let ue;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(y,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),t[41]=ue):ue=t[41];let de;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`span`,{className:`flex-1`,children:(0,$.jsx)(r,{id:`jRAGrQ`})}),t[42]=de):de=t[42];let fe;t[43]!==p||t[44]!==z.settings?(fe=(0,$.jsxs)(E,{onSelect:p,"data-testid":z.settings,children:[ue,de]}),t[43]=p,t[44]=z.settings,t[45]=fe):fe=t[45];let pe;t[46]!==V||t[47]!==N||t[48]!==Z||t[49]!==ce||t[50]!==le||t[51]!==fe||t[52]!==oe||t[53]!==se||t[54]!==z.menu?(pe=(0,$.jsxs)(A,{align:V,className:`max-h-80 min-w-[200px]`,"data-testid":z.menu,...N,children:[oe,se,Z,ce,le,fe]}),t[46]=V,t[47]=N,t[48]=Z,t[49]=ce,t[50]=le,t[51]=fe,t[52]=oe,t[53]=se,t[54]=z.menu,t[55]=pe):pe=t[55];let me;t[56]!==b||t[57]!==pe||t[58]!==ae?(me=(0,$.jsxs)(te,{modal:!1,onOpenChange:b,children:[ae,pe]}),t[56]=b,t[57]=pe,t[58]=ae,t[59]=me):me=t[59];let he;return t[60]!==P||t[61]!==me||t[62]!==X?(he=(0,$.jsxs)(x,{className:P,children:[X,me]}),t[60]=P,t[61]=me,t[62]=X,t[63]=he):he=t[63],he}var ve=`open-knowledge:active-terminal-input`;function ye(e,t,n=typeof window>`u`?new EventTarget:window){let r={text:e,newTab:t?.newTab===!0,submit:t?.submit===!0,...t?.target===`agents`?{target:`agents`}:{}};v({kind:`active-input`,...r},n)||n.dispatchEvent(new CustomEvent(ve,{detail:r}))}function be(e,t=typeof window>`u`?new EventTarget:window){let n=t=>{let n=t instanceof CustomEvent?t.detail:void 0;n!==void 0&&typeof n.text==`string`&&e({text:n.text,newTab:n.newTab===!0,submit:n.submit===!0,...n.target===`agents`?{target:`agents`}:{}})};return t.addEventListener(ve,n),()=>t.removeEventListener(ve,n)}function xe(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Se(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex max-w-sm flex-col items-center gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Ce=c(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4`}},defaultVariants:{variant:`default`}});function we(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,s;t[4]!==n||t[5]!==a?(s=o(Ce({variant:a,className:n})),t[4]=n,t[5]=a,t[6]=s):s=t[6];let c;return t[7]!==r||t[8]!==s||t[9]!==a?(c=(0,$.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":a,className:s,...r}),t[7]=r,t[8]=s,t[9]=a,t[10]=c):c=t[10],c}function Te(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?u:`div`,s;t[4]===n?s=t[5]:(s=o(`font-heading text-sm font-medium tracking-tight`,n),t[4]=n,t[5]=s);let c;return t[6]!==a||t[7]!==r||t[8]!==s?(c=(0,$.jsx)(a,{"data-slot":`empty-title`,className:s,...r}),t[6]=a,t[7]=r,t[8]=s,t[9]=c):c=t[9],c}function Ee(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function De(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`empty-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Oe(e){let t=null,n=()=>(t===null&&(t=e(),t.catch(()=>{})),t),r=(0,I.lazy)(n);return r.preload=n,r}var ke=1024,Ae=1280,je={left:ke,right:Ae};function Me(e,t,n){return e==null?t>=je[n]?`above`:`below`:`embedded`}function Ne(e){return e===`above`?`open`:`collapsed`}var Pe=`ok-sidebar-pins-v2`;function Fe(e){return e===`open`||e===`collapsed`}function Ie(e){return e===`above`||e===`below`||e===`embedded`}function Le(e){if(typeof e!=`object`||!e)return!1;let t=e;for(let e of Object.keys(t))if(!Ie(e)||!Fe(t[e]))return!1;return!0}function Re(e){let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n=t,r={};return Le(n.left)&&(r.left=n.left),Le(n.right)&&(r.right=n.right),r}function ze(e){try{let t=(e??localStorage).getItem(Pe);return t==null?{}:Re(t)}catch{return{}}}function Be(e,t){try{t.setItem(Pe,JSON.stringify(e))}catch{}}function Ve(e,t,n){return n[e]?.[t]??Ne(t)}function He(e,t,n,r){let i=r??localStorage,a=ze(i);return a[e]={...a[e],[t]:n},Be(a,i),a}function Ue(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function We(e){let{value:t,unit:n}=Ue(e);return n===`rem`?t*16:t}function Ge(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var Ke=3600*24*7;function qe(e){let t=(0,Q.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,ee=p===void 0?!0:p,E=m===void 0?Je:m,D=g===void 0?Ke:g,O=_===void 0?!1:_,k=(0,I.useRef)(null),A=(0,I.useRef)(0),te=(0,I.useRef)(0),j=(0,I.useRef)(!1),M=(0,I.useRef)(!1),ne=(0,I.useRef)(null),N=(0,I.useRef)(0),P=(0,I.useRef)(!1),F=(0,I.useRef)(0),L=(0,I.useRef)(0),R=(0,I.useRef)(null),z=(0,I.useRef)(r),B=(0,I.useRef)(y),V,H;t[0]===r?(V=t[1],H=t[2]):(V=()=>{z.current=r},H=[r],t[0]=r,t[1]=V,t[2]=H),(0,I.useEffect)(V,H);let U,W;t[3]===y?(U=t[4],W=t[5]):(U=()=>{B.current=y},W=[y],t[3]=y,t[4]=U,t[5]=W),(0,I.useEffect)(U,W);let G=We(b),K;t[6]===x?K=t[7]:(K=We(x),t[6]=x,t[7]=K);let q=K,J;t[8]!==ee||t[9]!==O?(J=function(e){ee&&(M.current=!0,A.current=B.current?0:We(z.current),te.current=e.clientX,N.current=e.clientX,ne.current=null,P.current=!1,F.current=0,L.current=0,R.current=O&&k.current?k.current.getBoundingClientRect():null,e.preventDefault())},t[8]=ee,t[9]=O,t[10]=J):J=t[10];let re=J,Y,X;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==O||t[17]!==q||t[18]!==G||t[19]!==i||t[20]!==a||t[21]!==E||t[22]!==D||t[23]!==h?(Y=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${D}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(O&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!M.current)return;let o=Math.abs(r.clientX-te.current);if(!j.current&&o>5&&(j.current=!0,E(!0)),j.current){let{unit:o}=Ue(z.current),s=R.current;O&&k.current&&(s=k.current.getBoundingClientRect());let c=t(r.clientX,N.current)?`expand`:`collapse`;ne.current!==c&&(ne.current=c),L.current=Math.abs(r.clientX-N.current);let l=Date.now();if(P.current&&l-F.current>200&&(P.current=!1),!P.current){if(C&&a&&!B.current){let e=n(r,te.current,A.current,s),t=!1;if(w<=1)t=e<=G*w;else if(e<=G){let n=G*(w-1);t=G-e>=n}if(c===`collapse`&&t){a(),N.current=r.clientX,P.current=!0,F.current=l;return}}if(a&&B.current&&c===`expand`&&L.current>G*T){a();let t=n(r,te.current,A.current,s),c=Math.max(G,Math.min(q,t)),u=Ge(o===`rem`?c/16:c,o);i(u),e(u),N.current=r.clientX,P.current=!0,F.current=l;return}}if(B.current)return;let u=n(r,te.current,A.current,s),d=Math.max(G,Math.min(q,u)),f=Ge(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){M.current&&(!j.current&&a&&S&&a(),j.current=!1,M.current=!1,ne.current=null,N.current=0,P.current=!1,F.current=0,L.current=0,R.current=null,E(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},X=[i,a,E,G,q,O,C,w,T,S,h,D,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=O,t[17]=q,t[18]=G,t[19]=i,t[20]=a,t[21]=E,t[22]=D,t[23]=h,t[24]=Y,t[25]=X):(Y=t[24],X=t[25]),(0,I.useEffect)(Y,X);let ie;return t[26]===re?ie=t[27]:(ie={dragRef:k,isDragging:j,handleMouseDown:re},t[26]=re,t[27]=ie),ie}function Je(){}var Ye=3600*24*7,Xe=`18rem`,Ze=`3rem`,Qe=`app-file-sidebar`,$e=`14.625rem`,et=`32rem`,tt=`sidebar_width`,nt=/^\d+(?:\.\d+)?(?:rem|px)$/,rt=I.createContext(null);function it(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${tt}=`))?.split(`=`)[1];if(!t)return e;let n;try{n=decodeURIComponent(t)}catch{return e}return nt.test(n)?n:e}function at(){let e=I.use(rt);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function ot(e){let t=(0,Q.c)(57),n,r,i,a,c,l,u;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7]):({open:i,onOpenChange:c,className:r,style:l,children:n,defaultWidth:u,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=c,t[6]=l,t[7]=u);let d=u===void 0?Xe:u,[f]=I.useState(ct),p;t[8]===f?p=t[9]:(p=()=>Me(f,window.innerWidth,`left`),t[8]=f,t[9]=p);let[m,h]=I.useState(p),g;t[10]===d?g=t[11]:(g=()=>it(d),t[10]=d,t[11]=g);let[v,y]=I.useState(g),[b,x]=I.useState(!1),[S,C]=I.useState(!1),w;t[12]===f?w=t[13]:(w=()=>{let e=ze();return Ve(`left`,Me(f,window.innerWidth,`left`),e)===`open`},t[12]=f,t[13]=w);let[T,ee]=I.useState(w),E=i??T,D;t[14]!==m||t[15]!==c?(D=e=>{let t=typeof e==`function`?e(te.current):e;c?c(t):ee(t),He(`left`,m,t?`open`:`collapsed`)},t[14]=m,t[15]=c,t[16]=D):D=t[16];let O=D,k;t[17]===O?k=t[18]:(k=function(){O(st)},t[17]=O,t[18]=k);let A=k,te=I.useRef(E),j;t[19]===E?j=t[20]:(j=()=>{te.current=E},t[19]=E,t[20]=j),I.useLayoutEffect(j);let M;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=function(){window.innerWidth>=1024||te.current&&(window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||C(!0))},t[21]=M):M=t[21];let ne=M,N,P;t[22]===f?(N=t[23],P=t[24]):(P=()=>{let e=window.matchMedia(`(min-width: ${ke}px)`),t=()=>{let e=Me(f,window.innerWidth,`left`);h(e),ee(Ve(`left`,e,ze())===`open`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},N=[f],t[22]=f,t[23]=N,t[24]=P),I.useEffect(P,N);let F,L;t[25]===E?(F=t[26],L=t[27]):(F=()=>{E||document.getElementById(Qe)?.contains(document.activeElement)&&document.querySelector(`[data-sidebar="trigger"]`)?.focus()},L=[E],t[25]=E,t[26]=F,t[27]=L),I.useLayoutEffect(F,L);let R,z;t[28]!==E||t[29]!==m||t[30]!==O?(R=()=>{if(m===`above`||!E)return;let e=e=>{if(e.key!==`Escape`||s())return;let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`)||O(!1)};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},z=[m,E,O],t[28]=E,t[29]=m,t[30]=O,t[31]=R,t[32]=z):(R=t[31],z=t[32]),I.useEffect(R,z);let B,V;t[33]===A?(B=t[34],V=t[35]):(B=()=>{if(typeof window<`u`&&window.okDesktop!=null)return;let e=e=>{_(e,`toggle-files-sidebar`)&&(s()||(e.preventDefault(),A()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},V=[A],t[33]=A,t[34]=B,t[35]=V),I.useEffect(B,V);let H=E?`expanded`:`collapsed`,U;t[36]!==b||t[37]!==E||t[38]!==O||t[39]!==S||t[40]!==H||t[41]!==A||t[42]!==v?(U={state:H,open:E,setOpen:O,toggleSidebar:A,width:v,setWidth:y,isDraggingRail:b,setIsDraggingRail:x,showPushPulse:S,setShowPushPulse:C,notifySidebarFileSelected:ne},t[36]=b,t[37]=E,t[38]=O,t[39]=S,t[40]=H,t[41]=A,t[42]=v,t[43]=U):U=t[43];let W;t[44]!==l||t[45]!==v?(W={"--sidebar-width":v,"--sidebar-width-icon":Ze,...l},t[44]=l,t[45]=v,t[46]=W):W=t[46];let G=W,K;t[47]===r?K=t[48]:(K=o(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[47]=r,t[48]=K);let q;t[49]!==n||t[50]!==a||t[51]!==G||t[52]!==K?(q=(0,$.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:G,className:K,...a,children:n}),t[49]=n,t[50]=a,t[51]=G,t[52]=K,t[53]=q):q=t[53];let J;return t[54]!==U||t[55]!==q?(J=(0,$.jsx)(rt.Provider,{value:U,children:q}),t[54]=U,t[55]=q,t[56]=J):J=t[56],J}function st(e){return!e}function ct(){return h()}function lt(e){let t=(0,Q.c)(39),n,r,a,s,c,l;t[0]===e?(n=t[1],r=t[2],a=t[3],s=t[4],c=t[5],l=t[6]):({side:s,variant:c,collapsible:l,className:r,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=s,t[5]=c,t[6]=l);let u=s===void 0?`left`:s,d=c===void 0?`sidebar`:c,f=l===void 0?`offcanvas`:l,{_:p}=i(),{state:m,isDraggingRail:h}=at();if(f===`none`){let e;t[7]===r?e=t[8]:(e=o(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let i;return t[9]!==n||t[10]!==a||t[11]!==e||t[12]!==d?(i=(0,$.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":d,className:e,...a,children:n}),t[9]=n,t[10]=a,t[11]=e,t[12]=d,t[13]=i):i=t[13],i}let g=m===`collapsed`?f:``,_=d===`floating`||d===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,v;t[14]===_?v=t[15]:(v=o(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,_,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[14]=_,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(`div`,{"data-slot":`sidebar-gap`,className:v}),t[16]=v,t[17]=y);let b;t[18]===p?b=t[19]:(b=p({id:`07q4Qk`}),t[18]=p,t[19]=b);let x=d===`floating`||d===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,S;t[20]!==r||t[21]!==x?(S=o(`fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none motion-reduce:duration-0 data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,x,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[20]=r,t[21]=x,t[22]=S):S=t[22];let C;t[23]===n?C=t[24]:(C=(0,$.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[23]=n,t[24]=C);let w;t[25]!==a||t[26]!==u||t[27]!==S||t[28]!==C||t[29]!==b?(w=(0,$.jsx)(`nav`,{id:Qe,"aria-label":b,"data-slot":`sidebar-container`,"data-side":u,className:S,...a,children:C}),t[25]=a,t[26]=u,t[27]=S,t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;return t[31]!==h||t[32]!==u||t[33]!==m||t[34]!==w||t[35]!==g||t[36]!==y||t[37]!==d?(T=(0,$.jsxs)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":m,"data-collapsible":g,"data-variant":d,"data-side":u,"data-slot":`sidebar`,"data-dragging":h,children:[y,w]}),t[31]=h,t[32]=u,t[33]=m,t[34]=w,t[35]=g,t[36]=y,t[37]=d,t[38]=T):T=t[38],T}function ut(e){let t=(0,Q.c)(34),n,r,a;t[0]===e?(n=t[1],r=t[2],a=t[3]):({className:n,onClick:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a);let{_:s}=i(),{toggleSidebar:c,state:u}=at(),d,f,p,m,h,_,v,y;if(t[4]!==s||t[5]!==u){let e=g(`toggle-files-sidebar`);d=l,f=`trigger`,p=`sidebar-trigger`,m=`ghost`,h=`icon-sm`,_=u===`expanded`,v=Qe,y=s(u===`expanded`?{id:`4PYsOz`,values:{sidebarShortcutLabel:e}}:{id:`jbSG8V`,values:{sidebarShortcutLabel:e}}),t[4]=s,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=_,t[12]=v,t[13]=y}else d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],_=t[11],v=t[12],y=t[13];let x;t[14]===n?x=t[15]:(x=o(n),t[14]=n,t[15]=x);let S;t[16]!==r||t[17]!==c?(S=e=>{r?.(e),c()},t[16]=r,t[17]=c,t[18]=S):S=t[18];let C;t[19]===u?C=t[20]:(C=u===`expanded`?(0,$.jsx)(b,{}):(0,$.jsx)(q,{}),t[19]=u,t[20]=C);let w;return t[21]!==d||t[22]!==a||t[23]!==f||t[24]!==C||t[25]!==p||t[26]!==m||t[27]!==h||t[28]!==_||t[29]!==v||t[30]!==y||t[31]!==x||t[32]!==S?(w=(0,$.jsx)(d,{"data-sidebar":f,"data-slot":p,variant:m,size:h,"aria-expanded":_,"aria-controls":v,"aria-label":y,className:x,onClick:S,...a,children:C}),t[21]=d,t[22]=a,t[23]=f,t[24]=C,t[25]=p,t[26]=m,t[27]=h,t[28]=_,t[29]=v,t[30]=y,t[31]=x,t[32]=S,t[33]=w):w=t[33],w}function dt(e){let t=(0,Q.c)(32),n,r,a,s,c;t[0]===e?(n=t[1],r=t[2],a=t[3],s=t[4],c=t[5]):({className:n,enableDrag:s,enableToggle:c,onMouseDown:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=s,t[5]=c);let l=s===void 0?!0:s,u=c===void 0?!0:c,{_:d}=i(),{toggleSidebar:f,setWidth:p,state:m,width:h,setIsDraggingRail:g}=at(),_=m===`collapsed`,v;t[6]!==l||t[7]!==u||t[8]!==g||t[9]!==p||t[10]!==_||t[11]!==f||t[12]!==h?(v={direction:`right`,enableDrag:l,enableToggle:u,onResize:p,onToggle:f,currentWidth:h,isCollapsed:_,minResizeWidth:$e,maxResizeWidth:et,setIsDraggingRail:g,widthCookieName:tt,widthCookieMaxAge:Ye},t[6]=l,t[7]=u,t[8]=g,t[9]=p,t[10]=_,t[11]=f,t[12]=h,t[13]=v):v=t[13];let{dragRef:y,handleMouseDown:b}=qe(v),x;t[14]!==d||t[15]!==m?(x=d(m===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[14]=d,t[15]=m,t[16]=x):x=t[16];let S;t[17]!==b||t[18]!==r?(S=e=>{r?.(e),e.defaultPrevented||b(e)},t[17]=b,t[18]=r,t[19]=S):S=t[19];let C;t[20]!==d||t[21]!==m?(C=d(m===`expanded`?{id:`w3vFfL`}:{id:`e8zRrb`}),t[20]=d,t[21]=m,t[22]=C):C=t[22];let w;t[23]===n?w=t[24]:(w=o(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,`md:group-data-[variant=inset]:after:inset-y-5`,n),t[23]=n,t[24]=w);let T;return t[25]!==y||t[26]!==a||t[27]!==x||t[28]!==S||t[29]!==C||t[30]!==w?(T=(0,$.jsx)(`button`,{ref:y,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":x,tabIndex:-1,onMouseDown:S,title:C,className:w,...a}),t[25]=y,t[26]=a,t[27]=x,t[28]=S,t[29]=C,t[30]=w,t[31]=T):T=t[31],T}function ft(e){let t=(0,Q.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onAnimationEnd:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{showPushPulse:a,setShowPushPulse:s}=at(),c;t[4]!==r||t[5]!==s?(c=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&s(!1)},t[4]=r,t[5]=s,t[6]=c):c=t[6];let l=c,u=a?``:void 0,d;t[7]===n?d=t[8]:(d=o(`relative flex w-full flex-1 flex-col bg-background peer-data-[variant=inset]:m-2 peer-data-[variant=inset]:ml-0 peer-data-[variant=inset]:rounded-xl peer-data-[variant=inset]:shadow-sm peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[7]=n,t[8]=d);let f;return t[9]!==l||t[10]!==i||t[11]!==u||t[12]!==d?(f=(0,$.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":u,onAnimationEnd:l,className:d,...i}),t[9]=l,t[10]=i,t[11]=u,t[12]=d,t[13]=f):f=t[13],f}function pt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ht(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`relative flex w-full min-w-0 flex-col p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _t(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,asChild:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?u:`div`,s;t[4]===n?s=t[5]:(s=o(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,n),t[4]=n,t[5]=s);let c;return t[6]!==a||t[7]!==r||t[8]!==s?(c=(0,$.jsx)(a,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:s,...r}),t[6]=a,t[7]=r,t[8]=s,t[9]=c):c=t[9],c}function vt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function yt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function bt(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var xt=c(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function St(e){let t=(0,Q.c)(28),n,r,i,a,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],s=t[5],c=t[6],l=t[7]):({asChild:i,isActive:a,variant:s,size:c,tooltip:l,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l);let m=i===void 0?!1:i,h=a===void 0?!1:a,g=s===void 0?`default`:s,_=c===void 0?`default`:c,v=m?u:`button`,y=I.use(rt),b;t[8]!==n||t[9]!==_||t[10]!==g?(b=o(xt({variant:g,size:_}),n),t[8]=n,t[9]=_,t[10]=g,t[11]=b):b=t[11];let x;t[12]!==v||t[13]!==h||t[14]!==r||t[15]!==_||t[16]!==b?(x=(0,$.jsx)(v,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":_,"data-active":h,className:b,...r}),t[12]=v,t[13]=h,t[14]=r,t[15]=_,t[16]=b,t[17]=x):x=t[17];let S=x;if(!l)return S;if(!y)throw Error(`SidebarMenuButton tooltip requires a SidebarProvider.`);if(typeof l==`string`){let e;t[18]===l?e=t[19]:(e={children:l},t[18]=l,t[19]=e),l=e}let C;t[20]===S?C=t[21]:(C=(0,$.jsx)(d,{asChild:!0,children:S}),t[20]=S,t[21]=C);let w=y.state!==`collapsed`,T;t[22]!==w||t[23]!==l?(T=(0,$.jsx)(f,{side:`right`,align:`center`,hidden:w,...l}),t[22]=w,t[23]=l,t[24]=T):T=t[24];let ee;return t[25]!==C||t[26]!==T?(ee=(0,$.jsxs)(p,{children:[C,T]}),t[25]=C,t[26]=T,t[27]=ee):ee=t[27],ee}function Ct(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,asChild:i,showOnHover:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let s=i===void 0?!1:i,c=a===void 0?!1:a,l=s?u:`button`,d=c&&`group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0`,f;t[5]!==n||t[6]!==d?(f=o(`absolute top-1.5 end-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0`,d,n),t[5]=n,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==l||t[9]!==r||t[10]!==f?(p=(0,$.jsx)(l,{"data-slot":`sidebar-menu-action`,"data-sidebar":`menu-action`,className:f,...r}),t[8]=l,t[9]=r,t[10]=f,t[11]=p):p=t[11],p}var wt=`flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none hover:bg-muted-foreground/20 hover:text-foreground hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/50`,Tt=`bg-sidebar-selected text-sidebar-selected-foreground`,Et=`bg-sidebar-selected! text-sidebar-selected-foreground!`,Dt=`bg-sidebar-hover! text-sidebar-hover-foreground!`,Ot=`${Tt} hover:bg-sidebar-selected focus-visible:bg-sidebar-selected`,kt={start:[F.Space],cancel:[F.Esc],end:[F.Space,F.Enter]};function At(e){return o(wt,e?`mr-1 opacity-100`:`pointer-events-none absolute right-1 opacity-0 group-hover:pointer-events-auto group-hover:opacity-100`)}var jt=`overflow-hidden whitespace-nowrap mask-r-from-[calc(100%-1.5rem)] mask-r-to-[100%]`;function Mt(e){return e?jt:`truncate group-hover:text-clip group-hover:mask-r-from-[calc(100%-3rem)] group-hover:mask-r-to-[calc(100%-1.5rem)]`}function Nt(e){return e?void 0:-1}function Pt({className:e,isDragging:t}){return o(e,t&&Ot)}function Ft(e){return e.code===F.Enter&&e.target===e.currentTarget}function It(e){return e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`}function Lt(e,t,n){for(let r of e.querySelectorAll(`[data-editor-tab-id]`))if(r.dataset.editorPaneId===t&&r.dataset.editorTabId===n)return r;return null}function Rt({event:e,hasKeyboardActivation:t,isDragging:n}){return e.defaultPrevented?`ignore`:!n&&t&&Ft(e)?`activate-tab`:`delegate-sortable`}function zt({activeWidth:e,disableMovement:t=!1,isDragging:n,outerStyle:r,transform:i,transition:a}){let o=n&&e?e:void 0;return{...r,transform:t?void 0:N.Transform.toString(i?{...i,scaleX:1,scaleY:1}:null),transition:t?void 0:a,flexBasis:o??r?.flexBasis,maxWidth:o??r?.maxWidth,minWidth:o??r?.minWidth,opacity:r?.opacity,width:o??r?.width,zIndex:n?20:r?.zIndex}}function Bt(e,t){let n=e?.querySelectorAll(t)??[],r=1/0,i=-1/0;for(let e of n){let t=e.getBoundingClientRect();r=Math.min(r,t.left),i=Math.max(i,t.right)}return Number.isFinite(r)&&Number.isFinite(i)?{left:r,right:i}:null}function Vt(e){return({activeNodeRect:t,transform:n})=>{let r={...n,y:0};if(!e||!t)return r;let i=e.left-t.left,a=e.right-t.right;return r.x=Math.min(Math.max(r.x,i),a),r}}function Ht(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`editor-tab`&&typeof t.paneId==`string`&&typeof t.tabId==`string`&&typeof t.splittable==`boolean`&&typeof t.label==`string`}function Ut(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`pane-edge`?typeof t.paneId==`string`&&(t.side===`left`||t.side===`right`):t.kind===`pane-strip`&&typeof t.paneId==`string`&&typeof t.index==`number`&&Number.isInteger(t.index)}function Wt(e,t){return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function Gt(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}var Kt=e=>{let t=e.droppableContainers.filter(e=>e.data.current?.kind===`pane-edge`),n=e.droppableContainers.filter(e=>e.data.current?.kind!==`pane-edge`),r=e.active.data.current,i=e.pointerCoordinates;if(i&&Ht(r)&&r.splittable){let n=t.find(t=>{let n=e.droppableRects.get(t.id);return n?Wt(i,n):!1});if(n)return[{id:n.id,data:{droppableContainer:n,value:0}}]}if(i){let t=n.filter(t=>{let n=e.droppableRects.get(t.id);return n?Wt(i,n):!1});if(t.length>0){let n=t.filter(e=>Ht(e.data.current));return P({...e,droppableContainers:n.length>0?n:t})}let r=n.filter(t=>{let n=t.data.current,r=e.droppableRects.get(t.id);return n?.kind!==`pane-strip`||!r?!1:Gt(e.collisionRect,r)});if(r.length===0)return[];let a=new Set(r.map(e=>e.data.current?.paneId)),o=n.filter(t=>{let n=t.data.current,r=e.droppableRects.get(t.id);return!Ht(n)||!a.has(n.paneId)||!r?!1:Gt(e.collisionRect,r)});return P({...e,droppableContainers:o.length>0?o:r})}return P({...e,droppableContainers:n})},qt=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(r){let e=1/0,i=-1/0,a=null,o=null;for(let r of t){let t=n.get(r.id);t&&(t.left<e&&(e=t.left,a=r),t.right>i&&(i=t.right,o=r))}if(!Number.isFinite(e)||!Number.isFinite(i))return[];let s=r.x<e?a:r.x>i?o:null;if(s)return[{id:s.id,data:{droppableContainer:s,value:0}}]}return P(e)};function Jt(e){Math.abs(e.deltaX)>=Math.abs(e.deltaY)||e.currentTarget.scrollWidth<=e.currentTarget.clientWidth||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY)}var Yt=`open-knowledge:new-preferred-session`;function Xt(e=typeof window>`u`?new EventTarget:window){e.dispatchEvent(new CustomEvent(Yt))}function Zt(e,t=typeof window>`u`?new EventTarget:window){let n=()=>e();return t.addEventListener(Yt,n),()=>t.removeEventListener(Yt,n)}export{be as $,pt as A,He as B,qt as C,gt as D,mt as E,bt as F,Oe as G,Ve as H,ot as I,Ee as J,xe as K,dt as L,yt as M,Ct as N,vt as O,St as P,ye as Q,ut as R,It as S,ht as T,Ae as U,ze as V,Me as W,we as X,Se as Y,Te as Z,Nt as _,Dt as a,he as at,Ut as b,Et as c,re as ct,Kt as d,G as dt,_e as et,Lt as f,At as g,zt as h,wt as i,pe as it,ft as j,_t as k,jt as l,J as lt,Rt as m,Zt as n,me as nt,kt as o,ae as ot,Pt as p,De as q,Jt as r,de as rt,Tt as s,se as st,Xt as t,ge as tt,Vt as u,H as ut,Mt as v,lt as w,Bt as x,Ht as y,at as z};
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-DKflYxqj.mjs";import"./init-Cuw6M3ez.mjs";import"./registry-probes-CpizlLKe.mjs";import"./src-C7TYDpda.mjs";import"./start-Dd8Kjf4r.mjs";import{n as e}from"./loader-DDluoWkF.mjs";import"./preview-ZhG30yAN.mjs";import"./cli.mjs";import"./repair-mcp-configs-ooUrwLkV.mjs";export{e as loadConfig};
@@ -1 +0,0 @@
1
- import{S as e,m as t,p as n,r}from"./start-Dd8Kjf4r.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};