@inkeep/open-knowledge 0.64.0-beta.4 → 0.64.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/{acp-harness-probe-B0ZOHZTz.mjs → acp-harness-probe-Bz_Xfqhw.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-BgJb28Cb.mjs +2 -0
  4. package/dist/git-handle-Bh1alj7a.mjs +1 -0
  5. package/dist/{git-handle-29BNYqgw.mjs → git-handle-UnQwrdlT.mjs} +2 -2
  6. package/dist/index.d.mts +32 -19
  7. package/dist/index.mjs +157 -157
  8. package/dist/init-Cpnor43q.mjs +1 -0
  9. package/dist/{init-XAxC4-D4.mjs → init-JIlCRbdu.mjs} +3 -3
  10. package/dist/{launch-json-removal-1-8ZHJtz.mjs → launch-json-removal-D1H1a769.mjs} +2 -2
  11. package/dist/{loader-BAhIE_G7.mjs → loader-BkOiHFr0.mjs} +2 -2
  12. package/dist/loader-ROlCo-Nz.mjs +1 -0
  13. package/dist/md-manager-BJ88tow5.mjs +2 -0
  14. package/dist/{open-browser-aU_PSdrG.mjs → open-browser-CrMsTPIV.mjs} +2 -2
  15. package/dist/parse-worker.mjs +1 -1
  16. package/dist/{preview-W17sbyAM.mjs → preview-BF5V_rVP.mjs} +2 -2
  17. package/dist/preview-PgQuIcNJ.mjs +1 -0
  18. package/dist/public/assets/{ActivityModeContent-CTkq714U.js → ActivityModeContent-CauWCpUS.js} +1 -1
  19. package/dist/public/assets/{AddPropertiesButton-BPD1FL9u.js → AddPropertiesButton-BNouQBfs.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-irQjcz1_.js → AgentDiffPane-DXQNRZ8O.js} +1 -1
  21. package/dist/public/assets/{AgentThreadClientBinder-BVL-74Xg.js → AgentThreadClientBinder-5zJFp5cf.js} +1 -1
  22. package/dist/public/assets/{BugReportHistory-DH6PeCd-.js → BugReportHistory-BATOeSHw.js} +1 -1
  23. package/dist/public/assets/{BugReportHistoryDialog-B8YFi-N2.js → BugReportHistoryDialog-sIMmVxt-.js} +1 -1
  24. package/dist/public/assets/CodeMirrorPropInput-DX8Yunfs.js +3 -0
  25. package/dist/public/assets/{ConsentDialogBody-oXXodDvV.js → ConsentDialogBody-C4z025ef.js} +1 -1
  26. package/dist/public/assets/DocumentContext-BV7jb-np.js +38 -0
  27. package/dist/public/assets/{EditorModeToggle-BaN2Oili.js → EditorModeToggle-B8yEewMp.js} +1 -1
  28. package/dist/public/assets/{EnableSyncConfirmDialog-xkXGTFo0.js → EnableSyncConfirmDialog-uAw_zEkg.js} +1 -1
  29. package/dist/public/assets/{ExcalidrawDocEditor-Dj9eB-pP.js → ExcalidrawDocEditor-DhTxtSyA.js} +1 -1
  30. package/dist/public/assets/FeedbackForm-DJ9TwFhA.js +1 -0
  31. package/dist/public/assets/{GraphPanel-DwUEHRhD.js → GraphPanel-Brg6YDja.js} +2 -2
  32. package/dist/public/assets/{ImportSkillDialog-DkMQKyPv.js → ImportSkillDialog-BYfuLW-m.js} +1 -1
  33. package/dist/public/assets/{LintConfigEditor-B-NsTPbc.js → LintConfigEditor-pJBzAP1G.js} +1 -1
  34. package/dist/public/assets/ManagedArtifactProperties-CFDGVAK1.js +1 -0
  35. package/dist/public/assets/{ManagedArtifactProperties-rX7XGDin.js → ManagedArtifactProperties-D1f8Frip.js} +1 -1
  36. package/dist/public/assets/{MermaidDocEditor-yQOGFE0A.js → MermaidDocEditor-DVxgZCM4.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-Du0eofgg.js → PropertyDisplayRow-9aYyPFhc.js} +1 -1
  38. package/dist/public/assets/{ReportBugDialogBody-CSy9sPgF.js → ReportBugDialogBody-YQEEGPWa.js} +1 -1
  39. package/dist/public/assets/{ReportBugMenuTrigger-DcXixDKs.js → ReportBugMenuTrigger-BYHhqbyX.js} +2 -2
  40. package/dist/public/assets/{SchemaConfigEditor-Bw4WfNdB.js → SchemaConfigEditor-0hGeiywr.js} +1 -1
  41. package/dist/public/assets/{SessionsHost-Bb2LhY4k.js → SessionsHost-BegjN_Wv.js} +2 -2
  42. package/dist/public/assets/{SettingsDialogBody-BOlhS9Ub.js → SettingsDialogBody-Bng9Ek1r.js} +4 -4
  43. package/dist/public/assets/{ShareBranchSwitchDialog-MPieYF0-.js → ShareBranchSwitchDialog-DNMbGcR3.js} +1 -1
  44. package/dist/public/assets/{ShareReceiveDialog-Dv4IxMEt.js → ShareReceiveDialog-CxRzoJmJ.js} +1 -1
  45. package/dist/public/assets/{ShareReceiveMissDialog-BDMgkM4B.js → ShareReceiveMissDialog-C2M-0S6A.js} +1 -1
  46. package/dist/public/assets/{SkillCostValue-BN4Joz66.js → SkillCostValue-0sdQK-kg.js} +1 -1
  47. package/dist/public/assets/{SkillEditBanner-ojtVKJKQ.js → SkillEditBanner-BIAkDbBb.js} +1 -1
  48. package/dist/public/assets/SkillInstallMenu-C5Y79gdz.js +2 -0
  49. package/dist/public/assets/{SkillOriginInline-C997nHPd.js → SkillOriginInline-C35IR2C_.js} +1 -1
  50. package/dist/public/assets/{SkillToolbarControls-Dj-887tA.js → SkillToolbarControls-DEiTj33j.js} +1 -1
  51. package/dist/public/assets/{SlidesToolbarControls-DW6XStbl.js → SlidesToolbarControls-Bua5dOtR.js} +1 -1
  52. package/dist/public/assets/SourceEditor-DzxE90kB.js +1 -0
  53. package/dist/public/assets/{TerminalPanel-CT7hDlGm.js → TerminalPanel-EZTkF_Im.js} +3 -3
  54. package/dist/public/assets/{TerminalWindowApp-YPZsrULF.js → TerminalWindowApp-zabnp2hc.js} +1 -1
  55. package/dist/public/assets/{TextDocEditor-7bDJHloT.js → TextDocEditor-5pSurn6C.js} +1 -1
  56. package/dist/public/assets/{ThreadView-DP3_zX56.js → ThreadView-DY925XKN.js} +5 -5
  57. package/dist/public/assets/{TimelineDiffPane-DG4VaixQ.js → TimelineDiffPane-BOSthuzR.js} +1 -1
  58. package/dist/public/assets/{agent-diff-store-DikFdttU.js → agent-diff-store-CWlSMAcS.js} +1 -1
  59. package/dist/public/assets/auth-state-cache-DN_6SHvB.js +11 -0
  60. package/dist/public/assets/{bug-report-send-manager-Di-wNg5H.js → bug-report-send-manager-idwD-g0s.js} +1 -1
  61. package/dist/public/assets/client-version-BBQwLhqb.js +1 -0
  62. package/dist/public/assets/{comment-chips-BNT5yiMX.js → comment-chips-BtWBKUUL.js} +1 -1
  63. package/dist/public/assets/{config-provider-D9QQqC6e.js → config-provider-BXiukxwE.js} +2 -2
  64. package/dist/public/assets/{dist-DTZ5Uilk.js → dist-C_QZEaeX.js} +86 -86
  65. package/dist/public/assets/{doc-paths-CbSX4XTW.js → doc-paths-DMctW8qz.js} +1 -1
  66. package/dist/public/assets/{documents-events-DxL5ysM1.js → documents-events-CwqQxQT5.js} +1 -1
  67. package/dist/public/assets/{file-tree-adapter-Dfj6r2ub.js → file-tree-adapter-CpTo1U5h.js} +1 -1
  68. package/dist/public/assets/{file-tree-utils-Cs7B4muN.js → file-tree-utils-DrK6l51M.js} +1 -1
  69. package/dist/public/assets/{folder-config-api-DrObHnBt.js → folder-config-api-Dxuhqlqr.js} +1 -1
  70. package/dist/public/assets/i18n-CHdOLU04.js +1 -0
  71. package/dist/public/assets/index-CEIpyn32.js +2204 -0
  72. package/dist/public/assets/{launcher-selection-B27yBVlr.js → launcher-selection-Btzbq8G9.js} +1 -1
  73. package/dist/public/assets/lint-config-client-pNtVqn1v.js +1 -0
  74. package/dist/public/assets/{markdownlint-rule-browser-CLc72-TR.js → markdownlint-rule-browser-IpH2V17S.js} +1 -1
  75. package/dist/public/assets/page-list-cache-DambRQ7B.js +1 -0
  76. package/dist/public/assets/{pending-receive-nav-store-CakgGJjG.js → pending-receive-nav-store-DLOxz1b_.js} +1 -1
  77. package/dist/public/assets/{progress-BJuxWr77.js → progress-BtHJSSZk.js} +3 -3
  78. package/dist/public/assets/{project-paths-vxe5ndBy.js → project-paths-BN2qP-Oz.js} +1 -1
  79. package/dist/public/assets/{prop-types-DcE7SWmX.js → prop-types-Boc_oFTG.js} +1 -1
  80. package/dist/public/assets/{receive-store-CkD0UhDA.js → receive-store-Rla0xjPc.js} +1 -1
  81. package/dist/public/assets/{selection-context-BFI-bqiT.js → selection-context-C0Dh06ez.js} +1 -1
  82. package/dist/public/assets/{skill-scope-grqY_b8j.js → skill-scope-C2Q18Fyo.js} +1 -1
  83. package/dist/public/assets/{skills-api-DNXy9jz0.js → skills-api-Du0yE_Ea.js} +1 -1
  84. package/dist/public/assets/{src-DXdR4ZQN.js → src-XvoJ42p_.js} +1 -1
  85. package/dist/public/assets/startup-marks-Cw2UqI10.js +1 -0
  86. package/dist/public/assets/{tag-pill-input-D34lLgUq.js → tag-pill-input-BWs4IhME.js} +1 -1
  87. package/dist/public/assets/{target-navigation-intent-XZyK8hlI.js → target-navigation-intent-C_Ucfr51.js} +1 -1
  88. package/dist/public/assets/{telemetry-impl-CQvRl6_a.js → telemetry-impl-DLl1oxED.js} +1 -1
  89. package/dist/public/assets/{telemetry-startup-BZHG8uvV.js → telemetry-startup-k7vK2L8Z.js} +1 -1
  90. package/dist/public/assets/{terminal-cli-display-C3XNS9Zb.js → terminal-cli-display-CrkxgiPR.js} +1 -1
  91. package/dist/public/assets/typing-burst-detector-CtCPp1ik.js +8 -0
  92. package/dist/public/assets/{uninstall-Cl4LM0CB.js → uninstall-Be_VK869.js} +1 -1
  93. package/dist/public/assets/{use-activity-panel-BdGnO2Z6.js → use-activity-panel-Bat2VfJF.js} +1 -1
  94. package/dist/public/assets/{use-apply-config-color-theme-Bwj3f7UC.js → use-apply-config-color-theme-3_75T4Q8.js} +1 -1
  95. package/dist/public/assets/{use-collab-url-OrVAc6Wo.js → use-collab-url-9MxkxDjK.js} +1 -1
  96. package/dist/public/assets/{use-live-xterm-theme-5k6Gqiaw.js → use-live-xterm-theme-BjybDd5E.js} +1 -1
  97. package/dist/public/assets/{use-open-skill-DymWWnJ_.js → use-open-skill-B004qnQw.js} +1 -1
  98. package/dist/public/assets/{use-settings-route-BFU85dl8.js → use-settings-route-6Aa41RPQ.js} +1 -1
  99. package/dist/public/assets/{use-skill-origin-BTVSbkkb.js → use-skill-origin-C0RzVLGk.js} +1 -1
  100. package/dist/public/assets/{use-skills-Dn1UHdyr.js → use-skills-BkWQHhha.js} +1 -1
  101. package/dist/public/assets/{use-terminal-enabled-DkT9h5DB.js → use-terminal-enabled-ST2-eUch.js} +1 -1
  102. package/dist/public/assets/use-timeline-entry-diff-C-o8h9N3.js +6 -0
  103. package/dist/public/assets/{use-workspace-BfO5PsIE.js → use-workspace-7B06onC_.js} +1 -1
  104. package/dist/public/index.html +47 -47
  105. package/dist/public/uninstall.html +3 -3
  106. package/dist/{repair-launch-json-BLY6J8I2.mjs → repair-launch-json-BVjKD52o.mjs} +2 -2
  107. package/dist/{repair-mcp-configs-lXWW4hnd.mjs → repair-mcp-configs-BQ7U1U_I.mjs} +2 -2
  108. package/dist/repair-skills-DIytACob.mjs +1 -0
  109. package/dist/{repair-skills-CRG-r1Xh.mjs → repair-skills-DPyYfXHX.mjs} +2 -2
  110. package/dist/{resolve-project-root-urAKqvDX.mjs → resolve-project-root-suxWrGvT.mjs} +2 -2
  111. package/dist/{server-lock-_JWkU2Mh.mjs → server-lock-CcnGITIh.mjs} +2 -2
  112. package/dist/server-lock-D8d0WVYU.mjs +1 -0
  113. package/dist/{skill-teardown-CVMrfSeZ.mjs → skill-teardown-D4qifTbZ.mjs} +2 -2
  114. package/dist/src-7XhmCEkb.mjs +1 -0
  115. package/dist/{src-BRlSw7bk.mjs → src-C8wtGJxJ.mjs} +1 -1
  116. package/dist/{src-CjFV1e1Z.mjs → src-CNSuUQTi.mjs} +4 -4
  117. package/dist/{src-DhKkOAcb.mjs → src-CaLoSvK5.mjs} +2 -2
  118. package/dist/src-CnywvEPN.mjs +20 -0
  119. package/dist/{start-BaCKwcGO.mjs → start-ClCOtrI0.mjs} +3 -3
  120. package/dist/start-CxNMq7dN.mjs +1 -0
  121. package/package.json +4 -4
  122. package/dist/constants-C-QXBCBl.mjs +0 -2
  123. package/dist/git-handle-DfQBBy3_.mjs +0 -1
  124. package/dist/init-DPb4O5KS.mjs +0 -1
  125. package/dist/loader-DhmZ3k83.mjs +0 -1
  126. package/dist/md-manager-CZcRasmz.mjs +0 -2
  127. package/dist/preview-ztEEIVyt.mjs +0 -1
  128. package/dist/public/assets/CodeMirrorPropInput-kIJWwKe4.js +0 -3
  129. package/dist/public/assets/DocumentContext-6gn-Aiv8.js +0 -38
  130. package/dist/public/assets/FeedbackForm-BnoSzKB_.js +0 -1
  131. package/dist/public/assets/ManagedArtifactProperties-DL8NyQe3.js +0 -1
  132. package/dist/public/assets/SkillInstallMenu-B3V2W9x9.js +0 -2
  133. package/dist/public/assets/SourceEditor-YP4-TM8J.js +0 -1
  134. package/dist/public/assets/auth-state-cache-Oucukckm.js +0 -11
  135. package/dist/public/assets/client-version-DpPDNVRX.js +0 -1
  136. package/dist/public/assets/i18n-CP94ib4l.js +0 -1
  137. package/dist/public/assets/index-DxkeeuEK.js +0 -2204
  138. package/dist/public/assets/lint-config-client-DbEZKTUk.js +0 -1
  139. package/dist/public/assets/page-list-cache-4RZDQAIl.js +0 -1
  140. package/dist/public/assets/startup-marks-C-m5WZDP.js +0 -1
  141. package/dist/public/assets/typing-burst-detector-CHFv8DDa.js +0 -8
  142. package/dist/public/assets/use-timeline-entry-diff-CQ3Ngq3P.js +0 -6
  143. package/dist/repair-skills-BABpOhB_.mjs +0 -1
  144. package/dist/server-lock-C_5VGPQF.mjs +0 -1
  145. package/dist/src-BZeMIn4S.mjs +0 -1
  146. package/dist/src-Cv5CfSHR.mjs +0 -20
  147. package/dist/start-Bqguzc8D.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,r as n,t as r}from"./chunk-DTipWd-i.mjs";import{A as i,At as a,Dt as o,E as s,Et as c,Ft as l,G as u,Gt as d,Ht as f,It as p,Jt as m,Kt as h,L as g,Lt as _,Mt as v,P as y,Rt as b,T as x,Ut as S,Vt as C,Wt as w,X as T,Z as E,Zt as D,at as O,bt as ee,ct as te,et as ne,jt as re,kt as k,l as ie,lt as ae,mt as oe,nt as A,q as se,rt as ce,tt as le,v as j,x as M,yt as ue,zt as N}from"./sleep-DyLEGHvt.mjs";import{n as de,t as fe}from"./markdownit-BNz2xGu4.mjs";import P from"node:path";import pe from"node:process";import{fileURLToPath as me}from"node:url";import{access as he,accessSync as ge,readFile as F,readFileSync as _e}from"node:fs";import{EOL as ve,homedir as ye}from"node:os";const be=`state/bug-reports`,xe=_({at:S(),transport:S(),outcome:S(),reference:S().optional(),error:S().optional(),errorCode:S().optional()}),Se=_({reason:S(),at:S(),errorCode:S().optional()});_({version:b().int().catch(1),id:S(),createdAt:S(),bundleLevel:S(),zipBytes:b().int().nonnegative().catch(0),zipDeleted:a().optional(),state:S(),systemWide:a().optional(),projectSlug:S().nullable().optional(),reference:S().optional(),lastError:Se.optional(),attempts:k(xe).optional(),note:S().optional()});const Ce=`.sent.yaml`;_({version:b().int().catch(1),id:S().optional(),sentAt:S().optional(),reference:S().optional()});const we=2,Te={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function Ee({kind:e,runtimeVersion:t}){return{[Te.protocol]:`2`,[Te.runtime]:t,[Te.kind]:e}}const De=[{name:`macos-home-path`,regex:/\/Users\/[^/]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/]+\//g,replacement:`~/`},{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)\S+/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@]+:[^/\s:@]+@/g,replacement:`://[REDACTED]@`},{name:`github-pat-fine-grained`,regex:/\bgithub_pat_[0-9A-Za-z_]{20,}/g,replacement:`[REDACTED-GH-PAT]`},{name:`openai-key-modern`,regex:/\bsk-(?:proj|svcacct|admin|None)-[A-Za-z0-9_-]{20,}/g,replacement:`[REDACTED-OPENAI]`},{name:`slack-token`,regex:/\bxox[a-z]-[A-Za-z0-9-]{10,}/g,replacement:`[REDACTED-SLACK]`},{name:`google-api-key`,regex:/\bAIza[0-9A-Za-z_-]{35}/g,replacement:`[REDACTED-GOOGLE]`},{name:`stripe-secret-key`,regex:/\b(?:sk|rk)_live_[0-9A-Za-z]{16,}\b/g,replacement:`[REDACTED-STRIPE]`},{name:`gitlab-pat`,regex:/\bglpat-[0-9A-Za-z_-]{20,}/g,replacement:`[REDACTED-GITLAB]`},{name:`bearer-token-json`,regex:/("[Aa]uthorization"\s*:\s*"[Bb]earer\s+)[^"]+/g,replacement:`$1[REDACTED]`}],Oe=De.map(e=>e.name);function ke(e){let t=new Set,n=0;return{redacted:e.split(`
1
+ import{i as e,o as t,r as n,t as r}from"./chunk-DTipWd-i.mjs";import{A as i,At as a,Dt as o,E as s,Et as c,Ft as l,G as u,Gt as d,Ht as f,It as p,Jt as m,Kt as h,L as g,Lt as _,Mt as v,P as y,Rt as b,T as x,Ut as S,Vt as C,Wt as w,X as T,Z as E,Zt as D,at as O,bt as ee,ct as te,et as ne,jt as re,kt as k,l as ie,lt as ae,mt as oe,nt as A,q as se,rt as ce,tt as le,v as j,x as M,yt as ue,zt as N}from"./sleep-DyLEGHvt.mjs";import{n as de,t as fe}from"./markdownit-BNz2xGu4.mjs";import P from"node:path";import pe from"node:process";import{fileURLToPath as me}from"node:url";import{access as he,accessSync as ge,readFile as F,readFileSync as _e}from"node:fs";import{EOL as ve,homedir as ye}from"node:os";const be=`state/bug-reports`,xe=_({at:S(),transport:S(),outcome:S(),reference:S().optional(),error:S().optional(),errorCode:S().optional()}),Se=_({reason:S(),at:S(),errorCode:S().optional()});_({version:b().int().catch(1),id:S(),createdAt:S(),bundleLevel:S(),zipBytes:b().int().nonnegative().catch(0),zipDeleted:a().optional(),state:S(),systemWide:a().optional(),projectSlug:S().nullable().optional(),reference:S().optional(),lastError:Se.optional(),attempts:k(xe).optional(),note:S().optional()});const Ce=`.sent.yaml`;_({version:b().int().catch(1),id:S().optional(),sentAt:S().optional(),reference:S().optional()});const we=2,Te={protocol:`x-ok-client-protocol`,runtime:`x-ok-client-runtime`,kind:`x-ok-client-kind`};function Ee({kind:e,runtimeVersion:t}){return{[Te.protocol]:`2`,[Te.runtime]:t,[Te.kind]:e}}const De=[{name:`github-pat`,regex:/\b(ghp_|gho_|ghu_|ghs_|ghr_)[A-Za-z0-9]{36,}\b/g,replacement:`[REDACTED-GH-PAT]`},{name:`aws-access-key`,regex:/\b(AKIA|ASIA|ABIA)[A-Z2-7]{16}\b/g,replacement:`[REDACTED-AWS-KEY]`},{name:`anthropic-key`,regex:/\bsk-ant-api03-[A-Za-z0-9_-]{20,}\b/g,replacement:`[REDACTED-ANTHROPIC]`},{name:`openai-key`,regex:/\bsk-[A-Za-z0-9]{20,}\b/g,replacement:`[REDACTED-OPENAI]`},{name:`bearer-token`,regex:/([Aa]uthorization:\s*[Bb]earer\s+)(?:\\"[^\s"\\]+\\"|"[A-Za-z0-9\-._~+/=]+"|[^\s"\\]+)/g,replacement:`$1[REDACTED]`},{name:`jwt`,regex:/eyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,replacement:`[REDACTED-JWT]`},{name:`url-credentials`,regex:/:\/\/[^/\s:@"]+:[^/\s:@"]+@/g,replacement:`://[REDACTED]@`},{name:`github-pat-fine-grained`,regex:/\bgithub_pat_[0-9A-Za-z_]{20,}/g,replacement:`[REDACTED-GH-PAT]`},{name:`openai-key-modern`,regex:/\bsk-(?:proj|svcacct|admin|None)-[A-Za-z0-9_-]{20,}/g,replacement:`[REDACTED-OPENAI]`},{name:`slack-token`,regex:/\bxox[a-z]-[A-Za-z0-9-]{10,}/g,replacement:`[REDACTED-SLACK]`},{name:`google-api-key`,regex:/\bAIza[0-9A-Za-z_-]{35}/g,replacement:`[REDACTED-GOOGLE]`},{name:`stripe-secret-key`,regex:/\b(?:sk|rk)_live_[0-9A-Za-z]{16,}\b/g,replacement:`[REDACTED-STRIPE]`},{name:`gitlab-pat`,regex:/\bglpat-[0-9A-Za-z_-]{20,}/g,replacement:`[REDACTED-GITLAB]`},{name:`bearer-token-json`,regex:/("[Aa]uthorization"\s*:\s*"[Bb]earer\s+)(?:\\"[^"\\]+\\"|[^"\\]+)/g,replacement:`$1[REDACTED]`},{name:`macos-home-path`,regex:/\/Users\/[^/"]+\//g,replacement:`~/`},{name:`linux-home-path`,regex:/\/home\/[^/"]+\//g,replacement:`~/`}],Oe=De.map(e=>e.name);function ke(e){let t=new Set,n=0;return{redacted:e.split(`
2
2
  `).map(e=>{let r=e,i=!1;for(let{name:e,regex:n,replacement:a}of De)n.lastIndex=0,n.test(r)&&(t.add(e),i=!0,n.lastIndex=0,r=r.replace(n,a));return i&&n++,r}).join(`
3
3
  `),patterns:[...t],lineCount:n}}function Ae(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Me(e.position):`start`in e||`end`in e?Me(e):`line`in e||`column`in e?je(e):``}function je(e){return Ne(e&&e.line)+`:`+Ne(e&&e.column)}function Me(e){return je(e&&e.start)+`-`+je(e&&e.end)}function Ne(e){return e&&typeof e==`number`?e:1}var Pe=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Ae(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Pe.prototype.file=``,Pe.prototype.name=``,Pe.prototype.reason=``,Pe.prototype.message=``,Pe.prototype.stack=``,Pe.prototype.column=void 0,Pe.prototype.line=void 0,Pe.prototype.ancestors=void 0,Pe.prototype.cause=void 0,Pe.prototype.fatal=void 0,Pe.prototype.place=void 0,Pe.prototype.ruleId=void 0,Pe.prototype.source=void 0;const Fe=new Map([[32,` `],[9,` `],[160,`\xA0`]]);function Ie(e){let t=/^&#(x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);$/.exec(e);if(!t)return null;let n=t[1],r=n[0]===`x`||n[0]===`X`,i=Number.parseInt(r?n.slice(1):n,r?16:10);return Number.isNaN(i)?null:i}function Le(e){let t=Ie(e);return t!==null&&Fe.has(t)}function Re(e){let t=Ie(e);return t===null?null:Fe.get(t)??null}const ze=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function Be(e){ze.lastIndex=0;let t=e.match(ze);if(t===null||t.join(``)!==e)return null;let n=``;for(let e of t){let t=Re(e);if(t===null)return null;n+=t}return n}const Ve=new Set([`*`,`_`,"`",`~`,`\\`,`$`]),He=/^={2,}/,Ue=/^<(?:[A-Za-z][A-Za-z0-9+.-]*:[^<>\s]*|[^\s<>@]+@[^\s<>]+)>/;function We(e,t){return Ue.test(e.slice(t,t+512))}function Ge(e,t){let n=e.lastIndexOf(`<`,t);return n<0||t-n>512?!1:Ue.exec(e.slice(n,t+1))?.[0].length===t+1-n}const Ke=/^<\/?[A-Za-z][A-Za-z0-9-]*(?:\s[^>]*?)?\/?>/,qe=/^!(?=\[)/,Je=/^\[\^/,Ye=/^\]\[[^\]]*\]/,Xe=/^\[\[[^\][|]*\|/,Ze=/^#[^\][|]*(?=\]\])/,Qe=/^\]\([^)]*\)/,$e=/^(?:#{1,6}[ \t]+|>[ \t]?|(?:[-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?)/,et=/^(?:`{3,}[^`\n]*|~{3,}[^\n]*)$/,tt=/^(?:(?:[-*_][ \t]*){3,}|=+[ \t]*|[|\-: \t]*-[|\-: \t]*)$/;function nt(e,t){let n=e.indexOf(`
4
4
  `,t),r=n===-1?e.length:n;if(r>t&&e[r-1]===`\r`&&--r,r-t>1024)return 0;let i=e.slice(t,r);return i.length===0||!et.test(i)&&!tt.test(i)?0:i.length}const rt=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/y;function it(e,t){if(e[t]!==`&`)return null;let n=t,r=``;for(;;){rt.lastIndex=n;let t=rt.exec(e)?.[0];if(t===void 0)break;let i=Re(t);if(i===null)break;r+=i,n+=t.length}return n===t?null:{length:n-t,rendered:r}}function at(e){return e===` `||e===` `||e===`
@@ -354,4 +354,4 @@ Read more at https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy#pl
354
354
  `);if(!(t[0]??``).startsWith(`template:`))return null;let n=[t[0]??``],r=1;for(;r<t.length;){let e=t[r]??``;if(/^[ \t]/.test(e)){n.push(e),r++;continue}if(e.trim()===``){let i=r+1;for(;i<t.length&&(t[i]??``).trim()===``;)i++;if(i<t.length&&/^[ \t]/.test(t[i]??``)){n.push(e),r++;continue}}break}let i=M9(n.join(`
355
355
  `))[j9];return{identity:typeof i==`object`&&i&&!Array.isArray(i)?i:{},docFrontmatterText:t.slice(r).join(`
356
356
  `).replace(/\n+$/,``)}}function P9(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,{frontmatter:n,body:r}=Qm(t);if(n===``)return{identity:{},starterContent:t};let i=eh(n),a=fne(i);if(a)return{identity:a.identity,starterContent:N9(a.docFrontmatterText,r)};let{frontmatter:o}=Qm(r);if(o!==``)return{identity:M9(i),starterContent:r};let s=M9(i);return typeof s.title==`string`?{identity:s,starterContent:r}:{identity:{},starterContent:N9(i,r)}}function pne(e,t){let{docFrontmatterText:n,markdown:r}=dne(t),i={};for(let[t,n]of Object.entries(e))n!==void 0&&(i[t]=n);let a=(0,mt.stringify)({[j9]:i});return`---\n${n.trim()===``?a:`${a}${n}\n`}---\n${r}`}function mne(e){return P9(e).starterContent}const F9=e=>e*8+4;F9(92),F9(40);const hne=/^(#{1,6})\s+(.+)$/;function gne(e,t){let n=(e.endsWith(`\r`)?e.slice(0,-1):e).match(hne);if(!n)return null;let r=n[2].trim(),i=QZ(r,t);return i?{level:n[1].length,text:r,slug:i}:null}Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));const _ne={fileSystem:`File System`,gitUpstream:`Git (upstream)`,service:`OpenKnowledge (service)`,generator:`OpenKnowledge (generated)`},vne=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],yne={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function bne(e,t=vne){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const xne={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`,"claude-acp":`claude`,"codex-acp":`openai`,"github-copilot-cli":`github`};function I9(e){return e?xne[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const Sne={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function Cne(e){let t=e?.trim();return t?Sne[I9(t)]??t:`Agent`}function L9(e){if(!e.includes(`%`))return e;let t;try{t=decodeURIComponent(e)}catch{return e}return t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`)||t.includes(`\0`)?e:t}function R9(e){return e===`.`||e===`..`?e:encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.codePointAt(0)?.toString(16).toUpperCase()}`)}function wne(e){return e.split(`/`).map(R9).join(`/`)}function z9(e){return e.split(`/`).map(L9).join(`/`)}function B9(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=L9(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=`.${(s[1]??``).toLowerCase()}`;if(!yn.includes(e))return null}let c=o.startsWith(`/`),l=c?o.slice(1):o,u=c?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[],d=l.split(`/`),f=d.length-1;for(let e=0;e<d.length;e++){let t=L9(d[e]??``);if(e===f&&(t=rn(t)),t===`..`){if(u.length===0)return null;u.pop()}else t!==`.`&&t!==``&&u.push(t)}return u.length===0?null:{docName:u.join(`/`),anchor:a||null}}function Tne(e){throw Error(`Unhandled ClassifiedLinkTarget variant: ${JSON.stringify(e)}`)}const V9=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function H9(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function U9(e){let t=e.trim();return V9.test(t)||t.startsWith(`//`)}function Ene(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(U9(n))return{kind:`external`,url:n};let r=n.indexOf(`#`),i=z9(r<0?n:n.slice(0,r)),a=ln(i,t);if(a)return{kind:`doc`,docName:a,anchor:r<0?null:n.slice(r+1)};let o=cn(i,t);if(o)return{kind:`doc`,docName:o,anchor:r<0?null:n.slice(r+1)};let s=B9(n,t);if(s)return{kind:`doc`,docName:s.docName,anchor:s.anchor};let c=H9(i);return c&&c!==`md`&&c!==`mdx`?{kind:`asset`,url:n,ext:c,literal:!1}:null}function W9(e,t){let n=e.trim();if(!n)return null;if(U9(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=H9(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r,literal:!0}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function Dne(e,t,n){let r=e.trim();if(!r||V9.test(r)||r.startsWith(`//`)||r.startsWith(`#`))return null;let i=r.indexOf(`#`),a=((i>=0?r.slice(0,i):r).split(`?`)[0]??``).trim();if(!a)return null;let o=a.startsWith(`/`),s=o?a.slice(1):a,c=o?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of s.split(`/`))if(e===`..`){if(c.length===0)return null;c.pop()}else e!==`.`&&e!==``&&c.push(n.literal?e:L9(e));return c.length===0?null:c.join(`/`)}function G9(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function K9(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function q9(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function J9(e){return e.split(`/`).filter(e=>e!==``)}function One(e,t){let n=q9(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function Y9(e,t){let n=q9(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:J9(r).length}function X9(e,t){let n=J9(e),r=J9(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function kne(){let e=new Map;function t(t){let n=G9(t);if(n===``)return;let r=K9(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=G9(t),r=K9(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=q9(G9(n)),o=[],s=[];for(let e of i)One(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=Y9(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=Y9(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=X9(a,q9(t));for(let r=1;r<e.length;r++){let i=e[r],o=X9(a,q9(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function Ane(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function jne(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function Z9(e){return`pagesBySlug`in e}function Mne(e){return Z9(e)?e.pages:e}function Nne(e,t){return Z9(e)?e.assetPaths??new Set:t??new Set}function Pne(e,t){return Z9(e)?e.filePaths??new Set:t??new Set}function Q9(e,t){return e<t?-1:+(e>t)}function Fne(e,t){let n=new Map;for(let r of e){let e=t(r);e&&!n.has(e)&&n.set(e,r)}return n}function Ine(e,t){let n=new Map,r=[...e].sort(Q9);for(let e of r){let r=e.lastIndexOf(`/`),i=t(r===-1?e:e.slice(r+1));i&&!n.has(i)&&n.set(i,e)}return n}function Lne(e,t){let n=XZ(e);if(n){if(Z9(t))return t.pagesBySlug.get(n);for(let e of t)if(XZ(e)===n)return e}}function Rne(e,t){if(e.includes(`/`))return;let n=XZ(e);if(!n)return;if(Z9(t))return t.pagesByBasename?.get(n);let r;for(let e of t){let t=e.lastIndexOf(`/`);XZ(t===-1?e:e.slice(t+1))===n&&(r===void 0||Q9(e,r)<0)&&(r=e)}return r}function zne(e){let t=e.trim();if(!t)return[];let n=XZ(t);return n.length>0&&n!==t?[n]:[]}function $9(e,t){let n=e.trim();if(!n)return;let r=Mne(t);if(r.has(n))return n;let i=Lne(n,t);if(i)return i;for(let e of zne(n))if(r.has(e))return e;return Bne(n,r)||Rne(n,t)}function Bne(e,t){let n=`${e}/index`;if(t.has(n))return n;let r=e.lastIndexOf(`/`),i=r===-1?e:e.slice(r+1),a=i?`${e}/${i}`:null;if(a&&t.has(a))return a}function Vne(e){let t=((e.trim().split(`#`)[0]??``).trim().split(`?`)[0]??``).trim();return t.startsWith(`/`)?t.slice(1):t}function Hne(e,t,n){let r=Vne(e);if(!r)return null;let i=r.toLowerCase(),a=n?[t,n]:[t];for(let e of a){if(e.has(r))return r;for(let t of e)if(t.toLowerCase()===i)return t}if(r.includes(`/`))return null;let o=[];for(let e of a)for(let t of e){let e=t.lastIndexOf(`/`);(e===-1?t:t.slice(e+1)).toLowerCase()===i&&o.push(t)}return o.length===0?null:o.sort(Q9)[0]??null}function Une(e,t,n){let r=W9(e,t);return r===null||r.kind!==`asset`||Hne(r.url,Nne(n),Pne(n))!==null||$9(e,n)===void 0?r:{kind:`doc`,docName:e.trim(),anchor:t?.trim()||null}}export{o9 as $,JX as $a,WQ as $i,S0 as $n,ex as $o,J$ as $r,Gt as $s,Y2 as $t,une as A,tZ as Aa,Ot as Ac,m$ as Ai,n2 as An,_x as Ao,R1 as Ar,Un as As,e3 as At,Vte as B,XX as Ba,Ce as Bc,r$ as Bi,w2 as Bn,ax as Bo,w1 as Br,wn as Bs,v4 as Bt,j9 as C,OZ as Ca,Bt as Cc,_$ as Ci,y2 as Cn,iz as Co,J1 as Cr,nee as Cs,m3 as Ct,lne as D,_Z as Da,jt as Dc,v$ as Di,t2 as Dn,Dw as Do,K1 as Dr,Zn as Ds,a3 as Dt,P9 as E,hZ as Ea,At as Ec,y$ as Ei,v2 as En,vP as Eo,$1 as Er,Xn as Es,c3 as Et,Xte as F,pZ as Fa,Oe as Fc,i$ as Fi,N2 as Fn,gx as Fo,z1 as Fr,Rn as Fs,N4 as Ft,D9 as G,UX as Ga,XQ as Gi,S2 as Gn,zb as Go,b1 as Gr,An as Gs,a4 as Gt,Bte as H,EX as Ha,QQ as Hi,M2 as Hn,jb as Ho,g1 as Hr,Mn as Hs,p4 as Ht,tne as I,mZ as Ia,ke as Ic,a$ as Ii,P2 as In,hx as Io,m1 as Ir,In as Is,M4 as It,Lte as J,TX as Ja,IQ as Ji,W2 as Jn,Ub as Jo,C1 as Jr,Nn as Js,t4 as Jt,Ite as K,WX as Ka,qQ as Ki,C2 as Kn,Rb as Ko,v1 as Kr,Fn as Ks,r4 as Kt,Zte as L,eZ as La,Te as Lc,o$ as Li,Q0 as Ln,px as Lo,h1 as Lr,Sn as Ls,A4 as Lt,ine as M,cZ as Ma,eee as Mc,c$ as Mi,Y0 as Mn,mx as Mo,F1 as Mr,Bn as Ms,B4 as Mt,ane as N,QX as Na,ct as Nc,s$ as Ni,X0 as Nn,lx as No,I1 as Nr,Vn as Ns,z4 as Nt,A9 as O,EZ as Oa,ht as Oc,x$ as Oi,r2 as On,bx as Oo,Y1 as Or,Yn as Os,Y4 as Ot,Yte as P,sZ as Pa,pt as Pc,d$ as Pi,Z0 as Pn,vx as Po,L1 as Pr,Ln as Ps,P4 as Pt,Ste as Q,RX as Qa,VQ as Qi,B0 as Qn,Kb as Qo,D1 as Qr,yn as Qs,Z2 as Qt,qte as R,fZ as Ra,Ee as Rc,e$ as Ri,$0 as Rn,nx as Ro,f1 as Rr,Cn as Rs,j4 as Rt,gne as S,MZ as Sa,zt as Sc,g$ as Si,J2 as Sn,hz as So,Z1 as Sr,sr as Ss,S3 as St,mne as T,xZ as Ta,Mt as Tc,C$ as Ti,x2 as Tn,DF as To,Q1 as Tr,Qn as Ts,s3 as Tt,Mte as U,HX as Ua,n$ as Ui,G0 as Un,Pb as Uo,_1 as Ur,On as Us,n4 as Ut,zte as V,IX as Va,be as Vc,ZQ as Vi,A2 as Vn,Mb as Vo,T1 as Vr,Tn as Vs,c4 as Vt,Nte as W,DX as Wa,JQ as Wi,K0 as Wn,Nb as Wo,d1 as Wr,jn as Ws,o4 as Wt,Tte as X,wX as Xa,PQ as Xi,G2 as Xn,sx as Xo,k1 as Xr,xn as Xs,$2 as Xt,h9 as Y,VX as Ya,RQ as Yi,q0 as Yn,ox as Yo,O1 as Yr,Dn as Ys,X2 as Yt,g9 as Z,BX as Za,NQ as Zi,K2 as Zn,$b as Zo,E1 as Zr,bn as Zs,Q2 as Zt,yne as _,HZ as _a,ln as _c,O$ as _i,f2 as _n,XH as _o,i0 as _r,or as _s,Y3 as _t,Ane as a,DQ as aa,an as ac,e1 as ai,F2 as an,PY as ao,P0 as ar,_b as as,p6 as at,Cne as b,zZ as ba,Ut as bc,T$ as bi,H0 as bn,Sz as bo,t0 as br,tee as bs,z3 as bt,Tne as c,_Q as ca,$t as cc,$$ as ci,e2 as cn,cG as co,A0 as cr,cb as cs,i6 as ct,U9 as d,hQ as da,en as dc,X$ as di,s2 as dn,SG as do,y0 as dr,eh as ds,$3 as dt,SQ as ea,Xt as ec,Y$ as ei,C0 as en,YX as eo,b0 as er,Wb as es,rte as et,Dne as f,mQ as fa,nn as fc,W$ as fi,c2 as fn,mG as fo,m0 as fr,ap as fs,r6 as ft,B9 as g,VZ as ga,on as gc,D$ as gi,d2 as gn,dW as go,r0 as gr,er as gs,U3 as gt,R9 as h,UZ as ha,dn as hc,I$ as hi,u2 as hn,KW as ho,n0 as hr,fr as hs,X3 as ht,$9 as i,kQ as ia,qt as ic,t1 as ii,L0 as in,hX as io,M0 as ir,vb as is,f6 as it,k9 as j,nZ as ja,ft as jc,u$ as ji,J0 as jn,ux as jo,P1 as jr,Wn as js,U4 as jt,cne as k,DZ as ka,Et as kc,f$ as ki,i2 as kn,dx as ko,X1 as kr,Hn as ks,n3 as kt,Ene as l,iQ as la,Wt as lc,Z$ as li,a2 as ln,uG as lo,O0 as lr,$m as ls,t6 as lt,wne as m,WZ as ma,_n as mc,N$ as mi,m2 as mn,oG as mo,d0 as mr,I as ms,Q3 as mt,Fne as n,OQ as na,Kt as nc,a1 as ni,T0 as nn,SX as no,D0 as nr,Cb as ns,ste as nt,jne as o,EQ as oa,Zt as oc,o1 as oi,z2 as on,wY as oo,F0 as or,hb as os,m6 as ot,z9 as p,XZ as pa,pn as pc,V$ as pi,h2 as pn,aG as po,l0 as pr,$a as ps,n6 as pt,Rte as q,qX as qa,LQ as qi,U2 as qn,Vb as qo,S1 as qr,kn as qs,i4 as qt,Une as r,AQ as ra,Jt as rc,r1 as ri,b2 as rn,pX as ro,j0 as rr,bb as rs,l6 as rt,kne as s,gQ as sa,Qt as sc,c1 as si,R2 as sn,CY as so,k0 as sr,fb as ss,c6 as st,Ine as t,jQ as ta,Yt as tc,s1 as ti,w0 as tn,yX as to,N0 as tr,wb as ts,bte as tt,W9 as u,pQ as ua,tn as uc,Q$ as ui,o2 as un,lG as uo,z0 as ur,Qm as us,e6 as ut,_ne as v,BZ as va,mn as vc,j$ as vi,p2 as vn,RH as vo,a0 as vr,tr as vs,V3 as vt,pne as w,vZ as wa,Ht as wc,S$ as wi,V2 as wn,qR as wo,q1 as wr,$n as ws,g3 as wt,I9 as x,FZ as xa,Vt as xc,h$ as xi,H2 as xn,xz as xo,e0 as xr,nr as xs,v3 as xt,bne as y,RZ as ya,vn as yc,w$ as yi,k2 as yn,LH as yo,c0 as yr,ar as ys,H3 as yt,Jte as z,uZ as za,we as zc,t$ as zi,I0 as zn,rx as zo,p1 as zr,Pn as zs,y4 as zt};
357
- //# sourceMappingURL=src-DhKkOAcb.mjs.map
357
+ //# sourceMappingURL=src-CaLoSvK5.mjs.map
@@ -0,0 +1,20 @@
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{$ as t,Q as n,n as r,r as i,yt as a}from"./sleep-DyLEGHvt.mjs";import{Bc as o,Fc as s,Ic as c,Oo as l,Vc as u}from"./src-CaLoSvK5.mjs";import{Bi as d,Fr as f,ct as p,h as m,lt as h,pi as g,st as _,ut as v}from"./src-CNSuUQTi.mjs";import{A as y,I as b,L as x,O as S}from"./fs-traced-C5oeVBiQ.mjs";import{C,S as w,_ as T,d as E,f as D,r as O}from"./server-lock-CcnGITIh.mjs";import{t as k}from"./yazl-DejPO9b3.mjs";import{h as ee,m as A,x as j}from"./resolve-project-root-suxWrGvT.mjs";import{c as te}from"./colors-DSyAT9Cz.mjs";import{a as ne,i as M}from"./acp-harness-probe-Bz_Xfqhw.mjs";import{D as re,E as N,S as ie,T as P,_ as ae,b as oe,o as se}from"./init-JIlCRbdu.mjs";import{n as ce}from"./constants-BgJb28Cb.mjs";import{t as le}from"./is-object-Bw0-z8qH.mjs";import"./loader-BkOiHFr0.mjs";import"./skill-teardown-D4qifTbZ.mjs";import"./preview-BF5V_rVP.mjs";import{execSync as ue,spawnSync as de}from"node:child_process";import{basename as F,dirname as I,join as L,relative as fe,resolve as R,sep as pe}from"node:path";import{cpSync as me,createWriteStream as he,existsSync as z,lstatSync as ge,mkdirSync as B,mkdtempSync as _e,readFileSync as V,readdirSync as H,readlinkSync as ve,rmSync as ye,statSync as be,writeFileSync as U}from"node:fs";import{arch as xe,freemem as Se,homedir as W,hostname as Ce,platform as we,release as Te,tmpdir as Ee,totalmem as De,type as Oe,uptime as ke}from"node:os";import"node:fs/promises";import{createHash as Ae}from"node:crypto";var je=a();let Me;function Ne(){return Me}function Pe(e,t){if(t!==void 0&&t.length>0)return t;try{return f(e)?.rootPath}catch{return}}function Fe(e){let t=Pe(e.cwd,e.configuredProjectName),n=m({name:`cli`,project:t});return Me=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const Ie=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Le(e,t,n=f){if(e!==void 0&&!Ie.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Re=null;function ze(e){Re=e}function Be(){return Re??process.cwd()}function G(){return L(W(),`.ok`,`bug-reports`)}function Ve(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=G(),r=`${t}-bugreport`,i=L(n,`${r}.zip`);for(let e=2;z(i);e+=1)i=L(n,`${r}-${e}.zip`);return i}function He(e,t){let n=L(e,`.ok`,`config.yml`);if(z(n))try{let e=V(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 z(L(e,`.ok`))?Ae(`sha256`).update(R(e)).digest(`hex`).slice(0,12):null}function Ue(){let e={timestamp:new Date().toISOString(),platform:we(),osType:Oe(),osRelease:Te(),hostname:`[redacted]`,uptime:ke(),freeMem:Se(),totalMem:De(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ue(`sw_vers -productVersion 2>/dev/null`,d({encoding:`utf8`})).trim()}catch{}try{let t=L(__dirname,`..`,`..`,`package.json`);z(t)&&(e.okVersion=JSON.parse(V(t,`utf8`)).version)}catch{}return e}const We=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Ge(e){let t=F(e);return We.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Ke(e,t){return Xe(e,t).files}const qe=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Je(e,t=ne){let n=L(e,`${t}.ShipIt`);return z(n)?qe.map(e=>L(n,e)).filter(e=>z(e)):[]}function Ye(e){if(!z(e))return[];try{let t=new Map;for(let n of H(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-o.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=>L(e,t))}catch{return[]}}function Xe(e,t){if(!z(t))return{files:[],excludedByProjectSlug:0};let n=H(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>L(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Ge),i=[],a=r.filter(t=>{try{return V(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=>!Ge(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ze(e){let t=L(e,`.ok`,`local`);return z(t)?{files:[`server.lock`,`last-spawn-error.log`,r].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function Qe(e){let t=L(e,`.ok`,`local`,`logs`);return z(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>L(t,e)).filter(e=>z(e))}:{files:[]}}function $e(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#${Ae(`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 et(e){let t=e.revealDocNames?e.content:$e(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=c(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 K(e){for(let t of e.files)try{et({zipfile:e.zipfile,name:`${e.prefix}/${F(t)}`,content:V(t,`utf8`),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 tt(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??L(W(),`.ok`,`logs`),c=t.projectDir?He(t.projectDir,i):null;B(I(r),{recursive:!0}),i?.info({projectSlug:c},`gathering diagnostic data`);let l=Ue();l.desktop=t.desktop??null,l.language=t.language??null;let{files:d,excludedByProjectSlug:f}=Xe(c,o),{files:p}=t.projectDir?Ze(t.projectDir):{files:[]},{files:m}=t.projectDir?Qe(t.projectDir):{files:[]},h=t.shipItLogFiles??[];i?.info({logFileCount:d.length,logFilesExcludedByProjectSlug:f,lockFileCount:p.length,localSinkFileCount:m.length,shipItLogFileCount:h.length},`files collected`);let g=[],_=[],{ZipFile:v}=await import(`./yazl-BwMlCqRQ.mjs`).then(t=>e(t.default,1)),y=new v;K({zipfile:y,files:[...d,...h],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),K({zipfile:y,files:p,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),K({zipfile:y,files:m,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),K({zipfile:y,files:t.bugReportLedgerFiles??[],prefix:u,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i});for(let e of t.extraFiles??[])try{let t=V(e.sourcePath),n=`extra/${e.zipName??F(e.sourcePath)}`;y.addBuffer(t,n),_.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&et({zipfile:y,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:_,redactions:g});let b=JSON.stringify(l,null,2);y.addBuffer(Buffer.from(b,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let x={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:_,redactions:g,sysinfo:l};y.addBuffer(Buffer.from(JSON.stringify(x,null,2),`utf8`),`MANIFEST.json`);let S=g.reduce((e,t)=>e+t.lineCount,0),C=new Set(h.map(e=>`logs/${F(e)}`)),w=_.filter(e=>C.has(e)),T=new Set((t.bugReportLedgerFiles??[]).map(e=>`${u}/${F(e)}`)),E=_.filter(e=>T.has(e)),D=c?_.filter(e=>e.startsWith(`logs/`)&&!Ge(e)&&!C.has(e)):[],O=[`# Bug Report Bundle`,``,`Generated: ${x.generatedAt}`,`Project: ${c??`(unscoped)`}`,`Discipline version: ${x.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...D.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:`,...D.map(e=>`- ${e}`),``]:[],...w.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:`,...w.map(e=>`- ${e}`),``]:[],...E.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:`,...E.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${s.join(`, `)}`,S>0?`${S} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
+ `);y.addBuffer(Buffer.from(O,`utf8`),`README.md`),y.end();let k=he(r);return y.outputStream.pipe(k),await new Promise((e,t)=>{k.on(`close`,e),k.on(`error`,t)}),i?.info({bundlePath:r,fileCount:_.length,redactionCount:S},`bundle written`),{zipPath:r,summary:{projectSlug:c,files:_,redactions:g,redactedLineCount:S,generatedAt:x.generatedAt}}}var nt=e(k(),1),q=e(te(),1);function rt(e){return x({absPath:y(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function it({home:e=W(),env:r=process.env}={}){let i=rt(e),{override:a,preferenceList:o}=S(r),{locale:s,source:c}=l({override:a,storedPreference:i,supportedLocales:t,preferenceList:o,autoDetectableLocales:n});return{preference:i,locale:s,source:c,systemLanguages:o}}function at(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e,t){if(typeof e==`string`)return at(e,t.contentDir);if(Array.isArray(e))return e.map(e=>J(e,t));if(!ot(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=J(i,t);return n}function st(e,t){let n=V(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=J(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}U(e,r?`${a.join(`
5
+ `)}\n`:a.join(`
6
+ `))}function ct(e,t){let n=V(e,`utf-8`);if(n.trim().length!==0)try{let r=J(JSON.parse(n),t),i=n.endsWith(`
7
+ `)?`
8
+ `:``;U(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=at(n,t.contentDir);r!==n&&U(e,r)}}function lt(e,t){let n=V(e,`utf-8`),r=at(n,t.contentDir);r!==n&&U(e,r)}function ut(e){try{return H(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>L(e,t.name))}catch{return[]}}const dt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function ft(e){return/\.log\.\d+$/.test(e)}function pt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||ft(e)}function mt(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of ut(L(e.stagingDir,n)))pt(r)?st(r,t):r.endsWith(`.json`)?ct(r,t):lt(r,t);for(let n of ut(L(e.stagingDir,`state`))){let e=F(n);n.endsWith(`.jsonl`)?st(n,t):dt.has(e)?ct(n,t):lt(n,t)}}const ht=[`.ok`,`local`,`telemetry`],gt=[`.ok`,`local`,`logs`],_t=[`.ok`,`local`,`loss-capture`],vt=`spans-current.jsonl`,yt=`spans-prev.jsonl`,bt=`server-current.jsonl`,xt=`server-prev.jsonl`,St=`loss-current.jsonl`,Ct=`loss-prev.jsonl`;function wt(e){return L(e,...ht,vt)}function Tt(e){return L(e,...ht,yt)}function Et(e){return L(e,...gt,bt)}function Dt(e){return L(e,...gt,xt)}function Ot(e){return L(e,..._t,St)}function kt(e){return L(e,..._t,Ct)}const At=1e3;async function jt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}async function Mt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}async function Nt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(At)});return t.ok?await t.text():null}catch{return null}}function Pt(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 Ft(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=de(`git`,[`-C`,t,`log`,`--oneline`,`-50`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function It(e){let t=L(e,`.git`,`ok`);if(!z(t))return null;let n=de(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],d({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Lt(){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 Rt(){return{nodeVersion:process.version,platform:we(),arch:xe()}}function zt(){return process.env.OTEL_SDK_DISABLED===`false`}function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bt(e){if(!z(e))return{};let t;try{t=(0,je.parse)(V(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(!Y(t))return{};let n=t.telemetry;if(!Y(n))return{};let r=n.localSink;return Y(r)?r:{}}function Vt(e){return typeof e==`boolean`?e:void 0}function Ht(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function X(e){if(Y(e))return Ht(e.maxBytes)}function Ut(e){let t=Bt(y(`project`,e)),n=Bt(y(`project-local`,e));return{enabled:Vt(n.enabled)??Vt(t.enabled)??!0,spansMaxBytes:X(n.spans)??X(t.spans)??52428800,logsMaxBytes:X(n.logs)??X(t.logs)??26214400}}function Wt(e){return Ae(`sha256`).update(e).digest(`hex`)}function Gt(e){let t=V(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Kt=[`"doc.name"`,`"docName"`];function qt(e){let t=V(e,`utf-8`),n=0;for(let e of Kt){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z(e,t){if(!z(e))return!1;try{return B(I(t),{recursive:!0}),me(e,t),!0}catch{return!1}}function Jt(e){let t=[],n=e=>{let r=H(e,{withFileTypes:!0});for(let i of r){let r=L(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Yt=new Set([`.jsonl`]);function Xt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Yt.has(e.slice(t))}const Zt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`]);function Qt(e){if(ft(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Zt.has(e.slice(t))}function $t(e){let t=[];for(let n of Jt(e)){let r=en(e,n);if(!Qt(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(V(n,`utf-8`));a.length!==0&&(U(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function en(e,t){return fe(e,t).split(pe).join(`/`)}async function tn(e){let t=R(e.contentDir),n=R(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??jt,s=a.fetchAgentEffects??Mt,c=a.fetchWatcherRecent??Nt,l=a.readShadowHead??Ft,d=a.readCheckpointRefs??It,f=a.now??(()=>new Date),p=a.okVersion??(()=>ce),m=a.readDesktopEnv??Lt,h=a.readLanguage??it,g=a.readRuntime??Rt,_=a.isOtlpPushEnabled??zt,v=_e(L(Ee(),`ok-bundle-`));try{B(L(v,`telemetry`),{recursive:!0}),B(L(v,`logs`),{recursive:!0}),B(L(v,`state`),{recursive:!0}),Z(wt(n),L(v,`telemetry`,vt)),Z(Tt(n),L(v,`telemetry`,yt)),Z(Et(n),L(v,`logs`,bt)),Z(Dt(n),L(v,`logs`,xt));for(let t of e.userLogFiles??[])Z(t,L(v,`logs`,F(t)));for(let t of e.userStateFiles??[])Z(t,L(v,u,F(t)));let y=L(n,`.ok`,`local`),b=L(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(z(b)){Z(b,L(v,`state`,`server.lock`));try{let e=V(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 o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(U(L(v,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await s(C);t!==null&&U(L(v,`state`,`agent-effects.json`),t);let n=await c(C);if(n!==null){let e=Pt(n);e!==null&&U(L(v,`state`,`watcher-recent.jsonl`),e)}}let w=l(t);w!==null&&U(L(v,`state`,`shadow-head.txt`),w);let T=d(t);T!==null&&U(L(v,`state`,`checkpoint-refs.txt`),T),Z(Ot(n),L(v,`state`,St)),Z(kt(n),L(v,`state`,Ct)),Z(L(y,`last-spawn-error.log`),L(v,`state`,`last-spawn-error.log`)),Z(L(y,i),L(v,`state`,i)),Z(L(y,r),L(v,`state`,r));let E=g(),D=m(),O=h(),k={ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};U(L(v,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let ee=x===`running`?`running
10
+ `:`not-running (${S})\n`;if(U(L(v,`state`,`server-status.txt`),ee),e.processDir&&z(e.processDir)){let t=L(v,`process`);B(t,{recursive:!0}),me(e.processDir,t,{recursive:!0})}let A=e.redact===!0;A&&mt({stagingDir:v,contentDir:t}),e.note&&U(L(v,`note.txt`),e.note);let j=null;e.scrubSecrets===!0&&(j=$t(v));for(let t of e.extraFiles??[])Z(t.sourcePath,L(v,`extra`,t.zipName??F(t.sourcePath)))||a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let te=Ut(n),ne=Jt(v),M=[],re=0,N=0;for(let e of ne){let t=en(v,e),n=be(e).size,r=Xt(t)?Gt(e):0;M.push({path:t,bytes:n,lines:r}),re+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(N+=qt(e))}let ie={applied:A};j!==null&&(ie.secretScrub=j);let P={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:Wt(t),absolutePath:A?`<CONTENT_DIR>`:t},telemetry:{localSink:te,otlpPushEnabled:_()},redaction:ie,serverStatus:x,files:M};U(L(v,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let ae=ne.some(e=>{try{return V(e,`utf-8`).includes(t)}catch{return!1}}),oe={totalBytes:re,fileCount:M.length,docNameCount:N,contentDirVisible:ae,redacted:A},se=!1;return{stagingDir:v,manifest:P,summary:oe,cleanup:()=>{se||(se=!0,ye(v,{recursive:!0,force:!0}))}}}catch(e){throw ye(v,{recursive:!0,force:!0}),e}}async function nn(e){let{collected:t,outputPath:n}=e,r=I(n);if(!z(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new nt.ZipFile,a=Jt(t.stagingDir);for(let e of a){let n=en(t.stagingDir,e);i.addFile(e,n)}i.end();let o=he(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 rn(e,t){let n=L(e,`.ok`,`config.yml`);if(z(n))try{let t=(0,je.parse)(V(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 R(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 R(e)}async function an(e,t,n,r){let i=He(t,e.logger),a=await tn({contentDir:rn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Ke(i,e.userLogsDir??L(W(),`.ok`,`logs`)),...Je(e.cachesDir??L(W(),`Library`,`Caches`))],userStateFiles:Ye(e.bugReportsDir??G()),deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{B(I(e.outputPath),{recursive:!0}),await nn({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function on(e){let{projectDir:t}=e,n=e.readDesktopEnv??Lt,r=e.readLanguage??it;if(e.level===`full`&&t!==void 0)return an(e,t,n,r);let{zipPath:i,summary:a}=await tt({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Je(e.cachesDir??L(W(),`Library`,`Caches`)),bugReportLedgerFiles:Ye(e.bugReportsDir??G()),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Q(e,t,n={}){let r=D(e,t);if(!z(r))return{status:`missing`,lockPath:r};let i;try{i=JSON.parse(V(r,`utf-8`))}catch{return{status:`corrupt`,lockPath:r}}if(!i||typeof i!=`object`||!C(i.pid))return{status:`corrupt`,lockPath:r};let a=i;if(!(n.isAlive??w)(a.pid))return{status:`dead-pid`,lockPath:r,lock:a};if(typeof a.machineId==`string`)return a.machineId===(n.machineId??T())?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a};let o=n.host??Ce();return a.hostname===o?{status:`alive`,lockPath:r,lock:a}:{status:`foreign-host`,lockPath:r,lock:a}}function sn(e){return e.replace(/:\d+$/,``)}function cn(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:sn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:sn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:sn(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 ln=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function un(e){return L(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const dn={existsSync:e=>z(e),readFileSync:(e,t)=>V(e,t),lstatSync:e=>ge(e),readlinkSync:e=>ve(e)};function fn(e,t=dn){let n=un(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 pn(e){let t=e.replace(ln,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function mn(e,t,n=dn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function hn(e){return A(e)||ee(e)||ie(e)}const gn=10*1024*1024;function _n(e,t,n,r){let i=se(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!hn(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);if(e.format===`file`){ye(a,{force:!0});let e=M(t,n);return{kind:`removed`,trust:e.action,...e.error===void 0?{}:{trustError:e.error}}}return e.format===`toml`?bn(a,o):e.format===`yaml`?yn(a,e.topLevelKey,o):vn(a,e.topLevelKey,e.serverMapSubKey,o)}function vn(e,t,n,r){let i;try{i=V(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>gn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=re(i,ae(t,n,r));return o?(b(e,a,{mode:P(e)}),{kind:`removed`}):{kind:`not-present`}}function yn(e,t,n){let r;try{r=V(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>gn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,je.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=N(a);a.trim()===``||a.endsWith(`
11
+ `)?c.endsWith(`
12
+ `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
13
+ `).replace(/\n/g,`\r
14
+ `));let u=`${i?``:``}${c}`;return u!==r&&b(e,u,{mode:P(e)}),{kind:`removed`}}function bn(e,t){let n=oe();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=V(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=N(a),s=a.trim()===``||a.endsWith(`
15
+ `),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
16
+ `)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
17
+ `).replace(/\n/g,`\r
18
+ `));let u=`${i?``:``}${l}`;return u!==r&&b(e,u,{mode:P(e)}),{kind:`removed`}}function xn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Sn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Cn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;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:p(n),command:n,isDesktop:xn(n)}}function $(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const wn=new Set([`running`,`desktop`,`foreign`]);function Tn(e){switch(e){case`running`:return q.default.green(e);case`desktop`:return q.default.blue(e);case`foreign`:return q.default.cyan(e);case`stale`:return q.default.yellow(e)}}function En(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Dn(e){return`${En(e.server.usage)} | ${En(e.ui?.usage??null)}`}function On(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function kn(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,On(e),Dn(e),$(e),String(e.server.pid),Sn(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=Tn($(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=q.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
+ `)}async function An(e={}){let t=e.discover??_,n=e.inspect??(e=>Q(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??h,a=e.resolveUsage??v,o=await t(),s=[];for(let e of o){let t=n(e),r=Cn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:$(e)}));r(JSON.stringify(e,null,2));return}r(kn(e.all?s:s.filter(e=>wn.has($(e)))))}function jn(){return new j(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await An({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Mn(e,t=Ne()){let n=Q(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=E(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500)});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 Nn(e,t={}){return{targets:Fn(e,t.isAlive??w)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}async function Pn(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??Mn,o=e.logger??Ne(),s=Nn(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 Fn(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function In(e,t=w){let n=await _(),r=null;for(let i of n){let n=Q(i,`server`);if(Fn(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function Ln(e,t){let n=await Pn({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Rn(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 zn(e){let t=await _(),n=0;for(let r of t)r!==e&&Fn(Q(r,`server`),w)&&n++;return n}function Bn(e){return new j(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. 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=g(process.cwd()),n=await Pn({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 zn(t);console.log(Rn(process.cwd(),e,{listingFollows:e>0})),e>0&&await An({})}return}if(i===`all`){let e=await _();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)Fn(Q(n,`server`),w)&&(await Ln(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 In(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await Ln(t,r);return}let a=R(Be(),i),o=g(a),s=[],c=await Pn({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(Rn(a,await zn(o)))})}export{Fe as S,G as _,_n as a,Le as b,un as c,cn as d,Q as f,Ve as g,nn as h,jn as i,fn as l,tn as m,Pn as n,ln as o,on as p,Bn as r,mn as s,Mn as t,pn as u,Be as v,Ne as x,ze as y};
20
+ //# sourceMappingURL=src-CnywvEPN.mjs.map
@@ -1,5 +1,5 @@
1
- import{L as e}from"./sleep-DyLEGHvt.mjs";import{Ac as t,Oc as n,kc as r,wc as i,xc as a}from"./src-DhKkOAcb.mjs";import{Ir as o,ei as s,s as c,t as l}from"./src-CjFV1e1Z.mjs";import{A as u,L as d}from"./fs-traced-C5oeVBiQ.mjs";import{r as f}from"./server-lock-_JWkU2Mh.mjs";import{C as p,S as m,x as h}from"./resolve-project-root-urAKqvDX.mjs";import{c as g,f as _,g as v,l as y,n as b,o as x,p as S,r as C,s as w,t as T}from"./acp-harness-probe-B0ZOHZTz.mjs";import{y as E}from"./init-XAxC4-D4.mjs";import{n as D}from"./constants-C-QXBCBl.mjs";import{spawn as O}from"node:child_process";import{basename as k,dirname as A,resolve as j}from"node:path";import{existsSync as M,realpathSync as N}from"node:fs";import{tmpdir as P}from"node:os";import{rm as F}from"node:fs/promises";import{setTimeout as I}from"node:timers/promises";function L(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function R(e){if(e===`server`)return e;throw new m(`--only must be 'server'`)}function z(e=M){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[j(t,`public`),j(t,`../../app/dist`),j(t,`../../../app/dist`)].find(t=>e(t))}function B(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 V(t){if(t===`off`)return`off`;if(!e.test(t))throw new m(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return t}function H(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function U(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function W(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||H(e.host))&&e.isTTY}function ee(e,t){let n;try{n=new URL(t)}catch{throw new m(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new m(`${e} must be an http(s) origin (got: ${t})`);return t}function G(e){return ee(`--external-url`,e)}function K(e){let t=k(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var q=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}},J=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${l}* 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 Y(e,t={}){let n=t.tmpdirFn??P,r=t.realpathFn??N,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?j(e):null}},a=j(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(A(a));o=e===null?null:j(e,k(a))}else o=null}if(o===null)return!1;let s=i(n());return s===null?!1:A(o)===s&&k(o).startsWith(`ok-ephemeral-`)}function X(e,t,n=e=>F(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Y(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 ${l}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Z(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 Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:l,mkdirSync:u}=await import(`node:fs`),{basename:d,dirname:f,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:y,resolveLockDir:x,seedEphemeralProjectDir:w,waitForServerLockDrain:D}=await import(`./src-BRlSw7bk.mjs`),O=e.log??g(`start`),k=e.singleFile!==void 0,A=k?c(e.singleFile).canonicalFilePath:void 0,j=A?f(A):void 0,M=A?d(A):void 0,N,P=!1;if(j!==void 0)if(e.projectDir!==void 0){if(N=e.projectDir,!Y(N))throw new J(N);l(p(N,`.ok`,`config.yml`))||w(N,j)}else N=h(j),P=!0;let I=async()=>{if(!(!P||N===void 0)){if(!Y(N)){O.warn({ephemeralProjectDir:N},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await F(N,{recursive:!0,force:!0})}catch(e){O.warn({err:e,ephemeralProjectDir:N},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},L=N;if(!k){if(!i&&!o(n))throw new q(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&O.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-lXWW4hnd.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BLY6J8I2.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-BABpOhB_.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let R=j??y(t,n);!k&&!l(R)&&(u(R,{recursive:!0}),O.info({contentDir:R},`Created content directory`));let z=v(),B=s(),V;try{{let e=x(N??n),t=Date.now(),r=await D(e);r!==`no-drain`&&O.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`)}V=await m({config:t,contentDir:R,projectDir:N??n,contentRoot:k?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:_,detectGhAccounts:S,tokenStore:z,embeddingsKeyStore:B,mcpTomlEditor:E(),...k?{ephemeral:!0,singleDocRelPath:M,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>T(e,t),probePiAcpBridge:e=>C(e),ensurePiAcpBridge:e=>b(e),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Z(L===void 0?n:X(n,L),{log:O,exit:e.idleExit})},log:O,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}})}catch(e){throw await I(),e}let H=V.destroy,U=P?async()=>{try{await H()}finally{await I()}}:H;return{httpServer:V.httpServer,destroy:U,lockDir:V.lockDir,contentDir:R,port:V.port,ready:V.ready,degraded:V.degraded}}function $(e,t,n=()=>d({absPath:u(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function te(e){if(e===`browser`||e===`app`)return e;throw new m(`--mode must be 'browser' or 'app'`)}function ne(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function re(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 ie(e,o){let s=$(e,o.singleFile),c=ne(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-B14xalho.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-CpP5E4wV.mjs`),m=process.cwd();process.title=K(m);let h;try{h=t(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=r(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=i(g),S=v??(_||b===void 0?[...x.bind]:[b]);U({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=i(r(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(`
2
- `)))}let O=o.port===void 0?void 0:Number(o.port),k=h.overrides.find(e=>e.envVar===`PORT`)?.value,A=O??k??s.server?.port,j=B({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:z}),M=j.dir;j.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 N;try{N=await Q({config:s,cwd:m,host:C,port:A,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...M?{reactShellDistDir:M}:{},idleThresholdMs:a(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{}})}catch(e){e instanceof q&&(console.error(f(e.message)),process.exit(1)),e instanceof J&&(console.error(f(e.message)),process.exit(1));let t=await import(`./src-BRlSw7bk.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&&(console.error(f(e.message)),process.exit(1)),se(e,t)){let e=t.resolveLockDir(m),n=null;try{n=await ae({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>I(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]=oe(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=ce(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 P=!1,F=async e=>{if(P)return;P=!0;let[t,...n]=re(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await N.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`,()=>{F(`SIGINT`)}),process.once(`SIGTERM`,()=>{F(`SIGTERM`)});let L=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${N.port}`,R=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${N.port}`:void 0,V=L;console.log(l({name:`open-knowledge`,version:D,localUrl:V,networkUrl:R,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let H={"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`};N.ready.then(async()=>{if(N.degraded.length>0){console.log();for(let e of N.degraded){let t=H[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(W({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:M!==void 0})){let{openBrowser:e}=await import(`./open-browser-aU_PSdrG.mjs`);e(V)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function ae(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:f(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 oe(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 se(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function ce(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 le(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)`,R).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)`,V).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,te).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 p(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new p(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,G).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'
1
+ import{L as e}from"./sleep-DyLEGHvt.mjs";import{Ac as t,Oc as n,kc as r,wc as i,xc as a}from"./src-CaLoSvK5.mjs";import{Ir as o,ei as s,s as c,t as l}from"./src-CNSuUQTi.mjs";import{A as u,L as d}from"./fs-traced-C5oeVBiQ.mjs";import{r as f}from"./server-lock-CcnGITIh.mjs";import{C as p,S as m,x as h}from"./resolve-project-root-suxWrGvT.mjs";import{c as g,f as _,g as v,l as y,n as b,o as x,p as S,r as C,s as w,t as T}from"./acp-harness-probe-Bz_Xfqhw.mjs";import{y as E}from"./init-JIlCRbdu.mjs";import{n as D}from"./constants-BgJb28Cb.mjs";import{spawn as O}from"node:child_process";import{basename as k,dirname as A,resolve as j}from"node:path";import{existsSync as M,realpathSync as N}from"node:fs";import{tmpdir as P}from"node:os";import{rm as F}from"node:fs/promises";import{setTimeout as I}from"node:timers/promises";function L(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function R(e){if(e===`server`)return e;throw new m(`--only must be 'server'`)}function z(e=M){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[j(t,`public`),j(t,`../../app/dist`),j(t,`../../../app/dist`)].find(t=>e(t))}function B(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 V(t){if(t===`off`)return`off`;if(!e.test(t))throw new m(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return t}function H(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function U(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function W(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||H(e.host))&&e.isTTY}function ee(e,t){let n;try{n=new URL(t)}catch{throw new m(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new m(`${e} must be an http(s) origin (got: ${t})`);return t}function G(e){return ee(`--external-url`,e)}function K(e){let t=k(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var q=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}},J=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${l}* 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 Y(e,t={}){let n=t.tmpdirFn??P,r=t.realpathFn??N,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?j(e):null}},a=j(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(A(a));o=e===null?null:j(e,k(a))}else o=null}if(o===null)return!1;let s=i(n());return s===null?!1:A(o)===s&&k(o).startsWith(`ok-ephemeral-`)}function X(e,t,n=e=>F(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Y(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 ${l}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Z(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 Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:l,mkdirSync:u}=await import(`node:fs`),{basename:d,dirname:f,resolve:p}=await import(`node:path`),{bootServer:m,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:y,resolveLockDir:x,seedEphemeralProjectDir:w,waitForServerLockDrain:D}=await import(`./src-C8wtGJxJ.mjs`),O=e.log??g(`start`),k=e.singleFile!==void 0,A=k?c(e.singleFile).canonicalFilePath:void 0,j=A?f(A):void 0,M=A?d(A):void 0,N,P=!1;if(j!==void 0)if(e.projectDir!==void 0){if(N=e.projectDir,!Y(N))throw new J(N);l(p(N,`.ok`,`config.yml`))||w(N,j)}else N=h(j),P=!0;let I=async()=>{if(!(!P||N===void 0)){if(!Y(N)){O.warn({ephemeralProjectDir:N},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await F(N,{recursive:!0,force:!0})}catch(e){O.warn({err:e,ephemeralProjectDir:N},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},L=N;if(!k){if(!i&&!o(n))throw new q(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{let t=typeof e.event==`string`?e.event:``;(t.endsWith(`-failed`)||t.endsWith(`-error`)||t.endsWith(`-missing`))&&O.warn({event:e},`[start] reclaim sweep reported a problem`)};try{(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BQ7U1U_I.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-BVjKD52o.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}try{await(e.repairSkillsFn??(await import(`./repair-skills-DIytACob.mjs`)).repairSkills)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){O.warn({err:e},`[start] skill repair sweep failed; continuing`)}}let R=j??y(t,n);!k&&!l(R)&&(u(R,{recursive:!0}),O.info({contentDir:R},`Created content directory`));let z=v(),B=s(),V;try{{let e=x(N??n),t=Date.now(),r=await D(e);r!==`no-drain`&&O.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`)}V=await m({config:t,contentDir:R,projectDir:N??n,contentRoot:k?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:_,detectGhAccounts:S,tokenStore:z,embeddingsKeyStore:B,mcpTomlEditor:E(),...k?{ephemeral:!0,singleDocRelPath:M,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>T(e,t),probePiAcpBridge:e=>C(e),ensurePiAcpBridge:e=>b(e),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Z(L===void 0?n:X(n,L),{log:O,exit:e.idleExit})},log:O,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{}})}catch(e){throw await I(),e}let H=V.destroy,U=P?async()=>{try{await H()}finally{await I()}}:H;return{httpServer:V.httpServer,destroy:U,lockDir:V.lockDir,contentDir:R,port:V.port,ready:V.ready,degraded:V.degraded}}function $(e,t,n=()=>d({absPath:u(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function te(e){if(e===`browser`||e===`app`)return e;throw new m(`--mode must be 'browser' or 'app'`)}function ne(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function re(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 ie(e,o){let s=$(e,o.singleFile),c=ne(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-B14xalho.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-CpP5E4wV.mjs`),m=process.cwd();process.title=K(m);let h;try{h=t(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=r(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=i(g),S=v??(_||b===void 0?[...x.bind]:[b]);U({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=i(r(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(`
2
+ `)))}let O=o.port===void 0?void 0:Number(o.port),k=h.overrides.find(e=>e.envVar===`PORT`)?.value,A=O??k??s.server?.port,j=B({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:z}),M=j.dir;j.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 N;try{N=await Q({config:s,cwd:m,host:C,port:A,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...M?{reactShellDistDir:M}:{},idleThresholdMs:a(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{}})}catch(e){e instanceof q&&(console.error(f(e.message)),process.exit(1)),e instanceof J&&(console.error(f(e.message)),process.exit(1));let t=await import(`./src-C8wtGJxJ.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&&(console.error(f(e.message)),process.exit(1)),se(e,t)){let e=t.resolveLockDir(m),n=null;try{n=await ae({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>I(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]=oe(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=ce(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 P=!1,F=async e=>{if(P)return;P=!0;let[t,...n]=re(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await N.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`,()=>{F(`SIGINT`)}),process.once(`SIGTERM`,()=>{F(`SIGTERM`)});let L=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${N.port}`,R=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${N.port}`:void 0,V=L;console.log(l({name:`open-knowledge`,version:D,localUrl:V,networkUrl:R,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let H={"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`};N.ready.then(async()=>{if(N.degraded.length>0){console.log();for(let e of N.degraded){let t=H[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(W({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:M!==void 0})){let{openBrowser:e}=await import(`./open-browser-CrMsTPIV.mjs`);e(V)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function ae(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:f(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 oe(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 se(e,t){let n=t.ServerLockCollisionError;return n!==void 0&&e instanceof n}function ce(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 le(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)`,R).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)`,V).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,te).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 p(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new p(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,G).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'
3
3
  `),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
4
4
  `),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=w(x());if(n.available){g({spawn:O},n);return}console.error(y(n.reason)),process.exit(1)}await ie(n,t)})}export{ce as C,le as S,Z as T,ne as _,oe as a,W as b,Y as c,V as d,R as f,$ as g,ae as h,K as i,se as l,L as m,q as n,re as o,z as p,Q as r,H as s,J as t,G as u,B as v,X as w,U as x,ie as y};
5
- //# sourceMappingURL=start-BaCKwcGO.mjs.map
5
+ //# sourceMappingURL=start-ClCOtrI0.mjs.map
@@ -0,0 +1 @@
1
+ import{S as e,m as t,p as n,r}from"./start-ClCOtrI0.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.64.0-beta.4",
3
+ "version": "0.64.0-beta.5",
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",
@@ -71,10 +71,10 @@
71
71
  "ajv-formats": "^3.0.1",
72
72
  "tsdown": "^0.21.7",
73
73
  "typescript": "^5.9.3",
74
- "@inkeep/open-knowledge-app": "0.64.0-beta.4",
74
+ "@inkeep/open-knowledge-app": "0.64.0-beta.5",
75
75
  "@inkeep/open-knowledge-native-config": "0.0.0",
76
- "@inkeep/open-knowledge-core": "0.64.0-beta.4",
77
- "@inkeep/open-knowledge-server": "0.64.0-beta.4"
76
+ "@inkeep/open-knowledge-server": "0.64.0-beta.5",
77
+ "@inkeep/open-knowledge-core": "0.64.0-beta.5"
78
78
  },
79
79
  "scripts": {
80
80
  "build:cli": "rm -rf dist && tsdown",
@@ -1,2 +0,0 @@
1
- import"./src-DhKkOAcb.mjs";var e=`0.64.0-beta.4`;const t=`config.yml`,n=e;export{n,t};
2
- //# sourceMappingURL=constants-C-QXBCBl.mjs.map
@@ -1 +0,0 @@
1
- import{i as e}from"./git-handle-29BNYqgw.mjs";export{e as createGitInstance};
@@ -1 +0,0 @@
1
- import"./src-CjFV1e1Z.mjs";import{g as e}from"./init-XAxC4-D4.mjs";export{e as runInit};
@@ -1 +0,0 @@
1
- import{n as e}from"./loader-BAhIE_G7.mjs";export{e as loadConfig};
@@ -1,2 +0,0 @@
1
- import{fs as e,ss as t,vo as n}from"./src-DhKkOAcb.mjs";const r=new n({extensions:t,deriveStructuralFreshness:!0}),i=e(t);export{i as n,r as t};
2
- //# sourceMappingURL=md-manager-CZcRasmz.mjs.map
@@ -1 +0,0 @@
1
- import{n as e,t}from"./preview-W17sbyAM.mjs";export{t as formatPreviewBlock,e as previewContent};