@inkeep/open-knowledge 0.84.0-beta.13 → 0.84.0-beta.14

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 (145) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/constants-B3X-QRRf.mjs +1 -0
  3. package/dist/index.d.mts +96 -0
  4. package/dist/index.mjs +1 -1
  5. package/dist/{init-0rxCvh5L.mjs → init-PjjvTgrO.mjs} +2 -2
  6. package/dist/init-SyGGlOHV.mjs +1 -0
  7. package/dist/{launch-json-removal-DcB-Wfiq.mjs → launch-json-removal-DlVzHl6B.mjs} +1 -1
  8. package/dist/{loader-Cc8WS_Kd.mjs → loader-BQS4fl0m.mjs} +1 -1
  9. package/dist/loader-aoEqsyEe.mjs +1 -0
  10. package/dist/{preview-DCg3Y_RC.mjs → preview-3gk2i1xX.mjs} +1 -1
  11. package/dist/preview-BhWNX5ES.mjs +1 -0
  12. package/dist/public/assets/{AccountSection-B9GFpr4F.js → AccountSection-CcrCMfiM.js} +1 -1
  13. package/dist/public/assets/{ActivityModeContent-Ctgs6wa7.js → ActivityModeContent-Dxzg-NgH.js} +1 -1
  14. package/dist/public/assets/{AddPropertiesButton-zJXBlIA5.js → AddPropertiesButton-BUhk-vu0.js} +2 -2
  15. package/dist/public/assets/{AgentDiffPane-Djl1ToN8.js → AgentDiffPane-B_LwSP7B.js} +1 -1
  16. package/dist/public/assets/{AgentThreadClientBinder-A456fHK5.js → AgentThreadClientBinder-uy3_BZY8.js} +1 -1
  17. package/dist/public/assets/{AttachmentsSection-2DavTRS4.js → AttachmentsSection-BJiZQ2MV.js} +1 -1
  18. package/dist/public/assets/{CodeMirrorPropInput-CvL4Fw3i.js → CodeMirrorPropInput-DkRMFYIK.js} +1 -1
  19. package/dist/public/assets/{ContentRulesSection-DI_-zh8B.js → ContentRulesSection-D4g32j4R.js} +1 -1
  20. package/dist/public/assets/{DiffViewBoundary-U3okJCMY.js → DiffViewBoundary-BEZkhnbH.js} +1 -1
  21. package/dist/public/assets/{DocumentContext-BTpye0wm.js → DocumentContext-BZi2BNlk.js} +5 -5
  22. package/dist/public/assets/{EditorModeToggle-ByL15J-o.js → EditorModeToggle-CCHArnnt.js} +1 -1
  23. package/dist/public/assets/{ExcalidrawDocEditor-cwGRFFsR.js → ExcalidrawDocEditor-ffnyxme7.js} +1 -1
  24. package/dist/public/assets/FeedbackForm-DNCliMhK.js +1 -0
  25. package/dist/public/assets/{GraphPanel-B9AzH70t.js → GraphPanel-fkRF4Ymc.js} +1 -1
  26. package/dist/public/assets/{ImportSkillDialog-C5Wc3l-X.js → ImportSkillDialog-D_5FqPZM.js} +1 -1
  27. package/dist/public/assets/{LinkPreviewsSection-I7k5npop.js → LinkPreviewsSection-rwx7LdIg.js} +1 -1
  28. package/dist/public/assets/{LintConfigEditor-CmVvgecx.js → LintConfigEditor-DaoCksvr.js} +1 -1
  29. package/dist/public/assets/{LintingSection-CrPyWSf6.js → LintingSection-D5I7tYlt.js} +1 -1
  30. package/dist/public/assets/{ManagedArtifactProperties-CyEh2d0o.js → ManagedArtifactProperties-CUpup7ho.js} +1 -1
  31. package/dist/public/assets/ManagedArtifactProperties-Cjwb2bDX.js +1 -0
  32. package/dist/public/assets/{MermaidDocEditor-BGRvDEPi.js → MermaidDocEditor-B3KYptUs.js} +1 -1
  33. package/dist/public/assets/{NetworkAccessSection-BWfjDmfO.js → NetworkAccessSection-LjctJODc.js} +1 -1
  34. package/dist/public/assets/{OkignoreSection-CVloj6Ys.js → OkignoreSection-BsqOZ0wD.js} +1 -1
  35. package/dist/public/assets/{PageListContext-aYEmqTv4.js → PageListContext-DgTeRFU-.js} +1 -1
  36. package/dist/public/assets/{ProjectTemplatesSection-v4jcksPy.js → ProjectTemplatesSection-7RWIVmXg.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-BKe17Em-.js → PropertyDisplayRow-CrzwKvEA.js} +1 -1
  38. package/dist/public/assets/{PublishToGitHubDialog-Dn1_oSW2.js → PublishToGitHubDialog-DYdMkEyQ.js} +1 -1
  39. package/dist/public/assets/{SchemaConfigEditor-BRehzWfq.js → SchemaConfigEditor-DIGJxK72.js} +1 -1
  40. package/dist/public/assets/{SearchSection-OsdFyUj1.js → SearchSection-BS4FOrKH.js} +1 -1
  41. package/dist/public/assets/{SessionsHost-Dfa3Kxga.js → SessionsHost-BtjoWr0r.js} +2 -2
  42. package/dist/public/assets/SettingsDialogBody-BA2gB2VO.js +2 -0
  43. package/dist/public/assets/{ShareReceiveMissDialog-WLm7H-Qq.js → ShareReceiveMissDialog-DUrgcHzv.js} +1 -1
  44. package/dist/public/assets/{SkillForkDialog-DIQyHpiy.js → SkillForkDialog-QqHr4a1o.js} +1 -1
  45. package/dist/public/assets/{SkillInstallMenu-MPmPQLvN.js → SkillInstallMenu-BQHSpQsX.js} +1 -1
  46. package/dist/public/assets/{SkillOriginInline-CImx-xbo.js → SkillOriginInline-DzV3iN2B.js} +1 -1
  47. package/dist/public/assets/{SkillToolbarControls-DPDzNMVA.js → SkillToolbarControls-Cvg-HsNg.js} +1 -1
  48. package/dist/public/assets/{SkillsManagerSection-6Bt4ADEN.js → SkillsManagerSection-C4ytRUcq.js} +1 -1
  49. package/dist/public/assets/{SlidesPluginSection-BLr0SHzx.js → SlidesPluginSection-DuBoITZp.js} +1 -1
  50. package/dist/public/assets/{SourceEditor-CgnUzAYs.js → SourceEditor-D9DNsiLu.js} +1 -1
  51. package/dist/public/assets/{SpellingSettings-Ccod57gT.js → SpellingSettings-BpZv35LE.js} +1 -1
  52. package/dist/public/assets/{SyncSection-Dmc70btB.js → SyncSection-CrxvCruv.js} +1 -1
  53. package/dist/public/assets/{SyncStatusBadge-YALZC8ph.js → SyncStatusBadge-BDB1rnZs.js} +1 -1
  54. package/dist/public/assets/{TemplateRow-B0mFlkDZ.js → TemplateRow-xwZoU5JB.js} +1 -1
  55. package/dist/public/assets/{TerminalSection-DyfUJxOe.js → TerminalSection-D8ayxcw-.js} +1 -1
  56. package/dist/public/assets/{TerminalWindowApp-ZlS6k93B.js → TerminalWindowApp-5w8Pgr5J.js} +1 -1
  57. package/dist/public/assets/{TextDocEditor-njGGLt-q.js → TextDocEditor-CJVX7Iiq.js} +1 -1
  58. package/dist/public/assets/{ThemePluginSection-DQuitacb.js → ThemePluginSection-Dj2GGGoa.js} +1 -1
  59. package/dist/public/assets/{ThreadView-BcJ87wpA.js → ThreadView-B8B9FyFL.js} +1 -1
  60. package/dist/public/assets/{TimelineDiffPane-KVwOFG02.js → TimelineDiffPane-Dap3gK1f.js} +1 -1
  61. package/dist/public/assets/{card-D0jvDdtx.js → card-DdkXkyr5.js} +1 -1
  62. package/dist/public/assets/{comment-chips-9Q2hv4Un.js → comment-chips-BuYSFClb.js} +1 -1
  63. package/dist/public/assets/{config-provider-CNfO-H0J.js → config-provider-CyBtB5MG.js} +2 -2
  64. package/dist/public/assets/config-schema-Dj0e1pm8.js +1 -0
  65. package/dist/public/assets/{doc-undo-manager-BM-wXcNc.js → doc-undo-manager-SYl0ECng.js} +1 -1
  66. package/dist/public/assets/{documents-events-C7Jq0Exs.js → documents-events-ckNvVQCr.js} +1 -1
  67. package/dist/public/assets/{field-controls-D7Pus9Z9.js → field-controls-BBWVj3AF.js} +1 -1
  68. package/dist/public/assets/field-controls-BshUGsc5.js +1 -0
  69. package/dist/public/assets/{folder-config-api-BceG_Bmf.js → folder-config-api-Db5-uEQR.js} +1 -1
  70. package/dist/public/assets/index-CbKG13-E.js +2205 -0
  71. package/dist/public/assets/{lint-config-client-B8HW3I8D.js → lint-config-client-CB91vevq.js} +1 -1
  72. package/dist/public/assets/{lint-plugins-DS-hzw80.js → lint-plugins-CvfQPI2r.js} +1 -1
  73. package/dist/public/assets/{markdown-lint-CH5x73AS.js → markdown-lint-ZeKFkjFe.js} +1 -1
  74. package/dist/public/assets/{markdownlint-rule-browser-feJ8vq-M.js → markdownlint-rule-browser-BbmlUEor.js} +1 -1
  75. package/dist/public/assets/messages-ANXyJliY.js +1 -0
  76. package/dist/public/assets/{messages-CFNq87YD.js → messages-B1FZsv56.js} +1 -1
  77. package/dist/public/assets/messages-B4Ao4T-h.js +1 -0
  78. package/dist/public/assets/messages-BcdGkp91.js +1 -0
  79. package/dist/public/assets/messages-CHvjKumb.js +1 -0
  80. package/dist/public/assets/messages-D0VuVwkB.js +1 -0
  81. package/dist/public/assets/messages-DY9xlGMT.js +1 -0
  82. package/dist/public/assets/messages-DfEF3nXA.js +1 -0
  83. package/dist/public/assets/messages-MLW9EqLI.js +1 -0
  84. package/dist/public/assets/messages-WD_ZkqZv.js +1 -0
  85. package/dist/public/assets/messages-WyXTlpZd.js +1 -0
  86. package/dist/public/assets/messages-dexq95NM.js +1 -0
  87. package/dist/public/assets/messages-jgN1s75x.js +1 -0
  88. package/dist/public/assets/{pending-receive-nav-store-qv7Cfy9Q.js → pending-receive-nav-store-BRYTI4O-.js} +1 -1
  89. package/dist/public/assets/{progress-YIJt8IwS.js → progress-CTEVJNXO.js} +1 -1
  90. package/dist/public/assets/{saved-themes-client-CGp8QQYb.js → saved-themes-client-DQK5ylqX.js} +1 -1
  91. package/dist/public/assets/{schema-section-CNrnBed2.js → schema-section-BdTNVIyL.js} +1 -1
  92. package/dist/public/assets/{schemas-cc1-CR2ooa34.js → schemas-cc1-DNrPPikD.js} +1 -1
  93. package/dist/public/assets/{selection-context-riqxN6LG.js → selection-context-D9wsGgDp.js} +1 -1
  94. package/dist/public/assets/{skills-api-C4z5vWyd.js → skills-api-DronAhV9.js} +1 -1
  95. package/dist/public/assets/{src-C2_yxMVl.js → src-DOSqBXQd.js} +2 -2
  96. package/dist/public/assets/{typing-burst-detector-BydS4hGG.js → typing-burst-detector-CNLhok7Q.js} +1 -1
  97. package/dist/public/assets/{uninstall-CaDWNOzh.js → uninstall-CfBkwPz3.js} +1 -1
  98. package/dist/public/assets/{use-activity-panel-CP-KbBLe.js → use-activity-panel-JcDF_NGH.js} +1 -1
  99. package/dist/public/assets/{use-apply-config-language-erUucjt8.js → use-apply-config-language-quJJgq3F.js} +2 -2
  100. package/dist/public/assets/{use-collab-url-BPJukLUh.js → use-collab-url-DPmF-V5e.js} +1 -1
  101. package/dist/public/assets/{use-conflicts-DgaZPKZv.js → use-conflicts-E9tj1NHs.js} +1 -1
  102. package/dist/public/assets/{use-git-sync-status-BwJMuoUW.js → use-git-sync-status-DPG8QuKs.js} +1 -1
  103. package/dist/public/assets/{use-open-skill-OC__o8wV.js → use-open-skill-BejdmcK8.js} +1 -1
  104. package/dist/public/assets/{use-semantic-search-status-CrlWLidR.js → use-semantic-search-status-Bq4BpHMI.js} +1 -1
  105. package/dist/public/assets/{use-settings-route-DT86DJkF.js → use-settings-route-BVEU1nrV.js} +1 -1
  106. package/dist/public/assets/{use-skill-origin-CPL6FU5s.js → use-skill-origin-BnTpq9XZ.js} +1 -1
  107. package/dist/public/assets/{use-skill-targets-mNqOFnfw.js → use-skill-targets-DcxmfKVk.js} +1 -1
  108. package/dist/public/assets/{use-skills-C6ZneXh8.js → use-skills-D9Qpt2AT.js} +1 -1
  109. package/dist/public/assets/{use-terminal-enabled-B4wyLrav.js → use-terminal-enabled-CqtBhC9Q.js} +1 -1
  110. package/dist/public/assets/{use-timeline-entry-diff-qr50coTA.js → use-timeline-entry-diff-JiMHabs-.js} +1 -1
  111. package/dist/public/index.html +37 -37
  112. package/dist/public/uninstall.html +3 -3
  113. package/dist/{registry-probes-dLB-QCwD.mjs → registry-probes-BJWCp_zI.mjs} +1 -1
  114. package/dist/{removal-file-path-CP_R44kA.mjs → removal-file-path-CnXRatEs.mjs} +1 -1
  115. package/dist/{repair-launch-json-DAdDamo4.mjs → repair-launch-json-DCtFnoyJ.mjs} +1 -1
  116. package/dist/{repair-mcp-configs-rvj-kL93.mjs → repair-mcp-configs-BbWY7hPn.mjs} +1 -1
  117. package/dist/src-B6vlrcvu.mjs +1 -0
  118. package/dist/{src-BskdlNkv.mjs → src-BQPZHOpx.mjs} +1 -1
  119. package/dist/{start-BFNDsvyi.mjs → start-6rBE8R0Q.mjs} +2 -2
  120. package/dist/start-uwbHcniG.mjs +1 -0
  121. package/package.json +4 -4
  122. package/dist/constants-7Qyq_zUm.mjs +0 -1
  123. package/dist/init-CXecl8YV.mjs +0 -1
  124. package/dist/loader-Cao__OIq.mjs +0 -1
  125. package/dist/preview-D3mT4ao_.mjs +0 -1
  126. package/dist/public/assets/FeedbackForm-CJG--Io-.js +0 -1
  127. package/dist/public/assets/ManagedArtifactProperties-CtspFBi-.js +0 -1
  128. package/dist/public/assets/SettingsDialogBody-BQilAbHN.js +0 -2
  129. package/dist/public/assets/config-schema-BJ8D4PAa.js +0 -1
  130. package/dist/public/assets/field-controls-BUg68wFl.js +0 -1
  131. package/dist/public/assets/index-Vwqm7UP0.js +0 -2205
  132. package/dist/public/assets/messages-1FbrCYYU.js +0 -1
  133. package/dist/public/assets/messages-BCW6gNH_.js +0 -1
  134. package/dist/public/assets/messages-C3so4edu.js +0 -1
  135. package/dist/public/assets/messages-C7ZxXIR8.js +0 -1
  136. package/dist/public/assets/messages-CPx8MTHw.js +0 -1
  137. package/dist/public/assets/messages-Cb0Efw8g.js +0 -1
  138. package/dist/public/assets/messages-Cdosk3Xf.js +0 -1
  139. package/dist/public/assets/messages-DAm73tZm.js +0 -1
  140. package/dist/public/assets/messages-DOqNxlqh.js +0 -1
  141. package/dist/public/assets/messages-DUki_neg.js +0 -1
  142. package/dist/public/assets/messages-DuTTY6Gu.js +0 -1
  143. package/dist/public/assets/messages-vvUSKBXn.js +0 -1
  144. package/dist/src-C5jErYFO.mjs +0 -1
  145. package/dist/start-C25e1SRP.mjs +0 -1
