@inkeep/open-knowledge 0.84.0-beta.1 → 0.84.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +71 -71
- package/dist/config-schema.json +4 -4
- package/dist/config.project.schema.json +1 -1
- package/dist/config.user.schema.json +4 -4
- package/dist/constants-GoNSmmHC.mjs +1 -0
- package/dist/dist-ASBco0Dy.mjs +2212 -0
- package/dist/dist-CI4jGrUv.mjs +1 -0
- package/dist/index.d.mts +13 -4
- package/dist/index.mjs +213 -213
- package/dist/init-BMbMbpaM.mjs +1 -0
- package/dist/{init-B3hJPfM5.mjs → init-CXkz2PQz.mjs} +63 -63
- package/dist/{launch-json-removal-BzsX8eCh.mjs → launch-json-removal-B88zT7Yg.mjs} +1 -1
- package/dist/{loader-C4DvYgf3.mjs → loader-Bdedlh_I.mjs} +1 -1
- package/dist/loader-C1wr_xdg.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-BfETHApY.mjs → md-manager-BGnqyqi1-BTvqIsKE.mjs} +137 -137
- package/dist/{open-browser-OupsHA1M.mjs → open-browser-_mf6YkKD.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-BHzfKSsK.mjs +1 -0
- package/dist/{preview-SXFixlwu.mjs → preview-D8X7GT0G.mjs} +1 -1
- package/dist/public/assets/AccountSection-CcFhIuKn.js +1 -0
- package/dist/public/assets/{ActivityModeContent-DZbyWBlo.js → ActivityModeContent-C0JqJh_W.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-DvtOOL5J.js → AddPropertiesButton-0AlTkIIp.js} +2 -2
- package/dist/public/assets/AgentConnectionsSection-uSC5Wl25.js +1 -0
- package/dist/public/assets/{AgentDiffPane-D9olUVts.js → AgentDiffPane-CUKAe9qN.js} +1 -1
- package/dist/public/assets/{AgentIconCluster-BRpsTDMH.js → AgentIconCluster-Qf_VPGzc.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-BTlP3z2T.js → AgentThreadClientBinder-DEy57m8m.js} +1 -1
- package/dist/public/assets/AppMenubar-CnD-jxNS.js +1 -0
- package/dist/public/assets/{AttachmentsSection-DdqsNOtE.js → AttachmentsSection-DrAtEVHV.js} +1 -1
- package/dist/public/assets/{AuthModal-CkHLmy_N.js → AuthModal-SudaNBin.js} +1 -1
- package/dist/public/assets/{BugReportHistory-BPO915fE.js → BugReportHistory-DXLqvyNw.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-CY6vlR_h.js → BugReportHistoryDialog-CkyHUUkn.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BTCkQ8gy.js → CodeMirrorPropInput-Do7nSTb0.js} +1 -1
- package/dist/public/assets/ConsentDialogBody-D79cEEFu.js +2 -0
- package/dist/public/assets/{ContentRulesSection-BPc0bEex.js → ContentRulesSection-D99GwTBa.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-BVzts2c4.js → DiffViewBoundary-DyfPtl_S.js} +1 -1
- package/dist/public/assets/{DocumentContext-Cgpe7PUq.js → DocumentContext-D3I5hwIX.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-8PbuUKPX.js → EditorModeToggle-CMIIvpQ1.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-DPjKh0Z6.js → ExcalidrawDocEditor-BAH8CKWS.js} +1 -1
- package/dist/public/assets/FeedbackForm-B00a8by5.js +1 -0
- package/dist/public/assets/{GraphPanel-COpuyFxT.js → GraphPanel-K91KgPSG.js} +1 -1
- package/dist/public/assets/{ImageAttachments-By1ZcRNT.js → ImageAttachments-Dovmnniy.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BRMCNFIO.js → ImportSkillDialog-DpWpWTj9.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-DrVzxhzA.js → LinkPreviewsSection-CVhMCyqv.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CYgb3HLw.js → LintConfigEditor-D_ZlJsuJ.js} +1 -1
- package/dist/public/assets/{LintingSection-DwEExyYA.js → LintingSection-CxWFbr4y.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-Crgt7BJp.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-Cejw-D7l.js → ManagedArtifactProperties-D8YQyA0O.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-TV8MQtbb.js → MermaidDocEditor-CGWMNeyW.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-G-tyEPOW.js → NetworkAccessSection-CqBhmTwX.js} +1 -1
- package/dist/public/assets/{OkignoreSection-DUIPj4Vl.js → OkignoreSection-CK7dC70g.js} +1 -1
- package/dist/public/assets/{PageListContext-CYKNvec7.js → PageListContext-aYEmqTv4.js} +1 -1
- package/dist/public/assets/{ProjectTemplatesSection-Ctdx9_AL.js → ProjectTemplatesSection-C1cqcdG5.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-DULpBoN1.js → PropertyDisplayRow-2fH34wwP.js} +2 -2
- package/dist/public/assets/{PublishToGitHubDialog-BcpO5RKl.js → PublishToGitHubDialog-ByMaK4s_.js} +1 -1
- package/dist/public/assets/RegisteredAgentIcon-DjlAkIlP.js +1 -0
- package/dist/public/assets/ReportBugDialogBody-DLBMwSqE.js +3 -0
- package/dist/public/assets/{ReportBugMenuTrigger-DwuaKFu1.js → ReportBugMenuTrigger-AJRYHH_Y.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-D79vqFmf.js → SchemaConfigEditor-MTTAovID.js} +1 -1
- package/dist/public/assets/{SearchSection-Dx8-C7aO.js → SearchSection-5u_qCLv4.js} +1 -1
- package/dist/public/assets/SessionsHost-WZATBnYe.js +2 -0
- package/dist/public/assets/{SettingsDialogBody-BmlfRDFb.js → SettingsDialogBody-0ex_IfqA.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-0PE01E7W.js → ShareReceiveMissDialog-bdN4FJQB.js} +1 -1
- package/dist/public/assets/{SharingSection-BvdibR47.js → SharingSection-Bjl_f8Kj.js} +1 -1
- package/dist/public/assets/{SkillCostValue-Bajv3P86.js → SkillCostValue-Cxzi3vI1.js} +1 -1
- package/dist/public/assets/{SkillEditBanner-B0ZxQBAN.js → SkillEditBanner-VIoAHWvy.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-BKGY1iRx.js → SkillForkDialog-bphSE5Zm.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-CuOKJ4_n.js → SkillInstallMenu-taqzd9mr.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-BrUb4Fgy.js → SkillOriginInline-oYxSvlYQ.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CT26YXuL.js → SkillToolbarControls-Ca0UKhB2.js} +1 -1
- package/dist/public/assets/{SkillsManagerSection-dqXRCM3C.js → SkillsManagerSection-B5fmoY8R.js} +1 -1
- package/dist/public/assets/{SlidesPluginSection-Bk1073RP.js → SlidesPluginSection-gB_5IAe_.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-D-0pa5F-.js → SlidesToolbarControls-DUmYa_3C.js} +1 -1
- package/dist/public/assets/{SourceEditor-DghQVHvX.js → SourceEditor-6ec_4awF.js} +1 -1
- package/dist/public/assets/{SpellingSettings-C3y5UjRC.js → SpellingSettings-CUh8Cur5.js} +1 -1
- package/dist/public/assets/SyncSection-D-l0j93S.js +1 -0
- package/dist/public/assets/SyncStatusBadge-CVLTODPA.js +1 -0
- package/dist/public/assets/{TemplateRow-C8tLmbrb.js → TemplateRow-BxUG6C5_.js} +1 -1
- package/dist/public/assets/{TerminalLaunchContext-58PQDilg.js → TerminalLaunchContext-CJTkwtCs.js} +1 -1
- package/dist/public/assets/{TerminalPanel-DOYDhObX.js → TerminalPanel-DVlVrgmd.js} +1 -1
- package/dist/public/assets/{TerminalSection-BBA8y3S1.js → TerminalSection-Sgh4OULE.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-DFmcq1vG.js → TerminalWindowApp-B_q3wJA1.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DxghXof_.js → TextDocEditor-CMGd0oZO.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-rW_Rhi3t.js → ThemePluginSection-D5RMx1zr.js} +1 -1
- package/dist/public/assets/{ThreadView-BcdaDwyX.js → ThreadView-BXyRrKwk.js} +3 -3
- package/dist/public/assets/{TimelineDiffPane-DbgES6nK.js → TimelineDiffPane-SM_XoZyD.js} +1 -1
- package/dist/public/assets/{agent-connections-Bc1t_U_m.js → agent-connections-D2w6claM.js} +1 -1
- package/dist/public/assets/agent-registry-B4dxoiaL.js +1 -0
- package/dist/public/assets/{bridge-BqL-1MyE.js → bridge-DsUUjTsy.js} +1 -1
- package/dist/public/assets/{calendar-U3XIfpfI.js → calendar-B94KcaTl.js} +1 -1
- package/dist/public/assets/{card-CHd8wMSS.js → card-CBVFHVPp.js} +1 -1
- package/dist/public/assets/{catalog-nXBoyoEn.js → catalog-Bdh906tM.js} +1 -1
- package/dist/public/assets/{comment-chips-D7PAXgFJ.js → comment-chips-BMoPD1Ry.js} +1 -1
- package/dist/public/assets/{config-errors-DCSQBhyj.js → config-errors-tVoeK4OC.js} +1 -1
- package/dist/public/assets/{config-provider-DBgrt1kx.js → config-provider-BTi-sP7f.js} +1 -1
- package/dist/public/assets/config-schema-eyeMoQiU.js +1 -0
- package/dist/public/assets/{constants-editors-05BNhhVl.js → constants-editors-DLxv8SuP.js} +1 -1
- package/dist/public/assets/constants-product-C4Nt9vD3.js +1 -0
- package/dist/public/assets/{css-color-to-hex-Dk3DSeEK.js → css-color-to-hex-D-oM_f97.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-DGQuNlgn.js → doc-undo-manager-Cbc4PXWq.js} +1 -1
- package/dist/public/assets/{documents-events-C04vpPEp.js → documents-events-C7Jq0Exs.js} +1 -1
- package/dist/public/assets/field-controls-CimT-Q0n.js +1 -0
- package/dist/public/assets/{field-controls-BqsFU6aY.js → field-controls-HfNIifff.js} +1 -1
- package/dist/public/assets/{folder-config-api-bwKmZWh2.js → folder-config-api-z8QlaVAB.js} +1 -1
- package/dist/public/assets/{frontmatter-tags-B7FS--Ga.js → frontmatter-tags-DIPhIb6q.js} +1 -1
- package/dist/public/assets/index-CkF842Pf.js +2205 -0
- package/dist/public/assets/{input-group-D_ozMCmW.js → input-group-CvtNBDpz.js} +1 -1
- package/dist/public/assets/{lint-config-client-C0cPUFg9.js → lint-config-client-C3bXT9G3.js} +1 -1
- package/dist/public/assets/{lint-plugins-24yMjYos.js → lint-plugins--vl7cqvK.js} +1 -1
- package/dist/public/assets/{markdown-lint-DxrbxECW.js → markdown-lint-CHBB9p4R.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-C-vo_WXw.js → markdownlint-rule-browser-wxyNMQfV.js} +1 -1
- package/dist/public/assets/messages-1uhX2IsZ.js +1 -0
- package/dist/public/assets/messages-B2-eoUL3.js +1 -0
- package/dist/public/assets/messages-BcCiD7aG.js +1 -0
- package/dist/public/assets/messages-BgyOnrYq.js +1 -0
- package/dist/public/assets/messages-CQMoMyU1.js +1 -0
- package/dist/public/assets/messages-CT5_GTjF.js +1 -0
- package/dist/public/assets/messages-CfUUYlOM.js +1 -0
- package/dist/public/assets/messages-CquoFi0L.js +1 -0
- package/dist/public/assets/messages-D5IRECaM.js +1 -0
- package/dist/public/assets/messages-DANY6DR0.js +1 -0
- package/dist/public/assets/messages-DMAo6q_T.js +1 -0
- package/dist/public/assets/messages-Ds-TaR2B.js +1 -0
- package/dist/public/assets/messages-aWcvBlQS.js +1 -0
- package/dist/public/assets/pending-receive-nav-store-B_q3sJ8u.js +1 -0
- package/dist/public/assets/platform-labels-jdatkx8d.js +1 -0
- package/dist/public/assets/{preferred-session-events-DZS0rMoL.js → preferred-session-events-BMXrfZPQ.js} +1 -1
- package/dist/public/assets/{progress-BXjvg4DI.js → progress-BWQfFuw_.js} +1 -1
- package/dist/public/assets/{project-paths-B82COK8C.js → project-paths-DhRV4pus.js} +1 -1
- package/dist/public/assets/{restart-collab-server-C16c-Ep9.js → restart-collab-server-BLCoCY2a.js} +1 -1
- package/dist/public/assets/saved-themes-client-lSuPRRmb.js +1 -0
- package/dist/public/assets/{schema-section-eljmMDBb.js → schema-section-DbGu5Jz2.js} +1 -1
- package/dist/public/assets/{schemas-api-BM3O7zA1.js → schemas-api-BbYGQuTW.js} +1 -1
- package/dist/public/assets/{schemas-cc1-hKlHTZpE.js → schemas-cc1-CR2ooa34.js} +1 -1
- package/dist/public/assets/{selection-context-C68gF2Oq.js → selection-context-CzcI-CBa.js} +1 -1
- package/dist/public/assets/{sign-in-terminal-events-Uy8J-zPE.js → sign-in-terminal-events-B_AuVu-u.js} +1 -1
- package/dist/public/assets/{skill-scope-CxuIje2Y.js → skill-scope-N3jmnGIX.js} +1 -1
- package/dist/public/assets/{skill-targets-schema-BqGbUdGW.js → skill-targets-schema-BujW07bM.js} +1 -1
- package/dist/public/assets/{skills-api-Cwv39pKK.js → skills-api-C4z5vWyd.js} +1 -1
- package/dist/public/assets/{src-COG_7U42.js → src-DMXiZZVP.js} +1 -1
- package/dist/public/assets/storage-scope-DSPgNqch.js +1 -0
- package/dist/public/assets/{tag-pill-input-DoehfrBo.js → tag-pill-input-C0Dbn5VR.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-vPUm3fxK.js → terminal-launch-events-C-sad7ou.js} +1 -1
- package/dist/public/assets/{thread-client-BoGcOSf9.js → thread-client-CHIeG-eB.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BKuWOIaA.js → typing-burst-detector-CH2d1q_L.js} +1 -1
- package/dist/public/assets/{uninstall-DiNfurw6.js → uninstall-D_aGIo20.js} +1 -1
- package/dist/public/assets/{use-activity-panel-BgzoGLEn.js → use-activity-panel-B_vTmuEF.js} +1 -1
- package/dist/public/assets/{use-apply-config-color-theme-DsCyuU3O.js → use-apply-config-color-theme-DiRXrQH-.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-BvXQKexF.js → use-apply-config-language-CHpGJFkS.js} +2 -2
- package/dist/public/assets/{use-collab-url-CEI12fca.js → use-collab-url-BPJukLUh.js} +1 -1
- package/dist/public/assets/{use-conflicts-CpABgIGI.js → use-conflicts-DgaZPKZv.js} +1 -1
- package/dist/public/assets/{use-git-sync-status-BQYF2F5Z.js → use-git-sync-status-BwJMuoUW.js} +1 -1
- package/dist/public/assets/use-installed-clis-DlMKIYvM.js +2 -0
- package/dist/public/assets/{use-live-xterm-theme-CkVAs5Ql.js → use-live-xterm-theme-D4uCjklq.js} +1 -1
- package/dist/public/assets/{use-open-skill-CDNmRdpj.js → use-open-skill-CSv_mbe3.js} +1 -1
- package/dist/public/assets/{use-semantic-search-status-BYu4PoVz.js → use-semantic-search-status-CrlWLidR.js} +1 -1
- package/dist/public/assets/{use-skill-origin-Be1NTkgW.js → use-skill-origin-E-sT1iHg.js} +1 -1
- package/dist/public/assets/{use-skill-targets-Cf23drqO.js → use-skill-targets-DtHz-14o.js} +1 -1
- package/dist/public/assets/{use-skills-gbn1t63C.js → use-skills-C6ZneXh8.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CYPFWXCG.js → use-terminal-enabled-wZmZdfpX.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-Cb24Bjqb.js → use-timeline-entry-diff-DJ_He9j4.js} +1 -1
- package/dist/public/assets/{use-workspace-BafUpQnS.js → use-workspace-Dyz_XHeI.js} +1 -1
- package/dist/public/index.html +74 -74
- package/dist/public/uninstall.html +4 -4
- package/dist/registry-probes-BSgmu91A.mjs +17 -0
- package/dist/{removal-file-path-Cu5dq8q6.mjs → removal-file-path-BkTuavpH.mjs} +1 -1
- package/dist/{repair-launch-json-UkFroP68.mjs → repair-launch-json-rStAXlRd.mjs} +1 -1
- package/dist/{repair-mcp-configs-B99J1tHK.mjs → repair-mcp-configs-fKZa8aHb.mjs} +1 -1
- package/dist/schemas/v0/config.project.schema.json +1 -1
- package/dist/schemas/v0/config.user.schema.json +4 -4
- package/dist/src-DE0UAXjz.mjs +11 -0
- package/dist/src-DnCuhNWM.mjs +1 -0
- package/dist/start-Dsj-6Klp.mjs +1 -0
- package/dist/start-ziWoBDkE.mjs +5 -0
- package/package.json +4 -4
- package/dist/constants-D6yB-BzW.mjs +0 -1
- package/dist/dist-BGJh5L15.mjs +0 -1
- package/dist/dist-Bxhfiafh.mjs +0 -2212
- package/dist/init-DRr0WZ2-.mjs +0 -1
- package/dist/loader-BvIyMxwm.mjs +0 -1
- package/dist/preview-Cg9DXSiC.mjs +0 -1
- package/dist/public/assets/AccountSection-BsoknTRm.js +0 -1
- package/dist/public/assets/AgentConnectionsSection-D_gmSJG4.js +0 -1
- package/dist/public/assets/AppMenubar-D7u5sV7t.js +0 -1
- package/dist/public/assets/ConsentDialogBody-CGhUvR3J.js +0 -2
- package/dist/public/assets/FeedbackForm-w2RNhl0R.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-sO6f840l.js +0 -1
- package/dist/public/assets/RegisteredAgentIcon-Begcc-nC.js +0 -1
- package/dist/public/assets/ReportBugDialogBody-CPjEs_zr.js +0 -3
- package/dist/public/assets/SessionsHost-DhB6vMF-.js +0 -2
- package/dist/public/assets/SyncSection-DmMPCcrO.js +0 -1
- package/dist/public/assets/SyncStatusBadge-7CGaFHUk.js +0 -1
- package/dist/public/assets/agent-registry-3ko3YkCm.js +0 -1
- package/dist/public/assets/config-schema-xOnB5jc5.js +0 -1
- package/dist/public/assets/constants-product-DhAo-666.js +0 -1
- package/dist/public/assets/field-controls-CnF_w0df.js +0 -1
- package/dist/public/assets/index-C_8iI96N.js +0 -2205
- package/dist/public/assets/messages-9pu0eKMD.js +0 -1
- package/dist/public/assets/messages-BCv3uDH5.js +0 -1
- package/dist/public/assets/messages-BGib4TMp.js +0 -1
- package/dist/public/assets/messages-BOWt1g5R.js +0 -1
- package/dist/public/assets/messages-BtwWpZz0.js +0 -1
- package/dist/public/assets/messages-BtzlQnhk.js +0 -1
- package/dist/public/assets/messages-BxPgHAGT.js +0 -1
- package/dist/public/assets/messages-C_IQGWPh.js +0 -1
- package/dist/public/assets/messages-CgvGzWvU.js +0 -1
- package/dist/public/assets/messages-CmBBJ_lX.js +0 -1
- package/dist/public/assets/messages-D07eucGp.js +0 -1
- package/dist/public/assets/messages-DHQmHLsP.js +0 -1
- package/dist/public/assets/messages-R6IvK1vE.js +0 -1
- package/dist/public/assets/pending-receive-nav-store-ge0q0US7.js +0 -1
- package/dist/public/assets/platform-labels-CtgIRyUl.js +0 -1
- package/dist/public/assets/saved-themes-client-CmQnQ6kY.js +0 -1
- package/dist/public/assets/storage-scope-67lIepq6.js +0 -1
- package/dist/public/assets/use-installed-clis-CXwm5pk2.js +0 -2
- package/dist/registry-probes-f66-hGoh.mjs +0 -17
- package/dist/src-BVjWHtw1.mjs +0 -1
- package/dist/src-Dhm5e2Py.mjs +0 -11
- package/dist/start-CffJVe15.mjs +0 -5
- package/dist/start-D7BNoa4h.mjs +0 -1
- /package/dist/public/assets/{ChangedOutsideBadge-BB-SCUmw.js → ChangedOutsideBadge-Dzr-p6dI.js} +0 -0
- /package/dist/public/assets/{DeleteConfirmationDialog-DrwlL-Hc.js → DeleteConfirmationDialog-BXUDIZYO.js} +0 -0
- /package/dist/public/assets/{SkillModeBanner-DaZYmbfZ.js → SkillModeBanner-DcxGGSM7.js} +0 -0
- /package/dist/public/assets/{alert-BY4HHcfV.js → alert-rmEQg7oS.js} +0 -0
- /package/dist/public/assets/{format-Yv4YAHdV.js → format-INdUJq6M.js} +0 -0
- /package/dist/public/assets/{sortable.esm-DuJVOTXv.js → sortable.esm-k5B4BkZq.js} +0 -0
- /package/dist/public/assets/{textarea-qPZDtk8V.js → textarea-CWb90goJ.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r,r as i}from"./dist-Nvb76hAm.js";import{t as a}from"./compiler-runtime-BfE3aGVn.js";import{t as o}from"./utils-CPqDy6Hr.js";import{t as s}from"./button-DzgjsZzC.js";import{n as c}from"./dist-BGzUo_18.js";import{t as l}from"./createLucideIcon-DdBzwsHe.js";import{C as u,E as d,d as f,h as p,i as m,n as h,t as g,v as _,w as v,x as y,y as b}from"./SyncStatusBadge-7CGaFHUk.js";import{t as x}from"./arrow-up-right-nJaICi16.js";import{t as S}from"./check-B2OLRY33.js";import{t as C}from"./folder-open-COGOeTzI.js";import{t as w}from"./info-CyR0W2SK.js";import{t as T}from"./spinner-Bx8xD6f8.js";import{n as E}from"./miss-dialog-store-CsiJb9Ou.js";import{t as D}from"./refresh-cw-CC7UZEnZ.js";import{t as O}from"./triangle-alert-BXrUEeRU.js";import{i as k,p as A}from"./doc-hash-BJkweiX9.js";import{r as j}from"./doc-paths-cEiFVCxr.js";import{t as M}from"./external-link-CldCnbtR.js";import{t as N}from"./use-git-sync-status-BQYF2F5Z.js";var P=l(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),F=l(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),I=l(`file-x-corner`,[[`path`,{d:`M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5`,key:`1jo35a`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m15 17 5 5`,key:`36xl1x`}],[`path`,{d:`m20 17-5 5`,key:`vdz27y`}]]),L=a(),R=e(n(),1),z=t(),B=`https://git-scm.com/docs/git-push`;function V(e,t){return e===`empty`?!0:!(e!==`stale`&&e!==`absent`||e===`stale`&&t?.syncEnabled===!0)}function ee(e){if(!e)return!1;let t=m(e);return t!==`dormant`&&t!==`disabled`&&t!==`auth-error`&&t!==`conflict`}function te(e){let t=(0,L.c)(11),{status:n,className:r}=e,i=n?.pausedReason;if(!f(i))return null;let a;t[0]===r?a=t[1]:(a=o(`flex min-w-0 flex-col gap-1.5`,r),t[0]=r,t[1]=a);let s;t[2]===i?s=t[3]:(s=(0,z.jsx)(`span`,{children:(0,z.jsx)(g,{reason:i})}),t[2]=i,t[3]=s);let c;t[4]!==i||t[5]!==n?.refusedSymlinkPaths?(c=i===`unsafe-incoming-symlinks`?(0,z.jsx)(h,{paths:n?.refusedSymlinkPaths}):null,t[4]=i,t[5]=n?.refusedSymlinkPaths,t[6]=c):c=t[6];let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,z.jsxs)(`div`,{className:a,"data-testid":`sync-now-paused-notice`,children:[s,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function H(e){let t=(0,L.c)(52),{freshness:n,status:a,kind:o}=e,{_:c}=i(),{confirmOpen:l,setConfirmOpen:u,onToggleRequest:d,onConfirm:f}=b(y()),[m,h]=(0,R.useState)(`idle`),g=(0,R.useRef)(null),v,C;if(t[0]!==a||t[1]!==m?(v=()=>{if(!(m!==`pending`||!a)){if(a.pushError||a.pushErrorCode){h(`idle`);return}(a.lastSyncUtc??null)!==g.current&&h(`synced`)}},C=[m,a],t[0]=a,t[1]=m,t[2]=v,t[3]=C):(v=t[2],C=t[3]),(0,R.useEffect)(v,C),!V(n,a))return null;if(n===`empty`){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(O,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[4]=e):e=t[4];let n;t[5]===c?n=t[6]:(n=c({id:`eazHgv`}),t[5]=c,t[6]=n);let r;return t[7]===n?r=t[8]:(r=(0,z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[e,(0,z.jsx)(`span`,{children:n})]}),t[7]=n,t[8]=r),r}if(m===`synced`){let e;return t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[(0,z.jsx)(S,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:(0,z.jsx)(r,{id:`fxbCNQ`})})]}),t[9]=e):e=t[9],e}let E=a?.syncEnabled===!0,k=a?.pushPermission?.checkStatus===`denied`,A=!!(a?.pushError||a?.pushErrorCode),j=k||A,M=n===`absent`&&!E,N;if(n===`absent`&&!E){let e;t[10]!==c||t[11]!==o?(e=c(o===`folder`?{id:`PrJYSN`}:{id:`3BnyYc`}),t[10]=c,t[11]=o,t[12]=e):e=t[12],N=e}else if(n===`stale`){let e;t[13]!==c||t[14]!==o?(e=c(o===`folder`?{id:`Gt4gOO`}:{id:`2IYGkU`}),t[13]=c,t[14]=o,t[15]=e):e=t[15],N=e}else{let e;t[16]!==c||t[17]!==o?(e=c(o===`folder`?{id:`nqV0Kk`}:{id:`gwykHF`}),t[16]=c,t[17]=o,t[18]=e):e=t[18],N=e}let P;t[19]!==c||t[20]!==A||t[21]!==k?(P=k?c({id:`9OIqw4`}):A?c({id:`K6MQQk`}):null,t[19]=c,t[20]=A,t[21]=k,t[22]=P):P=t[22];let F=P,I;t[23]===a?.lastSyncUtc?I=t[24]:(I=()=>{g.current=a?.lastSyncUtc??null,h(`pending`),_(`sync`).catch(e=>{console.warn(`[share-freshness] sync trigger failed`,e instanceof Error?e.message:e),h(`idle`)})},t[23]=a?.lastSyncUtc,t[24]=I);let H=I,W=M?O:w,G;t[25]===W?G=t[26]:(G=(0,z.jsx)(W,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),t[25]=W,t[26]=G);let K;t[27]===N?K=t[28]:(K=(0,z.jsx)(`span`,{children:N}),t[27]=N,t[28]=K);let q;t[29]===F?q=t[30]:(q=F?(0,z.jsx)(`span`,{children:F}):null,t[29]=F,t[30]=q);let J;t[31]!==j||t[32]!==H||t[33]!==d||t[34]!==a||t[35]!==E||t[36]!==m?(J=j?null:E?ee(a)?(0,z.jsx)(`div`,{children:m===`pending`?(0,z.jsxs)(s,{variant:`outline`,size:`xs`,disabled:!0,children:[(0,z.jsx)(T,{icon:D,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`EHu0x2`})]}):(0,z.jsx)(s,{variant:`outline`,size:`xs`,onClick:H,children:(0,z.jsx)(r,{id:`lb_UU4`})})}):(0,z.jsx)(te,{status:a}):(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,z.jsx)(s,{variant:`outline`,size:`xs`,onClick:()=>d(!0),children:(0,z.jsx)(r,{id:`pPiV8s`})}),(0,z.jsxs)(`a`,{href:B,target:`_blank`,rel:`noopener noreferrer`,onClick:ne,onAuxClick:U,className:`inline-flex items-center gap-1 transition-colors hover:text-primary`,children:[(0,z.jsx)(r,{id:`GLxIKR`}),(0,z.jsx)(x,{className:`size-3 shrink-0`,"aria-hidden":`true`})]})]}),t[31]=j,t[32]=H,t[33]=d,t[34]=a,t[35]=E,t[36]=m,t[37]=J):J=t[37];let Y;t[38]!==K||t[39]!==q||t[40]!==J?(Y=(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[K,q,J]}),t[38]=K,t[39]=q,t[40]=J,t[41]=Y):Y=t[41];let X;t[42]!==G||t[43]!==Y?(X=(0,z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed border-border bg-muted/40 p-2 text-xs text-muted-foreground`,"data-testid":`share-freshness-row`,children:[G,Y]}),t[42]=G,t[43]=Y,t[44]=X):X=t[44];let Z;t[45]!==l||t[46]!==f||t[47]!==u?(Z=(0,z.jsx)(p,{open:l,onOpenChange:u,onConfirm:f}),t[45]=l,t[46]=f,t[47]=u,t[48]=Z):Z=t[48];let Q;return t[49]!==X||t[50]!==Z?(Q=(0,z.jsxs)(z.Fragment,{children:[X,Z]}),t[49]=X,t[50]=Z,t[51]=Q):Q=t[51],Q}function U(e){return M(e,B)}function ne(e){return M(e,B)}function W(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function G(e){let t=(0,L.c)(17),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={phase:`pending`},t[0]=n):n=t[0];let[r,i]=(0,R.useState)(n),[a,o]=(0,R.useState)(0),s=e.branch,c;t[1]!==s||t[2]!==e.contentRootDepth||t[3]!==e.kind||t[4]!==e.path||t[5]!==e.repositoryPath?(c=()=>{let t=window.okDesktop??null;if(!t||s===null){i({phase:`resolved`,resolution:{verdict:`unknown`}});return}let n=!1;return t.project.fetchTargetStatus({projectPath:t.config.projectPath,branch:s,path:e.repositoryPath??e.path,kind:e.kind,...e.contentRootDepth===void 0?{}:{contentRootDepth:e.contentRootDepth}}).then(e=>{n||i({phase:`resolved`,resolution:e??{verdict:`unknown`}})}).catch(e=>{n||(console.warn(`[receive] miss target-status fetch failed`,e instanceof Error?e.message:e),i({phase:`resolved`,resolution:{verdict:`unknown`}}))}),()=>{n=!0}},t[1]=s,t[2]=e.contentRootDepth,t[3]=e.kind,t[4]=e.path,t[5]=e.repositoryPath,t[6]=c):c=t[6];let l;t[7]!==s||t[8]!==a||t[9]!==e.contentRootDepth||t[10]!==e.kind||t[11]!==e.path||t[12]!==e.repositoryPath?(l=[s,e.kind,e.path,e.repositoryPath,e.contentRootDepth,a],t[7]=s,t[8]=a,t[9]=e.contentRootDepth,t[10]=e.kind,t[11]=e.path,t[12]=e.repositoryPath,t[13]=l):l=t[13],(0,R.useEffect)(c,l);let u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i({phase:`pending`}),o(K)},t[14]=u):u=t[14];let d;return t[15]===r?d=t[16]:(d={state:r,refetch:u},t[15]=r,t[16]=d),d}function K(e){return e+1}function q(e){let t=(0,L.c)(15),{onEnabled:n}=e,i=y(),a;t[0]===n?a=t[1]:(a={onEnabled:n},t[0]=n,t[1]=a);let{confirmOpen:o,setConfirmOpen:c,onToggleRequest:l,onConfirm:u}=b(i,a),d;t[2]===l?d=t[3]:(d=()=>l(!0),t[2]=l,t[3]=d);let f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,z.jsx)(D,{className:`size-4`,"aria-hidden":`true`}),m=(0,z.jsx)(r,{id:`pPiV8s`}),t[4]=f,t[5]=m):(f=t[4],m=t[5]);let h;t[6]===d?h=t[7]:(h=(0,z.jsxs)(s,{onClick:d,"data-testid":`share-receive-miss-enable-sync`,children:[f,m]}),t[6]=d,t[7]=h);let g;t[8]!==o||t[9]!==u||t[10]!==c?(g=(0,z.jsx)(p,{open:o,onOpenChange:c,onConfirm:u}),t[8]=o,t[9]=u,t[10]=c,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,z.jsxs)(z.Fragment,{children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function J(e){let t=(0,L.c)(23),{status:n,onSyncCompleted:a}=e,{_:o}=i(),[l,u]=(0,R.useState)(!1),d=(0,R.useRef)(null),f;t[0]!==a||t[1]!==l||t[2]!==n.lastSyncUtc||t[3]!==n.pushError||t[4]!==n.pushErrorCode?(f=()=>{if(l){if(n.pushError||n.pushErrorCode){u(!1);return}(n.lastSyncUtc??null)!==d.current&&(u(!1),a?.())}},t[0]=a,t[1]=l,t[2]=n.lastSyncUtc,t[3]=n.pushError,t[4]=n.pushErrorCode,t[5]=f):f=t[5];let p;t[6]!==a||t[7]!==l||t[8]!==n?(p=[l,n,a],t[6]=a,t[7]=l,t[8]=n,t[9]=p):p=t[9],(0,R.useEffect)(f,p);let m;t[10]!==o||t[11]!==n.lastSyncUtc?(m=()=>{d.current=n.lastSyncUtc??null,u(!0),_(`sync`).catch(e=>{console.warn(`[receive] miss sync trigger failed`,e instanceof Error?e.message:e),u(!1),c.error(o({id:`1u-mAI`}))})},t[10]=o,t[11]=n.lastSyncUtc,t[12]=m):m=t[12];let h=m,g;t[13]!==h||t[14]!==l?(g=l?(0,z.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-sync-now`,children:[(0,z.jsx)(T,{icon:D,className:`size-4`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`EHu0x2`})]}):(0,z.jsxs)(s,{onClick:h,"data-testid":`share-receive-miss-sync-now`,children:[(0,z.jsx)(D,{className:`size-4`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`lb_UU4`})]}),t[13]=h,t[14]=l,t[15]=g):g=t[15];let v;t[16]===l?v=t[17]:(v=l?(0,z.jsx)(r,{id:`dXOolp`}):null,t[16]=l,t[17]=v);let y;t[18]===v?y=t[19]:(y=(0,z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-sync-status`,children:v}),t[18]=v,t[19]=y);let b;return t[20]!==g||t[21]!==y?(b=(0,z.jsxs)(z.Fragment,{children:[g,y]}),t[20]=g,t[21]=y,t[22]=b):b=t[22],b}var Y=!1;function X(e){return!Y&&e!==null&&e.syncEnabled!==!0}function Z(e){return e===null?!1:e.hasRemote&&e.lastPullUtc!==void 0&&e.state!==`conflict`}function Q(e,t){let n=(0,L.c)(15),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(!1),l=(0,R.useRef)(null),u,d;n[0]!==t||n[1]!==r||n[2]!==e?(u=()=>{if(!r||(e?.lastPullUtc??null)===l.current)return;i(!1);let n=e?.lastPullOutcome??null;if(n===null){t?.();return}switch(n){case`refused`:case`error`:o(n);return;case`succeeded`:case`up-to-date`:if(X(e)){Y=!0,c(!0);return}t?.();return;case`conflict`:t?.();return;default:t?.();return}},d=[r,e,t],n[0]=t,n[1]=r,n[2]=e,n[3]=u,n[4]=d):(u=n[3],d=n[4]),(0,R.useEffect)(u,d);let f;n[5]===t?f=n[6]:(f=()=>{c(!1),t?.()},n[5]=t,n[6]=f);let p;n[7]===e?.lastPullUtc?p=n[8]:(p=()=>{l.current=e?.lastPullUtc??null,o(null),i(!0),_(`pull`).catch(e=>{console.warn(`[receive] miss pull trigger failed`,e instanceof Error?e.message:e),i(!1),o(`error`)})},n[7]=e?.lastPullUtc,n[8]=p);let m;return n[9]!==a||n[10]!==s||n[11]!==r||n[12]!==f||n[13]!==p?(m={pending:r,failure:a,offering:s,resolveOffer:f,start:p},n[9]=a,n[10]=s,n[11]=r,n[12]=f,n[13]=p,n[14]=m):m=n[14],m}function re(e){let t=(0,L.c)(10),{pending:n,onPull:i}=e,a;t[0]!==i||t[1]!==n?(a=n?(0,z.jsxs)(s,{disabled:!0,"aria-busy":`true`,"data-testid":`share-receive-miss-pull-now`,children:[(0,z.jsx)(T,{icon:D,className:`size-4`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`4uNLmk`})]}):(0,z.jsxs)(s,{onClick:i,"data-testid":`share-receive-miss-pull-now`,children:[(0,z.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`fevEu0`})]}),t[0]=i,t[1]=n,t[2]=a):a=t[2];let o;t[3]===n?o=t[4]:(o=n?(0,z.jsx)(r,{id:`glG1TR`}):null,t[3]=n,t[4]=o);let c;t[5]===o?c=t[6]:(c=(0,z.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`sr-only`,"data-testid":`share-receive-miss-pull-status`,children:o}),t[5]=o,t[6]=c);let l;return t[7]!==a||t[8]!==c?(l=(0,z.jsxs)(z.Fragment,{children:[a,c]}),t[7]=a,t[8]=c,t[9]=l):l=t[9],l}function ie(e){let t=(0,L.c)(18),{onResolve:n,strandedCommitCount:r}=e,i=v(),a=(0,R.useRef)(!1),o;t[0]===n?o=t[1]:(o=function(){a.current||(a.current=!0,n())},t[0]=n,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c={onApplied:s},t[2]=s,t[3]=c);let{confirmOpen:l,setConfirmOpen:d,onModeSelect:f,onConfirm:m}=u(i,`off`,c),h=(0,R.useRef)(!1),g,_;t[4]===f?(g=t[5],_=t[6]):(g=()=>{h.current||(h.current=!0,f(`follow`))},_=[f],t[4]=f,t[5]=g,t[6]=_),(0,R.useEffect)(g,_);let y;t[7]!==s||t[8]!==d?(y=e=>{d(e),e||s()},t[7]=s,t[8]=d,t[9]=y):y=t[9];let b;t[10]!==m||t[11]!==s?(b=()=>{m(),s()},t[10]=m,t[11]=s,t[12]=b):b=t[12];let x;return t[13]!==l||t[14]!==r||t[15]!==y||t[16]!==b?(x=(0,z.jsx)(p,{open:l,onOpenChange:y,onConfirm:b,variant:`follow`,strandedCommitCount:r}),t[13]=l,t[14]=r,t[15]=y,t[16]=b,t[17]=x):x=t[17],x}function ae(e){let t=(0,L.c)(108),{nav:n,state:a,onBrowseFolder:o,onOpenRenamed:c,onEnableAutoSync:l,onSyncCompleted:u,onPullApplied:p}=e,{_:m}=i(),_=N(),v=Q(_,p),y=n.branch,b;t[0]!==m||t[1]!==n.kind?(b=n.kind===`folder`?m({id:`ugoTXs`}):m({id:`XH30C4`}),t[0]=m,t[1]=n.kind,t[2]=b):b=t[2];let x=b;if(a.phase===`pending`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{className:`size-5`,"aria-hidden":`true`}),(0,z.jsx)(r,{id:`c8jBgX`})]}),t[3]=e):e=t[3],e}let{resolution:S}=a,w,D;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,z.jsx)(C,{className:`size-4`,"aria-hidden":`true`}),D=(0,z.jsx)(r,{id:`hItdtk`}),t[4]=w,t[5]=D):(w=t[4],D=t[5]);let O;t[6]===o?O=t[7]:(O=(0,z.jsxs)(s,{variant:`outline`,onClick:o,"data-testid":`share-receive-miss-browse`,children:[w,D]}),t[6]=o,t[7]=O);let k=O,A,j,M,R=null;if(S.verdict===`renamed`){let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(E,{className:`size-9`,"aria-hidden":`true`}),t[8]=e):e=t[8],A=e;let n;t[9]!==S.renamedTo||t[10]!==x?(n={0:S.renamedTo,targetNoun:x},t[9]=S.renamedTo,t[10]=x,t[11]=n):n=t[11];let i;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[12]=i):i=t[12];let a;t[13]===n?a=t[14]:(a=(0,z.jsx)(r,{id:`P0HC30`,values:n,components:i}),t[13]=n,t[14]=a),j=a;let o;t[15]!==c||t[16]!==S.renamedTo?(o=()=>c(S.renamedTo),t[15]=c,t[16]=S.renamedTo,t[17]=o):o=t[17];let l,u;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,z.jsx)(E,{className:`size-4`,"aria-hidden":`true`}),u=(0,z.jsx)(r,{id:`AItsE5`}),t[18]=l,t[19]=u):(l=t[18],u=t[19]);let d;t[20]===o?d=t[21]:(d=(0,z.jsxs)(s,{onClick:o,"data-testid":`share-receive-miss-open-renamed`,children:[l,u]}),t[20]=o,t[21]=d);let f;t[22]!==k||t[23]!==d?(f=(0,z.jsxs)(z.Fragment,{children:[d,k]}),t[22]=k,t[23]=d,t[24]=f):f=t[24],M=f}else if(S.verdict===`deleted`){let e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(I,{className:`size-9`,"aria-hidden":`true`}),t[25]=e):e=t[25],A=e;let n;t[26]!==y||t[27]!==x?(n={targetNoun:x,branch:y},t[26]=y,t[27]=x,t[28]=n):n=t[28];let i;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[29]=i):i=t[29];let a;t[30]===n?a=t[31]:(a=(0,z.jsx)(r,{id:`kpqWwG`,values:n,components:i}),t[30]=n,t[31]=a),j=a,M=k}else if(S.verdict===`never-on-branch`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(F,{className:`size-9`,"aria-hidden":`true`}),t[32]=e):e=t[32],A=e;let n;t[33]!==y||t[34]!==x?(n={targetNoun:x,branch:y},t[33]=y,t[34]=x,t[35]=n):n=t[35];let i;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(i={0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})},t[36]=i):i=t[36];let a;t[37]===n?a=t[38]:(a=(0,z.jsx)(r,{id:`i9TPUi`,values:n,components:i}),t[37]=n,t[38]=a),j=a,M=k}else if(S.verdict===`changed-locally`){let e;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(P,{className:`size-9`,"aria-hidden":`true`}),t[39]=e):e=t[39],A=e;let n=_?.syncEnabled===!0,i=_?.pushPermission?.checkStatus===`denied`||!!(_?.pushError||_?.pushErrorCode);if(n){let e;t[40]!==y||t[41]!==x?(e=y===null?(0,z.jsx)(r,{id:`RyIKxy`,values:{targetNoun:x}}):(0,z.jsx)(r,{id:`l6kpzR`,values:{targetNoun:x,branch:y},components:{0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[40]=y,t[41]=x,t[42]=e):e=t[42],j=e}else{let e;t[43]!==y||t[44]!==x?(e=y===null?(0,z.jsx)(r,{id:`UuYo7g`,values:{targetNoun:x}}):(0,z.jsx)(r,{id:`HoWElC`,values:{targetNoun:x,branch:y},components:{0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[43]=y,t[44]=x,t[45]=e):e=t[45],j=e}let a=null;if(_?.syncEnabled){let e;t[46]===_?e=t[47]:(e=ee(_),t[46]=_,t[47]=e);let n=e,r;t[48]!==n||t[49]!==_?(r=!n&&f(_.pausedReason),t[48]=n,t[49]=_,t[50]=r):r=t[50];let o=r,s=o?`w-full max-w-md text-balance text-1sm text-muted-foreground`:`sr-only`,c;t[51]!==o||t[52]!==_?(c=o?(0,z.jsx)(te,{status:_}):null,t[51]=o,t[52]=_,t[53]=c):c=t[53];let l;if(t[54]!==s||t[55]!==c?(l=(0,z.jsx)(`div`,{role:`status`,className:s,"data-testid":`share-receive-miss-sync-paused`,children:c}),t[54]=s,t[55]=c,t[56]=l):l=t[56],R=l,n&&!i){let e;t[57]!==u||t[58]!==_?(e=(0,z.jsx)(J,{status:_,onSyncCompleted:u}),t[57]=u,t[58]=_,t[59]=e):e=t[59],a=e}}else if(_!==null){let e;t[60]===l?e=t[61]:(e=(0,z.jsx)(q,{onEnabled:l}),t[60]=l,t[61]=e),a=e}let o;t[62]!==k||t[63]!==a?(o=(0,z.jsxs)(z.Fragment,{children:[a,k]}),t[62]=k,t[63]=a,t[64]=o):o=t[64],M=o}else{let e;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(d,{className:`size-9`,"aria-hidden":`true`}),t[65]=e):e=t[65],A=e;let n;t[66]===_?n=t[67]:(n=Z(_),t[66]=_,t[67]=n);let i=n;if(i){let e;t[68]===y?e=t[69]:(e=y===null?(0,z.jsx)(r,{id:`gwEcOD`}):(0,z.jsx)(r,{id:`wvK7Ay`,values:{branch:y},components:{0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[68]=y,t[69]=e),j=e}else{let e;t[70]===y?e=t[71]:(e=y===null?(0,z.jsx)(r,{id:`Xewl6B`}):(0,z.jsx)(r,{id:`d1JjXo`,values:{branch:y},components:{0:(0,z.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-0.5 text-foreground/80`})}}),t[70]=y,t[71]=e),j=e}let a=v.failure===`refused`&&_?.pausedReason===`unsafe-incoming-symlinks`,o=a?`flex w-full max-w-md flex-col gap-2`:`contents`,s=v.failure===null?`sr-only`:`max-w-md text-balance text-1sm text-destructive`,c;t[72]!==v.failure||t[73]!==a?(c=a?(0,z.jsx)(g,{reason:`unsafe-incoming-symlinks`}):v.failure===`refused`?(0,z.jsx)(r,{id:`Xp7Kq4`}):v.failure===`error`?(0,z.jsx)(r,{id:`JG_8KT`}):null,t[72]=v.failure,t[73]=a,t[74]=c):c=t[74];let l;t[75]!==s||t[76]!==c?(l=(0,z.jsx)(`p`,{role:`alert`,className:s,"data-testid":`share-receive-miss-pull-error`,children:c}),t[75]=s,t[76]=c,t[77]=l):l=t[77];let u;t[78]!==a||t[79]!==_?.refusedSymlinkPaths?(u=a?(0,z.jsx)(h,{paths:_?.refusedSymlinkPaths}):null,t[78]=a,t[79]=_?.refusedSymlinkPaths,t[80]=u):u=t[80];let f;t[81]!==l||t[82]!==u||t[83]!==o?(f=(0,z.jsxs)(`div`,{className:o,children:[l,u]}),t[81]=l,t[82]=u,t[83]=o,t[84]=f):f=t[84],R=f;let p;t[85]!==i||t[86]!==v.pending||t[87]!==v.start?(p=i?(0,z.jsx)(re,{pending:v.pending,onPull:v.start}):null,t[85]=i,t[86]=v.pending,t[87]=v.start,t[88]=p):p=t[88];let m;t[89]!==v.offering||t[90]!==v.resolveOffer||t[91]!==_?.ahead?(m=v.offering?(0,z.jsx)(ie,{onResolve:v.resolveOffer,strandedCommitCount:_?.ahead??0}):null,t[89]=v.offering,t[90]=v.resolveOffer,t[91]=_?.ahead,t[92]=m):m=t[92];let b;t[93]!==k||t[94]!==p||t[95]!==m?(b=(0,z.jsxs)(z.Fragment,{children:[p,k,m]}),t[93]=k,t[94]=p,t[95]=m,t[96]=b):b=t[96],M=b}let B;t[97]===A?B=t[98]:(B=(0,z.jsx)(`div`,{className:`flex size-16 items-center justify-center rounded-full border bg-muted/40 text-muted-foreground`,children:A}),t[97]=A,t[98]=B);let V;t[99]===j?V=t[100]:(V=(0,z.jsx)(`p`,{className:`max-w-md text-balance text-base leading-6 text-foreground/90`,children:j}),t[99]=j,t[100]=V);let H;t[101]===M?H=t[102]:(H=(0,z.jsx)(`div`,{className:`flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:justify-center`,children:M}),t[101]=M,t[102]=H);let U;return t[103]!==R||t[104]!==B||t[105]!==V||t[106]!==H?(U=(0,z.jsxs)(z.Fragment,{children:[B,V,R,H]}),t[103]=R,t[104]=B,t[105]=V,t[106]=H,t[107]=U):U=t[107],U}function $(e){return e.replace(/^\/+|\/+$/g,``)}function oe(e,t){if(t.kind===`folder`){if(A(e))return $(t.path)===``;let n=k(e);return n!==null&&$(n)===$(t.path)}let n=k(e);return n===null?!1:j(n)===j(t.path)}function se(){let e=null,t=new Set,n=!1;function r(){for(let e of t)e()}function i(t){e!==t&&(e=t,r())}function a(){e!==null&&(oe(window.location.hash,e)||i(null))}function o(){n||typeof window>`u`||(n=!0,window.addEventListener(`hashchange`,a))}return{arm(e){o(),i(e)},clear(){i(null)},getSnapshot(){return e},subscribe(e){return t.add(e),()=>{t.delete(e)}},dispose(){n&&typeof window<`u`&&(window.removeEventListener(`hashchange`,a),n=!1),i(null)}}}var ce=se();function le(e,t){if(e.contentRootDepth===void 0)return{...e,path:t,repositoryPath:t};let n=(e.repositoryPath??e.path).split(`/`).slice(0,e.contentRootDepth);return{...e,path:t,repositoryPath:[...n,...t===``?[]:t.split(`/`)].join(`/`)}}function ue(e,t){return e===null||e.kind!==`missing`||t===null||j(t.path)!==e.target?null:t}export{W as a,V as c,ae as i,le as n,G as o,ce as r,H as s,ue as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./dist-C_FzPxEX2.js";function t(t){return t===`win32`?e._({id:`qi1F96`}):t===`linux`?e._({id:`e1Rn_k`}):e._({id:`LtSYdi`})}function n(t){return t===`win32`?e._({id:`o9yN4T`}):e._({id:`q3TWG7`})}function r(t){return t===`win32`?e._({id:`cVp1YI`}):e._({id:`GQ3O42`})}export{t as n,r,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import"./constants-upload-CVKO8P4d.js";import{S as r,a as i,d as a,f as o,g as s,i as c,p as l,t as u,u as d,v as f,x as p,y as m}from"./schemas-B93JY9Ef.js";import{A as h,Dt as g,Et as _,F as ee,Ft as v,M as y,N as b,Ot as x,P as S,j as C,k as w}from"./schemas-api-BM3O7zA1.js";import{t as T}from"./constants-github-DOek7bCt.js";import{c as E,l as te,u as D}from"./share-D-LUU2aX-DfD-mrg-.js";import{n as O}from"./_envelope-Dwl6i2K9-DPqJ_Q4W.js";import{g as ne,h as k,m as A,v as re}from"./use-apply-config-color-theme-DsCyuU3O.js";import{u as ie}from"./use-apply-config-language-BvXQKexF.js";var ae=n(),j=e(t(),1),M=null,N=new Set;function P(){return M}function oe(e){let t=e!==null&&e.length>0?e:null;if(t!==M){M=t;for(let e of N)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function se(e){return N.add(e),()=>{N.delete(e)}}function F(){return(0,j.useSyncExternalStore)(se,P,P)}var I=Symbol.for(`@inkeep/open-knowledge/field-registry`),L=globalThis;L[I]===void 0&&(L[I]=r());var R=L[I];function ce(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=le(t)?R.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function le(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}var ue=[`markdownlint`,`frontmatter`,`okf`],de=[`missing`,`invalid`];function fe(e){return e.frontmatterScope!==void 0}[...ue];var pe=[`off`,`warning`,`error`],z=`warning`,me=[`error`,`warning`];function B(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&(v(e.getIn(r,!0))||e.deleteIn(r))}}function he(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){B(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}B(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function V(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var H={provider:u(T).register(R,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Declares that this git host is a GitHub Enterprise Server instance, so OpenKnowledge treats its remotes the way it treats github.com (OpenKnowledge credential handling, the push-permission check, share links, and the default host for `ok auth`). 'github' is the only accepted value today. A host that is not declared here and is not github.com is treated as a generic git remote, so OpenKnowledge leaves the machine's own git credentials alone and does not check push permission. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. The declaration takes effect when OpenKnowledge next starts."})},ge=Object.fromEntries(Object.entries(H).map(([e,t])=>[e,t.optional().catch(void 0)])),_e=Object.fromEntries(Object.entries(H).map(([e,t])=>[e,t.nullish()])),ve=a(ge).catch({});s(f(),a(H).partial());var ye=a({git:a({hosts:s(f(),a(_e).nullish()).nullish()}).nullish()});function be(e){let t=ye.safeParse(e);return t.success?null:{code:`SCHEMA_INVALID`,issues:t.error.issues.map(V)}}var U=l({prefix:f().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,{message:`prefix must start with a letter and use only letters, digits, _ and -`}),url:f().regex(/^https?:\/\/[^\s<>]*<num>[^\s<>]*$/,{message:`url must be an http or https URL containing <num>`})});c(U);var xe=U.nullable().catch(null);function Se(){return Object.fromEntries(_.map(e=>[e,f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${g[e]}, as a #rrggbb hex string.`}).optional()]))}function Ce(){return ne.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var W=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),G=52428800,K=26214400,q=12582912,J=`https://api.openai.com/v1`,Y=`text-embedding-3-small`,X=96e3,Z=3e4,we=2048,Te=16384e3,Ee=6e5,De=Object.freeze([`127.0.0.1`]),Oe=/^[1-9]\d*(s|m|h)$/,ke=/^https?:\/\//,Ae=24550;function je(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function Me(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&je(e)?null:`insecure-scheme`}function Ne(e){let t=e.trim();return t===``?`./`:t}function Pe(e){let t=Ne(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}var Fe=a({content:a({dir:f().register(R,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:f().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(Pe,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:a({theme:u([`light`,`dark`,`system`]).register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:u([`system`,...ie]).register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${Ce()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(A,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${Ce()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(A,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(A,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:a({name:f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:f().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:u([`dark`,`light`]).register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...Se()}).optional(),preview:a({autoOpen:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:a({showHiddenFiles:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillGroups:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Group skills in the sidebar by where they came from — the publisher they were imported from, or the plugin that ships them. Skills you authored stay ungrouped at the top of their scope. Per-machine (project-local) — not shared with collaborators.`}).default(!0),pinnedProjectSkills:c(f()).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Project-scope skills pinned to the top of the Skills sidebar, by name. A pinned skill also keeps its normal row, so a provenance group still lists everything from its source. Per-machine (project-local) — not shared with collaborators.`}).default([]),pinnedGlobalSkills:c(f()).register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Global-scope skills pinned to the top of the Skills sidebar, by name. Stored per USER rather than per project, so a pinned global skill follows you into every project.`}).default([])}).optional()}).default({preview:{autoOpen:!0}}),editor:a({wordWrap:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:a({autoApproveOkTools:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools for agents launched from the built-in terminal (plus `ok open` on Claude) and for in-app Agents-panel chats with any ACP agent. Destructive tools (delete/move/share/install/import) still prompt. Per-machine personal preference (user scope)."}).default(!0),browserTools:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Give in-app Claude Code and Codex chats a browser they can drive (Playwright MCP, started through npx from OpenKnowledge's own folder with a fresh in-memory profile), so an agent can open pages, click, and take screenshots. Every browser action asks for approval, with no option to always allow it, unless the agent's own mode or permission settings skip approvals. Needs Google Chrome and Node.js. Off by default; takes effect for chats started after the change. Per-machine personal preference (user scope).`}).default(!1)}).default({autoApproveOkTools:!0,browserTools:!1}),autoSync:a({mode:u(D).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`What this machine syncs on a schedule for this project: 'off' (Manual — nothing scheduled; the manual pull/push actions still work), 'follow' (Auto, pull only — scheduled pulls, never a scheduled push; 'pull' is accepted as a legacy alias), or 'full' (Auto, pull and push — bidirectional). Explicit user-triggered pushes work in every mode. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:u(te).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),pullIntervalSeconds:o().int().min(30).max(E).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pulls while autoSync.mode is follow or full (default 30). Per-machine (project-local) — not shared.`}).optional().catch(void 0),pushIntervalSeconds:o().int().min(30).max(E).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pushes while autoSync.mode is full (default 60). Ignored in every other mode, which never pushes on a schedule. Each cycle with pending edits authors a commit, so a shorter interval means more, smaller commits in the repo's shared history. Per-machine (project-local) — not shared.`}).optional().catch(void 0),default:m([i(),u(D)]).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),git:a({hosts:s(f(),ve).register(R,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Per-git-host declarations, keyed by hostname (for example ghes.example.com). Each entry says how OpenKnowledge should treat remotes on that host; today the only key an entry carries is `provider`. Hosts absent from this map are treated as generic git remotes. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. Declarations take effect when OpenKnowledge next starts."}).default({}).catch({})}).default({hosts:{}}),terminal:a({enabled:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null),shell:f().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Absolute Windows shell executable override for the in-app terminal. PowerShell, cmd.exe, and Git Bash support OpenKnowledge-managed launches (agent chat tabs and fixed commands such as Resolve in terminal or Install Slidev) and dropped-file path insertion. A different existing executable remains usable for plain terminal tabs and shows a capability notice; requested agent and command launches open only the plain shell without running the agent or command, and dropped-file paths are refused. Empty values use automatic shell discovery. Per-machine (project-local), human-managed, and never shared via git, clone, or sync.`}).optional()}).default({enabled:null}),slides:a({enabled:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:a({localSink:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:a({maxBytes:o().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(G)}).default({maxBytes:G}),logs:a({maxBytes:o().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(K)}).default({maxBytes:K}),attributeDenylist:c(f()).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...W])}).default({enabled:!0,spans:{maxBytes:G},logs:{maxBytes:K},attributeDenylist:[...W]}),skillInstallReports:a({enabled:i().register(R,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:G},logs:{maxBytes:K},attributeDenylist:[...W]},skillInstallReports:{enabled:!0}}),lossCapture:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:o().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(q)}).default({enabled:!0,maxBytes:q}),bridge:a({backgroundThrottle:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:a({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:a({semantic:a({enabled:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:f().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (stored in secrets.yml in the OpenKnowledge home folder); it is sent to whichever endpoint this names."}).default(J),model:f().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(Y),dimensions:o().int().positive().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:o().min(0).max(1).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional(),maxBatchSize:o().int().min(1).max(we).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Maximum number of text chunks sent in one indexing request (1–2048, default 96). The ceiling follows OpenAI's input-array limit; other providers may impose different limits. Larger requests may still be split by the character budget. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(96).catch(96),maxBatchChars:o().int().min(1).max(Te).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Approximate cumulative character budget per indexing request (1–16384000, default 96000). A single chunk can exceed this budget. OpenAI separately caps total input at 300000 tokens per request; this character budget does not enforce that limit, and high values can produce rejected requests. Other providers have their own limits. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(X).catch(X),docTimeoutMs:o().int().min(1).max(Ee).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Timeout in milliseconds for each indexing request attempt (1–600000, default 30000). A request can retry four times, and a failed grouped request can trigger individual-document requests. There is no total indexing-pass deadline: large timeouts can delay newly queued work for hours. The query timeout remains 8 seconds per attempt. Changing it preserves cached vectors and applies to the next indexing pass; an in-progress pass keeps its current timeout. Invalid values use the default and are reported by ok config validate and server logs.`}).default(Z).catch(Z)}).default({enabled:!1,baseUrl:J,model:Y,maxBatchSize:96,maxBatchChars:X,docTimeoutMs:Z})}).default({semantic:{enabled:!1,baseUrl:J,model:Y,maxBatchSize:96,maxBatchChars:X,docTimeoutMs:Z}}),contentRules:a({markdownlint:l({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:l({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:c(l({appliesTo:m([f(),c(f())]).optional(),file:f(),enabled:i().optional()})).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:l({enabled:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:s(f(),i()).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:l({index:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:a({links:u(pe).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(z),fileTreeIndicators:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0),suppressLogLinkAdvisories:i().register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether unresolved links in the reserved change-history documents (lowercase-stemmed log.md / log.mdx at any depth, where the extension's case does not matter and the stem's does) are omitted from broken-link advisories: the Problems panel, file-tree indicators, source diagnostics, audits, and agent write/edit results. Default true. Raw link views still show them, and LOG.md, Log.md, and every other stem spelling are ordinary documents.`}).default(!0)}).default({links:z,fileTreeIndicators:!0,suppressLogLinkAdvisories:!0}),autolinks:c(xe).register(R,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Turn ticket references into links; today they apply to Agents-panel chat messages. Each entry pairs a `prefix` (for example `PRD-`) with a `url` template containing `<num>` (for example `https://linear.app/inkeep/issue/PRD-<num>`); the prefix followed by digits links to that URL with the digits in place of `<num>`. Matching is case-sensitive. An invalid entry is skipped with a warning and the others still apply. Shared with collaborators (project scope, `.ok/config.yml`)."}).default([]).catch([]),linkPreviews:a({enabled:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor, and a status card when you hover a GitHub pull request or issue link in an agent chat. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata, and hovering a GitHub reference asks the GitHub host's API for it, signed in as you when a GitHub sign-in is available — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),server:a({port:o().int().min(1).max(65535).register(R,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Read at server start; changing it requires a restart.`}).optional(),bind:c(f().min(1)).min(1).register(R,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...De]),externalUrl:p({protocol:/^https?$/}).regex(ke).register(R,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — its host joins the Host/Origin allowlists (external-Host + CORS admission). Unset by default: the server admits only loopback Hosts. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Read at server start; changing it requires a restart.`}).optional(),allowExternal:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. A non-loopback server.bind without allowExternal: true is refused at boot with a one-line fix; a server.externalUrl without it boots (a committed externalUrl never arms exposure on clones — but it is project-scoped, so its host still joins the Host/Origin allowlists there), but requests carrying forwarding headers (X-Forwarded-For etc.) are refused until consent is given — proxy tolerance requires both keys. Default off. The server has no authentication of its own, so only consent behind an authenticating edge. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:i().register(R,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:m([d(`off`),f().regex(Oe)]).register(R,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' for a loopback-only, unexposed server; 'off' otherwise — a non-loopback bind, or a loopback bind declared externally reachable (server.allowExternal + server.externalUrl), stays up, because a remote agent keeps it busy over /mcp, which the idle timer does not count. Residual case the derivation cannot see: a loopback server reached by remote agents with no server.externalUrl (e.g. behind a same-box reverse proxy) still idles at 30m — set 'off' by hand. Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...De],allowExternal:!1})});function Ie(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Le(e,t){let n=e;for(let e of t){n=Ie(n);let t=n?._zod?.def?.shape;if(!t){let e=n?._zod?.def;if(e?.type!==`record`)return;n=e.valueType;continue}if(n=t[String(e)],n===void 0)return}return n}function Re(e,t){let n=Le(e,t);if(n!==void 0)return ce(n)}function Q(e){return{authoritative:e,themes:k,warnings:[],truncated:!1}}function ze(e){let{scheme:t}=e;return{id:e.id,label:t.name,kind:t.variant,scheme:t,toTokens:()=>x(t)}}function Be(e,t){return{id:e,label:t.name,kind:t.variant,scheme:t,toTokens:()=>x(t)}}function $(e,t,n={}){console.warn(JSON.stringify({event:`ok-saved-theme-request-failed`,action:e,result:t,...n.status===void 0?{}:{status:n.status},...n.error===void 0?{}:{errorName:n.error instanceof Error?n.error.name:`UnknownError`}}))}async function Ve(e={}){let t=e.request??globalThis.fetch;try{let n=await t(`/api/saved-themes`,{signal:e.signal});if(!n.ok)return $(`list`,`http-error`,{status:n.status}),Q(!1);let r=ee.safeParse(await n.json());if(!r.success)return console.warn(`[themes] saved-themes response failed schema validation`,r.error.issues),Q(!1);let i=[],a=[];for(let e of r.data.themes)e.ok?i.push(ze(e)):a.push({filename:e.filename,id:e.id,code:e.code,...e.conflictingFilenames?{conflictingFilenames:e.conflictingFilenames}:{}});return{authoritative:!0,themes:i.length===0?k:[...k,...i],warnings:a,truncated:r.data.truncated}}catch(t){return e.signal?.aborted||$(`list`,`request-error`,{error:t}),Q(!1)}}function He(e){switch(e.detail){case`empty`:case`too-long`:case`invalid-chars`:return e.detail;default:return}}async function Ue(e,t={}){let n=h.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=C.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=O.safeParse(t);if(!i.success)return{ok:!1,reason:`unexpected`};if(i.data.type===`urn:ok:error:theme-name-taken`)return{ok:!1,reason:`name-taken`};if(i.data.type===`urn:ok:error:theme-name-invalid`){let e=He(i.data);return e?{ok:!1,reason:`name-invalid`,detail:e}:{ok:!1,reason:`name-invalid`}}return{ok:!1,reason:`unexpected`}}catch(e){return $(`save`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function We(e,t={}){let n=b.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=S.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=O.safeParse(t);return i.success&&i.data.type===`urn:ok:error:not-found`?{ok:!1,reason:`not-found`}:{ok:!1,reason:`unexpected`}}catch(e){return $(`update`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function Ge(e,t={}){if(!re(e).ok)return{ok:!1,reason:`unexpected`};let n=t.request??globalThis.fetch;try{let t=await n(`/api/saved-theme?${new URLSearchParams({id:e})}`,{method:`DELETE`}),r=await t.json().catch(()=>null);if(!t.ok)return{ok:!1,reason:`unexpected`};let i=w.safeParse(r);if(!i.success)return{ok:!1,reason:`unexpected`};if(!i.data.existed)return{ok:!0,existed:!1};let a=y.safeParse(i.data.scheme);return a.success?{ok:!0,existed:!0,filename:i.data.filename,scheme:a.data}:{ok:!1,reason:`unexpected`}}catch(e){return $(`delete`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}var Ke=(0,j.createContext)(null);function qe(e){let t=(0,ae.c)(20),{children:n}=e,r=F(),[i,a]=(0,j.useState)(Xe),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(`custom`),[f,p]=(0,j.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={},t[0]=m):m=t[0];let h=(0,j.useRef)(m),g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[1]=g):g=t[1];let[_,ee]=(0,j.useState)(g),v=(0,j.useRef)(0),y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=0,t=null,n=!1,r=null,i,o=[250,1e3,4e3],c=()=>{i!==void 0&&clearTimeout(i),i=void 0},u=()=>{if(t)return n=!0,t;let i=e,o=(async()=>{let t;do{n=!1;let o=v.current,u=new AbortController;r=u;let{authoritative:d,...f}=await Ve({signal:u.signal});if(i!==e)return!1;t=d,d?(c(),o===v.current&&a(f),s(!0),l(!1)):l(!0)}while(n);return t})().finally(()=>{t===o&&(t=null)});return t=o,o};return{refresh:u,startAutomaticRetry:()=>{e+=1;let a=e;r?.abort(),r=null,t=null,n=!1,c();let s=async t=>{let n=await u();a!==e||n||t>=o.length||(i=setTimeout(()=>void s(t+1),o[t]))};return s(0),()=>{a===e&&(e+=1,r?.abort(),r=null,t=null,n=!1,c())}}}},t[2]=y):y=t[2];let[b]=(0,j.useState)(y),x=b.refresh,S;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{let e=new Map,t=(t,n)=>{let r=(e.get(t)??Promise.resolve()).then(n,n),i=r.then(Ye,Je);return e.set(t,i),i.finally(()=>{e.get(t)===i&&e.delete(t)}),r},n=(e,t,n)=>{v.current+=1;let r=Be(e,t);a(t=>({...t,themes:t.themes.some(t=>t.id===e)?t.themes.map(t=>t.id===e?r:t):[...t.themes,r],warnings:t.warnings.filter(t=>t.id!==e&&(n===void 0||t.filename!==n))}))};return{updateTheme:e=>t(e.id,async()=>{let t=await We(e);return t.ok&&n(e.id,e.scheme,t.filename),t}),deleteTheme:e=>t(e,async()=>{let t=await Ge(e);if(t.ok){let t={...h.current,[e]:(h.current[e]??0)+1};h.current=t,ee(t),v.current+=1,a(t=>({...t,themes:t.themes.filter(t=>t.id!==e),warnings:t.warnings.filter(t=>t.id!==e)}))}return t}),restoreTheme:e=>t(e.id,async()=>{let t=await Ue({name:e.name,stem:e.stem,scheme:e.scheme,extension:e.extension});return t.ok&&n(t.id,e.scheme,t.filename),t})}},t[3]=S):S=t[3];let[C]=(0,j.useState)(S),w;t[4]===b?w=t[5]:(w=()=>b.startAutomaticRetry(),t[4]=b,t[5]=w);let T;t[6]!==b||t[7]!==r?(T=[b,r],t[6]=b,t[7]=r,t[8]=T):T=t[8],(0,j.useEffect)(w,T);let E;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(E=function(e){if(e===null){p(!1);return}d(e),p(!0)},t[9]=E):E=t[9];let te=E,D;return t[10]!==n||t[11]!==i||t[12]!==u||t[13]!==c||t[14]!==o||t[15]!==C||t[16]!==x||t[17]!==f||t[18]!==_?(D=(0,j.createElement)(Ke,{value:{...i,loaded:o,loadError:c,refresh:x,...C,editingThemeId:u,themeIncarnations:_,themeEditorOpen:f,selectThemeToEdit:te}},n),t[10]=n,t[11]=i,t[12]=u,t[13]=c,t[14]=o,t[15]=C,t[16]=x,t[17]=f,t[18]=_,t[19]=D):D=t[19],D}function Je(){}function Ye(){}function Xe(){return Q(!1)}function Ze(){let e=(0,j.use)(Ke);if(!e)throw Error(`useSavedThemes must be used within <SavedThemesProvider />`);return e}export{ce as C,fe as S,F as T,V as _,Fe as a,de as b,X as c,Ee as d,Te as f,Ne as g,Me as h,Le as i,Y as l,he as m,Ze as n,J as o,we as p,Re as r,Z as s,qe as t,Ae as u,be as v,oe as w,me as x,z as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./bridge-BqL-1MyE.js";function t(e,t){return t===null?e:`${e}:${n(t)}`}function n(t){return e(t)}export{t as n,n as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ReportBugDialogBody-CPjEs_zr.js","./chunk-CYidjpOJ.js","./dist-Nvb76hAm.js","./jsx-runtime-BUgB2tll.js","./react-f2sANaYj.js","./checkbox-CKD8LETI.js","./dist-DTFuvKje.js","./dist-CSCUSbQc.js","./react-dom-DPxgxlDT.js","./dist-DBXmXNZF.js","./dist-CRjqnzU7.js","./check-B2OLRY33.js","./createLucideIcon-DdBzwsHe.js","./minus-DdRxss3A.js","./compiler-runtime-BfE3aGVn.js","./utils-CPqDy6Hr.js","./bundle-mjs-SHeFpKGC.js","./collapsible-BKbszYZV.js","./chevron-right-Bofu4lib.js","./circle-alert-eBm4JPxY.js","./spinner-Bx8xD6f8.js","./bug-report-send-manager-Btm-R8Ei.js","./trace-api-BjgnT4Mc.js","./propagation-api-BP58TooP.js","./contact-email-store-hvqYKCGj.js","./BugReportHistory-BPO915fE.js","./chevron-down-CEv6N8LG.js","./folder-open-COGOeTzI.js","./trash-2-CchZ0T47.js","./badge-DmdA1C7r.js","./dist-BsJYDohW.js","./button-DzgjsZzC.js","./platform-labels-CtgIRyUl.js","./dist-C_FzPxEX2.js","./triangle-alert-BXrUEeRU.js","./schemas-B93JY9Ef.js","./ImageAttachments-By1ZcRNT.js","./tooltip-DBqLYfio.js","./dist-YVu4MRkZ2.js","./floating-ui.dom-DkPPH5vF.js","./dist-CxbWbOvU.js","./paperclip-BHdV1F_7.js","./x-DM2drskU.js","./file-tree-adapter-BeSKxnyg.js","./file-tree-rename-validation-CQF8z42p.js","./file-tree-utils-DUpeRMj2.js","./constants-cc1-Bt4QPTUe.js","./util-doc-name-D-_o-n0R.js","./navigation-targets-DTSxcGor.js","./doc-paths-cEiFVCxr.js","./constants-upload-CVKO8P4d.js","./doc-extensions-CcO7K8uD-B004ggqh.js","./doc-hash-BJkweiX9.js","./input-C-Qm8YDT.js","./textarea-qPZDtk8V.js","./image-attachment-IPVf2vc9.js","./tool-list-format-CS7MZY1Q.js","./acp-thread-protocol-6IlNVy7A.js","./dialog-BJEjKJjL.js","./electron-drag-strip-D9GZhMg_.js","./es2015-Dtr4fzLT.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";var a=e(r(),1),o=i(),s=0,c=0,l=!1,u=null;function d(){if(typeof window>`u`)return()=>{};if(u!==null)return u;let e=new AbortController,t={passive:!0,signal:e.signal};return window.addEventListener(`pointermove`,e=>{s=e.clientX,c=e.clientY,l=!0},t),window.addEventListener(`pointerout`,e=>{e.relatedTarget===null&&(l=!1)},t),u=()=>{e.abort(),l=!1,u=null},u}function f(){return l?{x:s,y:c}:null}var p=n(),m=(0,a.lazy)(()=>t(()=>import(`./ReportBugDialogBody-CPjEs_zr.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]),import.meta.url)),h=1200,g=`[cmdk-root],[data-radix-popper-content-wrapper]`,_=500;function v(){let e=f();if(e===null)return null;let t=document.createElement(`div`);return t.className=`ok-pointer-marker`,t.setAttribute(`aria-hidden`,`true`),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,document.body.append(t),()=>t.remove()}function y(e){let t=(0,o.c)(14),n,r;t[0]===e?(n=t[1],r=t[2]):({launcherBorne:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let i=r===void 0?!1:r,[s,c]=(0,a.useState)(n.open),[l,u]=(0,a.useState)(!1),[d,f]=(0,a.useState)(null),[y,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),T=(0,a.useRef)(0);n.open&&!s&&c(!0);let E,D;if(t[3]!==i||t[4]!==n.crashInvite||t[5]!==n.open?(E=()=>{if(!n.open){u(!1);return}let e=T.current+=1;w(!1);let t=window.okDesktop?.bugReport?.crashDumpAvailability;n.crashInvite===void 0&&typeof t==`function`&&t().then(t=>{T.current===e&&w(t.available)}).catch(x);let r=window.okDesktop?.bugReport?.captureScreenshot;if(typeof r!=`function`||n.crashInvite!==void 0){f(null),u(!0);return}f(null);let a=!1,o=b,s=!1,c=t=>{a||T.current!==e||(a=!0,o(),f(t),S(t!==null&&s),u(!0))},l=setTimeout(()=>{console.warn(`[bug-report] screenshot capture did not settle within ${h}ms; revealing without one`),c(null)},h),d=performance.now(),p=0,m=()=>{if(a||T.current!==e)return;let t=performance.now()-d>=_;if(i&&document.querySelector(g)!==null&&!t){p=requestAnimationFrame(m);return}if(!i){let e=v();e!==null&&(o=e,s=!0)}p=requestAnimationFrame(()=>{a||T.current!==e||r().then(c).catch(e=>{console.warn(`[bug-report] screenshot capture failed:`,e),c(null)})})};return p=requestAnimationFrame(m),()=>{T.current+=1,clearTimeout(l),cancelAnimationFrame(p),o()}},D=[n.open,n.crashInvite,i],t[3]=i,t[4]=n.crashInvite,t[5]=n.open,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,a.useEffect)(E,D),!s)return null;let O=n.open&&l,k;return t[8]!==C||t[9]!==y||t[10]!==n||t[11]!==d||t[12]!==O?(k=(0,p.jsx)(a.Suspense,{fallback:null,children:(0,p.jsx)(m,{...n,open:O,screenshot:d,pointerMarked:y,crashDumpAvailable:C})}),t[8]=C,t[9]=y,t[10]=n,t[11]=d,t[12]=O,t[13]=k):k=t[13],k}function b(){}function x(e){console.warn(`[bug-report] crash-dump availability probe failed:`,e)}function S(){let e=(0,o.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0];let[n,r]=(0,a.useState)(t),i,s;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=window.okDesktop?.terminal;if(typeof e?.cliInstalledMap!=`function`)return;let t=!1,n=()=>{e.cliInstalledMap().then(e=>{t||r(e)}).catch(C)};return n(),window.addEventListener(`focus`,n),()=>{t=!0,window.removeEventListener(`focus`,n)}},s=[],e[1]=i,e[2]=s):(i=e[1],s=e[2]),(0,a.useEffect)(i,s),n}function C(e){console.warn(`[terminal] cliInstalledMap probe failed:`,e)}export{y as n,d as r,S as t};
|
|
@@ -1,17 +0,0 @@
|
|
|
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,nf as f,pf as p,sd as m,yf as h}from"./md-manager-BGnqyqi1-BfETHApY.mjs";import{Eo as g,In as _,Qo as v,Vo as y,Xn as b,Zo as x,dr as ee,is as S,m as C,ma as te,rs as ne}from"./dist-Bxhfiafh.mjs";import{$ as re,A as w,J as ie,M as T,O as E,P as ae,R as oe,T as se,X as D,at as ce,ct as le,d as ue,dt as de,f as fe,it as pe,j as me,k as he,lt as ge,nt as _e,o as ve,rt as ye,tt as be,v as xe,w as Se,x as Ce,y as we}from"./init-B3hJPfM5.mjs";import{t as Te}from"./is-object-BGze3w87.mjs";import{t as Ee}from"./removal-file-path-Cu5dq8q6.mjs";import{spawn as De}from"node:child_process";import{basename as O,dirname as k,join as A,resolve as j,win32 as Oe}from"node:path";import{accessSync as ke,constants as M,existsSync as N,lstatSync as P,mkdirSync as Ae,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as je,rmdirSync as Me,statSync as R,unlinkSync as Ne}from"node:fs";import{homedir as z}from"node:os";import{createHash as Pe}from"node:crypto";import{isDeepStrictEqual as Fe}from"node:util";import{setTimeout as Ie}from"node:timers/promises";var Le=s();let Re;function ze(){return Re}function Be(e,t){if(t!==void 0&&t.length>0)return t;try{return ee(e)?.rootPath}catch{return}}function Ve(e){let t=Be(e.cwd,e.configuredProjectName),n=_({name:`cli`,project:t});return Re=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function B(){return i(a)}function V(){return d().keyringService}function H(e){try{e()}catch{}}var He=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(V(),e).getPassword()}catch(t){return H(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return H(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return H(()=>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(V(),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(V(),e).deletePassword()}catch{}}},U=class{backend=`file`;authFile;constructor(e){this.authFile=e??A(v(),`auth.yml`)}read(){if(!N(this.authFile))return{};try{let e=F(this.authFile,`utf-8`);return(0,Le.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=k(this.authFile);N(t)||Ae(t,{recursive:!0,mode:448}),x(this.authFile,(0,Le.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)}},Ue=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 ${B()} 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 We(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(V(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
|
-
`),H(()=>t?.onBackendSelected?.({backend:`keyring`})),new Ue(new He(t?.onKeychainRead),new U(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${B()}) — OS keychain unavailable: ${r}\n`),H(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new U(e)}}function Ge(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 (${B()})\n`),r(new U(e))},n)});try{return await Promise.race([We(e),r])}catch{return new U(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Ke(e){let t=Ge(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function qe(e){let t=Ge(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 Je(e,t){let n=[],r=new U(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(V(),`__probe__`);let r,a=await new He(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(V(),e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function Ye(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Xe(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function Ze(e){return g({detached:!0,stdio:`ignore`,shell:!1,env:Ye(e)})}function Qe(e,t,n={}){let r=(n.spawn??De)(e,[...t],Ze(n.env??process.env));return r.unref(),r}function $e(e,t,n={}){let r=n.spawn??De,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],Ze(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Xe(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Xe(e))}})}const et=p.stable.appId,W=[p.stable,p.beta];function tt(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return R(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function nt(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}let t=e.homeDir??z();for(let n of W)for(let r of[A(t,`Applications`),`/Applications`]){let t=A(r,`${n.productName}.app`);if(rt(e,A(t,`Contents`,`MacOS`,n.productName)))return t}return null}function rt(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function it(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&W.find(t=>e.execPath.toLowerCase().endsWith(`\\${h(t).toLowerCase()}`)))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of W)for(let r of l(n)){let i=Oe.join(t,`Programs`,r,h(n));if(rt(e,i))return i}return null}function at(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&W.find(t=>e.execPath.endsWith(`/${t.linuxExecutableName}`)))return e.execPath;for(let t of W){let n=`/opt/${t.productName}/${t.linuxExecutableName}`;if(rt(e,n))return n}return null}function ot(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?nt(e):e.platform===`win32`?it(e):at(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(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`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function st(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)");let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}if(r===`darwin`){Qe(`open`,[`-a`,i],{spawn:e.spawn});return}Qe(i,[],{spawn:e.spawn})}function ct(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 G(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 lt(e){return Pe(`sha256`).update(e).digest(`hex`)}function K(e){return A(v(j(e)),`pi-trust`)}function ut(e,t){return A(K(e),lt(j(t)))}function dt(e,t,n){return A(ut(e,t),`${lt(n)}.json`)}var q=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${G(e)} ${G(t)}; ${G(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function J(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 q(e,`could not ${t}: ${i}`,a,n)}function Y(e){let t;try{t=P(e)}catch(t){if(t.code===`ENOENT`)return!1;throw J(e,`be inspected`,t)}if(!t.isDirectory())throw new q(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function ft(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function pt(e,t){if(!Te(e)||!ft(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==j(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==j(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==j(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!Te(e.previous))throw new q(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&&ft(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&ft(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new q(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 mt(e,t,n){let r;try{r=P(n)}catch(e){throw J(n,`be inspected`,e)}if(!r.isFile())throw new q(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=F(n,`utf8`)}catch(e){throw J(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new q(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=pt(a,n);if(o.cwd!==j(t)||n!==dt(e,t,o.canonicalTrustPath))throw new q(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 ht(e,t){let{record:n,path:r}=t;for(let t of[K(e),ut(e,n.cwd)])if(!Y(t))throw new q(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=mt(e,n.cwd,r);if(!Fe(i.record,n))throw new q(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function gt(e,t,n,r,i){let a={version:1,cwd:j(t),configuredTrustPath:j(n),canonicalTrustPath:j(r),state:`pending`,previous:i},o=dt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Fe(pt(JSON.parse(s),o),a))throw new q(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);Y(K(e)),Y(k(o));try{Ae(k(o),{recursive:!0,mode:448})}catch(e){throw J(k(o),`be created`,e)}let c;try{c=P(o,{throwIfNoEntry:!1})}catch(e){throw J(o,`be inspected`,e)}if(c)throw new q(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{x(o,s,{mode:384})}catch(e){throw J(o,`be written`,e)}return{path:o,record:a}}function _t(e,t){let n=ht(e,t);if(n.record.state!==`pending`)throw new q(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 J(n.path,`be committed`,e)}return{path:n.path,record:r}}function X(e,t){if(!Y(K(e)))return[];let n=ut(e,t);if(!Y(n))return[];let r;try{r=I(n).sort()}catch(e){throw J(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>mt(e,t,A(n,r)))}function Z(e,t){let n=ht(e,t);try{Ne(n.path)}catch(e){throw J(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),K(e)])try{Me(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw J(t,`be removed after reconciling its grant`,e)}}var vt=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`)}}})),yt=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())}}})),bt=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}})),xt=n(((t,n)=>{var r=e(`fs`),i=vt(),a=yt(),o=bt(),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
|
-
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=te,e.createWriteStream=ne;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);x=g.ReadStream,S=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=ee);var v=e.WriteStream;v&&(S.prototype=Object.create(v.prototype),S.prototype.open=C),Object.defineProperty(e,"ReadStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(e){S=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ee(){var e=this;w(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 S(e,t){return this instanceof S?(v.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function C(){var e=this;w(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function te(t,n){return new e.ReadStream(t,n)}function ne(t,n){return new e.WriteStream(t,n)}var re=e.open;e.open=w;function w(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 re(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))}}})),St=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}})),Ct=n((e=>{var t=St();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}}})),wt=n(((e,t)=>{t.exports=Ct()})),Tt=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`)})),Et=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=Tt(),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)}}})),Dt=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})),Ot=n(((t,n)=>{let r=e(`path`),i=xt(),a=wt(),o=Et(),s=Dt(),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})),kt=n(((e,t)=>{let n=xt();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}})),At=t(n(((e,t)=>{let n=Ot(),{toPromise:r,toSync:i,toSyncOptions:a}=kt();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 jt=5e3;function Mt(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 ${jt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Nt(e,t){ze()?.warn(t,e)}function Pt(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 Ft(e,t,n){await ne(`${t}.ok.lock`,async()=>{let t=performance.now()+jt,r;for(;;)try{r=await At.default.lock(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ie(Mt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Pt(i,e)},{onWarn:Nt})}function It(e,t,n){S(`${t}.ok.lock`,()=>{let t=performance.now()+jt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=At.default.lockSync(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Mt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Pt(a,e)},{onWarn:Nt})}const Lt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Rt=class extends Error{name=`PiResourceInspectionError`};function zt(e){let t;try{t=P(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=R(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Rt(me(`missing-symlink-target`),{cause:e}):e}return ke(e,M.R_OK|(n.isDirectory()?M.X_OK:0)),!0}function Bt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Vt(e,t,n){let r=e;try{let i=L(e),a;r=t;try{a=L(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=j(t)}let o=A(a,`.agents`,`skills`),s=[];for(let e of Lt)r=A(i,`.pi`,e),zt(r)&&s.push(r);if(r=A(i,`.pi`,`extensions`),zt(r))for(let t of I(r).sort()){let i=A(r,t);j(n)!==A(j(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[A(i,`.pi`,`skills`),A(i,`.agents`,`skills`)])if(e!==o&&(r=e,zt(e)))for(let t of I(e).sort())Bt(t)||s.push(A(e,t));let c=k(i);for(;c!==i;){r=A(c,`.agents`,`skills`),r!==o&&zt(r)&&s.push(r);let e=k(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 ${G(r)}: ${e instanceof Rt?e.message:me(T(e))}`}}}function Ht(e,t,n){let r=j(e),i=le({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:D.pi.projectConfigPath(r),trustPath:A(i,`trust.json`)}}function Ut(e){try{let t=L(e);return R(t).isDirectory()?(ke(t,M.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${G(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${G(e)} could not be resolved or accessed: ${G(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Wt(e){let t=Ut(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${G(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function Gt(e,t,n){let r=ve(D.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 ye(i)?{state:`own-current`,text:a}:se(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function Kt(e,t){let n;try{n=F(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:T(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 Te(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
|
-
`)}:{state:`unreadable`,reason:`invalid-json`}}function qt(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 me(e)}}function Q(e,t){return{kind:`refused`,error:`trust store ${G(e)}: ${qt(t)}`}}function Jt(e){let t=Ee(e);try{switch(t.kind){case`declined`:return Q(e,t.reason);case`ready`:return{kind:`ready`,path:L(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=k(e),r=[O(e)],i=P(n,{throwIfNoEntry:!1});for(;!i;){let t=k(n);if(t===n)return Q(e,`unavailable-root`);r.unshift(O(n)),n=t,i=P(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:A(L(n),...r)}}catch(t){return Q(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:T(t))}}catch(t){return Q(e,T(t))}}function Yt(e,t){let n=Jt(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Q(e,`path-changed`):n}function Xt(e,t,n){let r=Ht(e,t,n),i=Ut(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=Gt(r.cwd,r.bridgePath,t).state,o=Jt(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:Kt(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:Zt(r.bridgePath).displayNames}}function Zt(e){let t=k(e),n=O(e);try{return{displayNames:I(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>G(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function Qt(e,t={mode:`published`},n,r,i){let a=Ht(e,n,r),o=Ut(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 ${G(i)} no longer matches the current directory ${G(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=Gt(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=Se(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=we(D.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}`:G(e.error)}}let l=await $t(a.trustPath,o.project,n??z());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function $t(e,t,n){let r=t.canonical,i=Jt(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Ae(k(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:G(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ft(e,i.path,()=>{let o=Wt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=Yt(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=Kt(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Q(e,c.reason).error;return}let l=$(n,()=>{let t=X(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&Z(n,t),gt(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?`
|
|
5
|
-
`:``),f=E(s.path);x(s.path,d,f===void 0?void 0:{mode:f}),$(n,()=>_t(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:G(e instanceof Error?e.message:String(e))}}return a}function en(e){let t=[],n=e;try{for(;;){if(P(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=L(n);return R(e).isDirectory()?(ke(e,M.X_OK),A(e,...t)):void 0}let e=k(n);if(e===n)return;t.unshift(O(n)),n=e}}catch{return}}function tn(e){let t={"not-present":0,removed:1,"kept-unowned":2,"kept-shared":3,"kept-unverified":4,"refused-unreadable":5,failed:6},n=e.reduce((e,n)=>t[n.action]>t[e.action]?n:e,{action:`not-present`}),r=e.flatMap(e=>e.error??[]),i=e.flatMap(e=>e.detail??[]);return r.length>0?{action:n.error===void 0?`failed`:n.action,error:[...r,...i].join(`
|
|
6
|
-
`)}:n.detail===void 0?n:{...n,detail:i.join(`
|
|
7
|
-
`)}}function nn(e,t,n,r={}){let i=Ht(e,t,n),a=t??z(),o=Ut(i.cwd),s=o.kind===`refused`&&r.recordedOnly?en(i.cwd):void 0,c=o.kind===`ready`?o.project.canonical:s,l;try{l=$(a,()=>{let e=X(a,i.cwd);return c===void 0||c===i.cwd?e:[...X(a,c),...e]})}catch(e){return{action:`failed`,error:G(e instanceof Error?e.message:String(e))}}if(l.length===0&&r.recordedOnly)return o.kind===`ready`||s!==void 0?{action:`not-present`}:{action:`kept-unverified`,error:`${o.error}. OpenKnowledge could not verify whether this path refers to a project with recorded Pi trust; cleanup was left pending. Retry once the project path can be resolved to check again.`};if(o.kind===`refused`){if(l.length===0)return{action:`kept-unverified`,error:o.error};let e=l.map(({path:e,record:t})=>`key ${G(JSON.stringify(t.cwd))}; configured store ${G(JSON.stringify(t.configuredTrustPath))}; recorded destination ${G(JSON.stringify(t.canonicalTrustPath))}; ownership record ${G(JSON.stringify(e))} (${t.state})`);return{action:`kept-unverified`,error:[`${o.error}. OpenKnowledge kept these Pi trust ownership records; current trust decisions were not checked:`,...e,`To review manually, close Pi, verify the intended store against its recorded destination, and inspect only the exact key. A pending record does not prove setup completed or ownership of a current grant. If you choose to undo a current true decision, restore the recorded previous value, or remove that key only when no previous entry was recorded. Preserve other current decisions; parent-folder and global trust settings still apply.`].join(`
|
|
8
|
-
`)}}let u=Vt(o.project.canonical,a,D.pi.projectConfigPath(o.project.canonical));if(u.kind===`unreadable`)return{action:`kept-unverified`,error:u.error};let d=u.kind===`shared`?u.paths:[],f=[],p=new Map,m=(e,t)=>{let n=p.get(e);if(!n){let t=Jt(e);if(t.kind===`refused`){f.push({action:`refused-unreadable`,error:t.error});return}n={trustPath:e,resolved:t,keys:new Map},p.set(e,n)}if(t){if(n.resolved.path!==t.record.canonicalTrustPath){f.push({action:`refused-unreadable`,error:`Pi trust store ${G(e)} no longer points to its recorded destination ${G(t.record.canonicalTrustPath)}; restore the intended file location or symlink, then retry`});return}n.keys.set(t.record.cwd,{cwd:t.record.cwd,mode:`recorded`,receipt:t})}};for(let e of l)m(e.record.configuredTrustPath,e);m(i.trustPath);for(let e of p.values()){for(let t of[o.project.canonical,i.cwd])e.keys.has(t)||e.keys.set(t,{cwd:t,mode:`inspect`,receipt:l.find(n=>n.record.cwd===t&&n.record.canonicalTrustPath===e.resolved.path)});f.push(rn(e,a,d,o.project))}return tn(f)}function $(e,t){try{return t()}catch(t){throw t instanceof q?t:Error(`Could not access OpenKnowledge's Pi trust ownership records at ${G(A(v(e),`pi-trust`))}: ${G(t instanceof Error?t.message:String(t))}. Check the records and their permissions, then retry.`,{cause:t})}}function rn(e,t,n,r){let{trustPath:i,resolved:a}=e,o=[...e.keys.values()];if(!o.some(e=>e.mode===`recorded`)&&a.kind===`missing`)return{action:`not-present`};if(a.kind===`missing`)try{P(k(a.path))}catch(e){return{action:`failed`,error:`The recorded Pi trust directory ${G(k(a.path))} is unavailable: ${G(e instanceof Error?e.message:String(e))}. Restore access to its parent directory or mounted drive, then retry; the ownership record was kept.`}}let s=[],c={result:{action:`not-present`}};try{It(i,a.path,()=>{let e=Wt(r);if(e){c.result={action:`kept-unverified`,error:e};return}let l=Yt(i,a);if(l.kind===`refused`){c.result={action:`refused-unreadable`,error:l.error};return}let u=Kt(l,r.canonical);if(u.state===`unreadable`){c.result={action:`refused-unreadable`,error:Q(i,u.reason).error};return}let d=o.map(e=>({cwd:e.cwd,mode:e.mode,expectedConfiguredPath:e.receipt?.record.configuredTrustPath,receipt:$(t,()=>X(t,e.cwd).find(e=>e.record.canonicalTrustPath===l.path))}));if(d.some(e=>e.receipt&&e.receipt.record.configuredTrustPath!==e.expectedConfiguredPath)){c.result={action:`failed`,error:`The Pi trust ownership record changed during cleanup; retry to read its current location.`};return}for(let e of d){try{an(e,t,i,l.path,u,n,r,c)}catch(t){let n=G(t instanceof Error?t.message:String(t)),r=t instanceof q?``:`; retry to check its current state.`;s.push({action:`failed`,error:`Pi trust entry ${G(JSON.stringify(e.cwd))} in ${G(i)} could not be reconciled: ${n}${r}`})}s.push(c.result),c.result={action:`not-present`}}})}catch(e){s.push({action:`failed`,error:G(e instanceof Error?e.message:String(e))})}return tn([...s,c.result])}function an(e,t,n,r,i,a,o,s){let{cwd:c,receipt:l}=e;if(i.entries[c]!==!0){l&&e.mode===`recorded`&&$(t,()=>Z(t,l)),s.result={action:`not-present`};return}let u=`To remove this grant manually, close Pi and remove only the ${G(JSON.stringify(c))} entry from ${G(n)}; parent-folder and global trust settings still apply.`;if(a.length>0&&c===o.canonical){let n=`kept Pi's folder trust because other resources still need it: ${a.slice(0,3).map(e=>G(JSON.stringify(e))).join(`, `)}${a.length>3?` (+${a.length-3} more)`:``}. ${u} Removing this grant may stop Pi from loading those resources, including any not listed here.`;s.result={action:`kept-shared`,detail:n},l&&e.mode===`recorded`&&$(t,()=>Z(t,l)),s.result={action:`kept-shared`,detail:`${n} ${l?e.mode===`recorded`?`OpenKnowledge has relinquished this grant and will not revoke it on later cleanup runs.`:`OpenKnowledge kept the existing ownership record; cleanup of its recorded location remains incomplete.`:`OpenKnowledge has no ownership record for this grant and will not revoke it on later cleanup runs.`}`};return}if(e.mode===`inspect`||!l||l.record.state===`pending`){let e=l?l.record.state===`pending`?`its ownership record is pending after an interrupted setup; completion cannot be verified. Re-running setup or cleanup does not reconcile this record while the folder remains trusted.`:`OpenKnowledge must reconcile its recorded location at ${G(l.record.configuredTrustPath)} before removing it.`:`no OpenKnowledge ownership record exists; this includes every grant made before ownership recording was introduced.`;s.result={action:`kept-unowned`,detail:`${c===o.canonical?`kept Pi's folder trust because ${e}`:`kept a Pi trust entry under a non-canonical project path because ${e} Pi uses the real project directory instead of this key.`} ${u}`};return}let d={...i.entries};l.record.previous.present?d[c]=l.record.previous.value:delete d[c];let f=JSON.stringify(d,null,2)+(i.trailingNewline?`
|
|
9
|
-
`:``),p=E(r);x(r,f,p===void 0?void 0:{mode:p}),i.entries=d,$(t,()=>Z(t,l)),s.result={action:`removed`}}function on(e){return ye(e)||pe(e)||se(e)}const sn=10485760;function cn(e,t,n,r=!1){let i=nn(e,t,n,{recordedOnly:r});switch(i.action){case`removed`:case`not-present`:return{trust:i.action};case`kept-shared`:case`kept-unowned`:return{trust:i.action,trustDetail:i.detail};case`failed`:case`refused-unreadable`:case`kept-unverified`:{let e=r?`Trust cleanup remains incomplete`:`The bridge file was left untouched`;throw Error(`Pi trust cleanup failed (${i.action}):\n${i.error}\n${e} so cleanup can be retried.`)}default:throw Error(`unhandled Pi trust cleanup result: ${i}`)}}function ln(e,t,n,r){if(e.id!==`pi`)return{kind:`not-present`};let i=cn(t,n,r,!0);return i.trust===`not-present`?{kind:`not-present`}:{kind:`removed`,...i}}function un(e,t,n,r,i){let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=Ee(a);if(o.kind===`not-present`)return ln(e,t,n,i);if(o.kind===`declined`)return o;let s=ve(e,t,n,o.path);if(s.kind===`absent`||s.kind===`no-entry`)return ln(e,t,n,i);if(s.kind===`decline`)return{kind:`declined`,reason:s.reason};if(!on(s.entry))return{kind:`left-foreign`};let c=e.serverName(t);if(e.format===`file`){let e=cn(t,n,i);try{je(a,{force:!0})}catch(t){throw e.trustDetail?Error(`${t instanceof Error?t.message:String(t)}\n${e.trustDetail}`,{cause:t}):t}return{kind:`removed`,...e}}return e.format===`toml`?pn(o.path,c):e.format===`yaml`?fn(o.path,e.topLevelKey,c):dn(o.path,e.topLevelKey,e.serverMapSubKey,c)}function dn(e,t,n,r){let i;try{i=F(e,`utf-8`)}catch(e){return{kind:`declined`,reason:T(e)}}if(Buffer.byteLength(i,`utf-8`)>sn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=w(i,xe(t,n,r));return o?(x(e,a,{mode:E(e)}),{kind:`removed`}):{kind:`not-present`}}function fn(e,t,n){let r;try{r=F(e,`utf-8`)}catch(e){return{kind:`declined`,reason:T(e)}}if(Buffer.byteLength(r,`utf-8`)>sn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Le.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=he(a);a.trim()===``||a.endsWith(`
|
|
10
|
-
`)?c.endsWith(`
|
|
11
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
12
|
-
`).replace(/\n/g,`\r
|
|
13
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&x(e,u,{mode:E(e)}),{kind:`removed`}}function pn(e,t){let n=de();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=F(e,`utf-8`)}catch(e){return{kind:`declined`,reason:T(e)}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=he(a),s=a.trim()===``||a.endsWith(`
|
|
14
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
15
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
16
|
-
`).replace(/\n/g,`\r
|
|
17
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&x(e,u,{mode:E(e)}),{kind:`removed`}}function mn(e,t){let n=u[e];return n===null?null:A(t,...n.split(`/`),C.discovery,`SKILL.md`)}function hn(e,t){let n=mn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!b(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=te(`discovery`,{checkDesktop:!0});return ae(k(n),t),{editorId:e,label:e,action:oe(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function gn(e){return N(A(e,...`.agents/skills`.split(`/`),C.discovery))?!0:c.some(t=>{let n=mn(t,e);return n!==null&&N(k(n))})}function _n(e,t){let n=mn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=k(n);try{return N(n)?(ae(r,t),je(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function vn(e){return e===`opencode`?ce:_e}function yn(e,t,n){let r=D[e],i=vn(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=fe(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function bn(e,t,n=[]){let r=N(A(e,C[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function xn(e,t){let n=ie.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=f.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:o}));return[...n,...r]}function Sn(e,t,n,r){let i=y(e,xn(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function Cn(e,t){let n=(t??z()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function wn(e,t){let n=D[e];return Ce(n,``,t)&&!ue(n,``,t)}function Tn(e,t,n,r,i){let a=D[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?Cn(o,r):void 0,c=ve(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&wn(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];ye(r)&&i.push(`reclaim-permissive`),pe(r)&&i.push(`pre-approval-exact`),vn(e)(r)&&i.push(`injection-functional`);let o=re(a,n);return i.length>0&&(o!==null&&be(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:ge(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function En(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let i=m(e.pathId);if(i===null)return null;if(i.kind===`central-skill-store`)return n===void 0?null:bn(A(n,o),`discovery`,Sn(n,u,e.agent,`global`));let a=i.editor;switch(i.kind){case`editor-user-skill-root`:{let e=u[a];return e===null||n===void 0?null:b(n).some(e=>e.editorId===a)?bn(A(n,e),`discovery`,Sn(n,u,a,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=r[a];return e===null?null:bn(A(t,e),`project`,Sn(t,r,a,`project`))}case`editor-user-config`:return Tn(a,e.strictness,t,n);case`editor-project-config`:{let r=D[a].projectConfigPath?.(t);return r===void 0?null:Tn(a,e.strictness,t,n,r)}}}}export{Ve as S,Je as _,hn as a,qe as b,Xt as c,ot as d,st as f,B as g,$e as h,gn as i,et as l,Qe as m,yn as n,un as o,ct as p,_n as r,Qt as s,En as t,tt as u,We as v,ze as x,Ke as y};
|
package/dist/src-BVjWHtw1.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BfETHApY.mjs";import"./src-Dhm5e2Py.mjs";import"./init-B3hJPfM5.mjs";import"./registry-probes-f66-hGoh.mjs";import"./start-CffJVe15.mjs";import{n as e}from"./loader-C4DvYgf3.mjs";import"./preview-SXFixlwu.mjs";import"./repair-mcp-configs-B99J1tHK.mjs";export{e as loadConfig};
|
package/dist/src-Dhm5e2Py.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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,u as te,vf as m,xf as h}from"./md-manager-BGnqyqi1-BfETHApY.mjs";import{Eo as g,Fi as _,Pi as v,Qo as y,Sa as b,Zn as x,_i as S,ai as C,di as w,dr as T,es as E,kt as D,m as O,ns as k,sr as A,ts as j,vi as M,wr as N,xs as P,yi as ne}from"./dist-Bxhfiafh.mjs";import{t as F}from"./yazl-BBz29IQN.mjs";import{Ct as I,ot as re,st as ie}from"./init-B3hJPfM5.mjs";import{l as ae,x as oe}from"./registry-probes-f66-hGoh.mjs";import{c as se}from"./colors-r_owlCuY.mjs";import{t as ce}from"./is-object-BGze3w87.mjs";import{n as le}from"./constants-D6yB-BzW.mjs";import"./loader-C4DvYgf3.mjs";import"./preview-SXFixlwu.mjs";import{execSync as ue,spawnSync as de}from"node:child_process";import{basename as L,dirname as R,isAbsolute as fe,join as z,relative as pe,resolve as B,sep as V}from"node:path";import{closeSync as me,cpSync as he,createWriteStream as ge,existsSync as H,lstatSync as _e,mkdirSync as U,mkdtempSync as ve,openSync as ye,readFileSync as W,readSync as be,readdirSync as G,readlinkSync as xe,realpathSync as Se,rmSync as K,rmdirSync as Ce,statSync as we,writeFileSync as q}from"node:fs";import{arch as Te,freemem as Ee,homedir as J,hostname as De,platform as Oe,release as ke,tmpdir as Ae,totalmem as je,type as Me,uptime as Ne}from"node:os";import"node:fs/promises";import{createHash as Pe}from"node:crypto";function Fe(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 Ie(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Fe([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=Fe(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Le(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 Re=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function ze(e,t,n=T){if(e!==void 0&&!Re.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Be=null;function Ve(e){Be=e}function He(){return Be??process.cwd()}const Ue=`Open Knowledge`;function We(e={}){let t=e.platformName??process.platform,n=e.productName??f().productName;return re(t).join(ie({...e,platformName:t}),n)}function Ge(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=re(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 Ke(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 qe(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ke(n)??[]}function Je(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Ke(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Ye=8192;function Xe(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function Ze(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Qe=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function $e(e){return e.replace(Qe,`$1"[REDACTED-DEVICE-ID]"`)}function et(e){return $e(Ze(e))}const tt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function nt(e){if(typeof e!=`string`)return null;let t=tt.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 rt(e){let t=ye(e,`r`);try{let e=Buffer.alloc(Ye),n=0,r=!1;for(;n<Ye;){let i=be(t,e,n,Ye-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{me(t)}}function it(e){try{let t=rt(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:nt(a)}}catch{return{kind:`unreadable`}}}function at(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function ot(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=we(n).mtimeMs}catch{continue}if(r<i)continue;let c=it(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!at(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}function Y(){return z(y(),`bug-reports`)}function st(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Y(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function ct(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function lt(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?Pe(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function ut(){let e={timestamp:new Date().toISOString(),platform:Oe(),osType:Me(),osRelease:ke(),hostname:`[redacted]`,uptime:Ne(),freeMem:Ee(),totalMem:je(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ue(`sw_vers -productVersion 2>/dev/null`,g({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const dt=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function ft(e){let t=L(e);return dt.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function pt(e,t){return _t(e,t).files}const mt=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ht(e,t=ae){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return mt.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>z(n,e.entry)))}function gt(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-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=>z(e,t))}catch{return[]}}function _t(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(ft),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!ft(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function vt(e){let n=z(e,`.ok`,`local`);return H(n)?{files:[`server.lock`,`last-spawn-error.log`,t,s].map(e=>z(n,e)).filter(e=>H(e))}:{files:[]}}function yt(e){let t=z(e,`.ok`,`local`,`logs`);return H(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function bt(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Pe(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function xt(e){let t=e.revealDocNames?e.content:bt(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=W(t,`utf8`);xt({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?et(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 St(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??z(y(),`logs`),s=t.projectDir?lt(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=ut();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=_t(s,o),{files:d}=t.projectDir?vt(t.projectDir):{files:[]},{files:f}=t.projectDir?yt(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=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=ct(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&xt({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let b=new Set(m.map(e=>`diagnostic-reports/${L(e)}`)),x=g.filter(e=>b.has(e)),S=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(t.diagnosticReports,x.length);v.addBuffer(Buffer.from(`${S}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`);let C=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(C,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let w={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(w,null,2),`utf8`),`MANIFEST.json`);let T=h.reduce((e,t)=>e+t.lineCount,0),E=new Set(p.map(e=>`logs/${L(e)}`)),D=g.filter(e=>E.has(e)),O=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${L(e)}`)),k=g.filter(e=>O.has(e)),A=s?g.filter(e=>e.startsWith(`logs/`)&&!ft(e)&&!E.has(e)):[],j=x.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.`]:[],M=j.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...j]:[`Redaction was disabled for this bundle; file contents are unmodified.`],N=[`# Bug Report Bundle`,``,`Generated: ${w.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${w.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...A.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:`,...A.map(e=>`- ${e}`),``]:[],...D.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:`,...D.map(e=>`- ${e}`),``]:[],...x.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:`,...x.map(e=>`- ${e}`),``]:[],...k.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:`,...k.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${ee.join(`, `)}`,T>0?`${T} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...j,``,`This bundle is safe to attach to a GitHub issue.`]:M].join(`
|
|
2
|
-
`);v.addBuffer(Buffer.from(N,`utf8`),`README.md`),v.end();let P=ge(r);return v.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:T},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:g,redactions:h,redactedLineCount:T,generatedAt:w.generatedAt}}}var Ct=c(),wt=e(F(),1),Z=e(se(),1);function Tt(e){let t=k(`user`,e,e);return E({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Et({home:e=J(),env:t=process.env}={}){let n=Tt(e),{override:r,preferenceList:o}=j(t),{locale:s,source:c}=Ie({override:r,storedPreference:n,supportedLocales:a,preferenceList:o,autoDetectableLocales:i});return{preference:n,locale:s,source:c,systemLanguages:o}}function Dt(e){let t=new Set([e]);try{t.add(Se.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function Ot(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function At(e,t){if(typeof e==`string`)return Ot(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>At(e,t));if(!kt(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=At(i,t);return n}function jt(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
3
|
-
`),i=n.split(`
|
|
4
|
-
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=At(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
5
|
-
`)}\n`:a.join(`
|
|
6
|
-
`);q(e,o)}function Mt(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=At(JSON.parse(n),t),i=n.endsWith(`
|
|
7
|
-
`)?`
|
|
8
|
-
`:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Ot(n,t.contentDirSpellings);r!==n&&q(e,r)}}function Nt(e,t){let n=W(e,`utf-8`),r=Ot(n,t.contentDirSpellings);r!==n&&q(e,r)}function Pt(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const Ft=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function It(e){return/\.log\.\d+$/.test(e)}function Lt(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||It(e)}const Rt=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function zt(e){let t={contentDirSpellings:Dt(e.contentDir)};for(let n of Rt)for(let r of Pt(z(e.stagingDir,n)))Lt(r)?jt(r,t):r.endsWith(`.json`)?Mt(r,t):Nt(r,t);for(let n of Pt(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?jt(n,t):Ft.has(e)?Mt(n,t):Nt(n,t)}}const Bt=[`.ok`,`local`,`telemetry`],Vt=[`.ok`,`local`,`logs`],Ht=[`.ok`,`local`,`loss-capture`],Ut=`spans-current.jsonl`,Wt=`spans-prev.jsonl`,Gt=`server-current.jsonl`,Kt=`server-prev.jsonl`,qt=`loss-current.jsonl`,Jt=`loss-prev.jsonl`;function Yt(e){return z(e,...Bt,Ut)}function Xt(e){return z(e,...Bt,Wt)}function Zt(e){return z(e,...Vt,Gt)}function Qt(e){return z(e,...Vt,Kt)}function $t(e){return z(e,...Ht,qt)}function en(e){return z(e,...Ht,Jt)}const tn=1e3;async function nn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}async function rn(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}async function an(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(tn)});return t.ok?await t.text():null}catch{return null}}function on(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
9
|
-
`)}\n`:null}catch{return null}}function sn(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=de(`git`,[`-C`,t,`log`,`--oneline`,`-50`],g({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function cn(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=de(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],g({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ln(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function un(){return{nodeVersion:process.version,platform:Oe(),arch:Te()}}function dn(){return process.env.OTEL_SDK_DISABLED===`false`}function fn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pn(e){if(!H(e))return{};let t;try{t=(0,Ct.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!fn(t))return{};let n=t.telemetry;if(!fn(n))return{};let r=n.localSink;return fn(r)?r:{}}function mn(e){return typeof e==`boolean`?e:void 0}function hn(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function gn(e){if(fn(e))return hn(e.maxBytes)}function _n(e){let t=pn(k(`project`,e)),n=pn(k(`project-local`,e));return{enabled:mn(n.enabled)??mn(t.enabled)??!0,spansMaxBytes:gn(n.spans)??gn(t.spans)??52428800,logsMaxBytes:gn(n.logs)??gn(t.logs)??26214400}}function vn(e){return Pe(`sha256`).update(e).digest(`hex`)}function yn(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const bn=[`"doc.name"`,`"docName"`];function xn(e){let t=W(e,`utf-8`),n=0;for(let e of bn){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,et(W(e,`utf-8`))):he(e,t),!0}catch{return!1}}function Sn(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Cn=new Set([`.jsonl`]);function wn(e){let t=e.lastIndexOf(`.`);return t!==-1&&Cn.has(e.slice(t))}const Tn=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function En(e){if(It(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Tn.has(e.slice(t))}function Dn(e){let t=[];for(let n of Sn(e)){let r=On(e,n);if(!En(r))continue;let{redacted:i,patterns:a,lineCount:o}=u(W(n,`utf-8`));a.length!==0&&(q(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function On(e,t){return pe(e,t).split(V).join(`/`)}async function kn(e){let n=B(e.contentDir),i=B(e.projectDir??e.contentDir),a=e.deps??{},o=a.fetchAgentPresence??nn,c=a.fetchAgentEffects??rn,l=a.fetchWatcherRecent??an,u=a.readShadowHead??sn,d=a.readCheckpointRefs??cn,ee=a.now??(()=>new Date),f=a.okVersion??(()=>le),p=a.readDesktopEnv??ln,m=a.readLanguage??Et,h=a.readRuntime??un,g=a.isOtlpPushEnabled??dn,_=ve(z(Ae(),`ok-bundle-`));try{U(z(_,`telemetry`),{recursive:!0}),U(z(_,`logs`),{recursive:!0}),U(z(_,`state`),{recursive:!0}),Q(Yt(i),z(_,`telemetry`,Ut)),Q(Xt(i),z(_,`telemetry`,Wt)),Q(Zt(i),z(_,`logs`,Gt)),Q(Qt(i),z(_,`logs`,Kt));for(let t of e.userLogFiles??[])Q(t,z(_,`logs`,L(t)));for(let t of e.userStateFiles??[])Q(t,z(_,te,L(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,z(_,`diagnostic-reports`,L(t)))&&(v+=1);let y=z(i,`.ok`,`local`),b=z(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(H(b)){Q(b,z(_,`state`,`server.lock`));try{let e=W(b,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:S=`lock present but no port`}catch{S=`lock present but unparseable`}}if(C!==null){let e=await o(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(q(z(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await c(C);t!==null&&q(z(_,`state`,`agent-effects.json`),t);let n=await l(C);if(n!==null){let e=on(n);e!==null&&q(z(_,`state`,`watcher-recent.jsonl`),e)}}let w=u(n);w!==null&&q(z(_,`state`,`shadow-head.txt`),w);let T=d(n);T!==null&&q(z(_,`state`,`checkpoint-refs.txt`),T),Q($t(i),z(_,`state`,qt)),Q(en(i),z(_,`state`,Jt)),Q(z(y,`last-spawn-error.log`),z(_,`state`,`last-spawn-error.log`)),Q(z(y,r),z(_,`state`,r)),Q(z(y,t),z(_,`state`,t)),Q(z(y,s),z(_,`state`,s));let E=h(),D=p(),O=m(),k={ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};q(z(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
10
|
-
`:`not-running (${S})\n`;q(z(_,`state`,`server-status.txt`),A);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Xe(e.diagnosticReports,v);if(q(z(_,`state`,`diagnostic-reports-status.txt`),`${j}\n`),e.processDir&&H(e.processDir)){let t=z(_,`process`);U(t,{recursive:!0}),he(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&zt({stagingDir:_,contentDir:n}),e.note&&q(z(_,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Dn(_));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!Q(t.sourcePath,z(_,`extra`,e))){a.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=ct(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let P=_n(i),ne=Sn(_),F=[],I=0,re=0;for(let e of ne){let t=On(_,e),n=we(e).size,r=wn(t)?yn(e):0;F.push({path:t,bytes:n,lines:r}),I+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(re+=xn(e))}let ie={applied:M};N!==null&&(ie.secretScrub=N);let ae={schemaVersion:2,createdAt:ee().toISOString(),ok:{version:f(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:vn(n),absolutePath:M?`<CONTENT_DIR>`:n},telemetry:{localSink:P,otlpPushEnabled:g()},redaction:ie,serverStatus:x,files:F};q(z(_,`manifest.json`),`${JSON.stringify(ae,null,2)}\n`);let oe=Dt(n),se=ne.some(e=>{try{let t=W(e,`utf-8`);return oe.some(e=>t.includes(e))}catch{return!1}}),ce={stagedDiagnosticReports:v,totalBytes:I,fileCount:F.length,docNameCount:re,contentDirVisible:se,redacted:M},le=!1;return{stagingDir:_,manifest:ae,summary:ce,cleanup:()=>{le||(le=!0,K(_,{recursive:!0,force:!0}))}}}catch(e){throw K(_,{recursive:!0,force:!0}),e}}async function An(e){let{collected:t,outputPath:n}=e,r=R(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new wt.ZipFile,a=Sn(t.stagingDir);for(let e of a){let n=On(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ge(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function jn(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,Ct.parse)(W(n,`utf-8`)),r=ce(t)?t.content:void 0,i=ce(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return B(e)}async function Mn(e,t,n,r,i){let a=lt(t,e.logger),o=await kn({contentDir:jn(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...pt(a,e.userLogsDir??z(y(),`logs`)),...ht(e.cachesDir??z(J(),`Library`,`Caches`))],userStateFiles:gt(e.bugReportsDir??Y()),diagnosticReports:i,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await An({collected:o,outputPath:e.outputPath});let t=o.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:a,files:o.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:o.manifest.createdAt}}}finally{o.cleanup()}}async function Nn(e){let{projectDir:t}=e,n=e.readDesktopEnv??ln,r=e.readLanguage??Et,i=()=>ot(e.diagnosticReportsDir??z(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Mn(e,t,n,r,i());let{zipPath:a,summary:o}=await St({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:ht(e.cachesDir??z(J(),`Library`,`Caches`)),bugReportLedgerFiles:gt(e.bugReportsDir??Y()),diagnosticReports:e.level===`full`?i():void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=ne(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??N()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??De());if(!a||typeof a!=`object`||!w(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??C)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function Pn(e){return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${e.lockPath} does not record its owning machine, and its recorded process ${e.pid} is still running on this machine. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:`Cannot verify shutdown: the server lock at ${e.lockPath} belongs to another machine. Stop OpenKnowledge on the owning machine. Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e.lockPath} and retry cleanup.`}function Fn(e){return e.replace(/:\d+$/,``)}function In(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Fn(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const Ln=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Rn(e){return l(h(),e)}function zn(){return o(h())}function Bn(){let e=h();if(e===`stable`)return Ln;let t=n(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const Vn={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>_e(e),readlinkSync:e=>xe(e)};function Hn(e,t=Vn){let n=Rn(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function Un(e){let t=e.replace(Bn(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Wn(e,t,n=Vn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Gn=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],Kn=[...D.map(e=>O[e]),`open-knowledge`];function qn(e){if(!fe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Jn(e,t){let n=pe(e,t);if(n.startsWith(`..`)||fe(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!_e(r).isDirectory())return!1}catch{return!1}}return!0}function Yn(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Xn(e){let t=qn(e),n=[],r=[],i=new Set;for(let e of Gn){let a=z(t,e.hostDir,`skills`);if(!Jn(t,a))continue;let o=Kn.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Yn(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Zn(e){try{if(!_e(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Qn(e){let t=new Set,n=new Set;for(let r of Gn){let i=z(e,r.hostDir,`skills`);for(let e of Kn)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function $n(e,t){let n=qn(e),r=Qn(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(Jn(n,e)&&Zn(e))try{K(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Jn(n,e))try{Ce(e),a.push(e)}catch{}return a}function er(e){let t=qn(e),n=[];for(let e of D){let r=O[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of d)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function tr(e,t){let n=[];for(let r of er(e))if(r.bundleId===t)try{K(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function nr(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function rr(e,t=Date.now()){if(e===null)return`—`;let n=Le(e,t);return n===`unknown`?`—`:n}function ir(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function ar(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:ir(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&S(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:A(n),command:n,isDesktop:nr(n)}}function or(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:return`stale`;default:return t}}const sr=new Set([`running`,`desktop`,`foreign`,`unverified`]);function cr(e){switch(e){case`running`:return Z.default.green(e);case`desktop`:return Z.default.blue(e);case`foreign`:return Z.default.cyan(e);case`unverified`:case`stale`:return Z.default.yellow(e)}}function lr(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function ur(e){return`${lr(e.server.usage)} | ${lr(e.ui?.usage??null)}`}function dr(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function fr(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,dr(e),ur(e),or(e),String(e.server.pid),rr(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=cr(or(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=Z.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
11
|
-
`)}async function pr(e={}){let t=e.discover??x,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??v,a=e.resolveUsage??_,o=await t(),s=[];for(let e of o){let t=n(e),r=ar(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:or(e)}));r(JSON.stringify(e,null,2));return}r(fr(e.all?s:s.filter(e=>sr.has(or(e)))))}function mr(){return new I(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await pr({all:t.all===!0||e===`all`,json:t.json===!0})})}async function hr(e,t=oe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=M(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function gr(e,t={}){return{targets:yr(e,t.isAlive??C)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function _r(e){try{return h()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function vr(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??hr,o=e.logger??oe(),s=t(),c=gr(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let l=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof l==`string`&&l.length>0){let t=e.selfChannel??_r(o);if(t!==void 0&&l!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${m(l)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,holderChannel:l,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:l}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let u=[],d=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),u.push(e)}catch(t){d.push({target:e,error:t instanceof Error?t.message:String(t)})}return u.length>0&&r(`Stopped: ${u.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:u.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:d.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),d.length>0&&i(`Failed to stop: ${d.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:u,failed:d,hadTargets:!0}}function yr(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function br(e,t=C){let n=await x(),r=null;for(let i of n){let n=$(i,`server`);if(yr(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function xr(e,t){let n=await vr({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function Sr(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:" — run `ok ps` to list them"}.`}async function Cr(e){let t=await x(),n=0;for(let r of t)r!==e&&yr($(r,`server`),C)&&n++;return n}function wr(e){return new I(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable or Beta) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=b(process.cwd()),n=await vr({lockDir:t,force:r,log:()=>{}});if(n.hadTargets){if(n.stopped.length>0){let e=n.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1)}else{let e=await Cr(t);console.log(Sr(process.cwd(),e,{listingFollows:e>0})),e>0&&await pr({})}return}if(i===`all`){let e=await x();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)yr($(n,`server`),C)&&(await xr(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await br(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await xr(t,r);return}let a=B(He(),i),o=b(a),s=[],c=await vr({lockDir:o,force:r,log:e=>s.push(e)});if((c.failed.length>0||c.declined!==void 0)&&(process.exitCode=1),c.hadTargets)for(let e of s)console.log(e);else console.log(Sr(a,await Cr(o)))})}export{He as A,ot as C,We as D,Ge as E,ze as M,qe as O,Y as S,Ue as T,$ as _,$n as a,An as b,er as c,Rn as d,zn as f,Pn as g,In as h,mr as i,Ve as j,Je as k,Ln as l,Un as m,vr as n,Xn as o,Hn as p,wr as r,tr as s,hr as t,Wn as u,Nn as v,Xe as w,st as x,kn as y};
|
package/dist/start-CffJVe15.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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-BfETHApY.mjs";import{Ni as s,_i as c,es as l,k as u,ns as d,oi as f,ps as p,xi as m}from"./dist-Bxhfiafh.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-B3hJPfM5.mjs";import{a as w,c as T,d as E,f as D,i as ee,n as O,o as k,p as A,r as j,s as M,t as N,u as P,y as te}from"./registry-probes-f66-hGoh.mjs";import{n as F}from"./constants-D6yB-BzW.mjs";import{execFileSync as I,spawn as L}from"node:child_process";import{basename as R,dirname as z,resolve as B}from"node:path";import{existsSync as V,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??I,i=H(t._fileExists??V),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...se.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function W(e,t={}){let n=t._exec??I,r=H(t._fileExists??V),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=ue(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=he(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function ue(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const de=/Logged in to \S+ account (\S+) \(/,fe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,pe=/^\s*-\s*Active account:\s*true\s*$/,me=/\u001b\[[0-9;]*m/g;function he(e){let t=[],n;for(let r of e.split(`
|
|
2
|
-
`)){let e=r.replace(me,``),i=de.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(fe.test(e)){n=void 0;continue}n&&pe.test(e)&&(n.active=!0)}return t}const ge={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){p(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function _e(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function ve(e,t,n,r,i){let a=v[e];try{let o=k(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),_e(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function ye(e,t,n){if(v[e].scope!==`global`)return q();if(n===`absent`)return ve(e,``,t.home,void 0,t.env);let r=(await y({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function be(e,t,n){let r=v[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ve(e,t.cwd,t.home,r,t.env);let i=S(v[e],t.cwd,ge,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function xe(e,t,n){let r=t.home??re();if(n===`absent`){let t=j(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=w(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Se(e,t,n){if(n===`absent`){let n=g(v[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,n.path,n.error),K()}}let r=C(v[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function Ce(e){return t=>{if(t.pathId===void 0)return Y();let n=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=V){let t=import.meta.dirname??new URL(`.`,import.meta.url).pathname;return[B(t,`public`),B(t,`../../app/dist`),B(t,`../../../app/dist`)].find(t=>e(t))}function De(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Oe(e){if(e===`off`)return`off`;if(!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=R(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super("This directory isn't set up yet. Run `ok init` first, then `ok start` again."),this.name=`OkDirMissingError`,this.cwd=e}},Z=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${u}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ok start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?B(e):null}},a=B(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(z(a));o=e===null?null:B(e,R(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&z(o)===s&&R(o).startsWith(`ok-ephemeral-`)}function $(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${u}* 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:u,resolve:d}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:x}=await import(`./dist-BGJh5L15.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?s(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Q(k))throw new Z(k);o(d(k,`.ok`,`config.yml`))||y(k,E)}else k=h(E),A=!0}let j=async()=>{if(!(!A||k===void 0)){if(!Q(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!f(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-B99J1tHK.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-UkFroP68.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(c(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let I=te(),L=m(),R;try{{let e=v(k??n),t=Date.now(),r=await x(e);r!==`no-drain`&&S.info({event:`start-waited-for-draining-predecessor`,outcome:r,waitedMs:Date.now()-t,drainLockDir:e},r===`released`?`[start] predecessor server finished draining — proceeding`:`[start] predecessor server still draining after wait — proceeding to collide`)}R=await p({config:t,contentDir:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:W,tokenStore:I,embeddingsKeyStore:L,mcpTomlEditor:b(),...C?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>O(e,t),probePiAcpBridge:e=>T(e),ensurePiAcpBridge:(e,t)=>M(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:N(e),execute:Ce(e),userSkillPresentAnywhere:ee}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Fe(P===void 0?n:$(n,P),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=A?async()=>{try{await z()}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function Le(e,t,n=()=>l({absPath:d(`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
|
-
`)))}let D=o.port===void 0?void 0:Number(o.port),ee=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=D??ee??s.server?.port,k=De({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Ee}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Ie({config:s,cwd:m,host:C,port:O,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...A?{reactShellDistDir:A}:{},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-BGJh5L15.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=>oe(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ue(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ge(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Be(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`)}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,te=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:F,localUrl:I,networkUrl:te,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(je({openBrowser:o.openBrowser!==!1&&E.openBrowser,explicitOn:o.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:o.singleFile!==void 0,only:o.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-OupsHA1M.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function He(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:c(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`&&ne.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
|
-
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
|
-
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=E(P());if(n.available){D({spawn:L},n);return}console.error(A(n.reason)),process.exit(1)}await Ve(n,t)})}export{Ge as C,W as D,le as E,Ke as S,Fe as T,ze as _,Ue as a,je as b,Q as c,Oe as d,Te as f,Le as g,He as h,Pe as i,We as l,we as m,X as n,Be as o,Ee as p,Ie as r,ke as s,Z as t,Ne as u,De as v,$ as w,Ae as x,Ve as y};
|
package/dist/start-D7BNoa4h.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-CffJVe15.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
/package/dist/public/assets/{ChangedOutsideBadge-BB-SCUmw.js → ChangedOutsideBadge-Dzr-p6dI.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|