@inkeep/open-knowledge 0.86.13-beta.5 → 0.86.13-beta.6
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 +6 -6
- package/dist/constants-QhGcX1jP.mjs +1 -0
- package/dist/{dist-BdWyx3_g.mjs → dist-B-LAoRmW.mjs} +246 -246
- package/dist/{dist-BscgfW_a.mjs → dist-DFHKTwRq.mjs} +1 -1
- package/dist/index.mjs +210 -210
- package/dist/init-DNcF_zUp.mjs +1 -0
- package/dist/{init-1vVkAiot.mjs → init-DsTDW8PN.mjs} +2 -2
- package/dist/{launch-json-removal-DqbFN0dI.mjs → launch-json-removal-C0-wLRJG.mjs} +1 -1
- package/dist/{loader-B9Kr25w_.mjs → loader-B14ip6IN.mjs} +1 -1
- package/dist/loader-CEVDxJIa.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-DK41xNGI.mjs → md-manager-BGnqyqi1-CPATjLIj.mjs} +160 -160
- package/dist/{open-browser-xLmZ24zo.mjs → open-browser-DfTjiF9R.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-CaYt3ZBx.mjs → preview-DCs1uVu5.mjs} +1 -1
- package/dist/preview-DptKn8iO.mjs +1 -0
- package/dist/public/assets/{AccountSection-CSXq4lUU.js → AccountSection-CowlGJFs.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-x9-Msbqr.js → ActivityModeContent-CcroJ-DG.js} +1 -1
- package/dist/public/assets/{ActivityPanelDiffView-D1HNJ0EL.js → ActivityPanelDiffView-EBKh4lfz.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-BuVEdcfe.js → AddPropertiesButton-Ack7vynK.js} +2 -2
- package/dist/public/assets/{AgentDiffPane-CFPz5Dby.js → AgentDiffPane-DiwxFrFb.js} +2 -2
- package/dist/public/assets/{AttachmentsSection-BZny6Oc-.js → AttachmentsSection-85LnQHCB.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-BM4EzAx7.js → CodeMirrorPropInput-UA1el3M1.js} +74 -76
- package/dist/public/assets/{ContentRulesSection-BsD_z17t.js → ContentRulesSection-mTywn1H0.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-D5GzWGIy.js → DiffViewBoundary-G84zg4aW.js} +1 -1
- package/dist/public/assets/{DocumentContext-dfNHh2sO.js → DocumentContext-Bpjsqo1P.js} +29 -29
- package/dist/public/assets/EditorModeToggle-BxZG0GCz.js +1 -0
- package/dist/public/assets/{ExcalidrawDocEditor-DIShhcol.js → ExcalidrawDocEditor-zDA0vdbs.js} +1 -1
- package/dist/public/assets/FeedbackForm-6XiRSy77.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-CwzOlSXW.js → ImportSkillDialog-30iXeyF6.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-CM9TVljO.js → LinkPreviewsSection-Dunim138.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DVvP72Bf.js → LintConfigEditor-DOaH26Y3.js} +1 -1
- package/dist/public/assets/{LintingSection-DHJ4-YoV.js → LintingSection-CR6EIafl.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-BmUZv2uD.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-D7tV0Whc.js → ManagedArtifactProperties-aljVpK04.js} +1 -1
- package/dist/public/assets/{Mermaid-OyqDVkV1.js → Mermaid-DrDUd07u.js} +2 -2
- package/dist/public/assets/{MermaidDocEditor-yB-6imOc.js → MermaidDocEditor-B8TfaHGr.js} +1 -1
- package/dist/public/assets/{MultiFileDiff-B6HXL4Bz.js → MultiFileDiff-BjX5FEfb.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-DQdZArKE.js → NetworkAccessSection-TETzOWD_.js} +1 -1
- package/dist/public/assets/PropertyDisplayRow-PpwMWELQ.js +2 -0
- package/dist/public/assets/{PublishToGitHubDialog-BmrMeByz.js → PublishToGitHubDialog-DHCNHDEf.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-Dy-_PYO_.js → SchemaConfigEditor-LrnwWr8i.js} +1 -1
- package/dist/public/assets/{SearchSection-DJOJRJWx.js → SearchSection-ey8z-UyU.js} +1 -1
- package/dist/public/assets/{SessionsHost-46jyHSQ_.js → SessionsHost-DV3rQaV6.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-hdv9GlF5.js → SettingsDialogBody-Bcv_vYHe.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-BswtkG8U.js → ShareReceiveMissDialog-MpyX-2te.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-C_vd4hTG.js → SkillForkDialog-CizHc05K.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-BLI5ligw.js → SkillOriginInline-BCqN9HRT.js} +2 -2
- package/dist/public/assets/{SkillToolbarControls-zrW5N5UZ.js → SkillToolbarControls-EF87XEf5.js} +1 -1
- package/dist/public/assets/{SkillUpdateConflictDialog-DPXsWJ1y.js → SkillUpdateConflictDialog-CgPPIuYI.js} +1 -1
- package/dist/public/assets/SourceEditor-Dns11FYK.js +1 -0
- package/dist/public/assets/{SyncSection-jC-_KK_s.js → SyncSection-BIbeHZvp.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-m_tTL7nH.js → SyncStatusBadge-DaMofnew.js} +1 -1
- package/dist/public/assets/{TerminalSection-4V4PDe2k.js → TerminalSection-DQWuBL3s.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BtyZIukg.js → TerminalWindowApp-LE6KPay1.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DrTLyQpB.js → TextDocEditor-BcJtDjng.js} +1 -1
- package/dist/public/assets/{ThreadView-py4zdjf-.js → ThreadView-DI-eMUWY.js} +4 -4
- package/dist/public/assets/{TimelineDiffPane-CuO2JpOz.js → TimelineDiffPane-SShlUARz.js} +2 -2
- package/dist/public/assets/{abnfDiagram-N423BO3Z-DI1MOTax.js → abnfDiagram-N423BO3Z-HaE-1SHy.js} +1 -1
- package/dist/public/assets/{architectureDiagram-T3A2C74G-CjnIcTlm.js → architectureDiagram-T3A2C74G-Ccu6kbYe.js} +1 -1
- package/dist/public/assets/{blockDiagram-VBNYF7ZC-CtugLD14.js → blockDiagram-VBNYF7ZC-DdBB9Ln0.js} +1 -1
- package/dist/public/assets/{c4Diagram-5PPSVZJV-jQGQqB7a.js → c4Diagram-5PPSVZJV-BD8BlKWy.js} +1 -1
- package/dist/public/assets/channel-CYnTkHik.js +1 -0
- package/dist/public/assets/{chunk-2GRJ4B5K-BluuBMiQ.js → chunk-2GRJ4B5K-sot9-RGs.js} +1 -1
- package/dist/public/assets/{chunk-3NCLNEKW-J87Pt5Ce.js → chunk-3NCLNEKW-B_jASG33.js} +1 -1
- package/dist/public/assets/{chunk-4I5QYGJK-VLITJA8M.js → chunk-4I5QYGJK-_A5aYnw2.js} +1 -1
- package/dist/public/assets/{chunk-5RXB4S5H-CAUonrKc.js → chunk-5RXB4S5H-DsIiMH6C.js} +1 -1
- package/dist/public/assets/{chunk-6Q2QTUOP-DksP2qPM.js → chunk-6Q2QTUOP-B44d4_I1.js} +1 -1
- package/dist/public/assets/{chunk-7Z6QIM7H-L0nm87vF.js → chunk-7Z6QIM7H-BkSyAoJV.js} +1 -1
- package/dist/public/assets/{chunk-BO2N2NFS-Cu3Zcp58.js → chunk-BO2N2NFS-CA1DMyeT.js} +4 -4
- package/dist/public/assets/{chunk-GF5L2VYU-DIj9Ac3d.js → chunk-GF5L2VYU-BiIl9j28.js} +1 -1
- package/dist/public/assets/{chunk-I66GZJ75-CHQVooIa.js → chunk-I66GZJ75-BBS7pKXH.js} +1 -1
- package/dist/public/assets/{chunk-J7OUQ5F2-BJaftJuu.js → chunk-J7OUQ5F2-Bym5ibCp.js} +2 -2
- package/dist/public/assets/{chunk-JQJVKLGR-Bg0yqFQE.js → chunk-JQJVKLGR-pDr7vdp1.js} +1 -1
- package/dist/public/assets/{chunk-KBJHAD2P-CZyxKjx5.js → chunk-KBJHAD2P-BFdlSWL6.js} +1 -1
- package/dist/public/assets/{chunk-NSK5VX7P-DKFvDLTr.js → chunk-NSK5VX7P-eSc6NYUh.js} +1 -1
- package/dist/public/assets/{chunk-QR6OTTB3-CFQoHy2U.js → chunk-QR6OTTB3-CgpJcD7h.js} +1 -1
- package/dist/public/assets/{chunk-UBXNYLIW-ByzoKB1b.js → chunk-UBXNYLIW-DH4CIV4Z.js} +1 -1
- package/dist/public/assets/{chunk-W5SLKNZC-C55mW624.js → chunk-W5SLKNZC-D-lroYqs.js} +1 -1
- package/dist/public/assets/{chunk-WRU74C26-ButWmYus.js → chunk-WRU74C26-d-2Ia2A3.js} +1 -1
- package/dist/public/assets/classDiagram-JCYQIIEL-YchR3ru9.js +1 -0
- package/dist/public/assets/classDiagram-v2-OCEON4UE-DovRAlnt.js +1 -0
- package/dist/public/assets/{client-version-B3pS4DlA.js → client-version-CdR5OEoA.js} +1 -1
- package/dist/public/assets/cm-theme-DsKCc8Du.js +3 -0
- package/dist/public/assets/{code-highlighter-impl-a2b98fkn.js → code-highlighter-impl-CNu9hCDQ.js} +1 -1
- package/dist/public/assets/{comment-chips-Cjd2SsR0.js → comment-chips-CGV3uBng.js} +3 -3
- package/dist/public/assets/{config-provider-7Po9hSaS.js → config-provider-DyQHdVWH.js} +1 -1
- package/dist/public/assets/{cynefinDiagram-MW4NZA55-BMApxUec.js → cynefinDiagram-MW4NZA55-Bt---2w-.js} +1 -1
- package/dist/public/assets/{dagre-VZM6K2ZE-CWAXiEIi.js → dagre-VZM6K2ZE-DadMRY2W.js} +1 -1
- package/dist/public/assets/{diagram-7IWD3JNH-CGgAPAS_.js → diagram-7IWD3JNH-xND6JtDz.js} +1 -1
- package/dist/public/assets/{diagram-B4RE2ZJO-HTZnbLMJ.js → diagram-B4RE2ZJO-CZVxA6hR.js} +1 -1
- package/dist/public/assets/{diagram-LBJQPF4R-BEqABlrl.js → diagram-LBJQPF4R-rX0Tq4jZ.js} +1 -1
- package/dist/public/assets/{diagram-Q27KOJAE-D0dG7XZ0.js → diagram-Q27KOJAE-nt3g7b0x.js} +1 -1
- package/dist/public/assets/{diagram-UB23O5K3-CN18Hs5e.js → diagram-UB23O5K3-szgv1p93.js} +1 -1
- package/dist/public/assets/dist-Bft6rZTE.js +1 -0
- package/dist/public/assets/{dist-CThTn0n3.js → dist-D3PI74Ez.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-BMGd9jfr.js → doc-undo-manager-BzYAqvBQ.js} +1 -1
- package/dist/public/assets/{ebnfDiagram-BXEA7PRR-e3dD5Nln.js → ebnfDiagram-BXEA7PRR-D6Uvf-oy.js} +1 -1
- package/dist/public/assets/{engine-compile--HhyEWi4.js → engine-compile-BycZLMmD.js} +1 -1
- package/dist/public/assets/{erDiagram-JOGREHBK-szVyqZkn.js → erDiagram-JOGREHBK-DpQfEzzT.js} +1 -1
- package/dist/public/assets/flowDiagram-UKHOOZJN-Bvgmb4Q6.js +1 -0
- package/dist/public/assets/{ganttDiagram-PKOTCBZU-CcKCaoog.js → ganttDiagram-PKOTCBZU-DLwqDN74.js} +1 -1
- package/dist/public/assets/{gitGraphDiagram-DS77QQ5N-iHZmSAWb.js → gitGraphDiagram-DS77QQ5N-Cc5MCrtO.js} +1 -1
- package/dist/public/assets/{highlighted-body-OFNGDK62-iKto6Lag.js → highlighted-body-OFNGDK62-DS7wrpMM.js} +1 -1
- package/dist/public/assets/ime-composition-gK1nUjUW.js +1 -0
- package/dist/public/assets/{index-BXC8xtHm.js → index-BUWsL8h_.js} +10 -10
- package/dist/public/assets/{infoDiagram-6WML65LV-CqhCLrMr.js → infoDiagram-6WML65LV-ChXfRabQ.js} +1 -1
- package/dist/public/assets/{ishikawaDiagram-WSZJBQD7-DqDbu5yX.js → ishikawaDiagram-WSZJBQD7-B0AT-ixb.js} +1 -1
- package/dist/public/assets/{journeyDiagram-NVQOT4AX-wc4iC-J-.js → journeyDiagram-NVQOT4AX-CF-x6pcZ.js} +1 -1
- package/dist/public/assets/{kanban-definition-27J2QSJJ-PXZDaBtc.js → kanban-definition-27J2QSJJ-BphUtkcd.js} +1 -1
- package/dist/public/assets/{lib-TFtgHRaJ.js → lib-BZsAU7Y2.js} +1 -1
- package/dist/public/assets/{lib-QQS1Brzc.js → lib-CY2yz3tg.js} +1 -1
- package/dist/public/assets/{lib-JGveGkyb.js → lib-DoyE8anS.js} +1 -1
- package/dist/public/assets/{line-DR0ZdS7v.js → line-C48bgrw0.js} +1 -1
- package/dist/public/assets/{lint-config-client-sgsQijtd.js → lint-config-client-CCGSFVIS.js} +1 -1
- package/dist/public/assets/{lint-plugins-BT8f0lok.js → lint-plugins-KeEVAAw5.js} +1 -1
- package/dist/public/assets/{markdown-lint-CJY47a4k.js → markdown-lint-Sq_kGPCg.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-CBGOMkmJ.js → markdownlint-rule-browser-dtdwuRgB.js} +1 -1
- package/dist/public/assets/mermaid-GHXKKRXX-CBCytjg2.js +1 -0
- package/dist/public/assets/mermaid.core-BVxpulpZ.js +1 -0
- package/dist/public/assets/{mermaid.core-Bn6Q9XXR.js → mermaid.core-F1GwOUF1.js} +3 -3
- package/dist/public/assets/{mindmap-definition-FAOFIHXS-CcvQ-MXn.js → mindmap-definition-FAOFIHXS-FCm0u13z.js} +1 -1
- package/dist/public/assets/{pegDiagram-VL7TDLO6-CgYLYwO0.js → pegDiagram-VL7TDLO6-BbT62SD0.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-B5YFCfmA.js → pending-receive-nav-store-tATiLz5K.js} +1 -1
- package/dist/public/assets/{pieDiagram-7S7Q4E2Y-CQIjti_a.js → pieDiagram-7S7Q4E2Y-BJNWjsh4.js} +1 -1
- package/dist/public/assets/{pierre-theme-DvUAgu98.js → pierre-theme-C-t7fYw4.js} +1 -1
- package/dist/public/assets/{preferred-session-events-BaHzKMnN.js → preferred-session-events-D23QukOQ.js} +1 -1
- package/dist/public/assets/{prod-CLa_vJbk.js → prod-CxRC-Qp7.js} +4 -4
- package/dist/public/assets/{progress-BH9xaz2e.js → progress-DqKVGUPv.js} +4 -4
- package/dist/public/assets/{quadrantDiagram-CIZ2JOQS-DuNJGeBa.js → quadrantDiagram-CIZ2JOQS-CIAFe2Yx.js} +1 -1
- package/dist/public/assets/{railroadDiagram-AXF67PYL-C85uSObP.js → railroadDiagram-AXF67PYL-z8dJWtZ0.js} +1 -1
- package/dist/public/assets/{requirementDiagram-LRYGKXZP-BXrpr1j3.js → requirementDiagram-LRYGKXZP-BLUmU7lf.js} +1 -1
- package/dist/public/assets/{sankeyDiagram-W5VNT64P-DzYrkeo7.js → sankeyDiagram-W5VNT64P-DwOYO9rY.js} +1 -1
- package/dist/public/assets/{selection-context-ByuyXymU.js → selection-context-C7GkLjF6.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-SI44F4Z6-Cf6wHWjC.js → sequenceDiagram-SI44F4Z6-CaFn_mL8.js} +1 -1
- package/dist/public/assets/{src-D4hratVH.js → src-BXx-EsNC.js} +1 -1
- package/dist/public/assets/{stateDiagram-OKZ733FA-9Rg5VJGs.js → stateDiagram-OKZ733FA-eaUxVBOS.js} +1 -1
- package/dist/public/assets/stateDiagram-v2-UEYNNEHI-CaQfCbFq.js +1 -0
- package/dist/public/assets/{swimlanes-SLNWSIFB-CAVgvhB7.js → swimlanes-SLNWSIFB-BxWGE_7Y.js} +1 -1
- package/dist/public/assets/swimlanesDiagram-ULZ7WXOC-CEPnDPH7.js +8 -0
- package/dist/public/assets/{syntax-CKL08zSk.js → syntax-sfl_d8Li.js} +1 -1
- package/dist/public/assets/tag-pill-input-CpqGo9X9.js +1 -0
- package/dist/public/assets/{telemetry-impl-BcNn4Cy4.js → telemetry-impl-Cwb_fUix.js} +1 -1
- package/dist/public/assets/{telemetry-startup-wdGBJvAj.js → telemetry-startup-Beq4pPTJ.js} +1 -1
- package/dist/public/assets/{timeline-definition-Z64GVDOM-CgsgxSIN.js → timeline-definition-Z64GVDOM-BUklZaYO.js} +1 -1
- package/dist/public/assets/{trim-lines-DfV8CCf7.js → trim-lines-DUSR4OI1.js} +1 -1
- package/dist/public/assets/typing-burst-detector-Bky0Uf5I.js +8 -0
- package/dist/public/assets/{use-activity-panel-Deu-fFDZ.js → use-activity-panel-BcSX-2vK.js} +1 -1
- package/dist/public/assets/{use-open-skill-DZLBQTON.js → use-open-skill-CwYfqsE-.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-Os-wpx6W.js → use-terminal-enabled-BtJN1Ej9.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BlLn-ZUs.js → use-timeline-entry-diff-C_vMkhk8.js} +1 -1
- package/dist/public/assets/{vennDiagram-T6HMQDX7-XL0mnmh6.js → vennDiagram-T6HMQDX7-D5U0ZIl2.js} +1 -1
- package/dist/public/assets/{wardleyDiagram-T6FBY63Y-Be2NrWXE.js → wardleyDiagram-T6FBY63Y-No5BmkiI.js} +1 -1
- package/dist/public/assets/{xychartDiagram-ELKLHX3M-vD-tBwgP.js → xychartDiagram-ELKLHX3M-CM_KjEoD.js} +1 -1
- package/dist/public/index.html +31 -31
- package/dist/{registry-probes-30qhugB8.mjs → registry-probes-BCYLuGAW.mjs} +1 -1
- package/dist/{removal-file-path-BEbm-0rr.mjs → removal-file-path-C94YYdie.mjs} +1 -1
- package/dist/{repair-launch-json-_YwH5w8W.mjs → repair-launch-json-BLHEsJOF.mjs} +1 -1
- package/dist/{repair-mcp-configs-DaXHfouZ.mjs → repair-mcp-configs-CRfhQbOD.mjs} +1 -1
- package/dist/src-C2dLuB-4.mjs +16 -0
- package/dist/src-DwoGfost.mjs +1 -0
- package/dist/start-B4k7Ovrz.mjs +1 -0
- package/dist/{start-CHPwQSO0.mjs → start-uMGB8N0f.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-CGJTsPn3.mjs +0 -1
- package/dist/init-CvnXSulz.mjs +0 -1
- package/dist/loader-CpT_mIAm.mjs +0 -1
- package/dist/preview-t8nmChxA.mjs +0 -1
- package/dist/public/assets/EditorModeToggle-BvJmVoGv.js +0 -1
- package/dist/public/assets/FeedbackForm-DOfFV6tX.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CqB5p1RR.js +0 -1
- package/dist/public/assets/PropertyDisplayRow-CFf2KJyB.js +0 -2
- package/dist/public/assets/SourceEditor-DWvkGKgL.js +0 -1
- package/dist/public/assets/channel-OzAyj6l2.js +0 -1
- package/dist/public/assets/classDiagram-JCYQIIEL-DF0YJ6u8.js +0 -1
- package/dist/public/assets/classDiagram-v2-OCEON4UE-CQ-KKEQq.js +0 -1
- package/dist/public/assets/cm-theme-o8S36rrW.js +0 -1
- package/dist/public/assets/dist-XYmEWMox.js +0 -1
- package/dist/public/assets/flowDiagram-UKHOOZJN-Dn0Imle8.js +0 -1
- package/dist/public/assets/frontmatter-tags-BHCWOjTl.js +0 -1
- package/dist/public/assets/mermaid-GHXKKRXX-SHS635CF.js +0 -1
- package/dist/public/assets/mermaid.core-Dta0iWzH.js +0 -1
- package/dist/public/assets/stateDiagram-v2-UEYNNEHI-CXxmQOoG.js +0 -1
- package/dist/public/assets/swimlanesDiagram-ULZ7WXOC-DhOdVr-O.js +0 -8
- package/dist/public/assets/tag-pill-input-TIigqEpB.js +0 -1
- package/dist/public/assets/typing-burst-detector-Bjq2UwET.js +0 -8
- package/dist/src-DF5_33AU.mjs +0 -16
- package/dist/src-DsQ0cj-4.mjs +0 -1
- package/dist/start-BRIc7GoN.mjs +0 -1
- /package/dist/public/assets/{ccount-BoHE53_k.js → ccount-Cc4-GkFF.js} +0 -0
- /package/dist/public/assets/{katex-ByejJr4L.js → katex-ACpOp-9g.js} +0 -0
- /package/dist/public/assets/{lib-DlDYgFfS.js → lib-D0X048Zn.js} +0 -0
- /package/dist/public/assets/{space-separated-tokens-l9yufOSK.js → space-separated-tokens-B5lqTxi5.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Ba as r,Df as i,Ef as a,Ju as o,Of as s,Rc as c,Uc as l,bf as u,if as d,kf as f,lf as p,md as m,of as h,sf as g,wf as _,xf as v}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Ba as r,Df as i,Ef as a,Ju as o,Of as s,Rc as c,Uc as l,bf as u,if as d,kf as f,lf as p,md as m,of as h,sf as g,wf as _,xf as v}from"./md-manager-BGnqyqi1-CPATjLIj.mjs";import{Ao as y,Go as ee,Ln as b,Zn as te,cs as x,fr as ne,m as S,ns as re,ss as ie,ts as C,va as ae}from"./dist-B-LAoRmW.mjs";import{$ as oe,A as se,J as ce,M as w,O as T,P as le,R as ue,T as de,X as E,at as fe,ct as pe,d as me,dt as he,f as ge,it as _e,j as ve,k as ye,lt as be,nt as xe,o as Se,rt as Ce,tt as we,v as Te,w as Ee,x as De,y as Oe}from"./init-DsTDW8PN.mjs";import{t as ke}from"./is-object-BGze3w87.mjs";import{t as Ae}from"./removal-file-path-C94YYdie.mjs";import{spawn as je}from"node:child_process";import{basename as Me,dirname as D,join as O,resolve as k,win32 as Ne}from"node:path";import{accessSync as Pe,constants as A,existsSync as j,lstatSync as M,mkdirSync as Fe,readFileSync as N,readdirSync as P,realpathSync as F,rmSync as Ie,rmdirSync as Le,statSync as I,unlinkSync as Re}from"node:fs";import{homedir as L}from"node:os";import{createHash as ze}from"node:crypto";import{isDeepStrictEqual as Be}from"node:util";import{setTimeout as Ve}from"node:timers/promises";var He=o();let Ue;function We(){return Ue}function Ge(e,t){if(t!==void 0&&t.length>0)return t;try{return ne(e)?.rootPath}catch{return}}function Ke(e){let t=Ge(e.cwd,e.configuredProjectName),n=b({name:`cli`,project:t});return Ue=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function R(){return l(c)}function z(){return _().keyringService}function B(e){try{e()}catch{}}var qe=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(z(),e).getPassword()}catch(t){return B(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return B(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return B(()=>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(z(),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(z(),e).deletePassword()}catch{}}},V=class{backend=`file`;authFile;constructor(e){this.authFile=e??O(re(),`auth.yml`)}read(){if(!j(this.authFile))return{};try{let e=N(this.authFile,`utf-8`);return(0,He.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=D(this.authFile);j(t)||Fe(t,{recursive:!0,mode:448}),C(this.authFile,(0,He.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)}},Je=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 ${R()} 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 Ye(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(z(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
2
|
`),B(()=>t?.onBackendSelected?.({backend:`keyring`})),new Je(new qe(t?.onKeychainRead),new V(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${R()}) — OS keychain unavailable: ${r}\n`),B(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new V(e)}}function Xe(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 (${R()})\n`),r(new V(e))},n)});try{return await Promise.race([Ye(e),r])}catch{return new V(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Ze(e){let t=Xe(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=Xe(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 $e(e,t){let n=[],r=new V(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(z(),`__probe__`);let r,a=await new qe(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(z(),e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function et(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function tt(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function nt(e){return y({detached:!0,stdio:`ignore`,shell:!1,env:et(e)})}function rt(e,t,n={}){let r=(n.spawn??je)(e,[...t],nt(n.env??process.env));return r.unref(),r}function it(e,t,n={}){let r=n.spawn??je,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],nt(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(tt(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(tt(e))}})}const at=u.stable.appId,ot=Object.keys(u),st=[`stable`,`beta`];function ct(e,t,n=e=>console.error(e)){try{return f(e,t)}catch(r){let i=f({...e,[v]:void 0},t);return n(`Treating this CLI as ${a(i)} for this command: ${r instanceof Error?r.message:String(r)}`),i}}function H(e){return st.includes(e)?st:[e,...st]}function lt(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:u[e.product].protocolScheme}}function ut(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return I(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function dt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let n=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(n?.[1]){let e=n[1];return{path:e,product:ot.find(t=>e.endsWith(`/${u[t].productName}.app`))??t}}}let n=e.homeDir??L();for(let r of H(t)){let{productName:t}=u[r];for(let i of[O(n,`Applications`),`/Applications`]){let n=O(i,`${t}.app`);if(ft(e,O(n,`Contents`,`MacOS`,t)))return{path:n,product:r}}}return null}function ft(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function pt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=ot.find(t=>e.execPath.toLowerCase().endsWith(`\\${i(u[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let r of H(t))for(let t of s(u[r])){let a=Ne.join(n,`Programs`,t,i(u[r]));if(ft(e,a))return{path:a,product:r}}return null}function mt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=ot.find(t=>e.execPath.endsWith(`/${u[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of H(t)){let{productName:t,linuxExecutableName:r}=u[n],i=`/opt/${t}/${r}`;if(ft(e,i))return{path:i,product:n}}return null}function ht(e){let t=ct(e.env,e.execPath,e.warn);if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`,cliProduct:t};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`,cliProduct:t};let n;try{n=e.platform===`darwin`?dt(e,t):e.platform===`win32`?pt(e,t):mt(e,t)}catch{return{available:!1,reason:`stat-error`,cliProduct:t}}if(!n)return{available:!1,reason:`no-bundle`,cliProduct:t};let r={bundlePath:n.path,product:n.product,cliProduct:t};return e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,...r}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,...r}:{available:!0,reason:`available`,...r}}function gt(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;if(t.bundlePath===void 0){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}let{productName:i}=u[t.product],[a]=u[t.cliProduct].cliCommandNames;n(`Launching ${i} desktop (use \`${a} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`);let o=t.bundlePath;if(r===`darwin`){rt(`open`,[`-a`,o],{spawn:e.spawn});return}rt(o,[],{spawn:e.spawn})}function _t(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 U(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 vt(e){return ze(`sha256`).update(e).digest(`hex`)}function W(e){return O(re(k(e)),`pi-trust`)}function yt(e,t){return O(W(e),vt(k(t)))}function bt(e,t,n){return O(yt(e,t),`${vt(n)}.json`)}var G=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${U(e)} ${U(t)}; ${U(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function K(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 G(e,`could not ${t}: ${i}`,a,n)}function q(e){let t;try{t=M(e)}catch(t){if(t.code===`ENOENT`)return!1;throw K(e,`be inspected`,t)}if(!t.isDirectory())throw new G(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function xt(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function St(e,t){if(!ke(e)||!xt(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==k(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==k(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==k(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!ke(e.previous))throw new G(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&&xt(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&xt(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new G(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 Ct(e,t,n){let r;try{r=M(n)}catch(e){throw K(n,`be inspected`,e)}if(!r.isFile())throw new G(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=N(n,`utf8`)}catch(e){throw K(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new G(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=St(a,n);if(o.cwd!==k(t)||n!==bt(e,t,o.canonicalTrustPath))throw new G(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 wt(e,t){let{record:n,path:r}=t;for(let t of[W(e),yt(e,n.cwd)])if(!q(t))throw new G(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=Ct(e,n.cwd,r);if(!Be(i.record,n))throw new G(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function Tt(e,t,n,r,i){let a={version:1,cwd:k(t),configuredTrustPath:k(n),canonicalTrustPath:k(r),state:`pending`,previous:i},o=bt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Be(St(JSON.parse(s),o),a))throw new G(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);q(W(e)),q(D(o));try{Fe(D(o),{recursive:!0,mode:448})}catch(e){throw K(D(o),`be created`,e)}let c;try{c=M(o,{throwIfNoEntry:!1})}catch(e){throw K(o,`be inspected`,e)}if(c)throw new G(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{C(o,s,{mode:384})}catch(e){throw K(o,`be written`,e)}return{path:o,record:a}}function Et(e,t){let n=wt(e,t);if(n.record.state!==`pending`)throw new G(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{C(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw K(n.path,`be committed`,e)}return{path:n.path,record:r}}function J(e,t){if(!q(W(e)))return[];let n=yt(e,t);if(!q(n))return[];let r;try{r=P(n).sort()}catch(e){throw K(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>Ct(e,t,O(n,r)))}function Y(e,t){let n=wt(e,t);try{Re(n.path)}catch(e){throw K(n.path,`be removed after reconciling its grant`,e)}for(let t of[D(n.path),W(e)])try{Le(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw K(t,`be removed after reconciling its grant`,e)}}var Dt=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`)}}})),Ot=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())}}})),kt=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}})),At=n(((t,n)=>{var r=e(`fs`),i=Dt(),a=Ot(),o=kt(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
3
3
|
GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=S,e.createWriteStream=re;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function S(t,n){return new e.ReadStream(t,n)}function re(t,n){return new e.WriteStream(t,n)}var ie=e.open;e.open=C;function C(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return ie(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),jt=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}})),Mt=n((e=>{var t=jt();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}}})),Nt=n(((e,t)=>{t.exports=Mt()})),Pt=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`)})),Ft=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=Pt(),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)}}})),It=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})),Lt=n(((t,n)=>{let r=e(`path`),i=At(),a=Nt(),o=Ft(),s=It(),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})),Rt=n(((e,t)=>{let n=At();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}})),zt=t(n(((e,t)=>{let n=Lt(),{toPromise:r,toSync:i,toSyncOptions:a}=Rt();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 Bt=5e3;function Vt(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 ${Bt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Ht(e,t){We()?.warn(t,e)}function Ut(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 Wt(e,t,n){await ie(`${t}.ok.lock`,async()=>{let t=performance.now()+Bt,r;for(;;)try{r=await zt.default.lock(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ve(Vt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Ut(i,e)},{onWarn:Ht})}function Gt(e,t,n){x(`${t}.ok.lock`,()=>{let t=performance.now()+Bt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=zt.default.lockSync(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Vt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Ut(a,e)},{onWarn:Ht})}const Kt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var qt=class extends Error{name=`PiResourceInspectionError`};function X(e){let t;try{t=M(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=I(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new qt(ve(`missing-symlink-target`),{cause:e}):e}return Pe(e,A.R_OK|(n.isDirectory()?A.X_OK:0)),!0}function Jt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Yt(e,t,n){let r=e;try{let i=F(e),a;r=t;try{a=F(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=k(t)}let o=O(a,`.agents`,`skills`),s=[];for(let e of Kt)r=O(i,`.pi`,e),X(r)&&s.push(r);if(r=O(i,`.pi`,`extensions`),X(r))for(let t of P(r).sort()){let i=O(r,t);k(n)!==O(k(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[O(i,`.pi`,`skills`),O(i,`.agents`,`skills`)])if(e!==o&&(r=e,X(e)))for(let t of P(e).sort())Jt(t)||s.push(O(e,t));let c=D(i);for(;c!==i;){r=O(c,`.agents`,`skills`),r!==o&&X(r)&&s.push(r);let e=D(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 ${U(r)}: ${e instanceof qt?e.message:ve(w(e))}`}}}function Xt(e,t,n){let r=k(e),i=pe({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:E.pi.projectConfigPath(r),trustPath:O(i,`trust.json`)}}function Z(e){try{let t=F(e);return I(t).isDirectory()?(Pe(t,A.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${U(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${U(e)} could not be resolved or accessed: ${U(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Zt(e){let t=Z(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${U(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function Qt(e,t,n){let r=Se(E.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return Ce(i)?{state:`own-current`,text:a}:de(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function $t(e,t){let n;try{n=N(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:w(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return ke(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
4
|
`)}:{state:`unreadable`,reason:`invalid-json`}}function en(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return ve(e)}}function Q(e,t){return{kind:`refused`,error:`trust store ${U(e)}: ${en(t)}`}}function tn(e){let t=Ae(e);try{switch(t.kind){case`declined`:return Q(e,t.reason);case`ready`:return{kind:`ready`,path:F(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=D(e),r=[Me(e)],i=M(n,{throwIfNoEntry:!1});for(;!i;){let t=D(n);if(t===n)return Q(e,`unavailable-root`);r.unshift(Me(n)),n=t,i=M(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:O(F(n),...r)}}catch(t){return Q(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:w(t))}}catch(t){return Q(e,w(t))}}function nn(e,t){let n=tn(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Q(e,`path-changed`):n}function rn(e,t,n){let r=Xt(e,t,n),i=Z(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=Qt(r.cwd,r.bridgePath,t).state,o=tn(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:$t(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:an(r.bridgePath).displayNames}}function an(e){let t=D(e),n=Me(e);try{return{displayNames:P(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>U(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function on(e,t={mode:`published`},n,r,i){let a=Xt(e,n,r),o=Z(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 ${U(i)} no longer matches the current directory ${U(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=Qt(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=Ee(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=Oe(E.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:U(e.error)}}let l=await sn(a.trustPath,o.project,n??L());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function sn(e,t,n){let r=t.canonical,i=tn(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Fe(D(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:U(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Wt(e,i.path,()=>{let o=Zt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=nn(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=$t(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=J(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&Y(n,t),Tt(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as e,S as t}from"./init-
|
|
1
|
+
import{M as e,S as t}from"./init-DsTDW8PN.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(t){return t.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:e(t)}}let o=t(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(t){return{kind:`declined`,reason:a&&t.code===`ENOENT`?`missing-symlink-target`:e(t)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
1
|
+
import{t as e}from"./launch-json-removal-C0-wLRJG.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{E as e}from"./md-manager-BGnqyqi1-CPATjLIj.mjs";import{J as t,X as n,et as r,f as i,rt as a,y as o}from"./init-DsTDW8PN.mjs";import{homedir as s}from"node:os";function c(e){let{priorCommand:t,priorArgs:n}=l(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function l(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function u(e){let r=e.logger??m,i=e.home??s(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=d(()=>t.configPath(``,i));if(s!==null&&a.push(f({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=d(()=>n(e.projectDir));i!==null&&a.push(f({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function d(e){try{return e()}catch{return null}}function f(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},s=i(t.target,t.cwd,t.home,t.configPathOverride);if(s===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(s))return{...n,outcome:`canonical`}}else{let i=e(s);if(i.kind===`recognized`&&i.disposition===`keep`){let e=r(s,t.target.buildEntry(t.cwd,{}));if(e.length===0)return{...n,outcome:`canonical`};let i=p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(i.outcome===`repaired`||i.outcome===`canonical`)&&t.logger({event:i.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:i.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),i.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:i}if(i.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:i.reason}),{...n,outcome:`foreign`,reason:i.reason}}return t.logger({...c({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:s}),severity:`info`}),p(t,n,o(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function p(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function m(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as n,u as repairMcpConfigs,c as t};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Df as t,Ef as n,Fl as r,G as i,Il as a,Jc as o,Ju as s,U as c,W as l,Wc as u,Yc as d,bf as f,hf as p,kf as m,l as h,u as ee,va as te,wf as g,ya as _}from"./md-manager-BGnqyqi1-CPATjLIj.mjs";import{Ao as v,At as y,Ea as b,Qn as x,Ri as S,Si as C,Tr as w,Ts as T,as as E,bi as D,cr as O,fr as k,is as A,m as ne,mi as j,ns as M,os as N,si as P,xi as F,zi as re}from"./dist-B-LAoRmW.mjs";import{t as ie}from"./yazl-BBz29IQN.mjs";import{Ct as I,ot as L,st as ae}from"./init-DsTDW8PN.mjs";import{l as oe,w as se}from"./registry-probes-BCYLuGAW.mjs";import{c as ce}from"./colors-r_owlCuY.mjs";import{t as le}from"./is-object-BGze3w87.mjs";import{n as ue}from"./constants-QhGcX1jP.mjs";import"./loader-B14ip6IN.mjs";import"./preview-DCs1uVu5.mjs";import{execFile as de,execSync as fe,spawnSync as pe}from"node:child_process";import{basename as R,dirname as z,isAbsolute as me,join as B,relative as he,resolve as V,sep as H,win32 as ge}from"node:path";import{closeSync as _e,cpSync as ve,createWriteStream as ye,existsSync as U,lstatSync as be,mkdirSync as W,mkdtempSync as xe,openSync as Se,readFileSync as G,readSync as Ce,readdirSync as K,readlinkSync as we,realpathSync as Te,rmSync as q,rmdirSync as Ee,statSync as De,writeFileSync as J}from"node:fs";import{arch as Oe,freemem as ke,homedir as Y,hostname as Ae,platform as je,release as Me,tmpdir as Ne,totalmem as Pe,type as Fe,uptime as Ie}from"node:os";import{readFile as Le,readdir as Re,stat as ze}from"node:fs/promises";import{createHash as Be}from"node:crypto";function Ve(e,t){let n=t.map(e=>[T(e),e]);for(let t of e){let e=T(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function He(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=Ve([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=Ve(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function Ue(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 We=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function Ge(e,t,n=k){if(e!==void 0&&!We.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ke=null;function qe(e){Ke=e}function Je(){return Ke??process.cwd()}const Ye=`Open Knowledge`;function Xe(e={}){let t=e.platformName??process.platform,n=e.productName??g().productName;return L(t).join(ae({...e,platformName:t}),n)}function Ze(e={}){let t=e.platformName??process.platform,n=e.home??Y(),r=e.env??process.env,i=L(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,`${g().packageName.replaceAll(`/`,``)}-updater`)}function Qe(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 $e(e){let t=B(e,`state.json`);if(!U(t))return[];let n;try{n=JSON.parse(G(t,`utf-8`))}catch{return[]}return Qe(n)??[]}function et(e){let t=B(e,`state.json`);if(!U(t))return!1;try{return Qe(JSON.parse(G(t,`utf-8`)))!==null}catch{return!1}}const tt=8192;function nt(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 rt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const it=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function at(e){return e.replace(it,`$1"[REDACTED-DEVICE-ID]"`)}function ot(e){return at(rt(e))}const st=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function ct(e){if(typeof e!=`string`)return null;let t=st.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 lt(e){let t=Se(e,`r`);try{let e=Buffer.alloc(tt),n=0,r=!1;for(;n<tt;){let i=Ce(t,e,n,tt-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{_e(t)}}function ut(e){try{let t=lt(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:ct(a)}}catch{return{kind:`unreadable`}}}function dt(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function ft(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=K(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=B(e,t.name),r;try{r=De(n).mtimeMs}catch{continue}if(r<i)continue;let c=ut(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!dt(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const pt=`state/os-termination-evidence.json`,mt=6048e5,ht=/openknowledge/i,gt=Object.values(f).map(t);function _t(e={}){return(t,n)=>new Promise(r=>{try{de(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...vt(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function vt(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function yt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
2
|
+
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function bt(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function xt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function St(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Ct(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function wt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Tt(e,t){let n=t.indexOf(`
|
|
3
|
+
`);if(n===-1)return null;let r,i;try{r=wt(JSON.parse(t.slice(0,n))),i=wt(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=wt(e);t===null||typeof t.name!=`string`||!dt(t.name)||a.push({name:t.name,pid:Ct(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Ct(t.rpages),lifetimeMaxPages:Ct(t.lifetimeMax)})}let o=ct(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Ct(wt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?dt(i.largestProcess):null,ownedProcesses:a}}const Et=/^JetsamEvent-.*\.ips$/;function Dt(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function Ot(e,t){let n=bt(`darwin`,`macos-jetsam`,[B(e,`JetsamEvent-*.ips`)]),r;try{r=await Re(e)}catch(e){return xt(n,e.code??`unknown`)}let i=Dt(await Promise.all(r.filter(e=>Et.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await ze(B(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-mt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Tt(t,await Le(B(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return St(n)}const kt=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],At=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],jt=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,Mt=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,Nt=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function Pt(e,t){let n=new Set,r;try{r=await Re(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!Nt.test(a))continue;let r=B(e,a);try{if(t.getTime()-(await ze(r)).mtimeMs>mt)continue;for(let e of(await Le(r,`utf8`)).split(`
|
|
4
|
+
`)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function Ft(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:ht.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function It(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
5
|
+
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=jt.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!ht.test(s)){n+=1;continue}let c=Ft(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function Lt(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
6
|
+
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=jt.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=Mt.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function Rt(e,t,n){let r=Lt(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await Pt(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function zt(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function Bt(e,t,n){let r=bt(`linux`,`linux-journal`,[`journalctl ${kt.join(` `)}`,`journalctl ${At.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...kt]),e(`journalctl`,[...At])]),o=[];if(zt(i)){let e=It(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${yt(i)}`);if(zt(a)){let e=await Rt(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${yt(a)}`);return o.length===2?xt(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:St(r)}const Vt={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},Ht={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function Ut(e){return e===`System`?Vt:Ht}function Wt(e){let t=`System[(${Object.keys(Ut(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${mt}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${gt.map(e=>`Data='${e}'`).join(` or `)}]]`}function Gt(e){return[`qe`,e,`/q:${Wt(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function Kt(e){return ge.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function qt(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function Jt(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function Yt(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>qt(e[1]??``).trim())}function Xt(e,t){let n=Ut(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=Yt(o,`Data`),u=Yt(o,`Name`),d=[...l,...u].some(e=>ht.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!Jt(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Zt(e,t){let n=Kt(t),r=[`System`,`Application`],i=bt(`win32`,`windows-event-log`,r.map(e=>`${n} ${Gt(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,Gt(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${yt(t)}`);continue}let n=Xt(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?xt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:St(i)}async function Qt(e={}){let t=e.platform??process.platform,n=e.runCommand??_t(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Ot(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return Bt(n,r,e.desktopLogsDir??B(M(),`logs`));case`win32`:return Zt(n,e.systemRoot??process.env.SystemRoot);default:return{...bt(t,null,[]),outcome:`unsupported`}}}const $t={schemaVersion:1,outcome:`not-collected`};function en(e){return`${JSON.stringify(e??$t,null,2)}\n`}const tn={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system and user journals`,"windows-event-log":`Windows event logs`};function nn(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${tn[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function rn(){return B(M(),`bug-reports`)}function an(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=rn(),r=`${t}-bugreport`,i=B(n,`${r}.zip`);for(let e=2;U(i);e+=1)i=B(n,`${r}-${e}.zip`);return i}function on(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function sn(e,t){let n=B(e,`.ok`,`config.yml`);if(U(n))try{let e=G(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 U(B(e,`.ok`))?Be(`sha256`).update(V(e)).digest(`hex`).slice(0,12):null}function cn(){let e={timestamp:new Date().toISOString(),platform:je(),osType:Fe(),osRelease:Me(),hostname:`[redacted]`,uptime:Ie(),freeMem:ke(),totalMem:Pe(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=fe(`sw_vers -productVersion 2>/dev/null`,v({encoding:`utf8`})).trim()}catch{}try{let t=B(__dirname,`..`,`..`,`package.json`);U(t)&&(e.okVersion=JSON.parse(G(t,`utf8`)).version)}catch{}return e}const ln=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function un(e){let t=R(e);return ln.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function dn(e,t){return hn(e,t).files}const fn=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function pn(e,t=oe){let n=B(e,`${t}.ShipIt`);if(!U(n))return[];let r;try{r=K(n)}catch{return[]}return fn.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=>B(n,e.entry)))}function mn(e){if(!U(e))return[];try{let t=new Map;for(let n of K(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-h.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=>B(e,t))}catch{return[]}}function hn(e,t){if(!U(t))return{files:[],excludedByProjectSlug:0};let n=K(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>B(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(un),i=[],a=r.filter(t=>{try{return G(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=>!un(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function gn(e){let t=B(e,`.ok`,`local`);return U(t)?{files:[`server.lock`,`last-spawn-error.log`,o,u].map(e=>B(t,e)).filter(e=>U(e))}:{files:[]}}function _n(e){let t=B(e,`.ok`,`local`,`logs`);return U(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>B(t,e)).filter(e=>U(e))}:{files:[]}}function vn(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#${Be(`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 yn(e){let t=e.revealDocNames?e.content:vn(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=_(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=G(t,`utf8`);yn({zipfile:e.zipfile,name:`${e.prefix}/${R(t)}`,content:t.endsWith(`.ips`)?ot(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 bn(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??B(M(),`logs`),s=t.projectDir?sn(t.projectDir,i):null;W(z(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=cn();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=hn(s,o),{files:d}=t.projectDir?gn(t.projectDir):{files:[]},{files:f}=t.projectDir?_n(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:ee,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=G(e.sourcePath),n=`extra/${e.zipName??R(e.sourcePath)}`;v.addBuffer(t,n),g.push(n);let r=on(e,n);r!==null&&h.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&yn({zipfile:v,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:g,redactions:h});let y=new Set(m.map(e=>`diagnostic-reports/${R(e)}`)),b=g.filter(e=>y.has(e)),x=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:nt(t.diagnosticReports,b.length);v.addBuffer(Buffer.from(`${x}\n`,`utf8`),`state/diagnostic-reports-status.txt`),g.push(`state/diagnostic-reports-status.txt`),yn({zipfile:v,name:pt,content:en(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:g,redactions:h});let S=JSON.stringify(c,null,2);v.addBuffer(Buffer.from(S,`utf8`),`sysinfo.json`),g.push(`sysinfo.json`);let C={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:g,redactions:h,sysinfo:c};v.addBuffer(Buffer.from(JSON.stringify(C,null,2),`utf8`),`MANIFEST.json`);let w=h.reduce((e,t)=>e+t.lineCount,0),T=new Set(p.map(e=>`logs/${R(e)}`)),E=g.filter(e=>T.has(e)),D=new Set((t.bugReportLedgerFiles??[]).map(e=>`${ee}/${R(e)}`)),O=g.filter(e=>D.has(e)),k=s?g.filter(e=>e.startsWith(`logs/`)&&!un(e)&&!T.has(e)):[],A=b.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],ne=A.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...A]:[`Redaction was disabled for this bundle; file contents are unmodified.`],j=[`# Bug Report Bundle`,``,`Generated: ${C.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${C.disciplineVersion}`,``,`## Contents`,``,...g.map(e=>`- ${e}`),``,`## Privacy`,``,...k.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...k.map(e=>`- ${e}`),``]:[],...E.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...E.map(e=>`- ${e}`),``]:[],...b.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...b.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system's own logs, covering`,`the last 7 days, to explain an exit the app could not record itself. On`,`macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${pt}`,``]:[],...O.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...O.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${te.join(`, `)}`,w>0?`${w} line(s) were scrubbed across ${h.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...A,``,`This bundle is safe to attach to a GitHub issue.`]:ne].join(`
|
|
7
|
+
`);v.addBuffer(Buffer.from(j,`utf8`),`README.md`),v.end();let N=ye(r);return v.outputStream.pipe(N),await new Promise((e,t)=>{N.on(`close`,e),N.on(`error`,t)}),i?.info({bundlePath:r,fileCount:g.length,redactionCount:w},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:g,redactions:h,redactedLineCount:w,generatedAt:C.generatedAt}}}var xn=s(),Sn=e(ie(),1),Z=e(ce(),1);function Cn(e){let t=N(`user`,e,e);return A({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function wn({home:e=Y(),env:t=process.env}={}){let n=Cn(e),{override:i,preferenceList:o}=E(t),{locale:s,source:c}=He({override:i,storedPreference:n,supportedLocales:a,preferenceList:o,autoDetectableLocales:r});return{preference:n,locale:s,source:c,systemLanguages:o}}function Tn(e){let t=new Set([e]);try{t.add(Te.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 En(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function Dn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function On(e,t){if(typeof e==`string`)return En(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>On(e,t));if(!Dn(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=On(i,t);return n}function kn(e,t){let n=G(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
8
|
+
`),i=n.split(`
|
|
9
|
+
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=On(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
10
|
+
`)}\n`:a.join(`
|
|
11
|
+
`);J(e,o)}function An(e,t){let n=G(e,`utf-8`);if(n.trim().length!==0)try{let r=On(JSON.parse(n),t),i=n.endsWith(`
|
|
12
|
+
`)?`
|
|
13
|
+
`:``;J(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=En(n,t.contentDirSpellings);r!==n&&J(e,r)}}function jn(e,t){let n=G(e,`utf-8`),r=En(n,t.contentDirSpellings);r!==n&&J(e,r)}function Mn(e){try{return K(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>B(e,t.name))}catch{return[]}}const Nn=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function Pn(e){return/\.log\.\d+$/.test(e)}function Fn(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||Pn(e)}const In=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function Ln(e){let t={contentDirSpellings:Tn(e.contentDir)};for(let n of In)for(let r of Mn(B(e.stagingDir,n)))Fn(r)?kn(r,t):r.endsWith(`.json`)?An(r,t):jn(r,t);for(let n of Mn(B(e.stagingDir,`state`))){let e=R(n);n.endsWith(`.jsonl`)?kn(n,t):Nn.has(e)?An(n,t):jn(n,t)}}const Rn=[`.ok`,`local`,`telemetry`],zn=[`.ok`,`local`,`logs`],Bn=[`.ok`,`local`,`loss-capture`],Vn=`spans-current.jsonl`,Hn=`spans-prev.jsonl`,Un=`server-current.jsonl`,Wn=`server-prev.jsonl`,Gn=`loss-current.jsonl`,Kn=`loss-prev.jsonl`;function qn(e){return B(e,...Rn,Vn)}function Jn(e){return B(e,...Rn,Hn)}function Yn(e){return B(e,...zn,Un)}function Xn(e){return B(e,...zn,Wn)}function Zn(e){return B(e,...Bn,Gn)}function Qn(e){return B(e,...Bn,Kn)}const $n=1e3;async function er(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout($n)});return t.ok?await t.text():null}catch{return null}}async function tr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout($n)});return t.ok?await t.text():null}catch{return null}}async function nr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout($n)});return t.ok?await t.text():null}catch{return null}}function rr(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
14
|
+
`)}\n`:null}catch{return null}}function ir(e){let t=B(e,`.git`,`ok`);if(!U(t))return null;let n=pe(`git`,[`-C`,t,`log`,`--oneline`,`-50`],v({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function ar(e){let t=B(e,`.git`,`ok`);if(!U(t))return null;let n=pe(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],v({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function or(){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 sr(){return{nodeVersion:process.version,platform:je(),arch:Oe()}}function cr(){return process.env.OTEL_SDK_DISABLED===`false`}function lr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ur(e){if(!U(e))return{};let t;try{t=(0,xn.parse)(G(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(!lr(t))return{};let n=t.telemetry;if(!lr(n))return{};let r=n.localSink;return lr(r)?r:{}}function dr(e){return typeof e==`boolean`?e:void 0}function fr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function pr(e){if(lr(e))return fr(e.maxBytes)}function mr(e){let t=ur(N(`project`,e)),n=ur(N(`project-local`,e));return{enabled:dr(n.enabled)??dr(t.enabled)??!0,spansMaxBytes:pr(n.spans)??pr(t.spans)??52428800,logsMaxBytes:pr(n.logs)??pr(t.logs)??26214400}}function hr(e){return Be(`sha256`).update(e).digest(`hex`)}function gr(e){let t=G(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const _r=[`"doc.name"`,`"docName"`];function vr(e){let t=G(e,`utf-8`),n=0;for(let e of _r){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Q(e,t){if(!U(e))return!1;try{return W(z(t),{recursive:!0}),e.endsWith(`.ips`)?J(t,ot(G(e,`utf-8`))):ve(e,t),!0}catch{return!1}}function yr(e){let t=[],n=e=>{let r=K(e,{withFileTypes:!0});for(let i of r){let r=B(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const br=new Set([`.jsonl`]);function xr(e){let t=e.lastIndexOf(`.`);return t!==-1&&br.has(e.slice(t))}const Sr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Cr(e){if(Pn(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Sr.has(e.slice(t))}function wr(e){let t=[];for(let n of yr(e)){let r=Tr(e,n);if(!Cr(r))continue;let{redacted:i,patterns:a,lineCount:o}=_(G(n,`utf-8`));a.length!==0&&(J(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Tr(e,t){return he(e,t).split(H).join(`/`)}async function Er(e){let t=V(e.contentDir),n=V(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??er,a=r.fetchAgentEffects??tr,s=r.fetchWatcherRecent??nr,c=r.readShadowHead??ir,l=r.readCheckpointRefs??ar,f=r.now??(()=>new Date),p=r.okVersion??(()=>ue),m=r.readDesktopEnv??or,h=r.readLanguage??wn,te=r.readRuntime??sr,g=r.isOtlpPushEnabled??cr,_=xe(B(Ne(),`ok-bundle-`));try{W(B(_,`telemetry`),{recursive:!0}),W(B(_,`logs`),{recursive:!0}),W(B(_,`state`),{recursive:!0}),Q(qn(n),B(_,`telemetry`,Vn)),Q(Jn(n),B(_,`telemetry`,Hn)),Q(Yn(n),B(_,`logs`,Un)),Q(Xn(n),B(_,`logs`,Wn));for(let t of e.userLogFiles??[])Q(t,B(_,`logs`,R(t)));for(let t of e.userStateFiles??[])Q(t,B(_,ee,R(t)));let v=0;for(let t of e.diagnosticReports?.files??[])Q(t,B(_,`diagnostic-reports`,R(t)))&&(v+=1);let y=B(n,`.ok`,`local`),b=B(y,`server.lock`),x=`not-running`,S=`no server.lock`,C=null;if(U(b)){Q(b,B(_,`state`,`server.lock`));try{let e=G(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 i(C);e===null?S=`agent-presence endpoint at :${C} unreachable`:(J(B(_,`state`,`agent-presence.json`),e),x=`running`,S=``);let t=await a(C);t!==null&&J(B(_,`state`,`agent-effects.json`),t);let n=await s(C);if(n!==null){let e=rr(n);e!==null&&J(B(_,`state`,`watcher-recent.jsonl`),e)}}let w=c(t);w!==null&&J(B(_,`state`,`shadow-head.txt`),w);let T=l(t);T!==null&&J(B(_,`state`,`checkpoint-refs.txt`),T),Q(Zn(n),B(_,`state`,Gn)),Q(Qn(n),B(_,`state`,Kn)),Q(B(y,`last-spawn-error.log`),B(_,`state`,`last-spawn-error.log`)),Q(B(y,d),B(_,`state`,d)),Q(B(y,o),B(_,`state`,o)),Q(B(y,u),B(_,`state`,u));let E=te(),D=m(),O=h(),k={ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O}};J(B(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let A=x===`running`?`running
|
|
15
|
+
`:`not-running (${S})\n`;J(B(_,`state`,`server-status.txt`),A);let ne=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:nt(e.diagnosticReports,v);if(J(B(_,`state`,`diagnostic-reports-status.txt`),`${ne}\n`),J(B(_,pt),en(e.osTerminationEvidence)),e.processDir&&U(e.processDir)){let t=B(_,`process`);W(t,{recursive:!0}),ve(e.processDir,t,{recursive:!0})}let j=e.redact===!0;j&&Ln({stagingDir:_,contentDir:t}),e.note&&J(B(_,`note.txt`),e.note);let M=null;e.scrubSecrets===!0&&(M=wr(_));for(let t of e.extraFiles??[]){let e=t.zipName??R(t.sourcePath);if(!Q(t.sourcePath,B(_,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=on(t,`extra/${e}`);n!==null&&(M??={redactions:[],redactedLineCount:0},M.redactions.push(n),M.redactedLineCount+=n.lineCount)}let N=mr(n),P=yr(_),F=[],re=0,ie=0;for(let e of P){let t=Tr(_,e),n=De(e).size,r=xr(t)?gr(e):0;F.push({path:t,bytes:n,lines:r}),re+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(ie+=vr(e))}let I={applied:j};M!==null&&(I.secretScrub=M);let L={schemaVersion:2,createdAt:f().toISOString(),ok:{version:p(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:D,language:O},contentDir:{pathSha256:hr(t),absolutePath:j?`<CONTENT_DIR>`:t},telemetry:{localSink:N,otlpPushEnabled:g()},redaction:I,serverStatus:x,files:F};J(B(_,`manifest.json`),`${JSON.stringify(L,null,2)}\n`);let ae=Tn(t),oe=P.some(e=>{try{let t=G(e,`utf-8`);return ae.some(e=>t.includes(e))}catch{return!1}}),se={stagedDiagnosticReports:v,totalBytes:re,fileCount:F.length,docNameCount:ie,contentDirVisible:oe,redacted:j},ce=!1;return{stagingDir:_,manifest:L,summary:se,cleanup:()=>{ce||(ce=!0,q(_,{recursive:!0,force:!0}))}}}catch(e){throw q(_,{recursive:!0,force:!0}),e}}async function Dr(e){let{collected:t,outputPath:n}=e,r=z(n);if(!U(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Sn.ZipFile,a=yr(t.stagingDir);for(let e of a){let n=Tr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=ye(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 Or(e,t){let n=B(e,`.ok`,`config.yml`);if(U(n))try{let t=(0,xn.parse)(G(n,`utf-8`)),r=le(t)?t.content:void 0,i=le(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return V(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 V(e)}async function kr(e,t,n,r,i,a){let o=sn(t,e.logger),s=await Er({contentDir:Or(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...dn(o,e.userLogsDir??B(M(),`logs`)),...pn(e.cachesDir??B(Y(),`Library`,`Caches`))],userStateFiles:mn(e.bugReportsDir??rn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{W(z(e.outputPath),{recursive:!0}),await Dr({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Ar(e){let{projectDir:t}=e,n=e.readDesktopEnv??or,r=e.readLanguage??wn,i=()=>ft(e.diagnosticReportsDir??B(Y(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return kr(e,t,n,r,i(),await Qt(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await bn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:pn(e.cachesDir??B(Y(),`Library`,`Caches`)),bugReportLedgerFiles:mn(e.bugReportsDir??rn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await Qt(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function $(e,t,n={}){let r=C(e,t),i;try{i=G(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??w()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??Ae());if(!a||typeof a!=`object`||!j(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??P)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}function jr(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 Mr(e){return e.replace(/:\d+$/,``)}function Nr(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Mr(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Mr(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Mr(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 Pr=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function Fr(e){return i(m(),e)}function Ir(){return l(m())}function Lr(){let e=m();if(e===`stable`)return Pr;let t=c(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const Rr={existsSync:e=>U(e),readFileSync:(e,t)=>G(e,t),lstatSync:e=>be(e),readlinkSync:e=>we(e)};function zr(e,t=Rr){let n=Fr(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 Br(e){let t=e.replace(Lr(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function Vr(e,t,n=Rr){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const Hr=[{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`}],Ur=[...y.map(e=>ne[e]),`open-knowledge`];function Wr(e){if(!me(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=V(e);if(t===H||z(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function Gr(e,t){let n=he(e,t);if(n.startsWith(`..`)||me(n))return!1;let r=e;for(let e of n.split(H)){r=B(r,e);try{if(!be(r).isDirectory())return!1}catch{return!1}}return!0}function Kr(e,t){try{return K(e).every(n=>t.has(B(e,n)))}catch{return!1}}function qr(e){let t=Wr(e),n=[],r=[],i=new Set;for(let e of Hr){let a=B(t,e.hostDir,`skills`);if(!Gr(t,a))continue;let o=Ur.map(e=>B(a,e)).filter(e=>U(e));n.push(...o);for(let e of o)i.add(e);let s=B(t,e.pruneRoot),c=a;for(;Kr(c,i)&&(r.push(c),i.add(c),c!==s);){let e=z(c);if(e===c||e===t||!e.startsWith(t+H))break;c=e}}return{skillDirs:n,emptyDirs:r}}function Jr(e){try{if(!be(e).isDirectory())return!1;let t=K(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Yr(e){let t=new Set,n=new Set;for(let r of Hr){let i=B(e,r.hostDir,`skills`);for(let e of Ur)t.add(B(i,e));let a=B(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=z(o);if(t===o||t===e||!t.startsWith(e+H))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Xr(e,t){let n=Wr(e),r=Yr(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(Gr(n,e)&&Jr(e))try{q(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(Gr(n,e))try{Ee(e),a.push(e)}catch{}return a}function Zr(e){let t=Wr(e),n=[];for(let e of y){let r=ne[e];n.push({path:B(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of p)n.push({path:B(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Qr(e,t){let n=[];for(let r of Zr(e))if(r.bundleId===t)try{q(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 $r(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function ei(e,t=Date.now()){if(e===null)return`—`;let n=Ue(e,t);return n===`unknown`?`—`:n}function ti(e){let t=z(e);return R(e)===`local`&&R(t)===`.ok`?z(t):R(e)===`.ok`?t:null}function ni(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:ti(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`&&D(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:O(n),command:n,isDesktop:$r(n)}}function ri(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 ii=new Set([`running`,`desktop`,`foreign`,`unverified`]);function ai(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 oi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function si(e){return`${oi(e.server.usage)} | ${oi(e.ui?.usage??null)}`}function ci(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function li(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??`—`,ci(e),si(e),ri(e),String(e.server.pid),ei(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=ai(ri(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(`
|
|
16
|
+
`)}async function ui(e={}){let t=e.discover??x,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??S,a=e.resolveUsage??re,o=await t(),s=[];for(let e of o){let t=n(e),r=ni(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:ri(e)}));r(JSON.stringify(e,null,2));return}r(li(e.all?s:s.filter(e=>ii.has(ri(e)))))}function di(){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 ui({all:t.all===!0||e===`all`,json:t.json===!0})})}async function fi(e,t=se()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=F(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 pi(e,t={}){return{targets:gi(e,t.isAlive??P)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function mi(e){try{return m()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function hi(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),r=e.kill??((e,t)=>process.kill(e,t)),i=e.log??(e=>console.log(e)),a=e.error??(e=>console.error(e)),o=e.probeClients??fi,s=e.logger??se(),c=t(),l=pi(c,{isAlive:e.isAlive});if(l.targets.length===0)return i(`No running open-knowledge processes.`),s?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let u=c.status===`alive`||c.status===`foreign-host`?c.lock.channel:void 0;if(e.force!==!0&&typeof u==`string`&&u.length>0){let t=e.selfChannel??mi(s);if(t!==void 0&&u!==t)return a(`Not stopping: the server at ${e.lockDir} belongs to ${n(u)}. Stop it from that app or its CLI, or re-run with --force to terminate anyway.`),s?.warn({lockDir:e.lockDir,holderChannel:u,selfChannel:t,pids:l.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:u}}}if(e.force!==!0){let t=await o(e.lockDir,s);if(t!==null&&t>0)return a(`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.`),s?.warn({lockDir:e.lockDir,clients:t,pids:l.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let d=[],f=[];for(let e of l.targets)try{r(e.pid,`SIGTERM`),d.push(e)}catch(t){f.push({target:e,error:t instanceof Error?t.message:String(t)})}return d.length>0&&i(`Stopped: ${d.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s?.info({lockDir:e.lockDir,signalled:d.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:f.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),f.length>0&&a(`Failed to stop: ${f.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:d,failed:f,hadTargets:!0}}function gi(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function _i(e,t=P){let n=await x(),r=null;for(let i of n){let n=$(i,`server`);if(gi(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}async function vi(e,t){let n=await hi({lockDir:e,force:t});return(n.failed.length>0||n.declined!==void 0)&&(process.exitCode=1),n}function yi(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 bi(e){let t=await x(),n=0;for(let r of t)r!==e&&gi($(r,`server`),P)&&n++;return n}function xi(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 hi({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 bi(t);console.log(yi(process.cwd(),e,{listingFollows:e>0})),e>0&&await ui({})}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)gi($(n,`server`),P)&&(await vi(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 _i(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await vi(t,r);return}let a=V(Je(),i),o=b(a),s=[],c=await hi({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(yi(a,await bi(o)))})}export{$e as A,Qt as C,Ye as D,nt as E,Je as M,qe as N,Ze as O,Ge as P,rn as S,ft as T,$ as _,Xr as a,Dr as b,Zr as c,Fr as d,Ir as f,jr as g,Nr as h,di as i,et as j,Xe as k,Pr as l,Br as m,hi as n,qr as o,zr as p,xi as r,Qr as s,fi as t,Vr as u,Ar as v,nn as w,an as x,Er as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-CPATjLIj.mjs";import"./src-C2dLuB-4.mjs";import"./init-DsTDW8PN.mjs";import"./registry-probes-BCYLuGAW.mjs";import"./start-uMGB8N0f.mjs";import{n as e}from"./loader-B14ip6IN.mjs";import"./preview-DCs1uVu5.mjs";import"./repair-mcp-configs-CRfhQbOD.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-uMGB8N0f.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{C as e,Cf as t,I as n,Q as r,Z as i,i as a,md as o,vl as s}from"./md-manager-BGnqyqi1-
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(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 be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=C(y[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(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 Ae(e){if(e===`off`)return`off`;if(!s.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${t()} init\` first, then \`${t()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${t()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-BscgfW_a.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=m(E),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Z(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new Y(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-DaXHfouZ.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-_YwH5w8W.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let re=T(),F=h(),I;try{{let e=v(O??n),t=Date.now(),r=await b(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`)}I=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:x(),...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)=>k(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:ne(e),execute:Te(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(M===void 0?n:Le(n,M),{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 L=I.destroy,R=A?async()=>{try{await L()}finally{await j()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:P,port:I.port,ready:I.ready,degraded:I.degraded}}function ze(e,t,n=()=>f({absPath:m(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(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 Ue(t,o){let s=ze(t,o.singleFile),c=Ve(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=Ie(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
-
`)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,te=ee??D??s.server?.port,O=ke({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Oe}),k=O.dir;O.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 A;try{A=await Q({config:s,cwd:m,host:C,port:te,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...k?{reactShellDistDir:k}:{},idleThresholdMs:n(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof Y&&(console.error(f(e.message)),process.exit(1)),e instanceof X&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-
|
|
1
|
+
import{C as e,Cf as t,I as n,Q as r,Z as i,i as a,md as o,vl as s}from"./md-manager-BGnqyqi1-CPATjLIj.mjs";import{Li as c,_s as l,bi as u,ci as d,is as f,k as p,os as m,wi as h}from"./dist-B-LAoRmW.mjs";import{Ct as g,L as _,Tt as v,X as y,b,ut as x,wt as S,y as C,z as w}from"./init-DsTDW8PN.mjs";import{S as T,a as E,c as ee,h as D,i as te,m as O,n as k,o as A,p as j,r as M,s as N,t as ne,u as P}from"./registry-probes-BCYLuGAW.mjs";import{n as re}from"./constants-QhGcX1jP.mjs";import{execFileSync as F,spawn as I}from"node:child_process";import{basename as L,dirname as R,resolve as z}from"node:path";import{existsSync as B,realpathSync as ie}from"node:fs";import{homedir as ae,tmpdir as oe}from"node:os";import{rm as se}from"node:fs/promises";import{setTimeout as ce}from"node:timers/promises";const le=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function V(e,t={}){let{login:n}=t,r=t._exec??F,i=H(t._fileExists??B),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`,...le.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ue).toString().trim();if(t.length>0)return t}catch{}}function de(e,t={}){let n=t._exec??F,r=H(t._fileExists??B),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=_e(o);if(e.length>0)return e}}function W(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function fe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=W(W(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=W(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 pe=/Logged in to \S+ account (\S+) \(/,me=/(?:Failed to log in to|Timeout trying to log in to) \S+/,he=/^\s*-\s*Active account:\s*true\s*$/,ge=/\u001b\[[0-9;]*m/g;function _e(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){l(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(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 be(e,t,n,r,i){let a=y[e];try{let o=A(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return l(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await b({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=C(y[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??ae();if(n===`absent`){let t=M(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=o(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new S(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(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 Ae(e){if(e===`off`)return`off`;if(!s.test(e))throw new S(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new S(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new S(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${t()} init\` first, then \`${t()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},X=class extends Error{projectDir;constructor(e){super(`--project-dir must be a throwaway ${p}* directory under the OS temp dir. Refusing to write ephemeral session state into ${e}. Omit --project-dir to let ${t()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Z(e,t={}){let n=t.tmpdirFn??oe,r=t.realpathFn??ie,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>se(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-DFHKTwRq.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?c(e.singleFile).canonicalFilePath:void 0,E=w?u(w):void 0,D=w?l(w):void 0,O,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(f(O,`.ok`,`config.yml`))||y(O,E)}else O=m(E),A=!0}let j=async()=>{if(!(!A||O===void 0)){if(!Z(O)){S.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await se(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},M=O;if(!C){if(!i&&!d(n))throw new Y(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-CRfhQbOD.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-BLHEsJOF.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=E??_(t,n);!C&&!o(P)&&(s(P,{recursive:!0}),S.info({contentDir:P},`Created content directory`));let re=T(),F=h(),I;try{{let e=v(O??n),t=Date.now(),r=await b(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`)}I=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:re,embeddingsKeyStore:F,mcpTomlEditor:x(),...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)=>k(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>N(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ae(),env:process.env};return{probe:ne(e),execute:Te(e),userSkillPresentAnywhere:te}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(M===void 0?n:Le(n,M),{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 L=I.destroy,R=A?async()=>{try{await L()}finally{await j()}}:L;return{httpServer:I.httpServer,destroy:R,lockDir:I.lockDir,contentDir:P,port:I.port,ready:I.ready,degraded:I.degraded}}function ze(e,t,n=()=>f({absPath:m(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new S(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(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 Ue(t,o){let s=ze(t,o.singleFile),c=Ve(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=Ie(m);let h;try{h=i(process.env)}catch(e){throw e instanceof a&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=e(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=o.bind!==void 0&&o.bind.length>0?o.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=o.externalUrl,E=r(e(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
+
`)))}let ee=o.port===void 0?void 0:Number(o.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,te=ee??D??s.server?.port,O=ke({explicitDir:o.reactShellDistDir,only:o.only,findBundledDir:Oe}),k=O.dir;O.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 A;try{A=await Q({config:s,cwd:m,host:C,port:te,bind:w,...o.serveContentAssets===void 0?{}:{serveContentAssets:o.serveContentAssets},...k?{reactShellDistDir:k}:{},idleThresholdMs:n(o.idleShutdown??E.idleShutdown),serverRuntime:E,...o.singleFile?{singleFile:o.singleFile}:{},...o.projectDir?{projectDir:o.projectDir}:{},...o.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof Y&&(console.error(f(e.message)),process.exit(1)),e instanceof X&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-DFHKTwRq.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)),Ke(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ce(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]=Ge(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=$(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 j=!1,M=async e=>{if(j)return;j=!0;let[t,...n]=He(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await A.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`,()=>{M(`SIGINT`)}),process.once(`SIGTERM`,()=>{M(`SIGTERM`)});let N=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${A.port}`,ne=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${A.port}`:void 0,P=N;console.log(l({name:`open-knowledge`,version:re,localUrl:P,networkUrl:ne,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let F={"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`};A.ready.then(async()=>{if(A.degraded.length>0){console.log();for(let e of A.degraded){let t=F[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Ne({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:k!==void 0})){let{openBrowser:e}=await import(`./open-browser-DfTjiF9R.mjs`);e(P)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function We(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:u(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 Ge(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 \`${t()} stop\` first if you want a fresh server.`]}function Ke(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`&&ie.native(n)===e.existing.projectDir}catch{return!1}}function $(e,n,r){let i=r.ServerAuthorityCollisionError;if(i!==void 0&&e instanceof i)return e.message;let a=r.ServerAuthorityRegistryError;if(a!==void 0&&e instanceof a)return e.message;let o=r.ServerLockCollisionError;if(o===void 0||!(e instanceof o))return null;try{let e=r.readServerLock(r.resolveLockDir(n)),i=t();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${i} stop\`.`:`OpenKnowledge server is already running on this project — check \`${i} status\` or \`${i} stop\`.`}catch{return null}}function qe(e){return new g(`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)`,De).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)`,Ae).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Be).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 v(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new v(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new v(`--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).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=j(P());if(n.available){O({spawn:I},n);return}console.error(D(n.reason)),process.exit(1)}await Ue(n,t)})}export{$ as C,de as D,V as E,qe as S,Re as T,Ve as _,Ge as a,Ne as b,Z as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,Y as n,He as o,Oe as p,Q as r,je as s,X as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.86.13-beta.
|
|
3
|
+
"version": "0.86.13-beta.6",
|
|
4
4
|
"description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knowledge-base",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@parcel/watcher": "^2.5.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@inkeep/open-knowledge-app": "0.86.13-beta.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.86.13-beta.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.86.13-beta.6",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.86.13-beta.6",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.86.13-beta.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.86.13-beta.6",
|
|
72
72
|
"@types/node": "^24.7.0",
|
|
73
73
|
"@types/proper-lockfile": "^4.1.4",
|
|
74
74
|
"@types/yazl": "^3.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-DK41xNGI.mjs";var e=`0.86.13-beta.5`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/init-CvnXSulz.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-BdWyx3_g.mjs";import{_ as e}from"./init-1vVkAiot.mjs";export{e as runInit};
|
package/dist/loader-CpT_mIAm.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-B9Kr25w_.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CaYt3ZBx.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -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{n as a}from"./dist-PQ5KMVDh.js";import{t as o}from"./compiler-runtime-BfE3aGVn.js";import{t as s}from"./utils-CPqDy6Hr.js";import{i as c,n as l,t as u}from"./tooltip-DBqLYfio.js";import{n as d,t as f}from"./toggle-group-B7p69Qfd.js";import{t as p}from"./button-DzgjsZzC.js";import{a as m,v as h}from"./constants-upload-CVKO8P4d.js";import{n as g}from"./dist-BGzUo_18.js";import{n as _}from"./config-errors-D_yVSvNT.js";import{i as v}from"./use-apply-config-theme-CYFG76sS.js";import{a as y}from"./frontmatter-tags-BHCWOjTl.js";import{t as b}from"./file-tree-utils-BPUSn1l0.js";import"./config-provider-7Po9hSaS.js";import{J as x,Tt as S}from"./dist-D2SphF3p.js";import{n as C,r as w,t as T}from"./cm-theme-o8S36rrW.js";import{t as E}from"./dist-hoz9JKdH.js";import{t as D}from"./text-viewer-languages-Dd-n1gav.js";var O=o(),k=e(n(),1),A=class extends Error{httpStatus;constructor(e,t){super(e),this.name=`ViewerTextLoadError`,this.httpStatus=t}};function j(e){let t=(0,O.c)(10),{_:n}=i(),r;t[0]===n?r=t[1]:(r=e=>n(e===413?{id:`C_WGy8`}:e===415?{id:`VM7H66`}:e===404?{id:`s0IDhW`}:e===400?{id:`N1mdmS`}:typeof e==`number`?{id:`96w9hU`,values:{status:e}}:{id:`ig5vUe`}),t[0]=n,t[1]=r);let a=r,{src:o,loadText:s}=e,c=(0,k.useRef)(s),l=(0,k.useRef)(a),u;t[2]!==s||t[3]!==a?(u=()=>{c.current=s,l.current=a},t[2]=s,t[3]=a,t[4]=u):u=t[4],(0,k.useEffect)(u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={status:`loading`},t[5]=d):d=t[5];let[f,p]=(0,k.useState)(d),m,h;return t[6]!==n||t[7]!==o?(m=()=>{let e=!1,t=new AbortController;p({status:`loading`});let r=c.current;return r?(r(t.signal).then(t=>{if(!e){if(t.ok){p({status:`loaded`,content:t.text});return}p({status:`error`,message:t.message??l.current(t.status),httpStatus:t.status})}}).catch(t=>{e||t instanceof Error&&t.name===`AbortError`||p({status:`error`,message:n({id:`ig5vUe`})})}),()=>{e=!0,t.abort()}):(fetch(o??``,{credentials:`same-origin`,signal:t.signal}).then(async e=>{if(!e.ok)throw new A(l.current(e.status),e.status);return e.text()}).then(t=>{e||p({status:`loaded`,content:t})}).catch(t=>{e||t instanceof Error&&t.name===`AbortError`||p({status:`error`,message:t instanceof Error?t.message:n({id:`ig5vUe`}),httpStatus:t instanceof A?t.httpStatus:void 0})}),()=>{e=!0,t.abort()})},h=[o,n],t[6]=n,t[7]=o,t[8]=m,t[9]=h):(m=t[8],h=t[9]),(0,k.useEffect)(m,h),f}var M=t();function N(e){let t=(0,O.c)(10),{fileName:n,dataAttr:i,extraAttrs:a}=e,o=`${i}-state`,s;t[0]!==i||t[1]!==o?(s={[i]:``,[o]:`loading`},t[0]=i,t[1]=o,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,M.jsx)(`span`,{children:(0,M.jsx)(r,{id:`Md709y`,values:{fileName:n}})}),t[3]=n,t[4]=c);let l;return t[5]!==a||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,M.jsx)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center bg-background text-muted-foreground text-sm`,"aria-label":n,...s,...a,children:c}),t[5]=a,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l}function P(e){let t=(0,O.c)(16),{fileName:n,dataAttr:i,extraAttrs:a,message:o,openFile:s}=e,c=`${i}-state`,l;t[0]!==i||t[1]!==c?(l={[i]:``,[c]:`error`},t[0]=i,t[1]=c,t[2]=l):l=t[2];let u;t[3]===n?u=t[4]:(u=(0,M.jsx)(`div`,{className:`font-medium text-sm`,children:(0,M.jsx)(r,{id:`qdBUHP`,values:{fileName:n}})}),t[3]=n,t[4]=u);let d;t[5]===o?d=t[6]:(d=(0,M.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:o}),t[5]=o,t[6]=d);let f;t[7]===s?f=t[8]:(f=s?(0,M.jsx)(p,{variant:`outline`,size:`sm`,className:`mt-2`,"data-testid":`viewer-open-file`,onClick:()=>{C({url:s.url,projectRelPath:s.projectRelPath,ext:s.ext,title:s.title,forceOsDelegation:!0})},children:(0,M.jsx)(r,{id:`9npOH9`})}):null,t[7]=s,t[8]=f);let m;return t[9]!==a||t[10]!==n||t[11]!==l||t[12]!==u||t[13]!==d||t[14]!==f?(m=(0,M.jsxs)(`main`,{className:`flex h-full min-h-0 flex-col items-center justify-center gap-2 bg-background p-4 text-center`,"aria-label":n,...l,...a,children:[u,d,f]}),t[9]=a,t[10]=n,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=m):m=t[15],m}function F({assetPath:e,fileName:t,extension:n,httpStatus:r}){if(!e||r===404)return;let i=n.toLowerCase();return{projectRelPath:e,ext:i,title:t,url:w(`${m.has(i)?`/api/asset`:`/api/asset-text`}?path=${encodeURIComponent(e)}`)}}var I=T({dark:!0,background:`var(--background)`,gutterBackground:`var(--muted)`}),L=T({dark:!1,background:`var(--background)`,gutterBackground:`var(--muted)`});function R(e){let t=(0,O.c)(28),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({fileName:r,extension:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let o=(0,k.useRef)(null),s=(0,k.useRef)(null),{resolvedTheme:c}=a(),l=j(i),u=l.status===`loaded`?l.content:null,d,f;t[4]!==n||t[5]!==u||t[6]!==c?(d=()=>{if(!o.current||u===null)return;let e=n.toLowerCase(),t=h(e),r=c===`dark`?I:L,i=!1,a=null;return D(e,t).then(e=>{if(i||!o.current)return;let t=[E,...e?[e]:[],x.editable.of(!0),S.readOnly.of(!0),x.lineWrapping,r];a=new x({state:S.create({doc:u,extensions:t}),parent:o.current}),s.current=a}),()=>{i=!0,a?.destroy(),s.current=null}},f=[u,n,c],t[4]=n,t[5]=u,t[6]=c,t[7]=d,t[8]=f):(d=t[7],f=t[8]),(0,k.useEffect)(d,f);let p;t[9]===n?p=t[10]:(p={"data-text-viewer-extension":n},t[9]=n,t[10]=p);let m=p;if(l.status===`loading`){let e;return t[11]!==m||t[12]!==r?(e=(0,M.jsx)(N,{fileName:r,dataAttr:`data-text-viewer`,extraAttrs:m}),t[11]=m,t[12]=r,t[13]=e):e=t[13],e}if(l.status===`error`){let e=l.message,a;t[14]!==n||t[15]!==l.httpStatus||t[16]!==r||t[17]!==i.assetPath?(a=F({assetPath:i.assetPath,fileName:r,extension:n,httpStatus:l.httpStatus}),t[14]=n,t[15]=l.httpStatus,t[16]=r,t[17]=i.assetPath,t[18]=a):a=t[18];let o;return t[19]!==m||t[20]!==l.message||t[21]!==r||t[22]!==a?(o=(0,M.jsx)(P,{fileName:r,dataAttr:`data-text-viewer`,extraAttrs:m,message:e,openFile:a}),t[19]=m,t[20]=l.message,t[21]=r,t[22]=a,t[23]=o):o=t[23],o}let g;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,M.jsx)(`div`,{ref:o,className:`min-h-0 flex-1 overflow-auto`}),t[24]=g):g=t[24];let _;return t[25]!==n||t[26]!==r?(_=(0,M.jsx)(`main`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":r,"data-text-viewer":``,"data-text-viewer-state":`loaded`,"data-text-viewer-extension":n,children:g}),t[25]=n,t[26]=r,t[27]=_):_=t[27],_}function z(e){let t=(0,O.c)(29),{entry:n,className:r}=e,{_:a}=i(),{projectLocalBinding:o,projectLocalSynced:c,merged:l}=v();if(l===null||!c)return null;let u=l?.appearance?.sidebar,d=u?.showHiddenFiles??!1,f=u?.showOnlyMarkdownFiles??!1,m;t[0]!==n||t[1]!==d||t[2]!==f?(m=b(n,{showHiddenFiles:d,showOnlyMarkdownFiles:f}),t[0]=n,t[1]=d,t[2]=f,t[3]=m):m=t[3];let h=m;if(!h.hiddenFiles&&!h.onlyMarkdownFiles)return null;let x;t[4]!==a||t[5]!==o?(x=e=>{if(o===null)return;let t=o.patch({appearance:{sidebar:e}});t.ok||(console.warn(`[NotInSidebarIndicator] sidebar visibility flip rejected:`,_(t.error)),g.error(a({id:`P47EWZ`}),{description:_(t.error)}))},t[4]=a,t[5]=o,t[6]=x):x=t[6];let S=x,C;t[7]===r?C=t[8]:(C=s(`flex items-center gap-1.5 text-muted-foreground/70 text-xs`,r),t[7]=r,t[8]=C);let w;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,M.jsx)(y,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),t[9]=w):w=t[9];let T;t[10]===a?T=t[11]:(T=a({id:`j9tqwO`}),t[10]=a,t[11]=T);let E;t[12]===T?E=t[13]:(E=(0,M.jsx)(`span`,{className:`whitespace-nowrap`,children:T}),t[12]=T,t[13]=E);let D;t[14]!==a||t[15]!==h.hiddenFiles||t[16]!==S||t[17]!==o?(D=h.hiddenFiles?(0,M.jsx)(p,{variant:`outline`,size:`sm`,className:`h-5 rounded-sm px-1.5 font-normal text-2xs text-muted-foreground hover:text-foreground`,disabled:o===null,onClick:()=>S({showHiddenFiles:!0}),"aria-label":a({id:`XcGbim`}),title:a({id:`XcGbim`}),"data-testid":`not-in-sidebar-flip-hidden-files`,children:a({id:`6KCH4m`})}):null,t[14]=a,t[15]=h.hiddenFiles,t[16]=S,t[17]=o,t[18]=D):D=t[18];let k;t[19]!==a||t[20]!==h.onlyMarkdownFiles||t[21]!==S||t[22]!==o?(k=h.onlyMarkdownFiles?(0,M.jsx)(p,{variant:`outline`,size:`sm`,className:`h-5 rounded-sm px-1.5 font-normal text-2xs text-muted-foreground hover:text-foreground`,disabled:o===null,onClick:()=>S({showOnlyMarkdownFiles:!1}),"aria-label":a({id:`10g8I_`}),title:a({id:`10g8I_`}),"data-testid":`not-in-sidebar-flip-only-markdown`,children:a({id:`5-o4kO`})}):null,t[19]=a,t[20]=h.onlyMarkdownFiles,t[21]=S,t[22]=o,t[23]=k):k=t[23];let A;return t[24]!==k||t[25]!==C||t[26]!==E||t[27]!==D?(A=(0,M.jsxs)(`div`,{"data-testid":`not-in-sidebar-indicator`,className:C,children:[w,E,D,k]}),t[24]=k,t[25]=C,t[26]=E,t[27]=D,t[28]=A):A=t[28],A}var B={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},V=e=>{let t=(0,O.c)(15),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,M.jsx)(`svg`,{"aria-hidden":`true`,...B,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},H=e=>{let t=(0,O.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,M.jsx)(`title`,{children:`Markdown`}),r=(0,M.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,M.jsxs)(V,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},U=e=>{let t=(0,O.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,M.jsx)(`title`,{children:`Textbox`}),r=(0,M.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,M.jsxs)(V,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function W(e){let t=(0,O.c)(48),{isSourceMode:n,onModeChange:a,sourceDisabled:o,wysiwygDisabled:s,wysiwygLabel:p,sourceLabel:m,wysiwygDisabledReason:h}=e,g=o===void 0?!1:o,_=s===void 0?!1:s,{_:v}=i(),y;t[0]!==v||t[1]!==p?(y=p??v({id:`ur2XSb`}),t[0]=v,t[1]=p,t[2]=y):y=t[2];let b=y,x;t[3]!==v||t[4]!==m?(x=m??v({id:`xbdtfY`}),t[3]=v,t[4]=m,t[5]=x):x=t[5];let S=x,C=(0,k.useId)(),w=_&&h?h:null,T=n?`source`:`wysiwyg`,E;t[6]===a?E=t[7]:(E=e=>{e&&a(e)},t[6]=a,t[7]=E);let D;t[8]===v?D=t[9]:(D=v({id:`n7aopT`}),t[8]=v,t[9]=D);let A=w?C:void 0,j;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,M.jsx)(U,{className:`size-4`}),t[10]=j):j=t[10];let N;t[11]!==A||t[12]!==_||t[13]!==b?(N=(0,M.jsx)(d,{value:`wysiwyg`,"aria-label":b,"aria-describedby":A,disabled:_,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:j}),t[11]=A,t[12]=_,t[13]=b,t[14]=N):N=t[14];let P;t[15]!==w||t[16]!==C?(P=w?(0,M.jsx)(`span`,{id:C,className:`sr-only`,children:w}):null,t[15]=w,t[16]=C,t[17]=P):P=t[17];let F;t[18]!==N||t[19]!==P?(F=(0,M.jsx)(c,{asChild:!0,children:(0,M.jsxs)(`div`,{children:[N,P]})}),t[18]=N,t[19]=P,t[20]=F):F=t[20];let I;t[21]!==_||t[22]!==h||t[23]!==p?(I=_&&h?h:p||(0,M.jsx)(r,{id:`Mb_20S`}),t[21]=_,t[22]=h,t[23]=p,t[24]=I):I=t[24];let L;t[25]===I?L=t[26]:(L=(0,M.jsx)(l,{side:`bottom`,children:I}),t[25]=I,t[26]=L);let R;t[27]!==F||t[28]!==L?(R=(0,M.jsxs)(u,{children:[F,L]}),t[27]=F,t[28]=L,t[29]=R):R=t[29];let z;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,M.jsx)(H,{className:`size-4`}),t[30]=z):z=t[30];let B;t[31]!==g||t[32]!==S?(B=(0,M.jsx)(c,{asChild:!0,children:(0,M.jsx)(`div`,{children:(0,M.jsx)(d,{value:`source`,"aria-label":S,disabled:g,className:`size-7 px-0 dark:data-[state=on]:bg-foreground/15`,children:z})})}),t[31]=g,t[32]=S,t[33]=B):B=t[33];let V;t[34]!==g||t[35]!==m?(V=g?(0,M.jsx)(r,{id:`G-JBA1`}):m||(0,M.jsx)(r,{id:`u6Hp4N`}),t[34]=g,t[35]=m,t[36]=V):V=t[36];let W;t[37]===V?W=t[38]:(W=(0,M.jsx)(l,{side:`bottom`,children:V}),t[37]=V,t[38]=W);let G;t[39]!==B||t[40]!==W?(G=(0,M.jsxs)(u,{children:[B,W]}),t[39]=B,t[40]=W,t[41]=G):G=t[41];let K;return t[42]!==R||t[43]!==G||t[44]!==T||t[45]!==E||t[46]!==D?(K=(0,M.jsxs)(f,{type:`single`,value:T,onValueChange:E,"aria-label":D,variant:`segmented`,size:`sm`,spacing:1,className:`shrink-0 bg-muted p-0.5 data-[size=sm]:rounded-[10px]`,children:[R,G]}),t[42]=R,t[43]=G,t[44]=T,t[45]=E,t[46]=D,t[47]=K):K=t[47],K}export{F as a,j as c,R as i,H as n,P as o,z as r,N as s,W as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-BXC8xtHm.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-D7tV0Whc.js";export{e as ManagedArtifactProperties};
|