@@ -94,7 +94,7 @@
94
94
  -->
95
95
  <script>(() => { try { const raw = localStorage.getItem('ok-language-v1'); if (!raw) return; const o = JSON.parse(raw); if (typeof o?.locale !== 'string' || !/^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{2,8})*$/.test(o.locale)) return; document.documentElement.lang = o.locale; document.documentElement.dir = o.dir === 'rtl' ? 'rtl' : 'ltr'; } catch {} })();</script>
96
96
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
97
- <script type="module" crossorigin src="./assets/index-Vwqm7UP0.js"></script>
97
+ <script type="module" crossorigin src="./assets/index-CbKG13-E.js"></script>
98
98
  <link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
99
99
  <link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
100
100
  <link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
@@ -133,16 +133,16 @@
133
133
  <link rel="modulepreload" crossorigin href="./assets/schemas-api-BbYGQuTW.js">
134
134
  <link rel="modulepreload" crossorigin href="./assets/dist-C_FzPxEX2.js">
135
135
  <link rel="modulepreload" crossorigin href="./assets/dist-BGzUo_18.js">
136
- <link rel="modulepreload" crossorigin href="./assets/messages-DuTTY6Gu.js">
137
- <link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-erUucjt8.js">
136
+ <link rel="modulepreload" crossorigin href="./assets/messages-CHvjKumb.js">
137
+ <link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-quJJgq3F.js">
138
138
  <link rel="modulepreload" crossorigin href="./assets/client-version-uAhaPZPt.js">
139
139
  <link rel="modulepreload" crossorigin href="./assets/dist-Nvb76hAm.js">
140
140
  <link rel="modulepreload" crossorigin href="./assets/use-apply-config-theme-CYFG76sS.js">
141
141
  <link rel="modulepreload" crossorigin href="./assets/use-apply-config-color-theme-DiRXrQH-.js">
142
142
  <link rel="modulepreload" crossorigin href="./assets/css-color-to-hex-D-oM_f97.js">
143
143
  <link rel="modulepreload" crossorigin href="./assets/constants-upload-CVKO8P4d.js">
144
- <link rel="modulepreload" crossorigin href="./assets/saved-themes-client-CGp8QQYb.js">
145
- <link rel="modulepreload" crossorigin href="./assets/config-provider-CNfO-H0J.js">
144
+ <link rel="modulepreload" crossorigin href="./assets/saved-themes-client-DQK5ylqX.js">
145
+ <link rel="modulepreload" crossorigin href="./assets/config-provider-CyBtB5MG.js">
146
146
  <link rel="modulepreload" crossorigin href="./assets/dist-Dc8tD1th.js">
147
147
  <link rel="modulepreload" crossorigin href="./assets/ccount-BoHE53_k.js">
148
148
  <link rel="modulepreload" crossorigin href="./assets/lib-QQS1Brzc.js">
@@ -164,7 +164,7 @@
164
164
  <link rel="modulepreload" crossorigin href="./assets/documents-fetch-Y7Dt9_Tn.js">
165
165
  <link rel="modulepreload" crossorigin href="./assets/note-window-mode-CI3Yju9B.js">
166
166
  <link rel="modulepreload" crossorigin href="./assets/structural-freshness-CIbkMFA3-CWi_lyiW.js">
167
- <link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-CvL4Fw3i.js">
167
+ <link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-DkRMFYIK.js">
168
168
  <link rel="modulepreload" crossorigin href="./assets/dist-CSCUSbQc.js">
169
169
  <link rel="modulepreload" crossorigin href="./assets/dist-DTFuvKje.js">
170
170
  <link rel="modulepreload" crossorigin href="./assets/dist-CRjqnzU7.js">
@@ -221,58 +221,58 @@
221
221
  <link rel="modulepreload" crossorigin href="./assets/react-error-boundary-6ac6QM6R.js">
222
222
  <link rel="modulepreload" crossorigin href="./assets/CopyButton-BGYz3S5f.js">
223
223
  <link rel="modulepreload" crossorigin href="./assets/config-errors-tVoeK4OC.js">
