@inkeep/open-knowledge 0.82.0-beta.2 → 0.82.0-beta.4
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/cli.mjs +58 -58
- package/dist/constants-W9G4vRvJ.mjs +1 -0
- package/dist/dist-C1WwDYOU.mjs +1 -0
- package/dist/dist-DdoZ294B.mjs +2132 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +12 -12
- package/dist/init-DaBUbh8G.mjs +1 -0
- package/dist/{init-DxmJQw-q.mjs → init-vgeY_wHD.mjs} +67 -67
- package/dist/{launch-json-removal-6P0pQNcb.mjs → launch-json-removal-D4FuJ2Te.mjs} +1 -1
- package/dist/{loader-DM58JL8z.mjs → loader-DYbtvtxH.mjs} +1 -1
- package/dist/loader-YyyVC5zh.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-_aOifsph.mjs → md-manager-BGnqyqi1-D77IwxHB.mjs} +149 -149
- package/dist/{open-browser-b5cByL_R.mjs → open-browser-Dg3gcrHM.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-B197-pRb.mjs → preview-1EGVW00C.mjs} +1 -1
- package/dist/preview-BQhr7b8a.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-DQuMnh5C.js → ActivityModeContent-qim4zFx-.js} +1 -1
- package/dist/public/assets/AddPropertiesButton-DKXiB5hC.js +2 -0
- package/dist/public/assets/{AgentDiffPane-CfePb4Vn.js → AgentDiffPane-BD8yOgrS.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-ZCMADC7K.js → AgentThreadClientBinder-18BD6ihn.js} +1 -1
- package/dist/public/assets/{BugReportHistory-DF4MWYfb.js → BugReportHistory-C2kxTgHh.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-gCloscKr.js → BugReportHistoryDialog-DgtiL-NP.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Cpqvck97.js → CodeMirrorPropInput-D7ODqRwE.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-B4dRFslY.js → ConsentDialogBody-CD7KM28d.js} +1 -1
- package/dist/public/assets/{DeleteConfirmationDialog-j-IypjMj.js → DeleteConfirmationDialog-C1zIx9Bd.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-DmVyFPz3.js → DiffViewBoundary-DGNf5H84.js} +1 -1
- package/dist/public/assets/DocumentContext-BHjfklWj.js +39 -0
- package/dist/public/assets/{EditorModeToggle-X2jghMca.js → EditorModeToggle-XKuoOdJs.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-DYtEACVo.js → ExcalidrawDocEditor-I2eQXX7E.js} +1 -1
- package/dist/public/assets/FeedbackForm-BQ8aBBom.js +1 -0
- package/dist/public/assets/{GraphPanel-BDvjXMEQ.js → GraphPanel-nDzxbZwr.js} +2 -2
- package/dist/public/assets/{ImageAttachments-D6OJOCsx.js → ImageAttachments-Dob2zdX6.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BhLkbnwE.js → ImportSkillDialog-CU7KSDgH.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CkcVzFfE.js → LintConfigEditor-81_fDdG_.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-C9JeOwFQ.js → ManagedArtifactProperties-DTfJaeLZ.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-yEjDaTS8.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-j_et9Ci3.js → MermaidDocEditor-Dw5SypSn.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuItem-BTXZ6GJd.js → OpenInAgentMenuItem-BMo7aLCS.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-C1uc8qxv.js → PropertyDisplayRow-Bn0kgK3p.js} +1 -1
- package/dist/public/assets/{RegisteredAgentIcon-DYSDhnfL.js → RegisteredAgentIcon-DbL9sShX.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-D641oLxH.js → ReportBugDialogBody-DEETk9Jo.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-BLGrQGJZ.js → ReportBugMenuTrigger-B1WREGjA.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-BaSvU0-b.js → SchemaConfigEditor-BLXTxBGL.js} +1 -1
- package/dist/public/assets/{SessionsHost-uURZn-05.js → SessionsHost-DquHUp9T.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CC9Qpr7Q.js → SettingsDialogBody-DKEUH63t.js} +4 -4
- package/dist/public/assets/ShareBranchSwitchDialog-BUS2my96.js +1 -0
- package/dist/public/assets/{ShareReceiveDialog-Bsy3uU-q.js → ShareReceiveDialog-BKgD7Duc.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CGkRwnD4.js → ShareReceiveMissDialog-_8dejDWk.js} +1 -1
- package/dist/public/assets/{SkillCostValue-DQ8Tx_1m.js → SkillCostValue-CmCcSYjJ.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-CFIWznnO.js → SkillEditBanner-DFdS9BhL.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-C_-Mxjb0.js → SkillForkDialog-D5Aha7ke.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-C1d_Onp0.js → SkillInstallMenu-Cju9gFSt.js} +2 -2
- package/dist/public/assets/{SkillOriginInline-CZCok01y.js → SkillOriginInline-DPQ0UfdG.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-jOPo2cwU.js → SkillToolbarControls-SRsQowBm.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-CyQHjFAZ.js → SlidesToolbarControls-8Tu4pV-S.js} +1 -1
- package/dist/public/assets/{SourceEditor-BkV5uQIG.js → SourceEditor-DUhZs5yo.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-DKTFq6nT.js → SyncStatusBadge-B9wP5KjD.js} +1 -1
- package/dist/public/assets/TerminalPanel-Db-Lo-iL.js +146 -0
- package/dist/public/assets/{TerminalWindowApp-Cmnoc_8o.js → TerminalWindowApp-CAjzSiBI.js} +1 -1
- package/dist/public/assets/{TextDocEditor-RnLIKCzS.js → TextDocEditor-C7dpFdVd.js} +1 -1
- package/dist/public/assets/{ThreadView-BbjIu_Tj.js → ThreadView-CsZKSzs5.js} +6 -6
- package/dist/public/assets/{TimelineDiffPane-CJOIx5co.js → TimelineDiffPane-DcChEu2J.js} +1 -1
- package/dist/public/assets/agent-connections-iuaYc-Gk.js +1 -0
- package/dist/public/assets/{auth-state-cache-DytZdZGG.js → auth-state-cache-Dz-Yvu70.js} +4 -4
- package/dist/public/assets/{bug-report-send-manager-vRHbDgcD.js → bug-report-send-manager-0DIkaLj0.js} +1 -1
- package/dist/public/assets/{client-version-BRUdlpYX.js → client-version-DJFCNOKL.js} +1 -1
- package/dist/public/assets/{comment-chips-D7-Sf8LJ.js → comment-chips-jwrddJ4n.js} +1 -1
- package/dist/public/assets/{config-provider-72j5NG_s.js → config-provider-B4cgjuAt.js} +1 -1
- package/dist/public/assets/{css-color-to-hex-CvWv027U.js → css-color-to-hex-oO6GoCcb.js} +1 -1
- package/dist/public/assets/{diagnostic-breadcrumb-WWSlN_l6.js → diagnostic-breadcrumb-DK-Cqae0.js} +1 -1
- package/dist/public/assets/{dist-BQnk7HYC.js → dist-CUgbgEDy.js} +199 -199
- package/dist/public/assets/{doc-paths-zlKNK6ew.js → doc-paths-DaHerw67.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CUYFsfKH.js → doc-undo-manager-ZAJ7EhHf.js} +1 -1
- package/dist/public/assets/{documents-events-BkJZtY8-.js → documents-events-AGLgPGQa.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-Bd2ICSy3.js → file-tree-adapter--GNP_kR2.js} +1 -1
- package/dist/public/assets/{file-tree-utils-BknD8oVN.js → file-tree-utils-lPpxK5Yq.js} +1 -1
- package/dist/public/assets/{folder-config-api-B069M2f5.js → folder-config-api-DDOXhGdo.js} +1 -1
- package/dist/public/assets/{index-PxHb8oCI.js → index-BdhkBLck.js} +15 -15
- package/dist/public/assets/{lint-config-client-CxrUSFhk.js → lint-config-client-B_xNfTBy.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-DLJGhZu8.js → markdownlint-rule-browser-DzjG_qoM.js} +1 -1
- package/dist/public/assets/{messages-DCLxtq5E.js → messages-15pqM65e.js} +1 -1
- package/dist/public/assets/{messages-s1kQ0F_h.js → messages-9WOa9KUm.js} +1 -1
- package/dist/public/assets/{messages-AFVdD964.js → messages-B_Wv5APO.js} +1 -1
- package/dist/public/assets/{messages-BcWRA-nI.js → messages-C7pSlTmA.js} +1 -1
- package/dist/public/assets/{messages-CbN1r9yA.js → messages-CAYad86H.js} +1 -1
- package/dist/public/assets/{messages-OBzrmAFm.js → messages-CQ1vIgoS.js} +1 -1
- package/dist/public/assets/{messages-C0Gd4qNa.js → messages-CciFZ7sP.js} +1 -1
- package/dist/public/assets/messages-CibA1WyZ.js +1 -0
- package/dist/public/assets/{messages-DM9zlCjV.js → messages-Dd9VKFx-.js} +1 -1
- package/dist/public/assets/{messages-BCP_tUaH.js → messages-DsNN544W.js} +1 -1
- package/dist/public/assets/{messages-hoIRV_jf.js → messages-KKn5PQmE.js} +1 -1
- package/dist/public/assets/{messages-C2ZTIk86.js → messages-WxVoyVTt.js} +1 -1
- package/dist/public/assets/{messages-l5K8pww3.js → messages-spfa9ZpO.js} +1 -1
- package/dist/public/assets/{navigation-targets-JXxslLnB.js → navigation-targets-DV1dMVAb.js} +1 -1
- package/dist/public/assets/{page-list-cache-BjuTcwZG.js → page-list-cache-BaKlIcC-.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-I34BHw8L.js → pending-receive-nav-store-4xt56kJR.js} +1 -1
- package/dist/public/assets/{preferred-session-events-Dn2B8C6Q.js → preferred-session-events-CeCXvWmc.js} +1 -1
- package/dist/public/assets/{progress-Cr6xP6xF.js → progress-D6YLD7xV.js} +1 -1
- package/dist/public/assets/{project-paths-B4WlvnNK.js → project-paths-Cs2SPmYR.js} +1 -1
- package/dist/public/assets/{prop-types-DTpxi1kh.js → prop-types-Dv_cZRA5.js} +1 -1
- package/dist/public/assets/{receive-store-CnxXP7Rx.js → receive-store-CvglCO2B.js} +1 -1
- package/dist/public/assets/{selection-context-uBhB3eE7.js → selection-context-CDv7YpZ_.js} +1 -1
- package/dist/public/assets/{sign-in-terminal-events-BinEsAuS.js → sign-in-terminal-events-BigKQgqQ.js} +1 -1
- package/dist/public/assets/{skill-scope-DPIrVPTZ.js → skill-scope-BGcfBWlz.js} +1 -1
- package/dist/public/assets/{skills-api-Crupv6z4.js → skills-api-mYKB0zDh.js} +1 -1
- package/dist/public/assets/{src-o93MaH3v.js → src-xGMvMbEd.js} +1 -1
- package/dist/public/assets/{startup-marks-DKfzso0C.js → startup-marks-yQqTMBm5.js} +1 -1
- package/dist/public/assets/{tag-pill-input-CLaEMXUD.js → tag-pill-input-BQLv6DZ1.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-zOwhEhjl.js → target-navigation-intent-BIFEl4OT.js} +1 -1
- package/dist/public/assets/{telemetry-startup-Co4ih8hj.js → telemetry-startup-DyEWsvUO.js} +1 -1
- package/dist/public/assets/{terminal-command-events-CSovYcNv.js → terminal-command-events-CoTkNESn.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-HpRiFG59.js → terminal-launch-events-BBjjknBw.js} +1 -1
- package/dist/public/assets/{terminal-telemetry-DcIn01ci.js → terminal-telemetry-CGR3Wr8L.js} +1 -1
- package/dist/public/assets/{thread-client-HIe8sJZj.js → thread-client-V2_Sw10t.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BJWhmLpH.js → typing-burst-detector-Bwb8vXQS.js} +4 -4
- package/dist/public/assets/{uninstall-F-GEBRwC.js → uninstall-BcI5d3jC.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DPXbm__T.js → use-activity-panel-Bm-_7omz.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-Cuqo14R8.js → use-apply-config-language-Bzn7Rbw_.js} +2 -2
- package/dist/public/assets/{use-collab-url-Xg2vl_9f.js → use-collab-url-D3j3svaH.js} +1 -1
- package/dist/public/assets/{use-conflicts-q41ecWBs.js → use-conflicts-8sSRJ_Uy.js} +1 -1
- package/dist/public/assets/{use-git-sync-status-DjWrCson.js → use-git-sync-status-CBlTkWfK.js} +1 -1
- package/dist/public/assets/{use-installed-clis-BXQp0M3M.js → use-installed-clis-ClKL7RtP.js} +2 -2
- package/dist/public/assets/{use-live-xterm-theme-DJANnc0z.js → use-live-xterm-theme-bJiLIpxd.js} +1 -1
- package/dist/public/assets/{use-open-skill-Bv2npv4w.js → use-open-skill-BpW3ZhuK.js} +1 -1
- package/dist/public/assets/{use-settings-route-9O_1v-q-.js → use-settings-route-DL25HSeL.js} +1 -1
- package/dist/public/assets/use-skill-origin-Cts8svd2.js +1 -0
- package/dist/public/assets/{use-skills-B6Tde6G8.js → use-skills-DXlhkRBq.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DbQnWyNv.js → use-terminal-enabled-Br80VTvl.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DYEZ5Kr0.js → use-timeline-entry-diff-l604pHZz.js} +4 -4
- package/dist/public/assets/{use-workspace-CgZbdppm.js → use-workspace-DtyUPSZ4.js} +1 -1
- package/dist/public/index.html +60 -60
- package/dist/public/uninstall.html +4 -4
- package/dist/{registry-probes-BVV-dp2_.mjs → registry-probes-BXgdIidc.mjs} +8 -8
- package/dist/{removal-file-path-IGB8kLW3.mjs → removal-file-path-Ce-oxAGQ.mjs} +1 -1
- package/dist/{repair-launch-json-Bm0KASfL.mjs → repair-launch-json-CtsInz2s.mjs} +1 -1
- package/dist/{repair-mcp-configs-LE7SMVZu.mjs → repair-mcp-configs-BESnoIPY.mjs} +1 -1
- package/dist/src-BPwbNxCr.mjs +1 -0
- package/dist/src-KNAqsxPK.mjs +11 -0
- package/dist/start-B8iic9V_.mjs +5 -0
- package/dist/start-BXE7aaH4.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-CzSXiZrq.mjs +0 -1
- package/dist/dist-3oA3zia0.mjs +0 -2132
- package/dist/dist-cOlZ_g1o.mjs +0 -1
- package/dist/init-PDchMTWx.mjs +0 -1
- package/dist/loader-B8l-Xtmg.mjs +0 -1
- package/dist/preview-CAoM5JFA.mjs +0 -1
- package/dist/public/assets/AddPropertiesButton-B1OSJ-0F.js +0 -2
- package/dist/public/assets/DocumentContext-oEOdA-1V.js +0 -39
- package/dist/public/assets/FeedbackForm-DWwETSKh.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-7hZevPi3.js +0 -1
- package/dist/public/assets/ShareBranchSwitchDialog-BaiZgNy4.js +0 -1
- package/dist/public/assets/TerminalPanel-d_daafCx.js +0 -146
- package/dist/public/assets/agent-connections-BriCDDPd.js +0 -1
- package/dist/public/assets/messages-fT_Mlcyb.js +0 -1
- package/dist/public/assets/use-skill-origin-CmJxQKvj.js +0 -1
- package/dist/src--KGw9ViN.mjs +0 -11
- package/dist/src-F_RCTw6-.mjs +0 -1
- package/dist/start-C96oJP3X.mjs +0 -5
- package/dist/start-Da74MpW4.mjs +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Ac as t,Df as n,Ds as r,Es as i,Fn as a,Ks as o,Ls as s,Oc as c,Pn as l,Ts as ee,Un as te,al as ne,jf as u,jo as d,nl as f,rl as p,td as m,yf as h}from"./md-manager-BGnqyqi1-D77IwxHB.mjs";import{$o as g,Co as _,Dt as v,Mi as y,Ni as b,Qo as x,Sr as S,Yn as C,Yo as w,Zo as T,_i as E,ar as D,gi as re,hi as ie,li as O,lr as k,m as A,ri as j,ya as M}from"./dist-DdoZ294B.mjs";import{t as N}from"./yazl-BBz29IQN.mjs";import{Ct as P,ot as F,st as ae}from"./init-vgeY_wHD.mjs";import{l as oe,x as se}from"./registry-probes-BXgdIidc.mjs";import{c as ce}from"./colors-r_owlCuY.mjs";import{t as le}from"./is-object-BGze3w87.mjs";import{n as ue}from"./constants-W9G4vRvJ.mjs";import"./loader-DYbtvtxH.mjs";import"./preview-1EGVW00C.mjs";import{execSync as de,spawnSync as fe}from"node:child_process";import{basename as I,dirname as L,isAbsolute as pe,join as R,relative as me,resolve as z,sep as B}from"node:path";import{closeSync as he,cpSync as ge,createWriteStream as _e,existsSync as V,lstatSync as ve,mkdirSync as H,mkdtempSync as ye,openSync as be,readFileSync as U,readSync as xe,readdirSync as W,readlinkSync as Se,rmSync as G,rmdirSync as Ce,statSync as we,writeFileSync as K}from"node:fs";import{arch as Te,freemem as Ee,homedir as q,hostname as De,platform as Oe,release as ke,tmpdir as Ae,totalmem as je,type as Me,uptime as Ne}from"node:os";import"node:fs/promises";import{createHash as Pe}from"node:crypto";const Fe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Ie(e,t,n=k){if(e!==void 0&&!Fe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Le=null;function Re(e){Le=e}function ze(){return Le??process.cwd()}const Be=`Open Knowledge`;function Ve(e={}){let t=e.platformName??process.platform,r=e.productName??n().productName;return F(t).join(ae({...e,platformName:t}),r)}function He(e={}){let t=e.platformName??process.platform,r=e.home??q(),i=e.env??process.env,a=F(t),o;return o=t===`win32`?i.LOCALAPPDATA||a.join(r,`AppData`,`Local`):t===`darwin`?a.join(r,`Library`,`Caches`):i.XDG_CACHE_HOME||a.join(r,`.cache`),a.join(o,`${n().packageName.replaceAll(`/`,``)}-updater`)}function Ue(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 We(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return Ue(n)??[]}function Ge(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return Ue(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const Ke=8192;function qe(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 Je(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ye=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function Xe(e){return e.replace(Ye,`$1"[REDACTED-DEVICE-ID]"`)}function Ze(e){return Xe(Je(e))}const Qe=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function $e(e){if(typeof e!=`string`)return null;let t=Qe.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 et(e){let t=be(e,`r`);try{let e=Buffer.alloc(Ke),n=0,r=!1;for(;n<Ke;){let i=xe(t,e,n,Ke-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{he(t)}}function tt(e){try{let t=et(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:$e(a)}}catch{return{kind:`unreadable`}}}function nt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function rt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(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=R(e,t.name),r;try{r=we(n).mtimeMs}catch{continue}if(r<i)continue;let c=tt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!nt(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function J(){return R(w(),`bug-reports`)}function it(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=J(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;V(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function at(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function ot(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let e=U(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 V(R(e,`.ok`))?Pe(`sha256`).update(z(e)).digest(`hex`).slice(0,12):null}function st(){let e={timestamp:new Date().toISOString(),platform:Oe(),osType:Me(),osRelease:ke(),hostname:`[redacted]`,uptime:Ne(),freeMem:Ee(),totalMem:je(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=de(`sw_vers -productVersion 2>/dev/null`,_({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);V(t)&&(e.okVersion=JSON.parse(U(t,`utf8`)).version)}catch{}return e}const ct=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function lt(e){let t=I(e);return ct.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ut(e,t){return mt(e,t).files}const dt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ft(e,t=oe){let n=R(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return dt.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=>R(n,e.entry)))}function pt(e){if(!V(e))return[];try{let t=new Map;for(let n of W(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-l.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=>R(e,t))}catch{return[]}}function mt(e,t){if(!V(t))return{files:[],excludedByProjectSlug:0};let n=W(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(lt),i=[],a=r.filter(t=>{try{return U(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=>!lt(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function ht(e){let t=R(e,`.ok`,`local`);return V(t)?{files:[`server.lock`,`last-spawn-error.log`,f,c].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function gt(e){let t=R(e,`.ok`,`local`,`logs`);return V(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function _t(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#${Pe(`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 vt(e){let t=e.revealDocNames?e.content:_t(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=s(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=U(t,`utf8`);vt({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?Ze(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 yt(t){let{redact:n,outputPath:r,logger:i}=t,o=t.revealDocNames??!1,s=t.userLogsDir??R(w(),`logs`),c=t.projectDir?ot(t.projectDir,i):null;H(L(r),{recursive:!0}),i?.info({projectSlug:c},`gathering diagnostic data`);let l=st();l.desktop=t.desktop??null,l.language=t.language??null;let{files:ee,excludedByProjectSlug:ne}=mt(c,s),{files:u}=t.projectDir?ht(t.projectDir):{files:[]},{files:d}=t.projectDir?gt(t.projectDir):{files:[]},f=t.shipItLogFiles??[],p=t.diagnosticReports?.files??[];i?.info({logFileCount:ee.length,logFilesExcludedByProjectSlug:ne,lockFileCount:u.length,localSinkFileCount:d.length,shipItLogFileCount:f.length,diagnosticReportCount:p.length},`files collected`);let m=[],h=[],{ZipFile:g}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),_=new g;Y({zipfile:_,files:[...ee,...f],prefix:`logs`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:u,prefix:`lockdir`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:d,prefix:`local-logs`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:t.bugReportLedgerFiles??[],prefix:a,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i}),Y({zipfile:_,files:p,prefix:`diagnostic-reports`,redact:n,revealDocNames:o,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=U(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;_.addBuffer(t,n),h.push(n);let r=at(e,n);r!==null&&m.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&vt({zipfile:_,name:`note.txt`,content:t.note,redact:n,revealDocNames:o,bundleFiles:h,redactions:m});let v=new Set(p.map(e=>`diagnostic-reports/${I(e)}`)),y=h.filter(e=>v.has(e)),b=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:qe(t.diagnosticReports,y.length);_.addBuffer(Buffer.from(`${b}\n`,`utf8`),`state/diagnostic-reports-status.txt`),h.push(`state/diagnostic-reports-status.txt`);let x=JSON.stringify(l,null,2);_.addBuffer(Buffer.from(x,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let S={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:h,redactions:m,sysinfo:l};_.addBuffer(Buffer.from(JSON.stringify(S,null,2),`utf8`),`MANIFEST.json`);let C=m.reduce((e,t)=>e+t.lineCount,0),T=new Set(f.map(e=>`logs/${I(e)}`)),E=h.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${a}/${I(e)}`)),re=h.filter(e=>D.has(e)),ie=c?h.filter(e=>e.startsWith(`logs/`)&&!lt(e)&&!T.has(e)):[],O=y.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.`]:[],k=O.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...O]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${S.generatedAt}`,`Project: ${c??`(unscoped)`}`,`Discipline version: ${S.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...ie.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:`,...ie.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}`),``]:[],...y.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:`,...y.map(e=>`- ${e}`),``]:[],...re.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:`,...re.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${te.join(`, `)}`,C>0?`${C} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...O,``,`This bundle is safe to attach to a GitHub issue.`]:k].join(`
|
|
2
|
+
`);_.addBuffer(Buffer.from(A,`utf8`),`README.md`),_.end();let j=_e(r);return _.outputStream.pipe(j),await new Promise((e,t)=>{j.on(`close`,e),j.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:C},`bundle written`),{zipPath:r,summary:{projectSlug:c,files:h,redactions:m,redactedLineCount:C,generatedAt:S.generatedAt}}}var bt=m(),xt=e(N(),1),X=e(ce(),1);function St(e){let t=g(`user`,e,e);return T({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Ct({home:e=q(),env:n=process.env}={}){let r=St(e),{override:i,preferenceList:a}=x(n),{locale:s,source:c}=o({override:i,storedPreference:r,supportedLocales:ne,preferenceList:a,autoDetectableLocales:t});return{preference:r,locale:s,source:c,systemLanguages:a}}function wt(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Tt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Et(e,t){if(typeof e==`string`)return wt(e,t.contentDir);if(Array.isArray(e))return e.map(e=>Et(e,t));if(!Tt(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Et(i,t);return n}function Dt(e,t){let n=U(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
+
`),i=n.split(`
|
|
4
|
+
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=Et(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
5
|
+
`)}\n`:a.join(`
|
|
6
|
+
`);K(e,o)}function Ot(e,t){let n=U(e,`utf-8`);if(n.trim().length!==0)try{let r=Et(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
+
`)?`
|
|
8
|
+
`:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=wt(n,t.contentDir);r!==n&&K(e,r)}}function kt(e,t){let n=U(e,`utf-8`),r=wt(n,t.contentDir);r!==n&&K(e,r)}function At(e){try{return W(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>R(e,t.name))}catch{return[]}}const jt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Mt(e){return/\.log\.\d+$/.test(e)}function Nt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Mt(e)}const Pt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Ft(e){let t={contentDir:e.contentDir};for(let n of Pt)for(let r of At(R(e.stagingDir,n)))Nt(r)?Dt(r,t):r.endsWith(`.json`)?Ot(r,t):kt(r,t);for(let n of At(R(e.stagingDir,`state`))){let e=I(n);n.endsWith(`.jsonl`)?Dt(n,t):jt.has(e)?Ot(n,t):kt(n,t)}}const It=[`.ok`,`local`,`telemetry`],Lt=[`.ok`,`local`,`logs`],Rt=[`.ok`,`local`,`loss-capture`],zt=`spans-current.jsonl`,Bt=`spans-prev.jsonl`,Vt=`server-current.jsonl`,Ht=`server-prev.jsonl`,Ut=`loss-current.jsonl`,Wt=`loss-prev.jsonl`;function Gt(e){return R(e,...It,zt)}function Kt(e){return R(e,...It,Bt)}function qt(e){return R(e,...Lt,Vt)}function Jt(e){return R(e,...Lt,Ht)}function Yt(e){return R(e,...Rt,Ut)}function Xt(e){return R(e,...Rt,Wt)}const Zt=1e3;async function Qt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function $t(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}async function en(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(Zt)});return t.ok?await t.text():null}catch{return null}}function tn(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(`
|
|
9
|
+
`)}\n`:null}catch{return null}}function nn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],_({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function rn(e){let t=R(e,`.git`,`ok`);if(!V(t))return null;let n=fe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],_({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function an(){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 on(){return{nodeVersion:process.version,platform:Oe(),arch:Te()}}function sn(){return process.env.OTEL_SDK_DISABLED===`false`}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cn(e){if(!V(e))return{};let t;try{t=(0,bt.parse)(U(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(!Z(t))return{};let n=t.telemetry;if(!Z(n))return{};let r=n.localSink;return Z(r)?r:{}}function ln(e){return typeof e==`boolean`?e:void 0}function un(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function dn(e){if(Z(e))return un(e.maxBytes)}function fn(e){let t=cn(g(`project`,e)),n=cn(g(`project-local`,e));return{enabled:ln(n.enabled)??ln(t.enabled)??!0,spansMaxBytes:dn(n.spans)??dn(t.spans)??52428800,logsMaxBytes:dn(n.logs)??dn(t.logs)??26214400}}function pn(e){return Pe(`sha256`).update(e).digest(`hex`)}function mn(e){let t=U(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const hn=[`"doc.name"`,`"docName"`];function gn(e){let t=U(e,`utf-8`),n=0;for(let e of hn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!V(e))return!1;try{return H(L(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,Ze(U(e,`utf-8`))):ge(e,t),!0}catch{return!1}}function _n(e){let t=[],n=e=>{let r=W(e,{withFileTypes:!0});for(let i of r){let r=R(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const vn=new Set([`.jsonl`]);function yn(e){let t=e.lastIndexOf(`.`);return t!==-1&&vn.has(e.slice(t))}const bn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function xn(e){if(Mt(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&bn.has(e.slice(t))}function Sn(e){let t=[];for(let n of _n(e)){let r=Cn(e,n);if(!xn(r))continue;let{redacted:i,patterns:a,lineCount:o}=s(U(n,`utf-8`));a.length!==0&&(K(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Cn(e,t){return me(e,t).split(B).join(`/`)}async function wn(e){let t=z(e.contentDir),n=z(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Qt,o=r.fetchAgentEffects??$t,s=r.fetchWatcherRecent??en,l=r.readShadowHead??nn,ee=r.readCheckpointRefs??rn,te=r.now??(()=>new Date),ne=r.okVersion??(()=>ue),u=r.readDesktopEnv??an,d=r.readLanguage??Ct,m=r.readRuntime??on,h=r.isOtlpPushEnabled??sn,g=ye(R(Ae(),`ok-bundle-`));try{H(R(g,`telemetry`),{recursive:!0}),H(R(g,`logs`),{recursive:!0}),H(R(g,`state`),{recursive:!0}),Q(Gt(n),R(g,`telemetry`,zt)),Q(Kt(n),R(g,`telemetry`,Bt)),Q(qt(n),R(g,`logs`,Vt)),Q(Jt(n),R(g,`logs`,Ht));for(let t of e.userLogFiles??[])Q(t,R(g,`logs`,I(t)));for(let t of e.userStateFiles??[])Q(t,R(g,a,I(t)));let _=0;for(let t of e.diagnosticReports?.files??[])Q(t,R(g,`diagnostic-reports`,I(t)))&&(_+=1);let v=R(n,`.ok`,`local`),y=R(v,`server.lock`),b=`not-running`,x=`no server.lock`,S=null;if(V(y)){Q(y,R(g,`state`,`server.lock`));try{let e=U(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?S=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(S!==null){let e=await i(S);e===null?x=`agent-presence endpoint at :${S} unreachable`:(K(R(g,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await o(S);t!==null&&K(R(g,`state`,`agent-effects.json`),t);let n=await s(S);if(n!==null){let e=tn(n);e!==null&&K(R(g,`state`,`watcher-recent.jsonl`),e)}}let C=l(t);C!==null&&K(R(g,`state`,`shadow-head.txt`),C);let w=ee(t);w!==null&&K(R(g,`state`,`checkpoint-refs.txt`),w),Q(Yt(n),R(g,`state`,Ut)),Q(Xt(n),R(g,`state`,Wt)),Q(R(v,`last-spawn-error.log`),R(g,`state`,`last-spawn-error.log`)),Q(R(v,p),R(g,`state`,p)),Q(R(v,f),R(g,`state`,f)),Q(R(v,c),R(g,`state`,c));let T=m(),E=u(),D=d(),re={ok:{version:ne(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D}};K(R(g,`state`,`runtime.json`),`${JSON.stringify(re,null,2)}\n`);let ie=b===`running`?`running
|
|
10
|
+
`:`not-running (${x})\n`;K(R(g,`state`,`server-status.txt`),ie);let O=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:qe(e.diagnosticReports,_);if(K(R(g,`state`,`diagnostic-reports-status.txt`),`${O}\n`),e.processDir&&V(e.processDir)){let t=R(g,`process`);H(t,{recursive:!0}),ge(e.processDir,t,{recursive:!0})}let k=e.redact===!0;k&&Ft({stagingDir:g,contentDir:t}),e.note&&K(R(g,`note.txt`),e.note);let A=null;e.scrubSecrets===!0&&(A=Sn(g));for(let t of e.extraFiles??[]){let e=t.zipName??I(t.sourcePath);if(!Q(t.sourcePath,R(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=at(t,`extra/${e}`);n!==null&&(A??={redactions:[],redactedLineCount:0},A.redactions.push(n),A.redactedLineCount+=n.lineCount)}let j=fn(n),M=_n(g),N=[],P=0,F=0;for(let e of M){let t=Cn(g,e),n=we(e).size,r=yn(t)?mn(e):0;N.push({path:t,bytes:n,lines:r}),P+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(F+=gn(e))}let ae={applied:k};A!==null&&(ae.secretScrub=A);let oe={schemaVersion:2,createdAt:te().toISOString(),ok:{version:ne(),nodeVersion:T.nodeVersion,platform:T.platform,arch:T.arch},host:{desktop:E,language:D},contentDir:{pathSha256:pn(t),absolutePath:k?`<CONTENT_DIR>`:t},telemetry:{localSink:j,otlpPushEnabled:h()},redaction:ae,serverStatus:b,files:N};K(R(g,`manifest.json`),`${JSON.stringify(oe,null,2)}\n`);let se=M.some(e=>{try{return U(e,`utf-8`).includes(t)}catch{return!1}}),ce={stagedDiagnosticReports:_,totalBytes:P,fileCount:N.length,docNameCount:F,contentDirVisible:se,redacted:k},le=!1;return{stagingDir:g,manifest:oe,summary:ce,cleanup:()=>{le||(le=!0,G(g,{recursive:!0,force:!0}))}}}catch(e){throw G(g,{recursive:!0,force:!0}),e}}async function Tn(e){let{collected:t,outputPath:n}=e,r=L(n);if(!V(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new xt.ZipFile,a=_n(t.stagingDir);for(let e of a){let n=Cn(t.stagingDir,e);i.addFile(e,n)}i.end();let o=_e(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 En(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let t=(0,bt.parse)(U(n,`utf-8`)),r=le(t)?t.content:void 0,i=le(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return z(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 z(e)}async function Dn(e,t,n,r,i){let a=ot(t,e.logger),o=await wn({contentDir:En(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ut(a,e.userLogsDir??R(w(),`logs`)),...ft(e.cachesDir??R(q(),`Library`,`Caches`))],userStateFiles:pt(e.bugReportsDir??J()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{H(L(e.outputPath),{recursive:!0}),await Tn({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function On(e){let{projectDir:t}=e,n=e.readDesktopEnv??an,r=e.readLanguage??Ct,i=()=>rt(e.diagnosticReportsDir??R(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Dn(e,t,n,r,i());let{zipPath:a,summary:o}=await yt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:ft(e.cachesDir??R(q(),`Library`,`Caches`)),bugReportLedgerFiles:pt(e.bugReportsDir??J()),diagnosticReports:e.level===`full`?i():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 $(e,t,n={}){let r=E(e,t),i;try{i=U(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}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??S()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??De());if(!a||typeof a!=`object`||!O(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??j)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function kn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. 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.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. 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.lockPath} and retry cleanup.`}function An(e){return e.replace(/:\d+$/,``)}function jn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:An(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:An(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 Mn=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Nn(e){return r(u(),e)}function Pn(){return i(u())}function Fn(){let e=u();if(e===`stable`)return Mn;let t=ee(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const In={existsSync:e=>V(e),readFileSync:(e,t)=>U(e,t),lstatSync:e=>ve(e),readlinkSync:e=>Se(e)};function Ln(e,t=In){let n=Nn(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 Rn(e){let t=e.replace(Fn(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function zn(e,t,n=In){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Bn=[{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`}],Vn=[...v.map(e=>A[e]),`open-knowledge`];function Hn(e){if(!pe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=z(e);if(t===B||L(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Un(e,t){let n=me(e,t);if(n.startsWith(`..`)||pe(n))return!1;let r=e;for(let e of n.split(B)){r=R(r,e);try{if(!ve(r).isDirectory())return!1}catch{return!1}}return!0}function Wn(e,t){try{return W(e).every(n=>t.has(R(e,n)))}catch{return!1}}function Gn(e){let t=Hn(e),n=[],r=[],i=new Set;for(let e of Bn){let a=R(t,e.hostDir,`skills`);if(!Un(t,a))continue;let o=Vn.map(e=>R(a,e)).filter(e=>V(e));n.push(...o);for(let e of o)i.add(e);let s=R(t,e.pruneRoot),c=a;for(;Wn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=L(c);if(e===c||e===t||!e.startsWith(t+B))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Kn(e){try{if(!ve(e).isDirectory())return!1;let t=W(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function qn(e){let t=new Set,n=new Set;for(let r of Bn){let i=R(e,r.hostDir,`skills`);for(let e of Vn)t.add(R(i,e));let a=R(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=L(o);if(t===o||t===e||!t.startsWith(e+B))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Jn(e,t){let n=Hn(e),r=qn(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(Un(n,e)&&Kn(e))try{G(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Un(n,e))try{Ce(e),a.push(e)}catch{}return a}function Yn(e){let t=Hn(e),n=[];for(let e of v){let r=A[e];n.push({path:R(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of h)n.push({path:R(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Xn(e,t){let n=[];for(let r of Yn(e))if(r.bundleId===t)try{G(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 Zn(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Qn(e,t=Date.now()){if(e===null)return`—`;let n=d(e,t);return n===`unknown`?`—`:n}function $n(e){let t=L(e);return I(e)===`local`&&I(t)===`.ok`?L(t):I(e)===`.ok`?t:null}function er(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:$n(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`&&ie(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:D(n),command:n,isDesktop:Zn(n)}}function tr(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`:return`stale`;default:return t}}const nr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function rr(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 ir(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ar(e){return`${ir(e.server.usage)} | ${ir(e.ui?.usage??null)}`}function or(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function sr(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??`—`,or(e),ar(e),tr(e),String(e.server.pid),Qn(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=rr(tr(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: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
+
`)}async function cr(e={}){let t=e.discover??C,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??y,a=e.resolveUsage??b,o=await t(),s=[];for(let e of o){let t=n(e),r=er(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:tr(e)}));r(JSON.stringify(e,null,2));return}r(sr(e.all?s:s.filter(e=>nr.has(tr(e)))))}function lr(){return new P(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) 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 cr({all:t.all===!0||e===`all`,json:t.json===!0})})}async function ur(e,t=se()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=re(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 dr(e,t={}){return{targets:pr(e,t.isAlive??j)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function fr(e){let t=e.inspect??(()=>$(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??ur,o=e.logger??se(),s=dr(t(),{isAlive:e.isAlive});if(s.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};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:s.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let c=[],l=[];for(let e of s.targets)try{n(e.pid,`SIGTERM`),c.push(e)}catch(t){l.push({target:e,error:t instanceof Error?t.message:String(t)})}return c.length>0&&r(`Stopped: ${c.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:c.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:l.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),l.length>0&&i(`Failed to stop: ${l.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:c,failed:l,hadTargets:!0}}function pr(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function mr(e,t=j){let n=await C(),r=null;for(let i of n){let n=$(i,`server`);if(pr(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function hr(e,t){let n=await fr({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function gr(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 `ok ps` to list them"}.`}async function _r(e){let t=await C(),n=0;for(let r of t)r!==e&&pr($(r,`server`),j)&&n++;return n}function vr(e){return new P(`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 editor windows or agents are still connected to the server`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=M(process.cwd()),n=await fr({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await _r(t);console.log(gr(process.cwd(),e,{listingFollows:e>0})),e>0&&await cr({})}return}if(i===`all`){let e=await C();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)pr($(n,`server`),j)&&(await hr(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 mr(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await hr(t,r);return}let a=z(ze(),i),o=M(a),s=[],c=await fr({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(gr(a,await _r(o)))})}export{ze as A,rt as C,Ve as D,He as E,Ie as M,We as O,J as S,Be as T,$ as _,Jn as a,Tn as b,Yn as c,Nn as d,Pn as f,kn as g,jn as h,lr as i,Re as j,Ge as k,Mn as l,Rn as m,fr as n,Gn as o,Ln as p,vr as r,Xn as s,ur as t,zn as u,On as v,qe as w,it as x,wn as y};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{Ws as e,_a as t,gt as n,qc as r,qs as i,xd as a,zo as o}from"./md-manager-BGnqyqi1-D77IwxHB.mjs";import{$o as s,Zo as c,hi as l,ii as u,ji as d,k as f,us as p,yi as m}from"./dist-DdoZ294B.mjs";import{Ct as h,L as g,Tt as _,X as v,b as y,ut as b,wt as x,y as S,z as C}from"./init-vgeY_wHD.mjs";import{a as w,c as T,d as E,f as D,i as ee,n as O,o as k,p as A,r as j,s as M,t as N,u as P,y as te}from"./registry-probes-BXgdIidc.mjs";import{n as F}from"./constants-W9G4vRvJ.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,resolve as B}from"node:path";import{existsSync as V,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??I,i=H(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...se.filter(e)]}function U(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 W(e,t={}){let n=t._exec??I,r=H(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(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 de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={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){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(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 ve(e,t,n,r,i){let a=v[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`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`),_e(o.kind)}catch(i){return p(`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 ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({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 be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,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 xe(e,t,n){let r=t.home??re();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=w(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 Se(e,t,n){if(n===`absent`){let n=g(v[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=C(v[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 Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=a(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return ye(n.editor,e,t.desired);case`editor-project-config`:return be(n.editor,e,t.desired);case`editor-project-skill-root`:return Se(n.editor,e,t.desired);case`editor-user-skill-root`:return xe(n.editor,e,t.desired)}}}function we(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Te(e){if(e===`server`)return e;throw new x(`--only must be 'server'`)}function Ee(e=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function De(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 Oe(e){if(e===`off`)return`off`;if(!r.test(e))throw new x(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function ke(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ae(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function je(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||ke(e.host))&&e.isTTY}function Me(e,t){let n;try{n=new URL(t)}catch{throw new x(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new x(`${e} must be an http(s) origin (got: ${t})`);return t}function Ne(e){return Me(`--external-url`,e)}function Pe(e){let t=R(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 `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${f}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function $(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 ${f}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Fe(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 Ie(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:c,dirname:l,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-C1WwDYOU.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?d(e.singleFile).canonicalFilePath:void 0,E=w?l(w):void 0,D=w?c(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Q(k))throw new Z(k);o(f(k,`.ok`,`config.yml`))||y(k,E)}else k=h(E),A=!0}let j=async()=>{if(!(!A||k===void 0)){if(!Q(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!u(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BESnoIPY.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&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-CtsInz2s.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(s(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let I=te(),L=m(),R;try{{let e=v(k??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.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:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:W,tokenStore:I,embeddingsKeyStore:L,mcpTomlEditor:b(),...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)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:N(e),execute:Ce(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(P===void 0?n:$(n,P),{log:S,exit:e.idleExit})},log:S,...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=A?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function Le(e,t,n=()=>c({absPath:s(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Re(e){if(e===`browser`||e===`app`)return e;throw new x(`--mode must be 'browser' or 'app'`)}function ze(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Be(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 Ve(r,a){let s=Le(r,a.singleFile),c=ze(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=Pe(m);let h;try{h=e(process.env)}catch(e){throw e instanceof n&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=a.bind!==void 0&&a.bind.length>0?a.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=i(g),S=v??(_||b===void 0?[...x.bind]:[b]);Ae({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=a.externalUrl,E=i(t(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 D=a.port===void 0?void 0:Number(a.port),ee=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=D??ee??s.server?.port,k=De({explicitDir:a.reactShellDistDir,only:a.only,findBundledDir:Ee}),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 Ie({config:s,cwd:m,host:C,port:O,bind:w,...a.serveContentAssets===void 0?{}:{serveContentAssets:a.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:o(a.idleShutdown??E.idleShutdown),serverRuntime:E,...a.singleFile?{singleFile:a.singleFile}:{},...a.projectDir?{projectDir:a.projectDir}:{},...a.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-C1WwDYOU.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)),We(e,t)){let e=t.resolveLockDir(m),n=null;try{n=await He({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]=Ue(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ge(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]=Be(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}`,te=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:F,localUrl:I,networkUrl:te,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(je({openBrowser:a.openBrowser!==!1&&E.openBrowser,explicitOn:a.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:a.singleFile!==void 0,only:a.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-Dg3gcrHM.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function He(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 Ue(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function We(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function Ge(e,t,n){let r=n.ServerLockCollisionError;if(r===void 0||!(e instanceof r))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Ke(e){return new h(`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)`,Te).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)`,Oe).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Re).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).`,Ne).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
|
+
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
|
+
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=E(P());if(n.available){D({spawn:L},n);return}console.error(A(n.reason)),process.exit(1)}await Ve(n,t)})}export{Ge as C,W as D,le as E,Ke as S,Fe as T,ze as _,Ue as a,je as b,Q as c,Oe as d,Te as f,Le as g,He as h,Pe as i,We as l,we as m,X as n,Be as o,Ee as p,Ie as r,ke as s,Z as t,Ne as u,De as v,$ as w,Ae as x,Ve as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-B8iic9V_.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.82.0-beta.
|
|
3
|
+
"version": "0.82.0-beta.4",
|
|
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.82.0-beta.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.82.0-beta.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.82.0-beta.4",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.82.0-beta.4",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.82.0-beta.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.82.0-beta.4",
|
|
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-_aOifsph.mjs";var e=`0.82.0-beta.2`;const t=`config.yml`,n=e;export{n,t};
|