@inkeep/open-knowledge 0.87.2-beta.1 → 0.87.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES.md +1 -0
- package/dist/cli.mjs +75 -75
- package/dist/constants-CjsWLxV4.mjs +1 -0
- package/dist/dist-BB-NSwQc.mjs +2214 -0
- package/dist/dist-BKGJO_91.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-C34FkXTd.mjs → init-BBJX1tEw.mjs} +11 -11
- package/dist/init-C6SuzeQN.mjs +1 -0
- package/dist/{launch-json-removal-hdPm7JJ9.mjs → launch-json-removal-vNqkqnfB.mjs} +1 -1
- package/dist/loader-BJYhNl_Y.mjs +1 -0
- package/dist/{loader-CpVD-p7P.mjs → loader-abngpKg0.mjs} +1 -1
- package/dist/{open-browser-Cv1yuEQw.mjs → open-browser-DWKagh4v.mjs} +1 -1
- package/dist/preview-DhGoOOxK.mjs +1 -0
- package/dist/{preview-D1IEqXE0.mjs → preview-_9prk5GA.mjs} +1 -1
- package/dist/public/assets/{AccountSection-BKI8ful_.js → AccountSection-BCXD7SZC.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-Cs8zvxnL.js → ActivityModeContent-BiulaGM9.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CEOdUsGs.js → AddPropertiesButton-UiasLZDQ.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-CzfUNzhW.js → AgentDiffPane-BxnJ3oTx.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-BAyVJFgf.js → AttachmentsSection-C5Sq9Rll.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BbOfR2Hg.js → CodeMirrorPropInput-CiKaTdcp.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-B6i1cLKg.js → ContentRulesSection-Dtu5BXHJ.js} +1 -1
- package/dist/public/assets/{DocumentContext-Ctu-HqT4.js → DocumentContext-CbdZO9O_.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-BxpOZKiM.js → EditorModeToggle-B_Y0Hud7.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CYiYdvF2.js → ExcalidrawDocEditor-DB2r-yaj.js} +1 -1
- package/dist/public/assets/FeedbackForm-DwdxS-5f.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-HOR9EZ2f.js → ImportSkillDialog-BZI83yK9.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-BQvvaJUI.js → LinkPreviewsSection-PSoIWcWo.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CWrXBDG_.js → LintConfigEditor-B4hXoSya.js} +1 -1
- package/dist/public/assets/{LintingSection-BiPYwYIO.js → LintingSection-Db_SW956.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-CadUWUsq.js → ManagedArtifactProperties-D9HOt10R.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-htmBqfrM.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-BxFPCx7g.js → MermaidDocEditor-CDOsMOCI.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-C_JY6CML.js → NetworkAccessSection-DmbCvoj2.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-CFACWxIE.js → PropertyDisplayRow-BEXJg0bS.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-Qg9R2-X0.js → PublishToGitHubDialog-CSObj1A1.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DEecND8S.js → SchemaConfigEditor-DYJLLjlf.js} +1 -1
- package/dist/public/assets/{SearchSection-C5h5t5Bm.js → SearchSection-DqJaDdzF.js} +1 -1
- package/dist/public/assets/{SessionsHost-DrGOAImZ.js → SessionsHost-DOlg6s6y.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-9HsCyl9q.js → SettingsDialogBody-B_JAITG9.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-N7vak44i.js → ShareReceiveMissDialog-CZRdcwHO.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-J3FRPp-3.js → SkillToolbarControls-ZJ66SSuc.js} +1 -1
- package/dist/public/assets/{SourceEditor-DijD2qin.js → SourceEditor-CU6R9E3V.js} +1 -1
- package/dist/public/assets/{SyncSection-TX1SH2IZ.js → SyncSection-Bo3LJcJU.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-i2xTrKQt.js → SyncStatusBadge-Dydd5r0z.js} +1 -1
- package/dist/public/assets/{TerminalSection-DIDjGimp.js → TerminalSection-DkzpJFCN.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-ZDSwFCcn.js → TerminalWindowApp-DLy_hfT4.js} +1 -1
- package/dist/public/assets/{TextDocEditor-BjdRabZO.js → TextDocEditor-i12Zi3JU.js} +1 -1
- package/dist/public/assets/{ThreadView-DJRjCobn.js → ThreadView-Cw5tBHCd.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-KJSvQLix.js → TimelineDiffPane-BV2A8IAW.js} +1 -1
- package/dist/public/assets/{client-version-CEUebx--.js → client-version-C0Jc4JJI.js} +1 -1
- package/dist/public/assets/{comment-chips-D8H8ksVb.js → comment-chips-Mc2Mv-pz.js} +1 -1
- package/dist/public/assets/{config-provider-QVZqDwsb.js → config-provider-CZy-mWdC.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CzYtyHUd.js → doc-undo-manager-1aQQtoK3.js} +1 -1
- package/dist/public/assets/{index-D2cACSaG.js → index-c--If4Yv.js} +7 -7
- package/dist/public/assets/{lint-plugins-CE1v_De9.js → lint-plugins-C_fUmRft.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-T3ZXK0s-.js → pending-receive-nav-store-Bb17fKS7.js} +1 -1
- package/dist/public/assets/{preferred-session-events-D2WKSTxQ.js → preferred-session-events-B2jU9Gzw.js} +1 -1
- package/dist/public/assets/{progress-CMZzr1ER.js → progress-CW3N-5hS.js} +1 -1
- package/dist/public/assets/{selection-context-DFEuubLf.js → selection-context-Dy-Fc0jG.js} +1 -1
- package/dist/public/assets/{src-C8wJZTqQ.js → src-Cep_PKNI.js} +1 -1
- package/dist/public/assets/{telemetry-impl-crprFKOe.js → telemetry-impl-CXoXg4ey.js} +1 -1
- package/dist/public/assets/{telemetry-startup-7Tdxo-4u.js → telemetry-startup-DZ2uqGCJ.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DdtI04xk.js → typing-burst-detector-Dw4u-apo.js} +1 -1
- package/dist/public/assets/{use-activity-panel-2Bs8Bhwk.js → use-activity-panel-CYP7NKHc.js} +1 -1
- package/dist/public/assets/{use-open-skill-B4p8VMLX.js → use-open-skill-D2nS0EB4.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DiTNDooB.js → use-terminal-enabled-C5444lCZ.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-JtbYOyhK.js → use-timeline-entry-diff-B6KJiK5_.js} +1 -1
- package/dist/public/index.html +19 -19
- package/dist/{registry-probes-BiySrvm_.mjs → registry-probes--ag3GT86.mjs} +3 -3
- package/dist/{removal-file-path-DUFtjkkZ.mjs → removal-file-path-Bfn04hQq.mjs} +1 -1
- package/dist/{repair-launch-json-B3uRu9qh.mjs → repair-launch-json-BLf3YgHr.mjs} +1 -1
- package/dist/{repair-mcp-configs-CYq7vfOM.mjs → repair-mcp-configs-D3Y1J0gf.mjs} +1 -1
- package/dist/src-C6N6mOpp.mjs +16 -0
- package/dist/src-Ds42jGaJ.mjs +1 -0
- package/dist/start-BEgiZxiL.mjs +1 -0
- package/dist/{start-CaZG06fC.mjs → start-C8uhecrD.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-DwtiG-TC.mjs +0 -1
- package/dist/dist-B_I6SNFI.mjs +0 -1
- package/dist/dist-WFhah2YJ.mjs +0 -2214
- package/dist/init-Dg1lyv-G.mjs +0 -1
- package/dist/loader-H2SukW6-.mjs +0 -1
- package/dist/preview-DDxcD2r1.mjs +0 -1
- package/dist/public/assets/FeedbackForm-BJ2Oe5Na.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CrGTWjB7.js +0 -1
- package/dist/src-CPB_oYOe.mjs +0 -16
- package/dist/src-Cee3yPhD.mjs +0 -1
- package/dist/start-D4vJF_D3.mjs +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{$c as t,$u as n,Bf as r,Bl as i,Ca as a,Ef as o,Ff as s,G as c,If as l,Jc as u,Mf as d,Sa as f,Tf as ee,U as p,Vl as m,W as h,Yc as g,bf as _,el as v,jf as y,kf as b,l as x,u as te}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{Co as S,Di as C,Ei as w,Gi as T,Mt as E,Ra as D,Ti as O,Uo as k,Zt as A,bs as j,fi as M,fr as N,ga as ne,gr as re,gs as P,ki as ie,m as F,nr as I,qi as ae,ra as oe,ri as se,vs as ce,ya as le,yi as ue,ys as de,zs as fe}from"./dist-BB-NSwQc.mjs";import{t as pe}from"./yazl-BBz29IQN.mjs";import{ct as me,gt as he,ht as ge,mt as _e,pt as ve,st as ye,wt as be}from"./init-BBJX1tEw.mjs";import{T as xe,l as Se,u as Ce}from"./registry-probes--ag3GT86.mjs";import{c as we}from"./colors-r_owlCuY.mjs";import{t as Te}from"./is-object-BGze3w87.mjs";import{n as Ee}from"./constants-CjsWLxV4.mjs";import"./loader-abngpKg0.mjs";import"./preview-_9prk5GA.mjs";import{execFile as De,execSync as Oe,spawnSync as ke}from"node:child_process";import{basename as L,dirname as R,isAbsolute as Ae,join as z,relative as je,resolve as B,sep as V,win32 as Me}from"node:path";import{closeSync as Ne,cpSync as Pe,createWriteStream as Fe,existsSync as H,lstatSync as Ie,mkdirSync as U,mkdtempSync as Le,openSync as Re,readFileSync as W,readSync as ze,readdirSync as G,readlinkSync as Be,realpathSync as Ve,rmSync as K,rmdirSync as He,statSync as Ue,writeFileSync as q}from"node:fs";import{arch as We,freemem as Ge,homedir as J,hostname as Ke,platform as qe,release as Je,tmpdir as Ye,totalmem as Xe,type as Ze,uptime as Qe}from"node:os";import{readFile as $e,readdir as et,stat as tt}from"node:fs/promises";import{createHash as nt}from"node:crypto";function rt(e,t){let n=t.map(e=>[fe(e),e]);for(let t of e){let e=fe(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function it(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=rt([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=rt(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function at(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const ot=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function st(e,t,n=re){if(e!==void 0&&!ot.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ct=null;function lt(e){ct=e}function ut(){return ct??process.cwd()}const dt=`Open Knowledge`;function ft(e={}){let t=e.platformName??process.platform,n=e.productName??d().productName;return ye(t).join(me({...e,platformName:t}),n)}function pt(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=ye(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,`${d().packageName.replaceAll(`/`,``)}-updater`)}function mt(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 ht(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return mt(n)??[]}function gt(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return mt(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const _t=8192;function vt(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 yt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const bt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function xt(e){return e.replace(bt,`$1"[REDACTED-DEVICE-ID]"`)}function St(e){return xt(yt(e))}const Ct=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function wt(e){if(typeof e!=`string`)return null;let t=Ct.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 Tt(e){let t=Re(e,`r`);try{let e=Buffer.alloc(_t),n=0,r=!1;for(;n<_t;){let i=ze(t,e,n,_t-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{Ne(t)}}function Et(e){try{let t=Tt(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:wt(a)}}catch{return{kind:`unreadable`}}}function Dt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Ot(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=Ue(n).mtimeMs}catch{continue}if(r<i)continue;let c=Et(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Dt(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`}}const kt=`state/os-termination-evidence.json`,At=6048e5,jt=/openknowledge/i,Mt=b.map(e=>l(o[e]));function Nt(e={}){return(t,n)=>new Promise(r=>{try{De(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Pt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Pt(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function Ft(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
2
|
+
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function It(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function Lt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Rt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function zt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Bt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Vt(e,t){let n=t.indexOf(`
|
|
3
|
+
`);if(n===-1)return null;let r,i;try{r=Bt(JSON.parse(t.slice(0,n))),i=Bt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=Bt(e);t===null||typeof t.name!=`string`||!Dt(t.name)||a.push({name:t.name,pid:zt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:zt(t.rpages),lifetimeMaxPages:zt(t.lifetimeMax)})}let o=wt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:zt(Bt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?Dt(i.largestProcess):null,ownedProcesses:a}}const Ht=/^JetsamEvent-.*\.ips$/;function Ut(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function Wt(e,t){let n=It(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await et(e)}catch(e){return Lt(n,e.code??`unknown`)}let i=Ut(await Promise.all(r.filter(e=>Ht.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await tt(z(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-At,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Vt(t,await $e(z(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Rt(n)}const Gt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Kt=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],qt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,Jt=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,Yt=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function Xt(e,t){let n=new Set,r;try{r=await et(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!Yt.test(a))continue;let r=z(e,a);try{if(t.getTime()-(await tt(r)).mtimeMs>At)continue;for(let e of(await $e(r,`utf8`)).split(`
|
|
4
|
+
`)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function Zt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:jt.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function Qt(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
5
|
+
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=qt.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!jt.test(s)){n+=1;continue}let c=Zt(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function $t(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
6
|
+
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=qt.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=Jt.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function en(e,t,n){let r=$t(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await Xt(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function tn(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function nn(e,t,n){let r=It(`linux`,`linux-journal`,[`journalctl ${Gt.join(` `)}`,`journalctl ${Kt.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...Gt]),e(`journalctl`,[...Kt])]),o=[];if(tn(i)){let e=Qt(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${Ft(i)}`);if(tn(a)){let e=await en(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${Ft(a)}`);return o.length===2?Lt(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:Rt(r)}const rn={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},an={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function on(e){return e===`System`?rn:an}function sn(e){let t=`System[(${Object.keys(on(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${At}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${Mt.map(e=>`Data='${e}'`).join(` or `)}]]`}function cn(e){return[`qe`,e,`/q:${sn(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function ln(e){return Me.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function un(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function dn(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function fn(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>un(e[1]??``).trim())}function pn(e,t){let n=on(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=fn(o,`Data`),u=fn(o,`Name`),d=[...l,...u].some(e=>jt.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!dn(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function mn(e,t){let n=ln(t),r=[`System`,`Application`],i=It(`win32`,`windows-event-log`,r.map(e=>`${n} ${cn(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,cn(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${Ft(t)}`);continue}let n=pn(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?Lt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:Rt(i)}async function hn(e={}){let t=e.platform??process.platform,n=e.runCommand??Nt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Wt(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return nn(n,r,e.desktopLogsDir??z(P(),`logs`));case`win32`:return mn(n,e.systemRoot??process.env.SystemRoot);default:return{...It(t,null,[]),outcome:`unsupported`}}}const gn={schemaVersion:1,outcome:`not-collected`};function _n(e){return`${JSON.stringify(e??gn,null,2)}\n`}const vn={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system and user journals`,"windows-event-log":`Windows event logs`};function yn(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${vn[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function bn(){return z(P(),`bug-reports`)}function xn(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=bn(),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 Sn(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Cn(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`))?nt(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function wn(){let e={timestamp:new Date().toISOString(),platform:qe(),osType:Ze(),osRelease:Je(),hostname:`[redacted]`,uptime:Qe(),freeMem:Ge(),totalMem:Xe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=Oe(`sw_vers -productVersion 2>/dev/null`,k({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 Tn=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function En(e){let t=L(e);return Tn.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Dn(e,t){return jn(e,t).files}const On=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function kn(e,t=Ce){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return On.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 An(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,-x.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 jn(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(En),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=>!En(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Mn(e){let n=z(e,`.ok`,`local`);return H(n)?{files:[`server.lock`,`last-spawn-error.log`,t,g].map(e=>z(n,e)).filter(e=>H(e))}:{files:[]}}function Nn(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 Pn(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#${nt(`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 Fn(e){let t=e.revealDocNames?e.content:Pn(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=a(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function Y(e){for(let t of e.files)try{let n=W(t,`utf8`);Fn({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?St(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 In(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??z(P(),`logs`),s=t.projectDir?Cn(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=wn();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=jn(s,o),{files:d}=t.projectDir?Mn(t.projectDir):{files:[]},{files:ee}=t.projectDir?Nn(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:ee.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 _;Y({zipfile:v,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:ee,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),Y({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);let r=Sn(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Fn({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)`:vt(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`),Fn({zipfile:v,name:kt,content:_n(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:g,redactions:h});let S=JSON.stringify(c,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:s,files:g,redactions:h,sysinfo:c};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=>`${te}/${L(e)}`)),O=g.filter(e=>D.has(e)),k=s?g.filter(e=>e.startsWith(`logs/`)&&!En(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: ${s??`(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}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system's own logs, covering`,`the last 7 days, to explain an exit the app could not record itself. On`,`macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${kt}`,``]:[],...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: ${f.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(`
|
|
7
|
+
`);v.addBuffer(Buffer.from(M,`utf8`),`README.md`),v.end();let N=Fe(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:s,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var Ln=n(),Rn=e(pe(),1),X=e(we(),1);function zn(e){let t=j(`user`,e,e);return ce({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Bn({home:e=J(),env:t=process.env}={}){let n=zn(e),{override:r,preferenceList:a}=de(t),{locale:o,source:s}=it({override:r,storedPreference:n,supportedLocales:m,preferenceList:a,autoDetectableLocales:i});return{preference:n,locale:o,source:s,systemLanguages:a}}function Vn(e){let t=new Set([e]);try{t.add(Ve.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function Hn(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function Un(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Wn(e,t){if(typeof e==`string`)return Hn(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>Wn(e,t));if(!Un(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Wn(i,t);return n}function Gn(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
8
|
+
`),i=n.split(`
|
|
9
|
+
`),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=Wn(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
10
|
+
`)}\n`:a.join(`
|
|
11
|
+
`);q(e,o)}function Kn(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=Wn(JSON.parse(n),t),i=n.endsWith(`
|
|
12
|
+
`)?`
|
|
13
|
+
`:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Hn(n,t.contentDirSpellings);r!==n&&q(e,r)}}function qn(e,t){let n=W(e,`utf-8`),r=Hn(n,t.contentDirSpellings);r!==n&&q(e,r)}function Jn(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const Yn=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Xn(e){return/\.log\.\d+$/.test(e)}function Zn(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Xn(e)}const Qn=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function $n(e){let t={contentDirSpellings:Vn(e.contentDir)};for(let n of Qn)for(let r of Jn(z(e.stagingDir,n)))Zn(r)?Gn(r,t):r.endsWith(`.json`)?Kn(r,t):qn(r,t);for(let n of Jn(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?Gn(n,t):Yn.has(e)?Kn(n,t):qn(n,t)}}const er=[`.ok`,`local`,`telemetry`],tr=[`.ok`,`local`,`logs`],nr=[`.ok`,`local`,`loss-capture`],rr=`spans-current.jsonl`,ir=`spans-prev.jsonl`,ar=`server-current.jsonl`,or=`server-prev.jsonl`,sr=`loss-current.jsonl`,cr=`loss-prev.jsonl`;function lr(e){return z(e,...er,rr)}function ur(e){return z(e,...er,ir)}function dr(e){return z(e,...tr,ar)}function fr(e){return z(e,...tr,or)}function pr(e){return z(e,...nr,sr)}function mr(e){return z(e,...nr,cr)}const hr=1e3;async function gr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(hr)});return t.ok?await t.text():null}catch{return null}}async function _r(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(hr)});return t.ok?await t.text():null}catch{return null}}async function vr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(hr)});return t.ok?await t.text():null}catch{return null}}function yr(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
14
|
+
`)}\n`:null}catch{return null}}function br(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=ke(`git`,[`-C`,t,`log`,`--oneline`,`-50`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function xr(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=ke(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],k({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Sr(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function Cr(){return{nodeVersion:process.version,platform:qe(),arch:We()}}function wr(){return process.env.OTEL_SDK_DISABLED===`false`}function Tr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Er(e){if(!H(e))return{};let t;try{t=(0,Ln.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!Tr(t))return{};let n=t.telemetry;if(!Tr(n))return{};let r=n.localSink;return Tr(r)?r:{}}function Dr(e){return typeof e==`boolean`?e:void 0}function Or(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function kr(e){if(Tr(e))return Or(e.maxBytes)}function Ar(e){let t=Er(j(`project`,e)),n=Er(j(`project-local`,e));return{enabled:Dr(n.enabled)??Dr(t.enabled)??!0,spansMaxBytes:kr(n.spans)??kr(t.spans)??52428800,logsMaxBytes:kr(n.logs)??kr(t.logs)??26214400}}function jr(e){return nt(`sha256`).update(e).digest(`hex`)}function Mr(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Nr=[`"doc.name"`,`"docName"`];function Pr(e){let t=W(e,`utf-8`),n=0;for(let e of Nr){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,St(W(e,`utf-8`))):Pe(e,t),!0}catch{return!1}}function Fr(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Ir=new Set([`.jsonl`]);function Lr(e){let t=e.lastIndexOf(`.`);return t!==-1&&Ir.has(e.slice(t))}const Rr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function zr(e){if(Xn(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Rr.has(e.slice(t))}function Br(e){let t=[];for(let n of Fr(e)){let r=Vr(e,n);if(!zr(r))continue;let{redacted:i,patterns:o,lineCount:s}=a(W(n,`utf-8`));o.length!==0&&(q(n,i),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Vr(e,t){return je(e,t).split(V).join(`/`)}async function Hr(e){let n=B(e.contentDir),r=B(e.projectDir??e.contentDir),i=e.deps??{},a=i.fetchAgentPresence??gr,o=i.fetchAgentEffects??_r,s=i.fetchWatcherRecent??vr,c=i.readShadowHead??br,l=i.readCheckpointRefs??xr,u=i.now??(()=>new Date),d=i.okVersion??(()=>Ee),f=i.readDesktopEnv??Sr,ee=i.readLanguage??Bn,p=i.readRuntime??Cr,m=i.isOtlpPushEnabled??wr,h=Le(z(Ye(),`ok-bundle-`));try{U(z(h,`telemetry`),{recursive:!0}),U(z(h,`logs`),{recursive:!0}),U(z(h,`state`),{recursive:!0}),Z(lr(r),z(h,`telemetry`,rr)),Z(ur(r),z(h,`telemetry`,ir)),Z(dr(r),z(h,`logs`,ar)),Z(fr(r),z(h,`logs`,or));for(let t of e.userLogFiles??[])Z(t,z(h,`logs`,L(t)));for(let t of e.userStateFiles??[])Z(t,z(h,te,L(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Z(t,z(h,`diagnostic-reports`,L(t)))&&(_+=1);let y=z(r,`.ok`,`local`),b=z(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Z(b,z(h,`state`,`server.lock`));try{let e=W(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await a(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(q(z(h,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await o(C);t!==null&&q(z(h,`state`,`agent-effects.json`),t);let n=await s(C);if(n!==null){let e=yr(n);e!==null&&q(z(h,`state`,`watcher-recent.jsonl`),e)}}let w=c(n);w!==null&&q(z(h,`state`,`shadow-head.txt`),w);let T=l(n);T!==null&&q(z(h,`state`,`checkpoint-refs.txt`),T),Z(pr(r),z(h,`state`,sr)),Z(mr(r),z(h,`state`,cr)),Z(z(y,`last-spawn-error.log`),z(h,`state`,`last-spawn-error.log`)),Z(z(y,v),z(h,`state`,v)),Z(z(y,t),z(h,`state`,t)),Z(z(y,g),z(h,`state`,g));let E=p(),D=f(),O=ee(),k={ok:{version:d(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};q(z(h,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
15
|
+
`:`not-running (${S})\n`;q(z(h,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:vt(e.diagnosticReports,_);if(q(z(h,`state`,`diagnostic-reports-status.txt`),`${j}\n`),q(z(h,kt),_n(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(h,`process`);U(t,{recursive:!0}),Pe(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&$n({stagingDir:h,contentDir:n}),e.note&&q(z(h,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Br(h));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!Z(t.sourcePath,z(h,`extra`,e))){i.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=Sn(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let ne=Ar(r),re=Fr(h),P=[],ie=0,F=0;for(let e of re){let t=Vr(h,e),n=Ue(e).size,r=Lr(t)?Mr(e):0;P.push({path:t,bytes:n,lines:r}),ie+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(F+=Pr(e))}let I={applied:M};N!==null&&(I.secretScrub=N);let ae={schemaVersion:2,createdAt:u().toISOString(),ok:{version:d(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:jr(n),absolutePath:M?`<CONTENT_DIR>`:n},telemetry:{localSink:ne,otlpPushEnabled:m()},redaction:I,serverStatus:x,files:P};q(z(h,`manifest.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=Vn(n),se=re.some(e=>{try{let t=W(e,`utf-8`);return oe.some(e=>t.includes(e))}catch{return!1}}),ce={stagedDiagnosticReports:_,totalBytes:ie,fileCount:P.length,docNameCount:F,contentDirVisible:se,redacted:M},le=!1;return{stagingDir:h,manifest:ae,summary:ce,cleanup:()=>{le||(le=!0,K(h,{recursive:!0,force:!0}))}}}catch(e){throw K(h,{recursive:!0,force:!0}),e}}async function Ur(e){let{collected:t,outputPath:n}=e,r=R(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Rn.ZipFile,a=Fr(t.stagingDir);for(let e of a){let n=Vr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=Fe(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Wr(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,Ln.parse)(W(n,`utf-8`)),r=Te(t)?t.content:void 0,i=Te(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return B(e)}async function Gr(e,t,n,r,i,a){let o=Cn(t,e.logger),s=await Hr({contentDir:Wr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Dn(o,e.userLogsDir??z(P(),`logs`)),...kn(e.cachesDir??z(J(),`Library`,`Caches`))],userStateFiles:An(e.bugReportsDir??bn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await Ur({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Kr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Sr,r=e.readLanguage??Bn,i=()=>Ot(e.diagnosticReportsDir??z(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Gr(e,t,n,r,i(),await hn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await In({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:kn(e.cachesDir??z(J(),`Library`,`Caches`)),bugReportLedgerFiles:An(e.bugReportsDir??bn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await hn(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function Q(e,t,n={}){let r=C(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r,text:i}}let o=a&&typeof a==`object`?a:{},s=ne(o),c=s&&!se(o,n);if(!a||typeof a!=`object`||!ue(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=S(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=A(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function qr(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function Jr(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${ie()}`:`records only the host ${Se(e.hostname)}, not this machine's ${Ke()}`}function Yr(e){return e===`win32`?`USERPROFILE`:`HOME`}function Xr(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${y()} stop\` confirm it from any home folder.`:``}function Zr(e,t){let n=`\`${y()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${Yr(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${Xr(e)}`}function Qr(e,t){let n=y();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${Yr(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${Xr(e)}`}function $r(e){return`Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e} and retry cleanup.`}function ei(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?Qr(n,t):`If ${Se(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${$r(r)}`}function ti(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${qr(e.pid)}. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${$r(n)}`:`Cannot verify shutdown: the server lock at ${n} ${Jr(e.lock)}. ${ei(e,t)}`}function ni(e){return e.replace(/:\d+$/,``)}function ri(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:ni(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:ni(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:ni(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const ii=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function ai(e){return c(r(),e)}function oi(){return h(r())}function si(){let e=r();if(e===`stable`)return ii;let t=p(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const ci={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>Ie(e),readlinkSync:e=>Be(e)};function li(e,t=ci){let n=ai(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function ui(e){let t=e.replace(si(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function di(e,t,n=ci){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const fi=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],pi=[...E.map(e=>F[e]),`open-knowledge`];function mi(e){if(!Ae(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function hi(e,t){let n=je(e,t);if(n.startsWith(`..`)||Ae(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!Ie(r).isDirectory())return!1}catch{return!1}}return!0}function gi(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function _i(e){let t=mi(e),n=[],r=[],i=new Set;for(let e of fi){let a=z(t,e.hostDir,`skills`);if(!hi(t,a))continue;let o=pi.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;gi(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function vi(e){try{if(!Ie(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function yi(e){let t=new Set,n=new Set;for(let r of fi){let i=z(e,r.hostDir,`skills`);for(let e of pi)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function bi(e,t){let n=mi(e),r=yi(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(hi(n,e)&&vi(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(hi(n,e))try{He(e),a.push(e)}catch{}return a}function xi(e){let t=mi(e),n=[];for(let e of E){let r=F[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of _)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Si(e,t){let n=[];for(let r of xi(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function Ci(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${ge(e)} readProcessStart=${t}`}function wi(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{ve(n,r),t.onNativeFailure?.({kind:e,reason:_e(n,r)})};try{let i=!1,a=he(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:Ci(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,ge(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function Ti(e,t={}){return oe(e,{platform:t.platform,readNative:e=>wi(e,{onNativeFailure:t.onNativeFailure})})}function Ei(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${u(`logs`)}. `:``)}function Di(e){let t=new Set;return le(n=>{let r=[],i=wi(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??xe())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Oi(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function ki(e,t=Date.now()){if(e===null)return`—`;let n=at(e,t);return n===`unknown`?`—`:n}function Ai(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function ji(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Ai(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&O(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:N(n),command:n,isDesktop:Oi(n)}}function Mi(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:case`reused-pid`:return`stale`;default:return t}}const Ni=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Pi(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`unverified`:case`stale`:return X.default.yellow(e)}}function Fi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Ii(e){return`${Fi(e.server.usage)} | ${Fi(e.ui?.usage??null)}`}function Li(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Ri(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,Li(e),Ii(e),Mi(e),String(e.server.pid),ki(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=Pi(Mi(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ${y()} stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
16
|
+
`)}async function zi(e={}){let t=e.discover??I,n=e.inspect??(e=>Q(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??T,a=e.resolveUsage??ae,o=await t(),s=[];for(let e of o){let t=n(e),r=ji(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Mi(e)}));r(JSON.stringify(e,null,2));return}r(Ri(e.all?s:s.filter(e=>Ni.has(Mi(e)))))}function Bi(){return new be(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await zi({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Vi(e,t=xe()){let n=Q(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=w(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function Hi(e,t={}){return $(e,t.isAlive??M)?{targets:[{name:`server`,pid:e.lock.pid,port:e.lock.port}],lock:e.lock}:{targets:[]}}function Ui(e){try{return r()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function Wi(e){let t=e.inspect??(()=>Q(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??Vi,o=e.logger??xe(),c=e.platform??process.platform,l=t(),u=Hi(l,{isAlive:e.isAlive}),{lock:d}=u,f=[],p=[],m=(t,n)=>{o?.warn({lockDir:e.lockDir,lockPath:n.lockPath,lockPid:n.pid,platform:c,cause:n.cause,...`nativeFailures`in n&&n.nativeFailures.length>0?{nativeFailures:n.nativeFailures}:{}},`stop declined: lock holder identity unverified`),p.push({target:t,error:qi(n,o!==void 0),unverified:n})},h=()=>{if(f.length>0){let e=f.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);r(`Stopped: ${e}`)}if(o?.info({lockDir:e.lockDir,signalled:f.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:p.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),p.length>0){let e=p.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `);i(`Failed to stop: ${e}`)}return{stopped:f,failed:p,hadTargets:!0}};if(l.status===`unverified-owner`){let{pid:e,lockPath:t}=l;return m({name:`server`,pid:e},{cause:`unverified-owner`,pid:e,lockPath:t}),h()}if(d===void 0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let g=l.status===`alive`||l.status===`foreign-host`?l.lock.channel:void 0;if(e.force!==!0&&typeof g==`string`&&g.length>0){let t=e.selfChannel??Ui(o);if(t!==void 0&&g!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${s(g)}. `+(g===`dev`?`Stop it from that dev build, or run \`${ee} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),o?.warn({lockDir:e.lockDir,holderChannel:g,selfChannel:t,pids:u.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:g}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:u.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}for(let t of u.targets){let a=[],o=(e.readProcessStart??Ti)(t.pid,{platform:c,onNativeFailure:e=>{a.push(e)}}),s=A(d,{isAlive:e.isAlive??M,readProcessStart:()=>o,refuseHolderStartedAfterLock:e.refuseHolderStartedAfterLock});switch(s.verdict){case`writer`:try{n(t.pid,`SIGTERM`),f.push(t)}catch(e){p.push({target:t,error:e instanceof Error?e.message:String(e)})}break;case`gone`:r(`${t.name} (pid=${t.pid}) had already exited`);break;case`replaced`:i(`Process ${t.pid} is no longer the server that wrote ${l.lockPath}; it was not signalled. Run \`${y()} clean\` to remove the stale lock.`);break;case`unverified`:m(t,Gi(s.cause,{pid:t.pid,lockPath:l.lockPath,lock:d,platform:c,nativeFailures:a}));break;default:return s}}return h()}function Gi(e,t){let{pid:n,lockPath:r}=t;switch(e){case`foreign-host`:return{cause:e,pid:n,lockPath:r,lock:t.lock,platform:t.platform};case`unverified-owner`:return{cause:e,pid:n,lockPath:r};default:return{cause:e,pid:n,lockPath:r,platform:t.platform,nativeFailures:t.nativeFailures}}}const Ki=`it was not signalled, and --force does not override this check.`;function qi(e,t){let{pid:n,lockPath:r}=e;switch(e.cause){case`foreign-host`:{let{lock:t}=e;return typeof t.machineId==`string`?`The server lock at ${r} ${Jr(t)}, so process ${n}, which is running on this machine, cannot be confirmed as the server that wrote it; ${Ki} ${Zr(t,e.platform)}`:`The server lock at ${r} ${Jr(t)}, and the start of process ${n}, which is running on this machine, does not confirm it as the server that wrote the lock; ${Ki} If ${Se(t.hostname)} is another machine, stop the server there. If it is an earlier name of this machine, confirm that process ${n} is an OpenKnowledge server before ending it yourself, and once no OpenKnowledge server is running for this project, remove ${r}.`}case`unverified-owner`:return`The server lock at ${r} ${qr(n)}, so it cannot be confirmed as the server that wrote the lock; ${Ki} Check whether process ${n} is an OpenKnowledge server, and if it is, stop it yourself. Do not remove the lock file while that process is running.`;default:{let n=Ji(e,Ki,`Once you have confirmed no OpenKnowledge server is running for this project, remove ${r}.`,t);return e.cause===`writer-identity-unrecorded`?`${n} A server you start again with this release records its machine ID, so \`${y()} stop\` can confirm it.`:n}}}function Ji(e,t,n,r){let{pid:i,lockPath:a,platform:o,nativeFailures:s}=e,c=`Before ending process ${i} yourself, confirm that it is an OpenKnowledge server.`;switch(e.cause){case`process-start-unreadable`:return`Could not read when process ${i} started, so it cannot be confirmed as the server that wrote ${a}; ${t} `+Ei({platform:o,pid:i,nativeFailures:s,causeRecorded:r})+`${c} ${n}`;case`process-start-incomparable`:return`The start of process ${i} cannot be compared with the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-start-mismatch`:return`Process ${i} started before the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-started-after-lock`:return`Process ${i} started after the server lock at ${a} was written, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`recorded-start-in-future`:return`The server lock at ${a} records a start later than the current time on this machine, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;case`writer-identity-unrecorded`:return`The server lock at ${a} records neither a machine ID nor a process start, as locks written by version 0.25.0 and earlier do, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;default:return e.cause}}function $(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function Yi(e,t=M){let n=await I(),r=null;for(let i of n){let n=Q(i,`server`);if($(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}function Xi(e){(e.failed.length>0||e.declined!==void 0)&&(process.exitCode=1)}async function Zi(e,t){let n=await Wi({lockDir:e,force:t});return Xi(n),n}function Qi(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:` — run \`${y()} ps\` to list them`}.`}async function $i(e){let t=await I(),n=0;for(let r of t)r!==e&&$(Q(r,`server`),M)&&n++;return n}function ea(e){return new be(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable, Beta or a dev build run from source) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=D(process.cwd()),n=[],i=await Wi({lockDir:t,force:r,log:e=>n.push(e)});if(i.hadTargets){for(let e of n)console.log(e);Xi(i)}else{let e=await $i(t);console.log(Qi(process.cwd(),e,{listingFollows:e>0})),e>0&&await zi({})}return}if(i===`all`){let e=await I();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)$(Q(n,`server`),M)&&(await Zi(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await Yi(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Zi(t,r);return}let a=B(ut(),i),o=D(a),s=[],c=await Wi({lockDir:o,force:r,log:e=>s.push(e)});if(Xi(c),c.hadTargets)for(let e of s)console.log(e);else console.log(Qi(a,await $i(o)))})}export{Ot as A,Kr as C,bn as D,xn as E,ht as F,gt as I,ut as L,dt as M,pt as N,hn as O,ft as P,lt as R,Q as S,Ur as T,ui as _,Bi as a,Jr as b,bi as c,xi as d,ii as f,li as g,oi as h,ea as i,vt as j,yn as k,_i as l,ai as m,Vi as n,Ti as o,di as p,Wi as r,Di as s,Ji as t,Si as u,ri as v,Hr as w,ti as x,ei as y,st as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-BeOFzphu.mjs";import"./src-C6N6mOpp.mjs";import"./init-BBJX1tEw.mjs";import"./registry-probes--ag3GT86.mjs";import"./start-C8uhecrD.mjs";import{n as e}from"./loader-abngpKg0.mjs";import"./preview-_9prk5GA.mjs";import"./repair-mcp-configs-D3Y1J0gf.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-C8uhecrD.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{Ai as c,
|
|
2
|
-
`)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(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 ye(e,t,n,r,i){let a=b[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`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`),ve(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function be(e,t,n){if(b[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function xe(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Ce(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function we(e){return t=>{if(t.pathId===void 0)return Y();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(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 ke(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(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 $(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:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-B_I6SNFI.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?d(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,k=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Q(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CYq7vfOM.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-B3uRu9qh.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.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`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=k?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>f({absPath:h(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(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 He(t,o){let s=Re(t,o.singleFile),c=Be(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Fe(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ 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
|
-
`)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??s.server?.port,k=Oe({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:De}),A=k.dir;k.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 j;try{j=await $({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-
|
|
1
|
+
import{C as e,Cl as t,I as n,Q as r,Z as i,i as a,jf as o,yd as s}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{Ai as c,Ti as l,Wi as u,bs as d,js as f,k as p,pi as m,vs as h}from"./dist-BB-NSwQc.mjs";import{B as g,Et as _,R as v,Tt as y,Z as b,b as x,dt as S,wt as C,x as w}from"./init-BBJX1tEw.mjs";import{C as T,a as E,c as ee,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as F,t as I}from"./registry-probes--ag3GT86.mjs";import{n as te}from"./constants-CjsWLxV4.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??L,i=U(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...se.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function ue(e,t={}){let n=t._exec??L,r=U(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=de(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=ge(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function de(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(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=G(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 fe=/Logged in to \S+ account (\S+) \(/,pe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,me=/^\s*-\s*Active account:\s*true\s*$/,he=/\u001b\[[0-9;]*m/g;function ge(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){f(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(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 ye(e,t,n,r,i){let a=b[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&f(`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`),ve(o.kind)}catch(i){return f(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function be(e,t,n){if(b[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await w({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function xe(e,t,n){let r=b[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=x(b[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Ce(e,t,n){if(n===`absent`){let n=v(b[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=g(b[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function we(e){return t=>{if(t.pathId===void 0)return Y();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new y(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(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 ke(e){if(e===`off`)return`off`;if(!t.test(e))throw new y(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new y(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new y(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${o()} init\` first, then \`${o()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${o()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(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 ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(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 $(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:l,dirname:d,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-BKGJO_91.mjs`),x=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?d(w):void 0,D=w?l(w):void 0,O,k=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Q(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-D3Y1J0gf.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BLf3YgHr.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(O??n),t=Date.now(),r=await b(e);r!==`no-drain`&&x.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`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:S(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=k?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>h({absPath:d(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new y(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(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 He(t,o){let s=Re(t,o.singleFile),c=Be(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Fe(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ 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
|
+
`)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??s.server?.port,k=Oe({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:De}),A=k.dir;k.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 j;try{j=await $({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-BKGJO_91.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),Ge(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await Ue({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(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]=We(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ke(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Ve(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,F=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:te,localUrl:I,networkUrl:F,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"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`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Me({openBrowser:o.openBrowser!==!1&&E.openBrowser,explicitOn:o.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:o.singleFile!==void 0,only:o.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-DWKagh4v.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function Ue(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:l(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 We(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 \`${o()} stop\` first if you want a fresh server.`]}function Ge(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ke(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ProcessLockFileError;if(a!==void 0&&e instanceof a)return e.message;let s=n.ServerLockCollisionError;if(s===void 0||!(e instanceof s))return null;try{let e=n.readServerLock(n.resolveLockDir(t)),r=o();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${r} stop\`.`:`OpenKnowledge server is already running on this project — check \`${r} status\` or \`${r} stop\`.`}catch{return null}}function qe(e){return new C(`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)`,Ee).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)`,ke).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ze).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 _(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new _(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new _(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).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).`,Pe).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=j(D());if(n.available){k({spawn:R},n);return}console.error(O(n.reason)),process.exit(1)}await He(n,t)})}export{Ke as C,ue as D,le as E,qe as S,Le as T,Be as _,We as a,Me as b,Q as c,ke as d,Ee as f,Re as g,Ue as h,Fe as i,Ge as l,Te as m,X as n,Ve as o,De as p,$ as r,Ae as s,Z as t,Pe as u,Oe as v,Ie as w,je as x,He as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.87.2-beta.
|
|
3
|
+
"version": "0.87.2-beta.2",
|
|
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",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@parcel/watcher": "^2.5.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@inkeep/open-knowledge-app": "0.87.2-beta.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.87.2-beta.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.87.2-beta.2",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.87.2-beta.2",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.87.2-beta.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.87.2-beta.2",
|
|
72
72
|
"@types/node": "^24.7.0",
|
|
73
73
|
"@types/proper-lockfile": "^4.1.4",
|
|
74
74
|
"@types/yazl": "^3.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BeOFzphu.mjs";var e=`0.87.2-beta.1`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/dist-B_I6SNFI.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Cc as e,Et as t,Ot as n,S as r,X as i,Za as a,ac as o,fc as s,v as c}from"./md-manager-BGnqyqi1-BeOFzphu.mjs";import{$ as l,$a as u,$i as d,$n as f,$r as p,$t as m,A as h,Aa as g,Ai as _,An as v,Ao as y,Ar as b,As as x,At as S,B as C,Ba as w,Bi as T,Bn as E,Bo as D,Br as O,Bs as k,Bt as A,C as j,Ca as M,Ci as N,Cn as P,Co as F,Cr as I,Cs as L,Ct as R,D as z,Da as B,Di as V,Dn as H,Do as U,Dr as W,Dt as G,E as K,Ea as q,Ei as J,En as Y,Eo as X,Er as Z,Et as Q,F as $,Fa as ee,Fi as te,Fn as ne,Fo as re,Fr as ie,Fs as ae,Ft as oe,G as se,Ga as ce,Gi as le,Gn as ue,Go as de,Gr as fe,Gt as pe,H as me,Ha as he,Hi as ge,Hn as _e,Ho as ve,Hr as ye,Hs as be,Ht as xe,I as Se,Ia as Ce,Ii as we,In as Te,Io as Ee,Ir as De,Is as Oe,It as ke,J as Ae,Ja as je,Ji as Me,Jn as Ne,Jo as Pe,Jr as Fe,Jt as Ie,K as Le,Ka as Re,Ki as ze,Kn as Be,Ko as Ve,Kr as He,Kt as Ue,L as We,La as Ge,Li as Ke,Ln as qe,Lo as Je,Lr as Ye,Lt as Xe,M as Ze,Ma as Qe,Mi as $e,Mn as et,Mo as tt,Mr as nt,Ms as rt,Mt as it,N as at,Na as ot,Ni as st,Nn as ct,No as lt,Nr as ut,Ns as dt,Nt as ft,O as pt,Oa as mt,Oi as ht,On as gt,Oo as _t,Or as vt,Os as yt,Ot as bt,P as xt,Pa as St,Pi as Ct,Pn as wt,Po as Tt,Pr as Et,Ps as Dt,Pt as Ot,Q as kt,Qa as At,Qi as jt,Qn as Mt,Qr as Nt,Qt as Pt,R as Ft,Ra as It,Ri as Lt,Rn as Rt,Ro as zt,Rr as Bt,Rt as Vt,S as Ht,Sa as Ut,Si as Wt,Sn as Gt,So as Kt,Sr as qt,St as Jt,T as Yt,Ta as Xt,Ti as Zt,Tn as Qt,To as $t,Tr as en,Tt as tn,U as nn,Ua as rn,Ui as an,Un as on,Uo as sn,Ur as cn,Ut as ln,V as un,Va as dn,Vi as fn,Vn as pn,Vo as mn,Vr as hn,Vs as gn,Vt as _n,W as vn,Wa as yn,Wi as bn,Wn as xn,Wo as Sn,Wr as Cn,Wt as wn,X as Tn,Xa as En,Xi as Dn,Xn as On,Xo as kn,Xr as An,Xt as jn,Y as Mn,Ya as Nn,Yi as Pn,Yn as Fn,Yo as In,Yr as Ln,Yt as Rn,Z as zn,Za as Bn,Zi as Vn,Zn as Hn,Zo as Un,Zr as Wn,Zt as Gn,_ as Kn,_a as qn,_i as Jn,_n as Yn,_o as Xn,_r as Zn,_t as Qn,a as $n,aa as er,ai as tr,an as nr,ao as rr,ar as ir,at as ar,b as or,ba as sr,bi as cr,bn as lr,bo as ur,br as dr,bt as fr,c as pr,ca as mr,ci as hr,cn as gr,co as _r,cr as vr,ct as yr,d as br,da as xr,di as Sr,dn as Cr,do as wr,dr as Tr,dt as Er,ea as Dr,ei as Or,en as kr,eo as Ar,er as jr,et as Mr,f as Nr,fa as Pr,fi as Fr,fn as Ir,fo as Lr,fr as Rr,ft as zr,g as Br,ga as Vr,gi as Hr,gn as Ur,go as Wr,gr as Gr,gt as Kr,h as qr,ha as Jr,hi as Yr,hn as Xr,ho as Zr,hr as Qr,ht as $r,i as ei,ia as ti,ii as ni,in as ri,io as ii,ir as ai,it as oi,j as si,ja as ci,ji as li,jn as ui,jo as di,jr as fi,js as pi,jt as mi,k as hi,ka as gi,ki as _i,kn as vi,ko as yi,kr as bi,ks as xi,kt as Si,l as Ci,la as wi,li as Ti,ln as Ei,lo as Di,lr as Oi,lt as ki,m as Ai,ma as ji,mi as Mi,mn as Ni,mo as Pi,mr as Fi,mt as Ii,n as Li,na as Ri,ni as zi,nn as Bi,no as Vi,nr as Hi,nt as Ui,o as Wi,oa as Gi,oi as Ki,on as qi,oo as Ji,or as Yi,ot as Xi,p as Zi,pa as Qi,pi as $i,pn as ea,po as ta,pr as na,pt as ra,q as ia,qa as aa,qi as oa,qn as sa,qo as ca,qr as la,qt as ua,r as da,ra as fa,ri as pa,rn as ma,ro as ha,rr as ga,rt as _a,s as va,sa as ya,si as ba,sn as xa,so as Sa,sr as Ca,st as wa,t as Ta,ta as Ea,ti as Da,tn as Oa,to as ka,tr as Aa,tt as ja,u as Ma,ua as Na,ui as Pa,un as Fa,uo as Ia,ur as La,ut as Ra,v as za,va as Ba,vi as Va,vn as Ha,vo as Ua,vr as Wa,vt as Ga,w as Ka,wa as qa,wi as Ja,wn as Ya,wo as Xa,wr as Za,ws as Qa,wt as $a,x as eo,xa as to,xi as no,xn as ro,xo as io,xr as ao,xt as oo,y as so,ya as co,yi as lo,yn as uo,yo as fo,yr as po,yt as mo,z as ho,za as go,zi as _o,zn as vo,zo as yo,zr as bo,zs as xo,zt as So}from"./dist-WFhah2YJ.mjs";export{Ta as AGENT_ID_MAX_LEN,Li as AGENT_ID_RE,da as AGENT_WRITE_ORIGIN,a as AUDIT_EMPTY_SCOPE_WARNING,ei as AcpPermissionStore,$n as AcpRegistry,Wi as AcpThreadManager,va as AgentFocusBroadcaster,pr as AgentPresenceBroadcaster,Ci as AgentSessionCapacityError,Ma as AgentSessionManager,br as AutoStartDisabledError,Nr as BUNDLE_IDS,Zi as BUNDLE_SCOPE,Ai as BUNDLE_SKILL_NAME,qr as BacklinkIndex,Br as CC1Broadcaster,s as CC1_CONTRACT_VERSION,Kn as CONCURRENT_REPLACE_WINDOW_MS,za as CONFIG_FILENAME,so as CONFLICT_MARKER_RE,or as CURSOR_BUNDLE_PATHS_BY_PLATFORM,eo as ConfigSchema,Ht as ConflictAuthority,j as DEFAULT_CHECKPOINT_RETENTION,Ka as DEFAULT_EMBEDDINGS_DIMENSIONS,Yt as DEFAULT_PACK_ID,K as DocumentDurabilityState,z as DocumentDurabilityStateError,pt as EMBEDDINGS_API_KEY_ENV,hi as EPHEMERAL_PROJECT_DIR_PREFIX,h as ExposureConsentError,si as FEATURED_AGENT_IDS,Ze as FILE_SYSTEM_WRITER,at as FILE_WATCHER_ORIGIN,xt as FileEmbeddingsBackend,$ as FilesystemRootProjectError,Se as GIT_PREFLIGHT_FAIL_SPAN_NAME,We as GIT_UPSTREAM_WRITER,L as GitDirAccessError,Ft as GitNotAvailableError,ho as GitTooOldError,C as HOCUSPOCUS_AUTH_REJECTION_REASONS,un as HocuspocusAuthRejection,me as HocuspocusAuthTokenSchema,nn as HomeProjectRootError,vn as INSTALLED_AGENTS_SCHEMES,se as JSON_SCHEMA_DIALECT_2020_12,gn as LINEAGE_EPOCH_KEY,Le as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ia as LOCK_FILE_ACCESS_REMEDY,Ae as MANAGED_RENAME_ORIGIN,Mn as MAX_ACP_THREADS,Tn as MAX_AGENT_SESSIONS,zn as MCP_CONNECTION_ID_HEADER,o as MCP_SERVER_NAME,kt as MIN_EVICTABLE_IDLE_MS,l as MIN_GIT_VERSION,Qa as MalformedGitPointerError,Mr as McpLogger,ja as MissingOkConfigError,Ui as OBSERVER_SYNC_ORIGIN,_a as OK_OKIGNORE_TEMPLATE,oi as ONBOARDING_BUNDLE_IDS,xo as ORPHAN_MODES,be as PROTOCOL_VERSION,yt as PinoLogger,ar as ProcessLockCollisionError,Xi as ProcessLockFileError,wa as ProjectGitInitError,yr as ROLLBACK_ORIGIN,ki as ROOT_GITIGNORE_TEMPLATE,Ra as RUNTIME_VERSION,Er as SERVICE_WRITER,zr as SKILL_INSTALL_EVENTS_FILENAME,c as SKILL_STATE_TARGETS,ra as STARTER_FOLDER_FRONTMATTER_FILENAME,Ii as STARTER_PACKS,$r as STARTER_PACK_IDS,Kr as STATE_MANIFEST_FILENAME,Qn as STATE_SCHEMA_VERSION,Ga as SYMLINK_MERGE_MIN_GIT_LABEL,mo as SYMLINK_MERGE_MIN_GIT_VERSION,e as SYSTEM_DOC_NAME,fr as SeedPrerequisiteError,oo as SeedRootDirError,Jt as ServerAuthorityCollisionError,R as ServerAuthorityRegistryError,$a as ServerLockCollisionError,tn as SingleFileNotAFileError,Q as SingleFileNotFoundError,G as SingleFileNotMarkdownError,bt as SingleFileProjectOverrideError,Si as StateManifestError,r as TEST_LOOP_CORE_MARKER,S as TEST_LOOP_SERVER_MARKER,mi as TagIndex,it as USER_GLOBAL_BUNDLE_IDS,ft as UnsafeIncomingSymlinkError,Ot as __getShowAllWalkStatsForTesting,oe as __resetShowAllWalkStatsForTesting,ke as acpThreadStoreRoots,Xe as acpThreadsDir,Vt as acquireProcessLock,So as acquireServerLock,A as applyAgentMarkdownWrite,_n as applyExternalChange,xe as applySeed,ln as assertCheckoutSymlinksSafe,wn as assertCompatibleStateManifest,pe as assertGitAvailable,Ue as assertIncomingSymlinksSafe,ua as assertMergeNameResolvesTo,Ie as assertNeverDiskEvent,Rn as assertRepoCheckoutSymlinksSafe,jn as assertSafeProjectRoot,Gn as assessLockHolder,Pt as attachAcpThreadSocket,m as attachCollabClientCounter,kr as attachIdleShutdown,Oa as auditScopeNotFoundTitle,Bi as bindConflictAuthority,ma as bootServer,ri as buildAndOpenSkill,nr as buildConfigYmlContent,qi as buildExecResult,xa as buildIngressPolicy,gr as buildOkMcpStdioCommand,Ei as buildSkillZip,Fa as buildStarterFolderFrontmatterYaml,Cr as buildWipTree,Ir as bundleSkillMdPath,ea as canonicalProjectKey,Ni as canonicalizeForCompare,Xr as classifyEvents,Ur as classifyFsPath,Yn as classifyLockHolder,Ha as clearAllEmbeddingsKeys,uo as coercePackId,lr as collectServerHostSnapshot,t as colorFromSeed,ro as commitUpstreamImport,Gt as commitWip,P as commitWipFromTree,Ya as compareSemver,Qt as composeEffectiveLinterConfig,Y as composeFrontmatterSchemasConfig,H as containsConflictMarkers,gt as contentHash,vi as contributorCount,v as countShadowObjects,ui as countStaleAgentWipRefs,et as countWipRefs,ct as createApiExtension,wt as createAssetServeMiddleware,ne as createCollaborationHost,Te as createContentFilter,qe as createContentFilterAsync,Rt as createEmbeddingsSecretStore,vo as createEphemeralProjectDir,E as createExternalChangeHandler,pn as createFileLogger,_e as createLiveDerivedIndexExtension,on as createMcpHttpHandler,xn as createOsProbe,ue as createPersistenceExtension,Be as createProbeFailureReporter,sa as createServer,Ne as createServerObserverExtension,Fn as createServerProbeResolver,On as createStreamingErrorWriter,xi as createTestLogger,Hn as describeStoredEmbeddingsKey,Mt as detectClaudeDesktopPresence,f as detectGit,jr as detectProjectShape,Aa as detectUserSkillHosts,Hi as discoverLockDirs,ga as discoverMarkdownlintConfig,ai as emitPreflightFailureSpan,ir as encodeDocName,Yi as encodeFolderRoute,Ca as encodeSkillRoute,vr as ensureProjectGit,Oi as errorResponse,La as evictStaleTrackerEntries,Tr as extractHeadings,Rr as extractOkBinaryPath,na as extractWikiLinksFromMarkdown,Fi as fallbackPaths,Qr as findEnclosingGitRoot,Gr as findEnclosingProjectRoot,Zn as findNativeMarkdownlintFile,Wa as flushFileLogger,po as formatAuditBrokenLinkSuppressionLine,dr as formatAuthRejectionWire,ao as formatContributorsFrom,qt as formatPackRationale,I as gcCheckpointRefs,Za as getCurrentMcpLogger,en as getIngressContext,Z as getLocalDir,W as getLogFilePath,x as getLogger,vt as getLogsDir,bi as getMachineId,b as getMeter,fi as getMetrics,nt as getTracer,ut as handleCollabSocketError,Et as handleSpawnCursor,ie as hasForwardingHeaders,De as hasGcLogLatch,n as iconFromClientName,Ye as incrementCollabSocketFilteredError,Bt as incrementServerObserverFire,bo as initContent,O as initShadowRepo,hn as initTelemetry,ye as initToleranceTelemetryWriter,cn as installJsonSchemaDialect,Cn as installPrettyZodErrors,pi as installTestLoggers,fe as installUserSkill,He as isAllowedApiOrigin,la as isAllowedWorkspaceHostHeader,Fe as isConfigDoc,Ln as isDefunctProcess,An as isDocInConflict,Wn as isFilesystemRoot,Nt as isHocuspocusAuthRejectionReason,p as isHomeDir,Or as isHostAdmitted,Da as isKnownPackId,zi as isLinkIndexExcludedDoc,pa as isLockFromThisMachine,ni as isLockProcessRunning,tr as isLoopbackAddress,Ki as isManagedArtifactDoc,ba as isMintedThreadId,hr as isOriginAdmitted,k as isOrphanMode,Ti as isPairedWriteOrigin,Pa as isPathWithinDir,Sr as isPeerAdmitted,Fr as isProcessAlive,$i as isProjectRoot,Mi as isReservedForUserTree,Yr as isSelfWrite,Hr as isSkillInstallReportEnvOptOut,Jn as isSystemDoc,Va as isToleranceTelemetryEnabled,lo as isValidLockPid,cr as lastKnownHash,no as listRescueCheckpoints,Wt as listStarterPacks,N as loadCustomAgents,Ja as loadPrincipal,Zt as lockAdvertisesUi,J as lockBaseUrl,V as lockFilePath,rt as loggerFactory,ht as loginShapedUserinfoUser,dt as logsCurrentPath,Dt as logsPreviousPath,_i as machineIdFilePath,_ as makeLazyEmbeddingsKeyStore,li as markServerLockDraining,$e as missingOkConfigMessage,st as mountMcpAndApi,Ct as normalizeFsPath,te as observeReadiness,we as packageVersionMajorMinor,Ke as parseAuthRejectionWire,Lt as parseGitVersion,_o as parseHocuspocusAuthToken,T as parseKeepaliveConnectionId,fn as parseProcessStartToken,ge as pathToDocName,an as planSeed,bn as prepareSingleFileOpen,le as processCommand,ze as processStartToken,oa as processUsage,Me as readAgentBrowserTools,Pn as readAllTargets,Dn as readBundleDecision,Vn as readDeclaredGitHubHosts,jt as readOriginCredentialHost,d as readOriginGitHubRepo,Dr as readOwnNativeRules,Ea as readProcessLock,Ri as readProcessLockDetailed,fa as readProcessStart,ti as readProcessState,er as readProjectHeadState,Gi as readProjectLocalSemanticConfig,ya as readServerLock,mr as readServerPackageVersion,wi as readSkillInstallStateSnapshot,Na as readStateManifest,xr as readTargetRecordedAt,Pr as readTargetVersion,Qi as reconcile,ji as recordContributor,Jr as recordSkillInstallEvent,Vr as recordsLockOwner,qn as redactShareSubprocessStderr,Ba as registerAllTools,co as registerNativeProcessStartReader,sr as registerWrite,to as releaseProcessLock,Ut as releaseServerLock,M as removeLastKnownHash,qa as removeLockIfUnchanged,Xt as removeProjectSkillGitignoreBlock,q as reportSkillInstall,B as resetMetrics,mt as resolveAuditScope,gi as resolveBuiltinSkillHosts,i as resolveBundleEnabled,g as resolveBundledSkillDir,ci as resolveContentDir,Qe as resolveCursorBinaryDefault,ot as resolveCursorSpawnInvocation,St as resolveEffectiveLinterConfig,ee as resolveEmbeddingsCredential,Ce as resolveGitHubAccountFromUrl,Ge as resolveGitHubAuthHost,It as resolveLockDir,go as resolveNativeConfigForDoc,w as resolveNativeMarkdownlintConfig,dn as resolvePack,he as resolvePackageVersion,rn as resolveSkillInstallReportSettings,yn as resolveUiInfo,ce as restoreContributors,Re as rewriteMarkdownLinksForDocumentRename,aa as rewriteWikiLinksForDocumentRename,je as runAuthReposSubprocess,Nn as runAuthStatusSubprocess,En as runCloneSubprocess,Bn as runDeviceFlowSubprocess,At as runWithMcpLogger,u as safeContentPath,Ar as safeSubdir,ka as safetyCheckpoint,Vi as sameGitHubLogin,ha as sanitizeClientName,ii as saveInMemoryCheckpoint,rr as saveVersion,Ji as scanLockProcesses,Sa as seedBasenameIndex,_r as seedEphemeralProjectDir,Di as serializeError,Ia as setActiveSpanAttributes,wr as setupServerObservers,Lr as shadowGit,ta as shutdownTelemetry,ae as spansCurrentPath,Oe as spansPreviousPath,Pi as spawnDetached,Zr as splitMarkdownBlocks,Wr as startWatcher,Xn as strategiesFor,Ua as streamedChunkOf,fo as streamingProblemEvent,ur as swapContributors,io as teardownToleranceTelemetryWriter,Kt as toBroadcasterKey,F as toProcessLockMetadata,Xa as tracedAppendFileSync,$t as tracedLinkSync,X as tracedMkdir,U as tracedMkdirSync,_t as tracedRename,yi as tracedRenameSync,y as tracedRmSync,di as tracedRmdirSync,tt as tracedUnlinkSync,lt as tracedWriteFile,Tt as tracedWriteFileSync,re as trustSystemCertificates,Ee as updateLastKnownHash,Je as updateProcessLockPort,zt as updateServerLockPort,yo as validateAgentId,D as validateCloneInputs,mn as validateSkillZip,ve as waitForServerLockDrain,sn as withHiddenWindowsConsole,Sn as withSpan,de as withSpanSync,Ve as writeBundleDecision,ca as writeMarkdownlintRule,Pe as writeRootGitignoreForNewRepo,In as writeStateManifest,kn as writeTargetVersion,Un as writeTracker};
|