224
- <link rel="modulepreload" crossorigin href="./assets/schemas-cc1-CR2ooa34.js">
225
- <link rel="modulepreload" crossorigin href="./assets/documents-events-C7Jq0Exs.js">
224
+ <link rel="modulepreload" crossorigin href="./assets/schemas-cc1-DNrPPikD.js">
225
+ <link rel="modulepreload" crossorigin href="./assets/documents-events-ckNvVQCr.js">
226
226
  <link rel="modulepreload" crossorigin href="./assets/parse-api-error-B5EVRh3T.js">
227
227
  <link rel="modulepreload" crossorigin href="./assets/diagnostic-breadcrumb-Cr0C15nJ.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/perf-DZJpLc5j.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/startup-marks-aftNzVFI.js">
230
- <link rel="modulepreload" crossorigin href="./assets/PageListContext-aYEmqTv4.js">
230
+ <link rel="modulepreload" crossorigin href="./assets/PageListContext-DgTeRFU-.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/file-tree-rename-validation-CQF8z42p.js">
232
232
  <link rel="modulepreload" crossorigin href="./assets/badge-DmdA1C7r.js">
233
233
  <link rel="modulepreload" crossorigin href="./assets/input-C-Qm8YDT.js">
234
234
  <link rel="modulepreload" crossorigin href="./assets/kbd-Cg1nrB7U.js">
235
235
  <link rel="modulepreload" crossorigin href="./assets/dist-D1AbXGbs.js">
236
236
  <link rel="modulepreload" crossorigin href="./assets/popover-BhiLJhH5.js">
237
- <link rel="modulepreload" crossorigin href="./assets/use-collab-url-BPJukLUh.js">
237
+ <link rel="modulepreload" crossorigin href="./assets/use-collab-url-DPmF-V5e.js">
238
238
  <link rel="modulepreload" crossorigin href="./assets/excalidraw-scene-WvG0vu5I.js">
239
239
  <link rel="modulepreload" crossorigin href="./assets/known-skill-dirs-DtxJ8qaH.js">
240
240
  <link rel="modulepreload" crossorigin href="./assets/constants-skills-BLHVRW90.js">
241
241
  <link rel="modulepreload" crossorigin href="./assets/skill-scope-N3jmnGIX.js">
242
- <link rel="modulepreload" crossorigin href="./assets/skills-api-C4z5vWyd.js">
242
+ <link rel="modulepreload" crossorigin href="./assets/skills-api-DronAhV9.js">
243
243
  <link rel="modulepreload" crossorigin href="./assets/storage-scope-DSPgNqch.js">
244
244
  <link rel="modulepreload" crossorigin href="./assets/use-workspace-Dyz_XHeI.js">
245
245
  <link rel="modulepreload" crossorigin href="./assets/utils-random-uuid-D7CMpgvf.js">
246
- <link rel="modulepreload" crossorigin href="./assets/DocumentContext-BTpye0wm.js">
246
+ <link rel="modulepreload" crossorigin href="./assets/DocumentContext-BZi2BNlk.js">
247
247
  <link rel="modulepreload" crossorigin href="./assets/dist-BKgU0kag.js">
248
248
  <link rel="modulepreload" crossorigin href="./assets/dist-d0R4nnoB.js">
249
249
  <link rel="modulepreload" crossorigin href="./assets/dist-UouvQIiM.js">
250
250
  <link rel="modulepreload" crossorigin href="./assets/dropdown-menu-DtLu9NwU.js">
251
- <link rel="modulepreload" crossorigin href="./assets/comment-chips-9Q2hv4Un.js">
251
+ <link rel="modulepreload" crossorigin href="./assets/comment-chips-BuYSFClb.js">
252
252
  <link rel="modulepreload" crossorigin href="./assets/file-tree-adapter-BeSKxnyg.js">
253
253
  <link rel="modulepreload" crossorigin href="./assets/acp-thread-protocol-6IlNVy7A.js">
254
254
  <link rel="modulepreload" crossorigin href="./assets/thread-client-DuyrjvRs.js">
255
255
  <link rel="modulepreload" crossorigin href="./assets/tool-list-format-CS7MZY1Q.js">
256
256
  <link rel="modulepreload" crossorigin href="./assets/image-attachment-IPVf2vc9.js">
257
257
  <link rel="modulepreload" crossorigin href="./assets/workspace-paths-BjilyZF6.js">
258
- <link rel="modulepreload" crossorigin href="./assets/progress-YIJt8IwS.js">
258
+ <link rel="modulepreload" crossorigin href="./assets/progress-CTEVJNXO.js">
259
259
  <link rel="modulepreload" crossorigin href="./assets/radio-group-G1GR05Rb.js">
260
260
  <link rel="modulepreload" crossorigin href="./assets/separator-D7s_9ZwH.js">
261
261
  <link rel="modulepreload" crossorigin href="./assets/toggle-group-B7p69Qfd.js">
262
262
  <link rel="modulepreload" crossorigin href="./assets/useQuery-ZeEDLtxh.js">
263
263
  <link rel="modulepreload" crossorigin href="./assets/markdownit-Cn1WWq3J.js">
264
- <link rel="modulepreload" crossorigin href="./assets/markdown-lint-CH5x73AS.js">
264
+ <link rel="modulepreload" crossorigin href="./assets/markdown-lint-ZeKFkjFe.js">
265
265
  <link rel="modulepreload" crossorigin href="./assets/format-vsw4a5Bb.js">
266
266
  <link rel="modulepreload" crossorigin href="./assets/braces--g9Mwtim.js">
267
- <link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-BKe17Em-.js">
267
+ <link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-CrzwKvEA.js">
268
268
  <link rel="modulepreload" crossorigin href="./assets/grip-vertical-DNbkgWZL.js">
269
269
  <link rel="modulepreload" crossorigin href="./assets/SkillCostValue-CzBUsuYu.js">
270
270
  <link rel="modulepreload" crossorigin href="./assets/textarea-CMYJSlFq.js">
271
- <link rel="modulepreload" crossorigin href="./assets/selection-context-riqxN6LG.js">
272
- <link rel="modulepreload" crossorigin href="./assets/lint-config-client-B8HW3I8D.js">
273
- <link rel="modulepreload" crossorigin href="./assets/use-skills-C6ZneXh8.js">
274
- <link rel="modulepreload" crossorigin href="./assets/folder-config-api-BceG_Bmf.js">
275
- <link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-CyEh2d0o.js">
271
+ <link rel="modulepreload" crossorigin href="./assets/selection-context-D9wsGgDp.js">
272
+ <link rel="modulepreload" crossorigin href="./assets/lint-config-client-CB91vevq.js">
273
+ <link rel="modulepreload" crossorigin href="./assets/use-skills-D9Qpt2AT.js">
274
+ <link rel="modulepreload" crossorigin href="./assets/folder-config-api-Db5-uEQR.js">
275
+ <link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-CUpup7ho.js">
276
276
  <link rel="modulepreload" crossorigin href="./assets/arrow-up-right-nJaICi16.js">
277
277
  <link rel="modulepreload" crossorigin href="./assets/git-merge-VDBzSZBV.js">
278
278
  <link rel="modulepreload" crossorigin href="./assets/refresh-cw-CC7UZEnZ.js">
@@ -280,11 +280,11 @@
280
280
  <link rel="modulepreload" crossorigin href="./assets/DisclosureWarning-DGH1_U0o.js">
281
281
  <link rel="modulepreload" crossorigin href="./assets/handoff-ClTYrgLm.js">
282
282
  <link rel="modulepreload" crossorigin href="./assets/terminal-command-events-DylLB9_L.js">
283
- <link rel="modulepreload" crossorigin href="./assets/use-conflicts-DgaZPKZv.js">
284
- <link rel="modulepreload" crossorigin href="./assets/use-git-sync-status-BwJMuoUW.js">
283
+ <link rel="modulepreload" crossorigin href="./assets/use-conflicts-E9tj1NHs.js">
284
+ <link rel="modulepreload" crossorigin href="./assets/use-git-sync-status-DPG8QuKs.js">
285
285
  <link rel="modulepreload" crossorigin href="./assets/keyboard-shortcuts-FtScAm_I.js">
286
- <link rel="modulepreload" crossorigin href="./assets/use-settings-route-DT86DJkF.js">
287
- <link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-YALZC8ph.js">
286
+ <link rel="modulepreload" crossorigin href="./assets/use-settings-route-BVEU1nrV.js">
287
+ <link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-BDB1rnZs.js">
288
288
  <link rel="modulepreload" crossorigin href="./assets/cursor-B6reg1lS.js">
289
289
  <link rel="modulepreload" crossorigin href="./assets/agent-registry-B4dxoiaL.js">
290
290
  <link rel="modulepreload" crossorigin href="./assets/RegisteredAgentIcon-DjlAkIlP.js">
@@ -298,7 +298,7 @@
298
298
  <link rel="modulepreload" crossorigin href="./assets/ChangedOutsideBadge-Yx_v8aj4.js">
299
299
  <link rel="modulepreload" crossorigin href="./assets/dist-ecS2llwR.js">
300
300
  <link rel="modulepreload" crossorigin href="./assets/context-menu-CKOBjlWm.js">
301
- <link rel="modulepreload" crossorigin href="./assets/SkillInstallMenu-MPmPQLvN.js">
301
+ <link rel="modulepreload" crossorigin href="./assets/SkillInstallMenu-BQHSpQsX.js">
302
302
  <link rel="modulepreload" crossorigin href="./assets/DeleteConfirmationDialog-CCv72H-k.js">
303
303
  <link rel="modulepreload" crossorigin href="./assets/monitor-IXzxTnmk.js">
304
304
  <link rel="modulepreload" crossorigin href="./assets/field-DFJgKWGh.js">
@@ -308,19 +308,19 @@
308
308
  <link rel="modulepreload" crossorigin href="./assets/agent-launcher-labels-BtrP7a_g.js">
309
309
  <link rel="modulepreload" crossorigin href="./assets/terminal-cli-display-BbrhD8t2.js">
310
310
  <link rel="modulepreload" crossorigin href="./assets/open-managed-artifact-tab-2lsv2g--.js">
311
- <link rel="modulepreload" crossorigin href="./assets/use-open-skill-OC__o8wV.js">
311
+ <link rel="modulepreload" crossorigin href="./assets/use-open-skill-BejdmcK8.js">
312
312
  <link rel="modulepreload" crossorigin href="./assets/platform-labels-BXA2LpOw.js">
313
313
  <link rel="modulepreload" crossorigin href="./assets/clipboard-adapter-DOdbK8py.js">
314
- <link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-zJXBlIA5.js">
314
+ <link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-BUhk-vu0.js">
315
315
  <link rel="modulepreload" crossorigin href="./assets/case-sensitive-DIxypOE0.js">
316
316
  <link rel="modulepreload" crossorigin href="./assets/chevron-left-C5T97PNU.js">
317
317
  <link rel="modulepreload" crossorigin href="./assets/lint-plugin-meta-CtDE2R0v.js">
318
318
  <link rel="modulepreload" crossorigin href="./assets/wrench-DqFwoSdV.js">
319
319
  <link rel="modulepreload" crossorigin href="./assets/panel-My61A8fk.js">
320
320
  <link rel="modulepreload" crossorigin href="./assets/skeleton-BPb29aFG.js">
321
- <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-BydS4hGG.js">
321
+ <link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-CNLhok7Q.js">
322
322
  <link rel="modulepreload" crossorigin href="./assets/miss-dialog-store-CsiJb9Ou.js">
323
- <link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-qv7Cfy9Q.js">
323
+ <link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-BRYTI4O-.js">
324
324
  <link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-D7IZjXLN.js">
325
325
  <link rel="modulepreload" crossorigin href="./assets/terminal-launch-events-C-sad7ou.js">
326
326
  <link rel="modulepreload" crossorigin href="./assets/contact-email-store-C4f018uF.js">
@@ -338,20 +338,20 @@
338
338
  <link rel="modulepreload" crossorigin href="./assets/dist-CzJghaXH.js">
339
339
  <link rel="modulepreload" crossorigin href="./assets/dist-6WGIsHaB.js">
340
340
  <link rel="modulepreload" crossorigin href="./assets/text-viewer-languages-BI95_whc.js">
341
- <link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-ByL15J-o.js">
341
+ <link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-CCHArnnt.js">
342
342
  <link rel="modulepreload" crossorigin href="./assets/ImageAttachments-Dd_h_7LM.js">
343
- <link rel="modulepreload" crossorigin href="./assets/TemplateRow-B0mFlkDZ.js">
343
+ <link rel="modulepreload" crossorigin href="./assets/TemplateRow-xwZoU5JB.js">
344
344
  <link rel="modulepreload" crossorigin href="./assets/ConfigSharingInfoTooltip-B2YLIcK1.js">
345
345
  <link rel="modulepreload" crossorigin href="./assets/RowDisclosure-D3-qDfvX.js">
346
346
  <link rel="modulepreload" crossorigin href="./assets/project-paths-DhRV4pus.js">
347
- <link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-Dn1_oSW2.js">
347
+ <link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-DYdMkEyQ.js">
348
348
  <link rel="modulepreload" crossorigin href="./assets/use-installed-clis-98lB00dU.js">
349
349
  <link rel="modulepreload" crossorigin href="./assets/ReportBugMenuTrigger-D6HmlS6i.js">
350
350
  <link rel="modulepreload" crossorigin href="./assets/SkillModeBanner-3mmeP37s.js">
351
- <link rel="modulepreload" crossorigin href="./assets/use-skill-targets-mNqOFnfw.js">
352
- <link rel="modulepreload" crossorigin href="./assets/card-D0jvDdtx.js">
351
+ <link rel="modulepreload" crossorigin href="./assets/use-skill-targets-DcxmfKVk.js">
352
+ <link rel="modulepreload" crossorigin href="./assets/card-DdkXkyr5.js">
353
353
  <link rel="modulepreload" crossorigin href="./assets/app-menubar-gate-BqU9JMN6.js">
354
- <link rel="modulepreload" crossorigin href="./assets/use-semantic-search-status-CrlWLidR.js">
354
+ <link rel="modulepreload" crossorigin href="./assets/use-semantic-search-status-Bq4BpHMI.js">
355
355
  <link rel="modulepreload" crossorigin href="./assets/agent-diff-store-C4k2G19B.js">
356
356
  <link rel="modulepreload" crossorigin href="./assets/ok-DmFq9DQB.js">
357
357
  <link rel="modulepreload" crossorigin href="./assets/config-ignore-nested-error-events-9jefebwW.js">
@@ -361,7 +361,7 @@
361
361
  <link rel="modulepreload" crossorigin href="./assets/use-live-xterm-theme-DnTcPzv0.js">
362
362
  <link rel="modulepreload" crossorigin href="./assets/alert-CF8zw7ni.js">
363
363
  <link rel="modulepreload" crossorigin href="./assets/input-group-MLVCQYFm.js">
364
- <link rel="modulepreload" crossorigin href="./assets/use-skill-origin-CPL6FU5s.js">
364
+ <link rel="modulepreload" crossorigin href="./assets/use-skill-origin-BnTpq9XZ.js">
365
365
  <link rel="modulepreload" crossorigin href="./assets/catalog-Bdh906tM.js">
366
366
  <link rel="modulepreload" crossorigin href="./assets/agent-presence-DJNS_1Pz.js">
367
367
  <link rel="modulepreload" crossorigin href="./assets/auth-prompt-store-CKSBhTB-.js">
@@ -32,7 +32,7 @@
32
32
  script above.
33
33
  -->
34
34
  <style>html { background-color: #fafafa } html.dark { background-color: #171717 }</style>
35
- <script type="module" crossorigin src="./assets/uninstall-CaDWNOzh.js"></script>
35
+ <script type="module" crossorigin src="./assets/uninstall-CfBkwPz3.js"></script>
36
36
  <link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
37
37
  <link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
38
38
  <link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
@@ -63,8 +63,8 @@
63
63
  <link rel="modulepreload" crossorigin href="./assets/textarea-CMYJSlFq.js">
64
64
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-Chd9yIcd.js">
65
65
  <link rel="modulepreload" crossorigin href="./assets/dist-BGzUo_18.js">
66
- <link rel="modulepreload" crossorigin href="./assets/messages-DuTTY6Gu.js">
67
- <link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-erUucjt8.js">
66
+ <link rel="modulepreload" crossorigin href="./assets/messages-CHvjKumb.js">
67
+ <link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-quJJgq3F.js">
68
68
  <link rel="stylesheet" crossorigin href="./assets/globals-B1rEv4ky.css">
69
69
  </head>
70
70
 
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$d as r,Bc as i,Fc as a,La as o,Vu as s,Zd as c,bf as l,ef as u,gf as d,mf as f,nf as p,pf as m,sd as h,vf as g,xf as _,yf as v}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Ln as y,Wo as ee,Zn as b,_a as te,es as x,fr as ne,ko as re,m as S,os as ie,ss as C,ts as ae}from"./dist-CjYbXRTw.mjs";import{$ as oe,A as se,J as ce,M as w,O as T,P as le,R as ue,T as de,X as E,at as fe,ct as pe,d as me,dt as he,f as ge,it as _e,j as ve,k as ye,lt as be,nt as xe,o as Se,rt as Ce,tt as we,v as Te,w as Ee,x as De,y as Oe}from"./init-0rxCvh5L.mjs";import{t as ke}from"./is-object-BGze3w87.mjs";import{t as Ae}from"./removal-file-path-CP_R44kA.mjs";import{spawn as je}from"node:child_process";import{basename as D,dirname as O,join as k,resolve as A,win32 as Me}from"node:path";import{accessSync as Ne,constants as j,existsSync as M,lstatSync as N,mkdirSync as Pe,readFileSync as P,readdirSync as F,realpathSync as I,rmSync as Fe,rmdirSync as Ie,statSync as L,unlinkSync as Le}from"node:fs";import{homedir as R}from"node:os";import{createHash as Re}from"node:crypto";import{isDeepStrictEqual as ze}from"node:util";import{setTimeout as Be}from"node:timers/promises";var Ve=s();let He;function Ue(){return He}function We(e,t){if(t!==void 0&&t.length>0)return t;try{return ne(e)?.rootPath}catch{return}}function Ge(e){let t=We(e.cwd,e.configuredProjectName),n=y({name:`cli`,project:t});return He=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function z(){return i(a)}function B(){return d().keyringService}function V(e){try{e()}catch{}}var Ke=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(B(),e).getPassword()}catch(t){return V(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return V(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return V(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(B(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(B(),e).deletePassword()}catch{}}},H=class{backend=`file`;authFile;constructor(e){this.authFile=e??k(ae(),`auth.yml`)}read(){if(!M(this.authFile))return{};try{let e=P(this.authFile,`utf-8`);return(0,Ve.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=O(this.authFile);M(t)||Pe(t,{recursive:!0,mode:448}),x(this.authFile,(0,Ve.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},qe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${z()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function Je(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(B(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{$d as r,Bc as i,Fc as a,La as o,Vu as s,Zd as c,bf as l,ef as u,gf as d,mf as f,nf as p,pf as m,sd as h,vf as g,xf as _,yf as v}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Ln as y,Wo as ee,Zn as b,_a as te,es as x,fr as ne,ko as re,m as S,os as ie,ss as C,ts as ae}from"./dist-CjYbXRTw.mjs";import{$ as oe,A as se,J as ce,M as w,O as T,P as le,R as ue,T as de,X as E,at as fe,ct as pe,d as me,dt as he,f as ge,it as _e,j as ve,k as ye,lt as be,nt as xe,o as Se,rt as Ce,tt as we,v as Te,w as Ee,x as De,y as Oe}from"./init-PjjvTgrO.mjs";import{t as ke}from"./is-object-BGze3w87.mjs";import{t as Ae}from"./removal-file-path-CnXRatEs.mjs";import{spawn as je}from"node:child_process";import{basename as D,dirname as O,join as k,resolve as A,win32 as Me}from"node:path";import{accessSync as Ne,constants as j,existsSync as M,lstatSync as N,mkdirSync as Pe,readFileSync as P,readdirSync as F,realpathSync as I,rmSync as Fe,rmdirSync as Ie,statSync as L,unlinkSync as Le}from"node:fs";import{homedir as R}from"node:os";import{createHash as Re}from"node:crypto";import{isDeepStrictEqual as ze}from"node:util";import{setTimeout as Be}from"node:timers/promises";var Ve=s();let He;function Ue(){return He}function We(e,t){if(t!==void 0&&t.length>0)return t;try{return ne(e)?.rootPath}catch{return}}function Ge(e){let t=We(e.cwd,e.configuredProjectName),n=y({name:`cli`,project:t});return He=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function z(){return i(a)}function B(){return d().keyringService}function V(e){try{e()}catch{}}var Ke=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(B(),e).getPassword()}catch(t){return V(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return V(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return V(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(B(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(B(),e).deletePassword()}catch{}}},H=class{backend=`file`;authFile;constructor(e){this.authFile=e??k(ae(),`auth.yml`)}read(){if(!M(this.authFile))return{};try{let e=P(this.authFile,`utf-8`);return(0,Ve.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=O(this.authFile);M(t)||Pe(t,{recursive:!0,mode:448}),x(this.authFile,(0,Ve.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},qe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${z()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function Je(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(B(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
2
2
  `),V(()=>t?.onBackendSelected?.({backend:`keyring`})),new qe(new Ke(t?.onKeychainRead),new H(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${z()}) — OS keychain unavailable: ${r}\n`),V(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new H(e)}}function Ye(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (${z()})\n`),r(new H(e))},n)});try{return await Promise.race([Je(e),r])}catch{return new H(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Xe(e){let t=Ye(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function Ze(e){let t=Ye(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function Qe(e,t){let n=[],r=new H(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(B(),`__probe__`);let r,a=await new Ke(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(B(),e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function $e(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function et(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function tt(e){return re({detached:!0,stdio:`ignore`,shell:!1,env:$e(e)})}function nt(e,t,n={}){let r=(n.spawn??je)(e,[...t],tt(n.env??process.env));return r.unref(),r}function rt(e,t,n={}){let r=n.spawn??je,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],tt(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(et(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(et(e))}})}const it=m.stable.appId,at=Object.keys(m),ot=[`stable`,`beta`];function st(e,t,n=e=>console.error(e)){try{return _(e,t)}catch(r){let i=_({...e,[f]:void 0},t);return n(`Treating this CLI as ${g(i)} for this command: ${r instanceof Error?r.message:String(r)}`),i}}function U(e){return ot.includes(e)?ot:[e,...ot]}function ct(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:m[e.product].protocolScheme}}function lt(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return L(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function ut(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let n=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(n?.[1]){let e=n[1];return{path:e,product:at.find(t=>e.endsWith(`/${m[t].productName}.app`))??t}}}let n=e.homeDir??R();for(let r of U(t)){let{productName:t}=m[r];for(let i of[k(n,`Applications`),`/Applications`]){let n=k(i,`${t}.app`);if(dt(e,k(n,`Contents`,`MacOS`,t)))return{path:n,product:r}}}return null}function dt(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function ft(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=at.find(t=>e.execPath.toLowerCase().endsWith(`\\${v(m[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let r of U(t))for(let t of l(m[r])){let i=Me.join(n,`Programs`,t,v(m[r]));if(dt(e,i))return{path:i,product:r}}return null}function pt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=at.find(t=>e.execPath.endsWith(`/${m[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of U(t)){let{productName:t,linuxExecutableName:r}=m[n],i=`/opt/${t}/${r}`;if(dt(e,i))return{path:i,product:n}}return null}function mt(e){let t=st(e.env,e.execPath,e.warn);if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`,cliProduct:t};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`,cliProduct:t};let n;try{n=e.platform===`darwin`?ut(e,t):e.platform===`win32`?ft(e,t):pt(e,t)}catch{return{available:!1,reason:`stat-error`,cliProduct:t}}if(!n)return{available:!1,reason:`no-bundle`,cliProduct:t};let r={bundlePath:n.path,product:n.product,cliProduct:t};return e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,...r}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,...r}:{available:!0,reason:`available`,...r}}function ht(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(t.bundlePath===void 0){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}let{productName:i}=m[t.product],[a]=m[t.cliProduct].cliCommandNames;n(`Launching ${i} desktop (use \`${a} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`);let o=t.bundlePath;if(r===`darwin`){nt(`open`,[`-a`,o],{spawn:e.spawn});return}nt(o,[],{spawn:e.spawn})}function gt(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it from https://openknowledge.ai/download, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function W(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function _t(e){return Re(`sha256`).update(e).digest(`hex`)}function G(e){return k(ae(A(e)),`pi-trust`)}function vt(e,t){return k(G(e),_t(A(t)))}function yt(e,t,n){return k(vt(e,t),`${_t(n)}.json`)}var K=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${W(e)} ${W(t)}; ${W(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function q(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new K(e,`could not ${t}: ${i}`,a,n)}function J(e){let t;try{t=N(e)}catch(t){if(t.code===`ENOENT`)return!1;throw q(e,`be inspected`,t)}if(!t.isDirectory())throw new K(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function bt(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function xt(e,t){if(!ke(e)||!bt(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==A(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==A(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==A(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!ke(e.previous))throw new K(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&bt(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&bt(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new K(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function St(e,t,n){let r;try{r=N(n)}catch(e){throw q(n,`be inspected`,e)}if(!r.isFile())throw new K(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=P(n,`utf8`)}catch(e){throw q(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new K(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=xt(a,n);if(o.cwd!==A(t)||n!==yt(e,t,o.canonicalTrustPath))throw new K(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function Ct(e,t){let{record:n,path:r}=t;for(let t of[G(e),vt(e,n.cwd)])if(!J(t))throw new K(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=St(e,n.cwd,r);if(!ze(i.record,n))throw new K(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function wt(e,t,n,r,i){let a={version:1,cwd:A(t),configuredTrustPath:A(n),canonicalTrustPath:A(r),state:`pending`,previous:i},o=yt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!ze(xt(JSON.parse(s),o),a))throw new K(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);J(G(e)),J(O(o));try{Pe(O(o),{recursive:!0,mode:448})}catch(e){throw q(O(o),`be created`,e)}let c;try{c=N(o,{throwIfNoEntry:!1})}catch(e){throw q(o,`be inspected`,e)}if(c)throw new K(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{x(o,s,{mode:384})}catch(e){throw q(o,`be written`,e)}return{path:o,record:a}}function Tt(e,t){let n=Ct(e,t);if(n.record.state!==`pending`)throw new K(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{x(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw q(n.path,`be committed`,e)}return{path:n.path,record:r}}function Y(e,t){if(!J(G(e)))return[];let n=vt(e,t);if(!J(n))return[];let r;try{r=F(n).sort()}catch(e){throw q(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>St(e,t,k(n,r)))}function X(e,t){let n=Ct(e,t);try{Le(n.path)}catch(e){throw q(n.path,`be removed after reconciling its grant`,e)}for(let t of[O(n.path),G(e)])try{Ie(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw q(t,`be removed after reconciling its grant`,e)}}var Et=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),Dt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),Ot=n(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),kt=n(((t,n)=>{var r=e(`fs`),i=Et(),a=Dt(),o=Ot(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
3
3
  GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=re,e.createWriteStream=S;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function re(t,n){return new e.ReadStream(t,n)}function S(t,n){return new e.WriteStream(t,n)}var ie=e.open;e.open=C;function C(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return ie(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),At=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),jt=n((e=>{var t=At();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),Mt=n(((e,t)=>{t.exports=jt()})),Nt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Pt=n(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Nt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),Ft=n(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),It=n(((t,n)=>{let r=e(`path`),i=kt(),a=Mt(),o=Pt(),s=Ft(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),Lt=n(((e,t)=>{let n=kt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),Rt=t(n(((e,t)=>{let n=It(),{toPromise:r,toSync:i,toSyncOptions:a}=Lt();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const zt=5e3;function Bt(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${zt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Vt(e,t){Ue()?.warn(t,e)}function Ht(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function Ut(e,t,n){await ie(`${t}.ok.lock`,async()=>{let t=performance.now()+zt,r;for(;;)try{r=await Rt.default.lock(O(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Be(Bt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Ht(i,e)},{onWarn:Vt})}function Wt(e,t,n){C(`${t}.ok.lock`,()=>{let t=performance.now()+zt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=Rt.default.lockSync(O(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Bt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Ht(a,e)},{onWarn:Vt})}const Gt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Kt=class extends Error{name=`PiResourceInspectionError`};function qt(e){let t;try{t=N(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=L(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Kt(ve(`missing-symlink-target`),{cause:e}):e}return Ne(e,j.R_OK|(n.isDirectory()?j.X_OK:0)),!0}function Jt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Yt(e,t,n){let r=e;try{let i=I(e),a;r=t;try{a=I(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=A(t)}let o=k(a,`.agents`,`skills`),s=[];for(let e of Gt)r=k(i,`.pi`,e),qt(r)&&s.push(r);if(r=k(i,`.pi`,`extensions`),qt(r))for(let t of F(r).sort()){let i=k(r,t);A(n)!==k(A(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[k(i,`.pi`,`skills`),k(i,`.agents`,`skills`)])if(e!==o&&(r=e,qt(e)))for(let t of F(e).sort())Jt(t)||s.push(k(e,t));let c=O(i);for(;c!==i;){r=k(c,`.agents`,`skills`),r!==o&&qt(r)&&s.push(r);let e=O(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${W(r)}: ${e instanceof Kt?e.message:ve(w(e))}`}}}function Xt(e,t,n){let r=A(e),i=pe({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:E.pi.projectConfigPath(r),trustPath:k(i,`trust.json`)}}function Zt(e){try{let t=I(e);return L(t).isDirectory()?(Ne(t,j.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${W(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${W(e)} could not be resolved or accessed: ${W(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Qt(e){let t=Zt(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${W(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function $t(e,t,n){let r=Se(E.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return Ce(i)?{state:`own-current`,text:a}:de(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function en(e,t){let n;try{n=P(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:w(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return ke(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
4
4
  `)}:{state:`unreadable`,reason:`invalid-json`}}function tn(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return ve(e)}}function Z(e,t){return{kind:`refused`,error:`trust store ${W(e)}: ${tn(t)}`}}function Q(e){let t=Ae(e);try{switch(t.kind){case`declined`:return Z(e,t.reason);case`ready`:return{kind:`ready`,path:I(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=O(e),r=[D(e)],i=N(n,{throwIfNoEntry:!1});for(;!i;){let t=O(n);if(t===n)return Z(e,`unavailable-root`);r.unshift(D(n)),n=t,i=N(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:k(I(n),...r)}}catch(t){return Z(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:w(t))}}catch(t){return Z(e,w(t))}}function nn(e,t){let n=Q(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Z(e,`path-changed`):n}function rn(e,t,n){let r=Xt(e,t,n),i=Zt(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=$t(r.cwd,r.bridgePath,t).state,o=Q(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:en(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:an(r.bridgePath).displayNames}}function an(e){let t=O(e),n=D(e);try{return{displayNames:F(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>W(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function on(e,t={mode:`published`},n,r,i){let a=Xt(e,n,r),o=Zt(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${W(i)} no longer matches the current directory ${W(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=$t(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=Ee(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=Oe(E.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:W(e.error)}}let l=await sn(a.trustPath,o.project,n??R());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function sn(e,t,n){let r=t.canonical,i=Q(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Pe(O(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:W(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ut(e,i.path,()=>{let o=Qt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=nn(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=en(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Z(e,c.reason).error;return}let l=$(n,()=>{let t=Y(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&X(n,t),wt(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
@@ -1 +1 @@
1
- import{M as e,S as t}from"./init-0rxCvh5L.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(t){return t.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:e(t)}}let o=t(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(t){return{kind:`declined`,reason:a&&t.code===`ENOENT`?`missing-symlink-target`:e(t)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
1
+ import{M as e,S as t}from"./init-PjjvTgrO.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(t){return t.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:e(t)}}let o=t(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(t){return{kind:`declined`,reason:a&&t.code===`ENOENT`?`missing-symlink-target`:e(t)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
@@ -1 +1 @@
1
- import{t as e}from"./launch-json-removal-DcB-Wfiq.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
1
+ import{t as e}from"./launch-json-removal-DlVzHl6B.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
@@ -1 +1 @@
1
- import{T as e}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{J as t,X as n,et as r,f as i,rt as a,y as o}from"./init-0rxCvh5L.mjs";import{homedir as s}from"node:os";function c(e){let{priorCommand:t,priorArgs:n}=l(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function l(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function u(e){let r=e.logger??m,i=e.home??s(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=d(()=>t.configPath(``,i));if(s!==null&&a.push(f({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=d(()=>n(e.projectDir));i!==null&&a.push(f({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function d(e){try{return e()}catch{return null}}function f(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},s=i(t.target,t.cwd,t.home,t.configPathOverride);if(s===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(s))return{...n,outcome:`canonical`}}else{let i=e(s);if(i.kind===`recognized`&&i.disposition===`keep`){let e=r(s,t.target.buildEntry(t.cwd,{}));if(e.length===0)return{...n,outcome:`canonical`};let i=p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(i.outcome===`repaired`||i.outcome===`canonical`)&&t.logger({event:i.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:i.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),i.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:i}if(i.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:i.reason}),{...n,outcome:`foreign`,reason:i.reason}}return t.logger({...c({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:s}),severity:`info`}),p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function p(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function m(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as n,u as repairMcpConfigs,c as t};
1
+ import{T as e}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{J as t,X as n,et as r,f as i,rt as a,y as o}from"./init-PjjvTgrO.mjs";import{homedir as s}from"node:os";function c(e){let{priorCommand:t,priorArgs:n}=l(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function l(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function u(e){let r=e.logger??m,i=e.home??s(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=d(()=>t.configPath(``,i));if(s!==null&&a.push(f({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=d(()=>n(e.projectDir));i!==null&&a.push(f({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function d(e){try{return e()}catch{return null}}function f(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},s=i(t.target,t.cwd,t.home,t.configPathOverride);if(s===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(s))return{...n,outcome:`canonical`}}else{let i=e(s);if(i.kind===`recognized`&&i.disposition===`keep`){let e=r(s,t.target.buildEntry(t.cwd,{}));if(e.length===0)return{...n,outcome:`canonical`};let i=p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(i.outcome===`repaired`||i.outcome===`canonical`)&&t.logger({event:i.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:i.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),i.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:i}if(i.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:i.reason}),{...n,outcome:`foreign`,reason:i.reason}}return t.logger({...c({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:s}),severity:`info`}),p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function p(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function m(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as n,u as repairMcpConfigs,c as t};
@@ -0,0 +1 @@
1
+ import"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import"./src-BQPZHOpx.mjs";import"./init-PjjvTgrO.mjs";import"./registry-probes-BJWCp_zI.mjs";import"./start-6rBE8R0Q.mjs";import{n as e}from"./loader-BQS4fl0m.mjs";import"./preview-3gk2i1xX.mjs";import"./repair-mcp-configs-BbWY7hPn.mjs";export{e as loadConfig};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Gc as t,H as n,Kc as r,Ml as i,Nl as a,U as o,Vc as s,Vu as c,W as l,_a as u,cf as d,ga as ee,gf as f,l as p,pf as m,u as te,vf as h,xf as g,yf as _}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{At as v,Li as y,Qn as b,Ri as x,Si as S,Ta as C,Tr as w,as as T,bi as E,cr as D,fr as O,is as ne,ko as k,m as re,mi as A,rs as j,si as M,ts as N,ws as P,xi as ie}from"./dist-CjYbXRTw.mjs";import{t as ae}from"./yazl-BBz29IQN.mjs";import{Ct as oe,ot as F,st as se}from"./init-0rxCvh5L.mjs";import{l as ce,w as le}from"./registry-probes-dLB-QCwD.mjs";import{c as ue}from"./colors-r_owlCuY.mjs";import{t as de}from"./is-object-BGze3w87.mjs";import{n as fe}from"./constants-7Qyq_zUm.mjs";import"./loader-Cc8WS_Kd.mjs";import"./preview-DCg3Y_RC.mjs";import{execFile as pe,execSync as me,spawnSync as he}from"node:child_process";import{basename as I,dirname as L,isAbsolute as ge,join as R,relative as _e,resolve as z,sep as B,win32 as ve}from"node:path";import{closeSync as ye,cpSync as be,createWriteStream as xe,existsSync as V,lstatSync as Se,mkdirSync as H,mkdtempSync as Ce,openSync as we,readFileSync as U,readSync as Te,readdirSync as W,readlinkSync as Ee,realpathSync as De,rmSync as G,rmdirSync as Oe,statSync as ke,writeFileSync as K}from"node:fs";import{arch as Ae,freemem as je,homedir as q,hostname as Me,platform as Ne,release as Pe,tmpdir as Fe,totalmem as Ie,type as Le,uptime as Re}from"node:os";import{readFile as ze,readdir as Be,stat as Ve}from"node:fs/promises";import{createHash as He}from"node:crypto";function Ue(e,t){let n=t.map(e=>[P(e),e]);for(let t of e){let e=P(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function We(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ue([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=Ue(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Ge(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const Ke=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function qe(e,t,n=O){if(e!==void 0&&!Ke.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Je=null;function Ye(e){Je=e}function Xe(){return Je??process.cwd()}const Ze=`Open Knowledge`;function Qe(e={}){let t=e.platformName??process.platform,n=e.productName??f().productName;return F(t).join(se({...e,platformName:t}),n)}function $e(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=F(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${f().packageName.replaceAll(`/`,``)}-updater`)}function et(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function tt(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return et(n)??[]}function nt(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return et(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const rt=8192;function it(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function at(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const ot=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function st(e){return e.replace(ot,`$1"[REDACTED-DEVICE-ID]"`)}function ct(e){return st(at(e))}const lt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function ut(e){if(typeof e!=`string`)return null;let t=lt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function dt(e){let t=we(e,`r`);try{let e=Buffer.alloc(rt),n=0,r=!1;for(;n<rt;){let i=Te(t,e,n,rt-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{ye(t)}}function ft(e){try{let t=dt(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:ut(a)}}catch{return{kind:`unreadable`}}}function pt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function mt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=ke(n).mtimeMs}catch{continue}if(r<i)continue;let c=ft(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!pt(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const ht=`state/os-termination-evidence.json`,gt=6048e5,_t=/openknowledge/i,vt=Object.values(m).map(_);function yt(e={}){return(t,n)=>new Promise(r=>{try{pe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...bt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function bt(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function xt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
1
+ import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Gc as t,H as n,Kc as r,Ml as i,Nl as a,U as o,Vc as s,Vu as c,W as l,_a as u,cf as d,ga as ee,gf as f,l as p,pf as m,u as te,vf as h,xf as g,yf as _}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{At as v,Li as y,Qn as b,Ri as x,Si as S,Ta as C,Tr as w,as as T,bi as E,cr as D,fr as O,is as ne,ko as k,m as re,mi as A,rs as j,si as M,ts as N,ws as P,xi as ie}from"./dist-CjYbXRTw.mjs";import{t as ae}from"./yazl-BBz29IQN.mjs";import{Ct as oe,ot as F,st as se}from"./init-PjjvTgrO.mjs";import{l as ce,w as le}from"./registry-probes-BJWCp_zI.mjs";import{c as ue}from"./colors-r_owlCuY.mjs";import{t as de}from"./is-object-BGze3w87.mjs";import{n as fe}from"./constants-B3X-QRRf.mjs";import"./loader-BQS4fl0m.mjs";import"./preview-3gk2i1xX.mjs";import{execFile as pe,execSync as me,spawnSync as he}from"node:child_process";import{basename as I,dirname as L,isAbsolute as ge,join as R,relative as _e,resolve as z,sep as B,win32 as ve}from"node:path";import{closeSync as ye,cpSync as be,createWriteStream as xe,existsSync as V,lstatSync as Se,mkdirSync as H,mkdtempSync as Ce,openSync as we,readFileSync as U,readSync as Te,readdirSync as W,readlinkSync as Ee,realpathSync as De,rmSync as G,rmdirSync as Oe,statSync as ke,writeFileSync as K}from"node:fs";import{arch as Ae,freemem as je,homedir as q,hostname as Me,platform as Ne,release as Pe,tmpdir as Fe,totalmem as Ie,type as Le,uptime as Re}from"node:os";import{readFile as ze,readdir as Be,stat as Ve}from"node:fs/promises";import{createHash as He}from"node:crypto";function Ue(e,t){let n=t.map(e=>[P(e),e]);for(let t of e){let e=P(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function We(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ue([t],i);if(e!==void 0)return{locale:e,source:`override`}}if(n!==void 0&&n!==`system`&&i.includes(n))return{locale:n,source:`explicit`};let o=Ue(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Ge(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.floor(Math.max(0,t-n)/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}const Ke=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function qe(e,t,n=O){if(e!==void 0&&!Ke.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Je=null;function Ye(e){Je=e}function Xe(){return Je??process.cwd()}const Ze=`Open Knowledge`;function Qe(e={}){let t=e.platformName??process.platform,n=e.productName??f().productName;return F(t).join(se({...e,platformName:t}),n)}function $e(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=F(t),a;return a=t===`win32`?r.LOCALAPPDATA||i.join(n,`AppData`,`Local`):t===`darwin`?i.join(n,`Library`,`Caches`):r.XDG_CACHE_HOME||i.join(n,`.cache`),i.join(a,`${f().packageName.replaceAll(`/`,``)}-updater`)}function et(e){if(typeof e!=`object`||!e)return null;let t=e.recentProjects;if(!Array.isArray(t))return null;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;typeof t.path==`string`&&typeof t.name==`string`&&n.push({path:t.path,name:t.name})}return n}function tt(e){let t=R(e,`state.json`);if(!V(t))return[];let n;try{n=JSON.parse(U(t,`utf-8`))}catch{return[]}return et(n)??[]}function nt(e){let t=R(e,`state.json`);if(!V(t))return!1;try{return et(JSON.parse(U(t,`utf-8`)))!==null}catch{return!1}}const rt=8192;function it(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function at(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const ot=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function st(e){return e.replace(ot,`$1"[REDACTED-DEVICE-ID]"`)}function ct(e){return st(at(e))}const lt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function ut(e){if(typeof e!=`string`)return null;let t=lt.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function dt(e){let t=we(e,`r`);try{let e=Buffer.alloc(rt),n=0,r=!1;for(;n<rt;){let i=Te(t,e,n,rt-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{ye(t)}}function ft(e){try{let t=dt(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:ut(a)}}catch{return{kind:`unreadable`}}}function pt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function mt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=W(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=R(e,t.name),r;try{r=ke(n).mtimeMs}catch{continue}if(r<i)continue;let c=ft(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!pt(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const ht=`state/os-termination-evidence.json`,gt=6048e5,_t=/openknowledge/i,vt=Object.values(m).map(_);function yt(e={}){return(t,n)=>new Promise(r=>{try{pe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...bt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function bt(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function xt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
2
2
  `)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function J(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function St(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Ct(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Y(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function wt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Tt(e,t){let n=t.indexOf(`
3
3
  `);if(n===-1)return null;let r,i;try{r=wt(JSON.parse(t.slice(0,n))),i=wt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=wt(e);t===null||typeof t.name!=`string`||!pt(t.name)||a.push({name:t.name,pid:Y(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Y(t.rpages),lifetimeMaxPages:Y(t.lifetimeMax)})}let o=ut(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Y(wt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`&&pt(i.largestProcess),ownedProcesses:a}}async function Et(e,t){let n=J(`darwin`,`macos-jetsam`,[R(e,`JetsamEvent-*.ips`)]),r;try{r=await Be(e)}catch(e){return St(n,e.code??`unknown`)}let i=t.getTime()-gt,a=[];for(let t of r)if(/^JetsamEvent-.*\.ips$/.test(t))try{let{mtimeMs:n}=await Ve(R(e,t));n>=i&&a.push({file:t,mtimeMs:n})}catch{n.unparseable+=1}a.sort((e,t)=>t.mtimeMs-e.mtimeMs),n.droppedOverCap=Math.max(0,a.length-50);for(let{file:t}of a.slice(0,50)){let r=null;try{r=Tt(t,await ze(R(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Ct(n)}const Dt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],Ot=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/;function kt(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:_t.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function At(e){let t=[],n=0,r=0;for(let i of e.split(`
4
4
  `)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=Ot.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!_t.test(s)){n+=1;continue}let c=kt(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}async function jt(e){let t=J(`linux`,`linux-journal`,[`journalctl ${Dt.join(` `)}`]),n=await e(`journalctl`,[...Dt]),r=n.status===1&&/^-- No entries --$/m.test(n.stdout);if(n.status!==0&&!r)return St(t,xt(n));let i=At(n.stdout);return t.droppedOverCap=Math.max(0,i.events.length-50),t.events.push(...i.events.slice(-50)),t.foreignIgnored=i.foreignIgnored,t.unparseable=i.unparseable,/not seeing messages from other users/i.test(`${n.stdout}\n${n.stderr}`)&&(t.restrictedToCurrentUser=!0),Ct(t)}const Mt={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},Nt={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function Pt(e){return e===`System`?Mt:Nt}function Ft(e){let t=`System[(${Object.keys(Pt(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${gt}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${vt.map(e=>`Data='${e}'`).join(` or `)}]]`}function It(e){return[`qe`,e,`/q:${Ft(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function Lt(e){return ve.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function Rt(e){return e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&apos;/g,`'`).replace(/&amp;/g,`&`)}function zt(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function Bt(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>Rt(e[1]??``).trim())}function Vt(e,t){let n=Pt(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=Bt(o,`Data`),u=Bt(o,`Name`),d=[...l,...u].some(e=>_t.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!zt(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Ht(e,t){let n=Lt(t),r=[`System`,`Application`],i=J(`win32`,`windows-event-log`,r.map(e=>`${n} ${It(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,It(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${xt(t)}`);continue}let n=Vt(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?St(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:Ct(i)}async function Ut(e={}){let t=e.platform??process.platform,n=e.runCommand??yt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Et(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return jt(n);case`win32`:return Ht(n,e.systemRoot??process.env.SystemRoot);default:return{...J(t,null,[]),outcome:`unsupported`}}}const Wt={schemaVersion:1,outcome:`not-collected`};function Gt(e){return`${JSON.stringify(e??Wt,null,2)}\n`}const Kt={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system journal`,"windows-event-log":`Windows event logs`};function qt(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${Kt[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function Jt(){return R(N(),`bug-reports`)}function Yt(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Jt(),r=`${t}-bugreport`,i=R(n,`${r}.zip`);for(let e=2;V(i);e+=1)i=R(n,`${r}-${e}.zip`);return i}function Xt(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Zt(e,t){let n=R(e,`.ok`,`config.yml`);if(V(n))try{let e=U(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return V(R(e,`.ok`))?He(`sha256`).update(z(e)).digest(`hex`).slice(0,12):null}function Qt(){let e={timestamp:new Date().toISOString(),platform:Ne(),osType:Le(),osRelease:Pe(),hostname:`[redacted]`,uptime:Re(),freeMem:je(),totalMem:Ie(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=me(`sw_vers -productVersion 2>/dev/null`,k({encoding:`utf8`})).trim()}catch{}try{let t=R(__dirname,`..`,`..`,`package.json`);V(t)&&(e.okVersion=JSON.parse(U(t,`utf8`)).version)}catch{}return e}const $t=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function en(e){let t=I(e);return $t.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function tn(e,t){return on(e,t).files}const nn=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function rn(e,t=ce){let n=R(e,`${t}.ShipIt`);if(!V(n))return[];let r;try{r=W(n)}catch{return[]}return nn.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>R(n,e.entry)))}function an(e){if(!V(e))return[];try{let t=new Map;for(let n of W(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-p.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>R(e,t))}catch{return[]}}function on(e,t){if(!V(t))return{files:[],excludedByProjectSlug:0};let n=W(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>R(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(en),i=[],a=r.filter(t=>{try{return U(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!en(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function sn(e){let n=R(e,`.ok`,`local`);return V(n)?{files:[`server.lock`,`last-spawn-error.log`,t,s].map(e=>R(n,e)).filter(e=>V(e))}:{files:[]}}function cn(e){let t=R(e,`.ok`,`local`,`logs`);return V(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>R(t,e)).filter(e=>V(e))}:{files:[]}}function ln(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#${He(`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 un(e){let t=e.revealDocNames?e.content:ln(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=u(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 X(e){for(let t of e.files)try{let n=U(t,`utf8`);un({zipfile:e.zipfile,name:`${e.prefix}/${I(t)}`,content:t.endsWith(`.ips`)?ct(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function dn(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??R(N(),`logs`),s=t.projectDir?Zt(t.projectDir,i):null;H(L(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Qt();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=on(s,o),{files:d}=t.projectDir?sn(t.projectDir):{files:[]},{files:f}=t.projectDir?cn(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let h=[],g=[],{ZipFile:_}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),v=new _;X({zipfile:v,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:t.bugReportLedgerFiles??[],prefix:te,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i}),X({zipfile:v,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:g,redactions:h,logger:i});for(let e of t.extraFiles??[])try{let t=U(e.sourcePath),n=`extra/${e.zipName??I(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=Xt(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&un({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${I(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:it(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`),un({zipfile:v,name:ht,content:Gt(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:g,redactions:h});let S=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${I(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${I(e)}`)),O=g.filter(e=>D.has(e)),ne=s?g.filter(e=>e.startsWith(`logs/`)&&!en(e)&&!T.has(e)):[],k=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],re=k.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...k]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...ne.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:`,...ne.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system rather than written`,`by OpenKnowledge, covering the last 7 days, to explain an exit the app`,`could not record itself. On macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${ht}`,``]:[],...O.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ee.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...k,``,`This bundle is safe to attach to a GitHub issue.`]:re].join(`
@@ -1,5 +1,5 @@
1
- import{F as e,S as t,X as n,Z as r,hl as i,i as a,sd as o}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Ii as s,as as c,bi as l,ci as u,gs as d,k as f,rs as p,wi as m}from"./dist-CjYbXRTw.mjs";import{Ct as h,L as g,Tt as _,X as v,b as y,ut as b,wt as x,y as S,z as C}from"./init-0rxCvh5L.mjs";import{S as w,a as T,c as E,h as D,i as O,m as k,n as A,o as j,p as M,r as N,s as P,t as ee,u as F}from"./registry-probes-dLB-QCwD.mjs";import{n as I}from"./constants-7Qyq_zUm.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as te}from"node:fs";import{homedir as ne,tmpdir as re}from"node:os";import{rm as ie}from"node:fs/promises";import{setTimeout as ae}from"node:timers/promises";const oe=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],se={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function ce(e,t={}){let{login:n}=t,r=t._exec??L,i=le(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function le(e){return[`gh`,...oe.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,se).toString().trim();if(t.length>0)return t}catch{}}function W(e,t={}){let n=t._exec??L,r=le(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
2
- `)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){d(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ve(e,t,n,r,i){let a=v[e];try{let o=j(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&d(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),_e(o.kind)}catch(i){return d(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function xe(e,t,n){let r=t.home??ne();if(n===`absent`){let t=N(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Se(e,t,n){if(n===`absent`){let n=g(v[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=C(v[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return ye(n.editor,e,t.desired);case`editor-project-config`:return be(n.editor,e,t.desired);case`editor-project-skill-root`:return Se(n.editor,e,t.desired);case`editor-user-skill-root`:return xe(n.editor,e,t.desired)}}}function we(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Te(e){if(e===`server`)return e;throw new x(`--only must be 'server'`)}function Ee(e=H){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)].find(t=>e(t))}function De(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Oe(e){if(e===`off`)return`off`;if(!i.test(e))throw new x(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function ke(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ae(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function je(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||ke(e.host))&&e.isTTY}function Me(e,t){let n;try{n=new URL(t)}catch{throw new x(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new x(`${e} must be an http(s) origin (got: ${t})`);return t}function Ne(e){return Me(`--external-url`,e)}function Pe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${f}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??re,r=t.realpathFn??te,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function $(e,t,n=e=>ie(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${f}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Fe(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Ie(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:c}=await import(`node:fs`),{basename:l,dirname:d,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-BrRa6ui7.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,T=C?s(e.singleFile).canonicalFilePath:void 0,D=T?d(T):void 0,k=T?l(T):void 0,j,M=!1;if(D!==void 0){if(e.projectDir!==void 0){if(j=e.projectDir,!Q(j))throw new Z(j);o(f(j,`.ok`,`config.yml`))||y(j,D)}else j=h(D),M=!0}let N=async()=>{if(!(!M||j===void 0)){if(!Q(j)){S.warn({ephemeralProjectDir:j},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ie(j,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:j},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},F=j;if(!C){if(!i&&!u(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-rvj-kL93.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DAdDamo4.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let I=D??_(t,n);!C&&!o(I)&&(c(I,{recursive:!0}),S.info({contentDir:I},`Created content directory`));let L=w(),R=m(),z;try{{let e=v(j??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}z=await p({config:t,contentDir:I,projectDir:j??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:ce,detectGhAccounts:W,tokenStore:L,embeddingsKeyStore:R,mcpTomlEditor:b(),...C?{ephemeral:!0,singleDocRelPath:k,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>A(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>P(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:j??n,home:ne(),env:process.env};return{probe:ee(e),execute:Ce(e),userSkillPresentAnywhere:O}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(F===void 0?n:$(n,F),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await N(),e}let B=z.destroy,V=M?async()=>{try{await B()}finally{await N()}}:B;return{httpServer:z.httpServer,destroy:V,lockDir:z.lockDir,contentDir:I,port:z.port,ready:z.ready,degraded:z.degraded}}function Le(e,t,n=()=>p({absPath:c(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Re(e){if(e===`browser`||e===`app`)return e;throw new x(`--mode must be 'browser' or 'app'`)}function ze(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Be(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ve(i,o){let s=Le(i,o.singleFile),c=ze(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Pe(m);let h;try{h=n(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Ae({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
1
+ import{F as e,S as t,X as n,Z as r,hl as i,i as a,sd as o}from"./md-manager-BGnqyqi1-BTvqIsKE.mjs";import{Ii as s,as as c,bi as l,ci as u,gs as d,k as f,rs as p,wi as m}from"./dist-CjYbXRTw.mjs";import{Ct as h,L as g,Tt as _,X as v,b as y,ut as b,wt as x,y as S,z as C}from"./init-PjjvTgrO.mjs";import{S as w,a as T,c as E,h as D,i as O,m as k,n as A,o as j,p as M,r as N,s as P,t as ee,u as F}from"./registry-probes-BJWCp_zI.mjs";import{n as I}from"./constants-B3X-QRRf.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as te}from"node:fs";import{homedir as ne,tmpdir as re}from"node:os";import{rm as ie}from"node:fs/promises";import{setTimeout as ae}from"node:timers/promises";const oe=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],se={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function ce(e,t={}){let{login:n}=t,r=t._exec??L,i=le(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function le(e){return[`gh`,...oe.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,se).toString().trim();if(t.length>0)return t}catch{}}function W(e,t={}){let n=t._exec??L,r=le(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
2
+ `)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){d(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ve(e,t,n,r,i){let a=v[e];try{let o=j(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&d(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),_e(o.kind)}catch(i){return d(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function xe(e,t,n){let r=t.home??ne();if(n===`absent`){let t=N(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=T(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Se(e,t,n){if(n===`absent`){let n=g(v[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=C(v[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return ye(n.editor,e,t.desired);case`editor-project-config`:return be(n.editor,e,t.desired);case`editor-project-skill-root`:return Se(n.editor,e,t.desired);case`editor-user-skill-root`:return xe(n.editor,e,t.desired)}}}function we(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Te(e){if(e===`server`)return e;throw new x(`--only must be 'server'`)}function Ee(e=H){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)].find(t=>e(t))}function De(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Oe(e){if(e===`off`)return`off`;if(!i.test(e))throw new x(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function ke(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Ae(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function je(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||ke(e.host))&&e.isTTY}function Me(e,t){let n;try{n=new URL(t)}catch{throw new x(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new x(`${e} must be an http(s) origin (got: ${t})`);return t}function Ne(e){return Me(`--external-url`,e)}function Pe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${f}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??re,r=t.realpathFn??te,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function $(e,t,n=e=>ie(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${f}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Fe(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Ie(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:c}=await import(`node:fs`),{basename:l,dirname:d,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-BrRa6ui7.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,T=C?s(e.singleFile).canonicalFilePath:void 0,D=T?d(T):void 0,k=T?l(T):void 0,j,M=!1;if(D!==void 0){if(e.projectDir!==void 0){if(j=e.projectDir,!Q(j))throw new Z(j);o(f(j,`.ok`,`config.yml`))||y(j,D)}else j=h(D),M=!0}let N=async()=>{if(!(!M||j===void 0)){if(!Q(j)){S.warn({ephemeralProjectDir:j},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ie(j,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:j},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},F=j;if(!C){if(!i&&!u(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-BbWY7hPn.mjs`)).repairMcpConfigs)({projectDir:n,reclaimDisableEnv:t,logger:r}).outcomes.filter(e=>e.outcome!==`no-entry`&&e.outcome!==`canonical`&&e.outcome!==`repaired`&&e.outcome!==`foreign`);i.length>0&&S.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){S.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DCtFnoyJ.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let I=D??_(t,n);!C&&!o(I)&&(c(I,{recursive:!0}),S.info({contentDir:I},`Created content directory`));let L=w(),R=m(),z;try{{let e=v(j??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}z=await p({config:t,contentDir:I,projectDir:j??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:ce,detectGhAccounts:W,tokenStore:L,embeddingsKeyStore:R,mcpTomlEditor:b(),...C?{ephemeral:!0,singleDocRelPath:k,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>A(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>P(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:j??n,home:ne(),env:process.env};return{probe:ee(e),execute:Ce(e),userSkillPresentAnywhere:O}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(F===void 0?n:$(n,F),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await N(),e}let B=z.destroy,V=M?async()=>{try{await B()}finally{await N()}}:B;return{httpServer:z.httpServer,destroy:V,lockDir:z.lockDir,contentDir:I,port:z.port,ready:z.ready,degraded:z.degraded}}function Le(e,t,n=()=>p({absPath:c(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Re(e){if(e===`browser`||e===`app`)return e;throw new x(`--mode must be 'browser' or 'app'`)}function ze(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Be(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ve(i,o){let s=Le(i,o.singleFile),c=ze(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Pe(m);let h;try{h=n(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Ae({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
3
3
  `)))}let D=o.port===void 0?void 0:Number(o.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,k=D??O??s.server?.port,A=De({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Ee}),j=A.dir;A.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 M;try{M=await Ie({config:s,cwd:m,host:C,port:k,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...j?{reactShellDistDir:j}:{},idleThresholdMs:e(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-BrRa6ui7.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(f(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(f(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(f(e.message)),process.exit(1)),We(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await He({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ae(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ue(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ge(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let N=!1,P=async e=>{if(N)return;N=!0;let[t,...n]=Be(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await M.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`,()=>{P(`SIGINT`)}),process.once(`SIGTERM`,()=>{P(`SIGTERM`)});let ee=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${M.port}`,F=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${M.port}`:void 0,L=ee;console.log(l({name:`open-knowledge`,version:I,localUrl:L,networkUrl:F,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let R={"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`};M.ready.then(async()=>{if(M.degraded.length>0){console.log();for(let e of M.degraded){let t=R[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(je({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:j!==void 0})){let{openBrowser:e}=await import(`./open-browser-BLOo3kBG.mjs`);e(L)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function He(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:l(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ue(e){return[`${e.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${e.pid}).`,` ${e.url}`,"Leaving it running — run `ok stop` first if you want a fresh server."]}function We(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&te.native(n)===e.existing.projectDir}catch{return!1}}function Ge(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let a=n.ServerLockCollisionError;if(a===void 0||!(e instanceof a))return null;try{let e=n.readServerLock(n.resolveLockDir(t));return e&&e.kind===`mcp-spawned`?"An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run `ok stop`.":"OpenKnowledge server is already running on this project — check `ok status` or `ok stop`."}catch{return null}}function Ke(e){return new h(`start`).description(`Start the OpenKnowledge server (UI + API + MCP + collab on one port)`).option(`-p, --port <port>`,`Server port`,void 0).option(`--bind <address>`,`Bind address (repeatable; default 127.0.0.1 — loopback only)`,(e,t)=>[...t??[],e]).option(`--no-open-browser`,`Do not open the browser after start (interactive loopback starts open it by default)`).option(`--only <module>`,`Serve one module: 'server' (API + MCP only, no shell or browser)`,Te).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Oe).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Re).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new _(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new _(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new _(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Ne).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
4
4
  `),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
5
5
  `),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=M(F());if(n.available){k({spawn:R},n);return}console.error(D(n.reason)),process.exit(1)}await Ve(n,t)})}export{Ge as C,W as D,ce as E,Ke as S,Fe as T,ze as _,Ue as a,je as b,Q as c,Oe as d,Te as f,Le as g,He as h,Pe as i,We as l,we as m,X as n,Be as o,Ee as p,Ie as r,ke as s,Z as t,Ne as u,De as v,$ as w,Ae as x,Ve as y};
@@ -0,0 +1 @@
1
+ import{S as e,m as t,p as n,r}from"./start-6rBE8R0Q.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.84.0-beta.13",
3
+ "version": "0.84.0-beta.14",
4
4
  "description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
5
5
  "keywords": [
6
6
  "knowledge-base",
@@ -65,10 +65,10 @@
65
65
  "@parcel/watcher": "^2.5.6"
66
66
  },
67
67
  "devDependencies": {
68
- "@inkeep/open-knowledge-app": "0.84.0-beta.13",
69
- "@inkeep/open-knowledge-core": "0.84.0-beta.13",
68
+ "@inkeep/open-knowledge-app": "0.84.0-beta.14",
69
+ "@inkeep/open-knowledge-core": "0.84.0-beta.14",
70
70
  "@inkeep/open-knowledge-native-config": "0.0.0",
71
- "@inkeep/open-knowledge-server": "0.84.0-beta.13",
71
+ "@inkeep/open-knowledge-server": "0.84.0-beta.14",
72
72
  "@types/node": "^24.7.0",
73
73
  "@types/proper-lockfile": "^4.1.4",
74
74
  "@types/yazl": "^3.3.1",
@@ -1 +0,0 @@
1
- import"./md-manager-BGnqyqi1-BTvqIsKE.mjs";var e=`0.84.0-beta.13`;const t=`config.yml`,n=e;export{n,t};