@inkeep/open-knowledge 0.88.6-beta.3 → 0.88.6-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alias-JE7RI5QX-D_KITrCa.mjs +1 -0
- package/dist/assets/skills/project/references/ingest-and-sources.md +1 -1
- package/dist/awk2-BBAGSFUB-CehlsFZ5.mjs +1 -0
- package/dist/bash-IJWYRKFO-D1gJZuWH.mjs +1 -0
- package/dist/chokidar-D0G-K3zc.mjs +3 -0
- package/dist/{chunk-3BS5SKQH-C9C8uLJE.mjs → chunk-3BS5SKQH-CKmQMz_L.mjs} +15 -15
- package/dist/{chunk-62RKD26F-Bv6peUyf.mjs → chunk-62RKD26F-B6OssxCM.mjs} +3 -3
- package/dist/{chunk-6Z5SFZXK-CiQN8zZ8.mjs → chunk-6Z5SFZXK-D2_6X1Dn.mjs} +35 -35
- package/dist/chunk-A4JSPFCI-DQxLkrTb.mjs +6 -0
- package/dist/chunk-D6CWQ5DW-BybImdUI.mjs +5 -0
- package/dist/chunk-GOV5EKKI-D42P07Xu.mjs +9 -0
- package/dist/{chunk-HKLCLINH-BHo2f5d2.mjs → chunk-HKLCLINH-C2rvDMlW.mjs} +20 -20
- package/dist/{chunk-HL6NGDO2-BFPiiJBP.mjs → chunk-HL6NGDO2-CvsVMff5.mjs} +9 -9
- package/dist/{chunk-I57KEIP3-C90kULU7.mjs → chunk-I57KEIP3-BrnLL4Gl.mjs} +4 -4
- package/dist/{chunk-K6LIBGJA-D-bMYdgr.mjs → chunk-K6LIBGJA-CN_13h4C.mjs} +7 -7
- package/dist/{chunk-KRBPSX3W-DXuvylLd.mjs → chunk-KRBPSX3W-CY8FCKFm.mjs} +2 -2
- package/dist/chunk-MDDMCKUK-ByCsPSNd.mjs +6 -0
- package/dist/chunk-MIZPJHVH-DrIwZ3F_.mjs +7 -0
- package/dist/chunk-NAERJDUW-nfjIZ3Pb.mjs +8 -0
- package/dist/chunk-NUYSJFDK-M0xrw_uS.mjs +7 -0
- package/dist/chunk-OCLXQMOG-DHLmxiVS.mjs +6 -0
- package/dist/{chunk-OCS6LSEM-BBT5tk28.mjs → chunk-OCS6LSEM-CUgQNrT_.mjs} +7 -7
- package/dist/{chunk-PBXLG62G-G7lHqZ9p.mjs → chunk-PBXLG62G-CuixUdAo.mjs} +3 -3
- package/dist/{chunk-T56QNPHK-BuLSSwpV.mjs → chunk-T56QNPHK-BhobE-0w.mjs} +3 -3
- package/dist/chunk-TLSUDHID-BpXt2GFu.mjs +6 -0
- package/dist/{chunk-TOMNU26N-CPb3jib2.mjs → chunk-TOMNU26N-Bhlbw7_h.mjs} +3 -3
- package/dist/{chunk-TP4BZANS-BKDDD1i2.mjs → chunk-TP4BZANS-Dv2qAxWh.mjs} +12 -12
- package/dist/{chunk-XKWWSDBF-CiyukTrj.mjs → chunk-XKWWSDBF-COm-Bab0.mjs} +10 -10
- package/dist/{chunk-YMMW5UAP-B7swMNER.mjs → chunk-YMMW5UAP-CTA9rr10.mjs} +7 -7
- package/dist/chunk-YTNYSM6T-gRMum0pq.mjs +11 -0
- package/dist/{chunk-YULBWSET-BjwIKz2I.mjs → chunk-YULBWSET-BZbeBpnM.mjs} +6 -6
- package/dist/{chunk-Z6LRHWXI-B5pNb54L.mjs → chunk-Z6LRHWXI-BE3EMa92.mjs} +5 -5
- package/dist/{chunk-ZZO3UDB3-Dr2Q2MNF.mjs → chunk-ZZO3UDB3-C92Poglu.mjs} +32 -32
- package/dist/cli-DtqA8k1H.mjs +110 -0
- package/dist/cli.mjs +1 -110
- package/dist/constants-D-73L_8T.mjs +1 -0
- package/dist/constants-ok-dir-DZ25OS9-.mjs +115 -0
- package/dist/{cp-XOYR4ABJ-BWvobbqd.mjs → cp-XOYR4ABJ-KRhRq3W9.mjs} +1 -1
- package/dist/{curl-47BFPSFW-CjxwhFSt.mjs → curl-47BFPSFW-D1cYHIfa.mjs} +8 -8
- package/dist/{diff-HJF2MPDN-B5Vu5bd_.mjs → diff-HJF2MPDN-CLb1d3Pm.mjs} +1 -1
- package/dist/dist-D4ipyg1q.mjs +1 -0
- package/dist/{dist-Br5t34YL.mjs → dist-DPe6aLSk.mjs} +518 -522
- package/dist/env-5EPCWSXR-B6cYhau7.mjs +1 -0
- package/dist/expansion-VBDYWVZR-vhATs2YP.mjs +1 -0
- package/dist/expr-YYCVMXE3-BG-gQLPe.mjs +1 -0
- package/dist/{file-IGDTDPLG-CRy1Omyh.mjs → file-IGDTDPLG-CqcQiax7.mjs} +1 -1
- package/dist/find-DH2ALKQS-DUCbwSBg.mjs +1 -0
- package/dist/flag-coverage-6JEX67RU-BgXRRqNM.mjs +1 -0
- package/dist/fs-find-project-root-BYV07wjn.mjs +5 -0
- package/dist/git-credential-get-BOA4DNNp.mjs +2 -0
- package/dist/git-credential-helper-DY8W25nc.mjs +1 -0
- package/dist/git-credential-operation-9lLcCrJB.mjs +1 -0
- package/dist/grep-2HUTXO5U-CbvcQZdY.mjs +1 -0
- package/dist/index.mjs +302 -302
- package/dist/{init-CFqa1MvX.mjs → init-C08CTCp9.mjs} +28 -28
- package/dist/init-CSYVvJYZ.mjs +1 -0
- package/dist/jq-LYZFFBZB-DP4gih1P.mjs +1 -0
- package/dist/{js-exec-VXN6TZ7U-Z8_USGOo.mjs → js-exec-VXN6TZ7U-B4rL1N_3.mjs} +4 -4
- package/dist/{js-exec-VXN6TZ7U-D--44jnh.mjs → js-exec-VXN6TZ7U-CByMmXZz.mjs} +8 -8
- package/dist/launch-json-removal-B39BoBBe.mjs +1 -0
- package/dist/{lib-CxwDRGVJ.mjs → lib-CGyiYSWt.mjs} +15 -15
- package/dist/{ln-4TRFBYAT-xkfE7-89.mjs → ln-4TRFBYAT-RK1Uvly1.mjs} +1 -1
- package/dist/loader-D4dq2xfA.mjs +1 -0
- package/dist/loader-DeOCcx0c.mjs +1 -0
- package/dist/{lzma-CEMDJHEs.mjs → lzma-B6QS2aZK.mjs} +2 -2
- package/dist/{lzma-PPHiE419.mjs → lzma-VPfz3anC.mjs} +1 -1
- package/dist/md-manager-BGnqyqi1-DmEmjhMs.mjs +400 -0
- package/dist/{mkdir-TDEMSB6C-DKSMdaAE.mjs → mkdir-TDEMSB6C-Ds9y3YxN.mjs} +1 -1
- package/dist/{mv-Z6MORUFL-C-C4Dr_j.mjs → mv-Z6MORUFL-C9ixK1Sz.mjs} +1 -1
- package/dist/{open-browser-BgcinSRG.mjs → open-browser-d8GjenQK.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-BD9T555q.mjs +1 -0
- package/dist/preview-BOmvdi0o.mjs +2 -0
- package/dist/printf-CX64KX2P-DlBDp9me.mjs +1 -0
- package/dist/public/assets/{AccountSection-LJRd8sB4.js → AccountSection-UK4fSEAo.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-CQSexLMh.js → ActivityModeContent-CD3FGIx9.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-CFKmvgxU.js → AddPropertiesButton-B6p_gdr8.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-_ihWGbD_.js → AgentDiffPane-DkoQ7ai2.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-DBsgV2Bw.js → AttachmentsSection-B4oQIzeZ.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-CijXVQab.js → CodeMirrorPropInput-B9s5B9Bw.js} +2 -2
- package/dist/public/assets/{ContentRulesSection-C6MePblA.js → ContentRulesSection-aWJrYA4j.js} +1 -1
- package/dist/public/assets/{DocumentContext-Ckv8SUWG.js → DocumentContext-DXpWi5ky.js} +2 -2
- package/dist/public/assets/{EditorModeToggle-N2hyqb1I.js → EditorModeToggle-Diya7MyF.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CP2HLZRg.js → ExcalidrawDocEditor-PRwr0WYf.js} +1 -1
- package/dist/public/assets/FeedbackForm-Cvqd9EXq.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-B6FRcFBN.js → ImportSkillDialog-CMk2xlCO.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-C4BQkoW1.js → LinkPreviewsSection-KX_4h53c.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-BZ5RnGQH.js → LintConfigEditor-7ZtCVw7Y.js} +1 -1
- package/dist/public/assets/{LintingSection-gYcf6zSw.js → LintingSection-ClAY_FjD.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-C6A9h_XM.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-7BpPCdWC.js → ManagedArtifactProperties-lEwwds9N.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-D8S17k_t.js → MermaidDocEditor-DHUtun4r.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-CfSEDmXg.js → NetworkAccessSection-CkW30CIT.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-BoNQImBU.js → PropertyDisplayRow-D6c0dfSa.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-Bc5NpD70.js → PublishToGitHubDialog-CwF7zH2X.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DXzybru5.js → SchemaConfigEditor-BEJxtFtu.js} +1 -1
- package/dist/public/assets/{SearchSection-C19oEXnN.js → SearchSection-CDyx2C9f.js} +1 -1
- package/dist/public/assets/{SessionsHost-Dq18GV-Q.js → SessionsHost-H5NLeN9a.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CKMzthec.js → SettingsDialogBody-C_YjecBu.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-CjeRKStG.js → ShareReceiveMissDialog-D_FkOpht.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-Bw0kbj8T.js → SkillToolbarControls-CtxNLAp-.js} +1 -1
- package/dist/public/assets/{SourceEditor-Cdd0XUzF.js → SourceEditor-B5LnWxyf.js} +1 -1
- package/dist/public/assets/{SpellingSettings-D39D0V93.js → SpellingSettings-05EGR87o.js} +1 -1
- package/dist/public/assets/{SyncSection-uN1z_93L.js → SyncSection-D3PTVWIM.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-DKqP2nFA.js → SyncStatusBadge-BaJrZaL1.js} +1 -1
- package/dist/public/assets/{TerminalSection-OQKUYevA.js → TerminalSection-CsRkbMx2.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CYJ1Jbl1.js → TerminalWindowApp-CA9GKqNE.js} +1 -1
- package/dist/public/assets/{TextDocEditor-O7zcpBhs.js → TextDocEditor-Ch27GvYs.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-DvDmnFk0.js → ThemePluginSection-_vipA-fZ.js} +1 -1
- package/dist/public/assets/{ThreadView-DXAtEUVo.js → ThreadView-Dj6jQfOU.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DfckigW2.js → TimelineDiffPane-4gPranZj.js} +1 -1
- package/dist/public/assets/{client-version-BJc8f8RK.js → client-version-B_xA5Zs6.js} +1 -1
- package/dist/public/assets/{comment-chips-D5QcVI38.js → comment-chips-nSpyi8g5.js} +1 -1
- package/dist/public/assets/{config-provider-B2uReVA0.js → config-provider-CNRgcd7O.js} +1 -1
- package/dist/public/assets/config-schema-BiXW8bgJ.js +1 -0
- package/dist/public/assets/{doc-undo-manager-eVCrXF_j.js → doc-undo-manager-mWX4_oGV.js} +1 -1
- package/dist/public/assets/{field-controls-BUVPC8fp.js → field-controls-7BMlpso-.js} +1 -1
- package/dist/public/assets/field-controls-Bx5mePuq.js +1 -0
- package/dist/public/assets/{index-DixZkzDK.js → index-DvFhVjVJ.js} +7 -7
- package/dist/public/assets/{lint-config-client-IECAMEY0.js → lint-config-client-CE9biPJr.js} +1 -1
- package/dist/public/assets/{lint-plugins-BkTeSxCo.js → lint-plugins-DAx86XSh.js} +1 -1
- package/dist/public/assets/{markdown-lint-Gr2dt_mE.js → markdown-lint-BU1ReVdL.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-BPUY-_hO.js → markdownlint-rule-browser-CX5Nb4yK.js} +1 -1
- package/dist/public/assets/messages-3TywIfo0.js +1 -0
- package/dist/public/assets/messages-60dgDSH4.js +1 -0
- package/dist/public/assets/messages-9vrrNpJf.js +1 -0
- package/dist/public/assets/messages-B-A9_jul.js +1 -0
- package/dist/public/assets/messages-B4Eyfdod.js +1 -0
- package/dist/public/assets/messages-BsQXyfTQ.js +1 -0
- package/dist/public/assets/messages-CIj-vRyV.js +1 -0
- package/dist/public/assets/messages-CZbBFMhU.js +1 -0
- package/dist/public/assets/messages-D5Q2aWu3.js +1 -0
- package/dist/public/assets/messages-D6ypArrS.js +1 -0
- package/dist/public/assets/messages-Zpi3sLU2.js +1 -0
- package/dist/public/assets/messages-lMmvlKg7.js +1 -0
- package/dist/public/assets/messages-yXb-shTo.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-Iv87HrBp.js → pending-receive-nav-store-hbWxGWbG.js} +1 -1
- package/dist/public/assets/{preferred-session-events-xfa2uZrO.js → preferred-session-events-CD3TX4uI.js} +1 -1
- package/dist/public/assets/{progress-BrArAZHf.js → progress-Bp-8Nd7B.js} +1 -1
- package/dist/public/assets/{saved-themes-client-CERsocAi.js → saved-themes-client-Cefq8Snw.js} +1 -1
- package/dist/public/assets/{schema-section-DxwzENze.js → schema-section-BTjV9wCm.js} +1 -1
- package/dist/public/assets/{selection-context-Dbqj5HIF.js → selection-context-C7DBYtd4.js} +1 -1
- package/dist/public/assets/{src-CY4cyl93.js → src-Bd4ITI6l.js} +1 -1
- package/dist/public/assets/{telemetry-impl-CzmRwkV2.js → telemetry-impl-D34TS_t5.js} +1 -1
- package/dist/public/assets/{telemetry-startup-6UOhK4H3.js → telemetry-startup-S6YVb_-D.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-43TkkCGr.js → typing-burst-detector-BPhBcJhO.js} +1 -1
- package/dist/public/assets/{uninstall-Drxc7ooZ.js → uninstall-CBADj29y.js} +1 -1
- package/dist/public/assets/{use-activity-panel-Bqo7iLoL.js → use-activity-panel-DAiQAul-.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-DWhramML.js → use-apply-config-language-BVhx79Sp.js} +2 -2
- package/dist/public/assets/{use-open-skill-DiaFh1sV.js → use-open-skill-BiGTEBAG.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-D67U-_lT.js → use-terminal-enabled-BPFt3ZjV.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-KpbAdkg7.js → use-timeline-entry-diff-DI6wb0mp.js} +1 -1
- package/dist/public/index.html +24 -24
- package/dist/public/uninstall.html +3 -3
- package/dist/python3-DNGS4G3E-BgcDJ4cm.mjs +11 -0
- package/dist/{python3-DNGS4G3E-CixyRGKv.mjs → python3-DNGS4G3E-Cm5Hwa-u.mjs} +3 -3
- package/dist/registry-probes-CQ5QHLWA.mjs +16 -0
- package/dist/{removal-file-path-BB7PGKh9.mjs → removal-file-path-DhnfL9uo.mjs} +1 -1
- package/dist/{repair-launch-json-BGnKoX_8.mjs → repair-launch-json-D4tGRImu.mjs} +1 -1
- package/dist/{repair-mcp-configs-CnuXQsDL.mjs → repair-mcp-configs-CkXUYNJq.mjs} +1 -1
- package/dist/rg-XNF3R3II-BCapXTDd.mjs +1 -0
- package/dist/{rm-RTZG23RL-CVxZCS0d.mjs → rm-RTZG23RL-pdC15ghA.mjs} +1 -1
- package/dist/{rmdir-XTQXT7RK-DnFOfz6J.mjs → rmdir-XTQXT7RK-DcllfdyA.mjs} +1 -1
- package/dist/sed-JAPPVBEU-BogTEm4c.mjs +1 -0
- package/dist/{sleep-VZFPZFWA-C-QGmlTD.mjs → sleep-VZFPZFWA-Z-cEwS7i.mjs} +1 -1
- package/dist/sqlite3-TE5AIOTF-DqoN8a9C.mjs +1 -0
- package/dist/{sqlite3-TE5AIOTF-DVwda1Ow.mjs → sqlite3-TE5AIOTF-DxxxT49W.mjs} +3 -3
- package/dist/src-DxORHPwx.mjs +1 -0
- package/dist/src-uYPRavFi.mjs +16 -0
- package/dist/start-BVplvpm0.mjs +5 -0
- package/dist/start-Dp7OVBDP.mjs +1 -0
- package/dist/tar-MZQD7NO4-DEw7Py1-.mjs +1 -0
- package/dist/{tar-MZQD7NO4-BRGDcHqv.mjs → tar-MZQD7NO4-ljX84Spn.mjs} +2 -2
- package/dist/time-DEUO3QV2-BdkhaszE.mjs +1 -0
- package/dist/{timeout-VRKMCG72-Bn-zPLw8.mjs → timeout-VRKMCG72-BJshiKR9.mjs} +1 -1
- package/dist/token-store-Bmb3_0hU.mjs +2 -0
- package/dist/touch-DX2IJOQ4-DQk2E3PA.mjs +1 -0
- package/dist/{tr-2HXZRDSW-D6nqhlWa.mjs → tr-2HXZRDSW-B9XzLO_W.mjs} +1 -1
- package/dist/xan-UD7JYIL2-B0nl-bKu.mjs +1 -0
- package/dist/xargs-I6EZUCYF-DyMYQH4H.mjs +1 -0
- package/dist/yq-OAKYHSXH-BuWuWli6.mjs +1 -0
- package/package.json +4 -4
- package/dist/alias-JE7RI5QX-DJCUhA0w.mjs +0 -1
- package/dist/awk2-BBAGSFUB-e61UM1Y8.mjs +0 -1
- package/dist/bash-IJWYRKFO-L9NsSg-G.mjs +0 -1
- package/dist/chokidar-BXdru135.mjs +0 -3
- package/dist/chunk-A4JSPFCI-Ywh1N_m_.mjs +0 -6
- package/dist/chunk-D6CWQ5DW-CWPsf9FV.mjs +0 -5
- package/dist/chunk-GOV5EKKI-DH8052og.mjs +0 -9
- package/dist/chunk-MDDMCKUK-B8V-vwhF.mjs +0 -6
- package/dist/chunk-MIZPJHVH-D45kCv1L.mjs +0 -7
- package/dist/chunk-NAERJDUW-g_zD_t_X.mjs +0 -8
- package/dist/chunk-NUYSJFDK-C3CfS8pU.mjs +0 -7
- package/dist/chunk-OCLXQMOG-BgcVHeKY.mjs +0 -6
- package/dist/chunk-TLSUDHID-BY7gVdyC.mjs +0 -6
- package/dist/chunk-YTNYSM6T-3WjLDS_v.mjs +0 -11
- package/dist/constants-qWODYpdZ.mjs +0 -1
- package/dist/dist-DFlcDcjF.mjs +0 -1
- package/dist/env-5EPCWSXR-hkmWHgd5.mjs +0 -1
- package/dist/expansion-VBDYWVZR-CPnYsIZl.mjs +0 -1
- package/dist/expr-YYCVMXE3-DtiMaNQl.mjs +0 -1
- package/dist/find-DH2ALKQS-44-asZtW.mjs +0 -1
- package/dist/flag-coverage-6JEX67RU-CvfAS1f3.mjs +0 -1
- package/dist/grep-2HUTXO5U-CoGVhBxG.mjs +0 -1
- package/dist/init-D5UpQ70d.mjs +0 -1
- package/dist/jq-LYZFFBZB-CXMPfDWj.mjs +0 -1
- package/dist/launch-json-removal-BiiU2YFK.mjs +0 -1
- package/dist/loader-B2fGi6oQ.mjs +0 -1
- package/dist/loader-CpSE6Pb3.mjs +0 -1
- package/dist/md-manager-BGnqyqi1-COpgRhOl.mjs +0 -514
- package/dist/preview-DSJofhni.mjs +0 -1
- package/dist/preview-W1qLrOTN.mjs +0 -2
- package/dist/printf-CX64KX2P-zCdxSgaG.mjs +0 -1
- package/dist/public/assets/FeedbackForm-DvbVD7xY.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-C21i-wVX.js +0 -1
- package/dist/public/assets/config-schema-JSuM1ay_.js +0 -1
- package/dist/public/assets/field-controls-DceP36U9.js +0 -1
- package/dist/public/assets/messages--JE1r0oK.js +0 -1
- package/dist/public/assets/messages-BPDRauYd.js +0 -1
- package/dist/public/assets/messages-Bw510bJG.js +0 -1
- package/dist/public/assets/messages-By-SAk_o.js +0 -1
- package/dist/public/assets/messages-C9dO0WcF.js +0 -1
- package/dist/public/assets/messages-CE48fdcx.js +0 -1
- package/dist/public/assets/messages-CQaF3pLd.js +0 -1
- package/dist/public/assets/messages-D-qO9G0a.js +0 -1
- package/dist/public/assets/messages-D4HWBQCW.js +0 -1
- package/dist/public/assets/messages-DE6pzo9b.js +0 -1
- package/dist/public/assets/messages-Dy13fRcA.js +0 -1
- package/dist/public/assets/messages-JfpWPtsW.js +0 -1
- package/dist/public/assets/messages-q-WCQc2m.js +0 -1
- package/dist/python3-DNGS4G3E-CRyO5yp1.mjs +0 -11
- package/dist/registry-probes-DwE2ywLj.mjs +0 -17
- package/dist/rg-XNF3R3II-ClllMprJ.mjs +0 -1
- package/dist/sed-JAPPVBEU-D49-i6JC.mjs +0 -1
- package/dist/sqlite3-TE5AIOTF-BK092fD6.mjs +0 -1
- package/dist/src-CMSKsmsA.mjs +0 -1
- package/dist/src-CbDiPIIp.mjs +0 -16
- package/dist/start-Bs7pMN0A.mjs +0 -5
- package/dist/start-Dx5wqmPM.mjs +0 -1
- package/dist/tar-MZQD7NO4-D__44nPJ.mjs +0 -1
- package/dist/time-DEUO3QV2-BAt2bzlP.mjs +0 -1
- package/dist/touch-DX2IJOQ4-BJTz2DiT.mjs +0 -1
- package/dist/xan-UD7JYIL2-IybnHHpT.mjs +0 -1
- package/dist/xargs-I6EZUCYF-CpVYZvg1.mjs +0 -1
- package/dist/yq-OAKYHSXH-kqRGBS-8.mjs +0 -1
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import"./chunk-R6VWJ2ZL-DJY9gweS.mjs";import"./chunk-CWQS3NFK-BbpS-dVt.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import{t as e}from"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import{n as t,t as n}from"./chunk-A5O5YHGN-BRMz0iFo.mjs";import{r}from"./chunk-OJDRYQWQ-JGMWNwO9.mjs";import{n as i}from"./chunk-24IMIIXA-Dj5K6qOb.mjs";import{n as a,t as o}from"./chunk-3THT3N7L-DVKHLRUO.mjs";import{t as s}from"./chunk-44UOCSGV-CeGMLWmo.mjs";import{r as c,t as l}from"./chunk-74CEPOFO-BuzahJu2.mjs";import{n as u,t as d}from"./chunk-I57KEIP3-C90kULU7.mjs";import{fileURLToPath as f}from"node:url";import{randomBytes as p}from"node:crypto";import{Worker as m}from"node:worker_threads";var h=1e4,g=6e4,_={name:`python3`,summary:`Execute Python code via CPython Emscripten`,usage:`python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]`,description:[`Execute Python code using CPython compiled to WebAssembly via Emscripten.`,``,`This command runs Python in an isolated environment with access to`,`the virtual filesystem. Standard library modules are available.`],options:[`-c CODE Execute CODE as Python script`,`-m MODULE Run library module as a script`,`--version Show Python version`,`--help Show this help`],examples:[`python3 -c "print(1 + 2)"`,`python3 -c "import sys; print(sys.version)"`,`python3 script.py`,`python3 script.py arg1 arg2`,`echo 'print("hello")' | python3`],notes:[`CPython runs in WebAssembly, so execution may be slower than native Python.`,`Standard library modules are available (no pip install).`,`Maximum execution time is 30 seconds by default.`]};function v(e){let t={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(e.length===0)return t;let n=e.findIndex(e=>!e.startsWith(`-`)||e===`-`||e===`--`);for(let r=0;r<(n===-1?e.length:n);r++){let n=e[r];if(n===`-c`)return r+1>=e.length?{stdout:``,stderr:`python3: option requires an argument -- 'c'
|
|
2
|
-
`,exitCode:2}:(t.code=e[r+1],t.scriptArgs=e.slice(r+2),t);if(n===`-m`)return r+1>=e.length?{stdout:``,stderr:`python3: option requires an argument -- 'm'
|
|
3
|
-
`,exitCode:2}:(t.module=e[r+1],t.scriptArgs=e.slice(r+2),t);if(n===`--version`||n===`-V`)return t.showVersion=!0,t;if(n.startsWith(`-`)&&n!==`-`)return{stdout:``,stderr:`python3: unrecognized option '${n}'
|
|
4
|
-
`,exitCode:2}}if(n!==-1){let r=e[n];r===`--`?n+1<e.length&&(t.scriptFile=e[n+1],t.scriptArgs=e.slice(n+2)):(t.scriptFile=r,t.scriptArgs=e.slice(n+1))}return t}var y=new WeakMap;function b(e){let t=y.get(e);return t||(t={executionQueue:[],isExecuting:!1},y.set(e,t)),t}var x=f(new URL(`./worker.js`,import.meta.url));function S(){return p(16).toString(`hex`)}function C(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:n.type===`security-violation`?{success:!1,error:`Security violation: ${typeof n.violation?.type==`string`?n.violation.type:`unknown`}`}:typeof n.success==`boolean`?n.success?{success:!0}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}function w(t){if(t.isExecuting||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0].canceled;)t.executionQueue.shift();if(t.executionQueue.length===0)return;let n=t.executionQueue.shift();if(!n)return;t.isExecuting=!0;let r;try{r=e.runTrusted(()=>new m(x,{workerData:n.input}))}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t);return}n.workerRef&&(n.workerRef.current=r);let a=i(n.requireDefenseContext,`python3`,`worker message callback`,e=>{n.resolve(C(e,n.input.protocolToken)),t.isExecuting=!1,r.terminate(),w(t)}),c=i(n.requireDefenseContext,`python3`,`worker error callback`,e=>{let r=o(s(e));n.resolve({success:!1,error:r}),t.isExecuting=!1,w(t)}),l=i(n.requireDefenseContext,`python3`,`worker exit callback`,()=>{t.isExecuting&&(n.resolve({success:!1,error:`Worker exited unexpectedly`}),t.isExecuting=!1,w(t))});r.on(`message`,e=>{try{a(e)}catch(e){let i=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(i)}),t.isExecuting=!1,r.terminate(),w(t)}}),r.on(`error`,e=>{try{c(e)}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}}),r.on(`exit`,()=>{try{l()}catch(e){let r=e instanceof Error?e.message:String(e);n.resolve({success:!1,error:o(r)}),t.isExecuting=!1,w(t)}})}async function T(e,a,c,l=[]){let f=u(),p=new d(f,a.fs,a.cwd,`python3`,a.fetch,a.limits?.maxOutputSize??0),m=a.limits?.maxPythonTimeoutMs??h,_=a.fetch?Math.max(m,g):m,v=b(a.fs),y={protocolToken:S(),sharedBuffer:f,pythonCode:e,cwd:a.cwd,env:r(a.env),args:l,scriptPath:c,timeoutMs:_},x={current:null},C=new Promise(e=>{let r={input:y,resolve:()=>{},workerRef:x,requireDefenseContext:a.requireDefenseContext},s=i(a.requireDefenseContext,`python3`,`worker timeout callback`,()=>{x.current?x.current.terminate():r.canceled=!0,e({success:!1,error:`Execution timeout: exceeded ${_}ms limit`})}),c=n(()=>{try{s()}catch(t){let n=t instanceof Error?t.message:String(t);e({success:!1,error:o(n)})}},_);r.resolve=n=>{t(c),e(n)},v.executionQueue.push(r),w(v)}),[T,E]=await Promise.all([p.run(_).catch(e=>({stdout:``,stderr:`python3: bridge error: ${o(s(e))}
|
|
5
|
-
`,exitCode:1})),C.catch(e=>({success:!1,error:o(s(e))}))]);if(!E.success&&E.error){let e=o(E.error);return{stdout:T.stdout,stderr:`${T.stderr}python3: ${e}
|
|
6
|
-
`,exitCode:T.exitCode||1}}return T}var E={name:`python3`,async execute(e,t){if(l(e))return c(_);let n=v(e);if(`exitCode`in n)return n;if(n.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
|
|
7
|
-
`,stderr:``,exitCode:0};let r,i;if(n.code!==null)r=n.code,i=`-c`;else if(n.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(n.module))return{stdout:``,stderr:`python3: No module named '${n.module.slice(0,200)}'
|
|
8
|
-
`,exitCode:1};r=`import runpy; runpy.run_module('${n.module}', run_name='__main__')`,i=n.module}else if(n.scriptFile===`-`)r=t.stdin,i=`-`;else if(n.scriptFile!==null){let e=t.fs.resolvePath(t.cwd,n.scriptFile);if(!await t.fs.exists(e))return{stdout:``,stderr:`python3: can't open file '${n.scriptFile}': [Errno 2] No such file or directory
|
|
9
|
-
`,exitCode:2};try{r=await t.fs.readFile(e),i=n.scriptFile}catch(e){let t=a(e.message);return{stdout:``,stderr:`python3: can't open file '${n.scriptFile}': ${t}
|
|
10
|
-
`,exitCode:2}}}else if(t.stdin.trim())r=t.stdin,i=`<stdin>`;else return{stdout:``,stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
|
|
11
|
-
`,exitCode:2};return T(r,t,i,n.scriptArgs)}},D={name:`python`,async execute(e,t){return E.execute(e,t)}};export{E as python3Command,D as pythonCommand};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Kf as r,Mf as i,Pf as a,Qf as o,Ya as s,Yf as c,al as l,el as u,jf as d,kf as f,np as p,op as m,qf as h,rp as g,tp as _,vd as v,zd as y}from"./md-manager-BGnqyqi1-COpgRhOl.mjs";import{Fs as b,Hn as x,Hs as ee,Ms as S,Pa as te,Vs as ne,_r as re,cs as ie,m as C,nr as ae,qo as oe}from"./dist-Br5t34YL.mjs";import{A as se,B as ce,E as le,F as ue,M as de,N as w,S as fe,T as pe,Y as me,Z as T,at as he,b as ge,et as _e,f as ve,ft as ye,it as be,j as xe,k as E,lt as Se,nt as Ce,ot as we,p as Te,rt as Ee,s as De,ut as Oe,y as ke}from"./init-CFqa1MvX.mjs";import{t as Ae}from"./is-object-BGze3w87.mjs";import{t as je}from"./removal-file-path-BB7PGKh9.mjs";import{spawn as Me}from"node:child_process";import{basename as Ne,dirname as D,join as O,resolve as k,win32 as Pe}from"node:path";import{accessSync as Fe,constants as A,existsSync as j,lstatSync as M,mkdirSync as Ie,readFileSync as N,readdirSync as P,realpathSync as F,rmSync as Le,rmdirSync as Re,statSync as I,unlinkSync as ze}from"node:fs";import{homedir as L}from"node:os";import{createHash as Be}from"node:crypto";import{isDeepStrictEqual as Ve}from"node:util";import{setTimeout as He}from"node:timers/promises";var Ue=v();let We;function Ge(){return We}function Ke(e,t){if(t!==void 0&&t.length>0)return t;try{return re(e)?.rootPath}catch{return}}function qe(e){let t=Ke(e.cwd,e.configuredProjectName),n=x({name:`cli`,project:t});return We=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}function R(){return l(u)}function z(){return o().keyringService}function B(e){try{e()}catch{}}var Je=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(b(),`auth.yml`)}read(){if(!j(this.authFile))return{};try{let e=N(this.authFile,`utf-8`);return(0,Ue.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)||Ie(t,{recursive:!0,mode:448}),S(this.authFile,(0,Ue.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)}},Ye=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 Xe(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
|
-
`),B(()=>t?.onBackendSelected?.({backend:`keyring`})),new Ye(new Je(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 Ze(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([Xe(e),r])}catch{return new V(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Qe(e){let t=Ze(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function $e(e){let t=Ze(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 et(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 Je(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 tt(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function nt(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function rt(e){return oe({detached:!0,stdio:`ignore`,shell:!1,env:tt(e)})}function it(e,t,n={}){let r=(n.spawn??Me)(e,[...t],rt(n.env??process.env));return r.unref(),r}function at(e,t,n={}){let r=n.spawn??Me,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],rt(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(nt(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(nt(e))}})}const ot=r.stable.appId,H=c,st=[`stable`,`beta`];function ct(e,t,n=e=>console.error(e)){try{return m(e,t)}catch(r){let i=m({...e,[h]:void 0},t);return n(`Treating this CLI as ${_(i)} for this command: ${r instanceof Error?r.message:String(r)}`),i}}function U(e){return st.includes(e)||!H.includes(e)?st:[e,...st]}function lt(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:r[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:H.find(t=>e.endsWith(`/${r[t].productName}.app`))??t}}}let n=e.homeDir??L();for(let i of U(t)){let{productName:t}=r[i];for(let r of[O(n,`Applications`),`/Applications`]){let n=O(r,`${t}.app`);if(ft(e,O(n,`Contents`,`MacOS`,t)))return{path:n,product:i}}}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=H.find(t=>e.execPath.toLowerCase().endsWith(`\\${p(r[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let i of U(t))for(let t of g(r[i])){let a=Pe.join(n,`Programs`,t,p(r[i]));if(ft(e,a))return{path:a,product:i}}return null}function mt(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=H.find(t=>e.execPath.endsWith(`/${r[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of U(t)){let{productName:t,linuxExecutableName:i}=r[n],a=`/opt/${t}/${i}`;if(ft(e,a))return{path:a,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)),i=e.platform??process.platform;if(t.bundlePath===void 0){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}let{productName:a}=r[t.product],[o]=r[t.cliProduct].cliCommandNames;n(`Launching ${a} desktop (use \`${o} start\` for the browser server, or \`OK_FORCE_BROWSER=1\` to always skip)`);let s=t.bundlePath;if(i===`darwin`){it(`open`,[`-a`,s],{spawn:e.spawn});return}it(s,[],{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 W(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function vt(e){return Be(`sha256`).update(e).digest(`hex`)}function G(e){return O(b(k(e)),`pi-trust`)}function yt(e,t){return O(G(e),vt(k(t)))}function bt(e,t,n){return O(yt(e,t),`${vt(n)}.json`)}var K=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${W(e)} ${W(t)}; ${W(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function q(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new K(e,`could not ${t}: ${i}`,a,n)}function J(e){let t;try{t=M(e)}catch(t){if(t.code===`ENOENT`)return!1;throw q(e,`be inspected`,t)}if(!t.isDirectory())throw new K(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function xt(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function St(e,t){if(!Ae(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`||!Ae(e.previous))throw new K(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&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 K(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function Ct(e,t,n){let r;try{r=M(n)}catch(e){throw q(n,`be inspected`,e)}if(!r.isFile())throw new K(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=N(n,`utf8`)}catch(e){throw q(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new K(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=St(a,n);if(o.cwd!==k(t)||n!==bt(e,t,o.canonicalTrustPath))throw new K(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function wt(e,t){let{record:n,path:r}=t;for(let t of[G(e),yt(e,n.cwd)])if(!J(t))throw new K(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=Ct(e,n.cwd,r);if(!Ve(i.record,n))throw new K(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function 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(!Ve(St(JSON.parse(s),o),a))throw new K(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);J(G(e)),J(D(o));try{Ie(D(o),{recursive:!0,mode:448})}catch(e){throw q(D(o),`be created`,e)}let c;try{c=M(o,{throwIfNoEntry:!1})}catch(e){throw q(o,`be inspected`,e)}if(c)throw new K(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{S(o,s,{mode:384})}catch(e){throw q(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 K(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{S(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw q(n.path,`be committed`,e)}return{path:n.path,record:r}}function Y(e,t){if(!J(G(e)))return[];let n=yt(e,t);if(!J(n))return[];let r;try{r=P(n).sort()}catch(e){throw q(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>Ct(e,t,O(n,r)))}function X(e,t){let n=wt(e,t);try{ze(n.path)}catch(e){throw q(n.path,`be removed after reconciling its grant`,e)}for(let t of[D(n.path),G(e)])try{Re(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw q(t,`be removed after reconciling its grant`,e)}}var 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
|
-
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=ne,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);x=g.ReadStream,S=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=ee);var v=e.WriteStream;v&&(S.prototype=Object.create(v.prototype),S.prototype.open=te),Object.defineProperty(e,"ReadStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(e){S=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ee(){var e=this;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 S(e,t){return this instanceof S?(v.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function te(){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 ne(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){Ge()?.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 ne(`${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 He(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){ee(`${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 Z(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(de(`missing-symlink-target`),{cause:e}):e}return Fe(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),Z(r)&&s.push(r);if(r=O(i,`.pi`,`extensions`),Z(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,Z(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&&Z(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 ${W(r)}: ${e instanceof qt?e.message:de(w(e))}`}}}function Xt(e,t,n){let r=k(e),i=Se({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:T.pi.projectConfigPath(r),trustPath:O(i,`trust.json`)}}function Zt(e){try{let t=F(e);return I(t).isDirectory()?(Fe(t,A.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${W(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${W(e)} could not be resolved or accessed: ${W(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Qt(e){let t=Zt(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${W(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function $t(e,t,n){let r=De(T.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 be(i)?{state:`own-current`,text:a}:le(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function en(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 Ae(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
|
-
`)}:{state:`unreadable`,reason:`invalid-json`}}function tn(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return de(e)}}function Q(e,t){return{kind:`refused`,error:`trust store ${W(e)}: ${tn(t)}`}}function nn(e){let t=je(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=[Ne(e)],i=M(n,{throwIfNoEntry:!1});for(;!i;){let t=D(n);if(t===n)return Q(e,`unavailable-root`);r.unshift(Ne(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 rn(e,t){let n=nn(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Q(e,`path-changed`):n}function an(e,t,n){let r=Xt(e,t,n),i=Zt(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=$t(r.cwd,r.bridgePath,t).state,o=nn(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:en(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:on(r.bridgePath).displayNames}}function on(e){let t=D(e),n=Ne(e);try{return{displayNames:P(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>W(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function sn(e,t={mode:`published`},n,r,i){let a=Xt(e,n,r),o=Zt(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${W(i)} no longer matches the current directory ${W(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=$t(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=pe(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=ge(T.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:W(e.error)}}let l=await cn(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 cn(e,t,n){let r=t.canonical,i=nn(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{Ie(D(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:W(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Wt(e,i.path,()=>{let o=Qt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=rn(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=en(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Q(e,c.reason).error;return}let l=$(n,()=>{let t=Y(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&X(n,t),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?`
|
|
5
|
-
`:``),f=E(s.path);S(s.path,d,f===void 0?void 0:{mode:f}),$(n,()=>Et(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:W(e instanceof Error?e.message:String(e))}}return a}function ln(e){let t=[],n=e;try{for(;;){if(M(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=F(n);return I(e).isDirectory()?(Fe(e,A.X_OK),O(e,...t)):void 0}let e=D(n);if(e===n)return;t.unshift(Ne(n)),n=e}}catch{return}}function un(e){let t={"not-present":0,removed:1,"kept-unowned":2,"kept-shared":3,"kept-unverified":4,"refused-unreadable":5,failed:6},n=e.reduce((e,n)=>t[n.action]>t[e.action]?n:e,{action:`not-present`}),r=e.flatMap(e=>e.error??[]),i=e.flatMap(e=>e.detail??[]);return r.length>0?{action:n.error===void 0?`failed`:n.action,error:[...r,...i].join(`
|
|
6
|
-
`)}:n.detail===void 0?n:{...n,detail:i.join(`
|
|
7
|
-
`)}}function dn(e,t,n,r={}){let i=Xt(e,t,n),a=t??L(),o=Zt(i.cwd),s=o.kind===`refused`&&r.recordedOnly?ln(i.cwd):void 0,c=o.kind===`ready`?o.project.canonical:s,l;try{l=$(a,()=>{let e=Y(a,i.cwd);return c===void 0||c===i.cwd?e:[...Y(a,c),...e]})}catch(e){return{action:`failed`,error:W(e instanceof Error?e.message:String(e))}}if(l.length===0&&r.recordedOnly)return o.kind===`ready`||s!==void 0?{action:`not-present`}:{action:`kept-unverified`,error:`${o.error}. OpenKnowledge could not verify whether this path refers to a project with recorded Pi trust; cleanup was left pending. Retry once the project path can be resolved to check again.`};if(o.kind===`refused`){if(l.length===0)return{action:`kept-unverified`,error:o.error};let e=l.map(({path:e,record:t})=>`key ${W(JSON.stringify(t.cwd))}; configured store ${W(JSON.stringify(t.configuredTrustPath))}; recorded destination ${W(JSON.stringify(t.canonicalTrustPath))}; ownership record ${W(JSON.stringify(e))} (${t.state})`);return{action:`kept-unverified`,error:[`${o.error}. OpenKnowledge kept these Pi trust ownership records; current trust decisions were not checked:`,...e,`To review manually, close Pi, verify the intended store against its recorded destination, and inspect only the exact key. A pending record does not prove setup completed or ownership of a current grant. If you choose to undo a current true decision, restore the recorded previous value, or remove that key only when no previous entry was recorded. Preserve other current decisions; parent-folder and global trust settings still apply.`].join(`
|
|
8
|
-
`)}}let u=Yt(o.project.canonical,a,T.pi.projectConfigPath(o.project.canonical));if(u.kind===`unreadable`)return{action:`kept-unverified`,error:u.error};let d=u.kind===`shared`?u.paths:[],f=[],p=new Map,m=(e,t)=>{let n=p.get(e);if(!n){let t=nn(e);if(t.kind===`refused`){f.push({action:`refused-unreadable`,error:t.error});return}n={trustPath:e,resolved:t,keys:new Map},p.set(e,n)}if(t){if(n.resolved.path!==t.record.canonicalTrustPath){f.push({action:`refused-unreadable`,error:`Pi trust store ${W(e)} no longer points to its recorded destination ${W(t.record.canonicalTrustPath)}; restore the intended file location or symlink, then retry`});return}n.keys.set(t.record.cwd,{cwd:t.record.cwd,mode:`recorded`,receipt:t})}};for(let e of l)m(e.record.configuredTrustPath,e);m(i.trustPath);for(let e of p.values()){for(let t of[o.project.canonical,i.cwd])e.keys.has(t)||e.keys.set(t,{cwd:t,mode:`inspect`,receipt:l.find(n=>n.record.cwd===t&&n.record.canonicalTrustPath===e.resolved.path)});f.push(fn(e,a,d,o.project))}return un(f)}function $(e,t){try{return t()}catch(t){throw t instanceof K?t:Error(`Could not access OpenKnowledge's Pi trust ownership records at ${W(O(b(e),`pi-trust`))}: ${W(t instanceof Error?t.message:String(t))}. Check the records and their permissions, then retry.`,{cause:t})}}function fn(e,t,n,r){let{trustPath:i,resolved:a}=e,o=[...e.keys.values()];if(!o.some(e=>e.mode===`recorded`)&&a.kind===`missing`)return{action:`not-present`};if(a.kind===`missing`)try{M(D(a.path))}catch(e){return{action:`failed`,error:`The recorded Pi trust directory ${W(D(a.path))} is unavailable: ${W(e instanceof Error?e.message:String(e))}. Restore access to its parent directory or mounted drive, then retry; the ownership record was kept.`}}let s=[],c={result:{action:`not-present`}};try{Gt(i,a.path,()=>{let e=Qt(r);if(e){c.result={action:`kept-unverified`,error:e};return}let l=rn(i,a);if(l.kind===`refused`){c.result={action:`refused-unreadable`,error:l.error};return}let u=en(l,r.canonical);if(u.state===`unreadable`){c.result={action:`refused-unreadable`,error:Q(i,u.reason).error};return}let d=o.map(e=>({cwd:e.cwd,mode:e.mode,expectedConfiguredPath:e.receipt?.record.configuredTrustPath,receipt:$(t,()=>Y(t,e.cwd).find(e=>e.record.canonicalTrustPath===l.path))}));if(d.some(e=>e.receipt&&e.receipt.record.configuredTrustPath!==e.expectedConfiguredPath)){c.result={action:`failed`,error:`The Pi trust ownership record changed during cleanup; retry to read its current location.`};return}for(let e of d){try{pn(e,t,i,l.path,u,n,r,c)}catch(t){let n=W(t instanceof Error?t.message:String(t)),r=t instanceof K?``:`; retry to check its current state.`;s.push({action:`failed`,error:`Pi trust entry ${W(JSON.stringify(e.cwd))} in ${W(i)} could not be reconciled: ${n}${r}`})}s.push(c.result),c.result={action:`not-present`}}})}catch(e){s.push({action:`failed`,error:W(e instanceof Error?e.message:String(e))})}return un([...s,c.result])}function pn(e,t,n,r,i,a,o,s){let{cwd:c,receipt:l}=e;if(i.entries[c]!==!0){l&&e.mode===`recorded`&&$(t,()=>X(t,l)),s.result={action:`not-present`};return}let u=`To remove this grant manually, close Pi and remove only the ${W(JSON.stringify(c))} entry from ${W(n)}; parent-folder and global trust settings still apply.`;if(a.length>0&&c===o.canonical){let n=`kept Pi's folder trust because other resources still need it: ${a.slice(0,3).map(e=>W(JSON.stringify(e))).join(`, `)}${a.length>3?` (+${a.length-3} more)`:``}. ${u} Removing this grant may stop Pi from loading those resources, including any not listed here.`;s.result={action:`kept-shared`,detail:n},l&&e.mode===`recorded`&&$(t,()=>X(t,l)),s.result={action:`kept-shared`,detail:`${n} ${l?e.mode===`recorded`?`OpenKnowledge has relinquished this grant and will not revoke it on later cleanup runs.`:`OpenKnowledge kept the existing ownership record; cleanup of its recorded location remains incomplete.`:`OpenKnowledge has no ownership record for this grant and will not revoke it on later cleanup runs.`}`};return}if(e.mode===`inspect`||!l||l.record.state===`pending`){let e=l?l.record.state===`pending`?`its ownership record is pending after an interrupted setup; completion cannot be verified. Re-running setup or cleanup does not reconcile this record while the folder remains trusted.`:`OpenKnowledge must reconcile its recorded location at ${W(l.record.configuredTrustPath)} before removing it.`:`no OpenKnowledge ownership record exists; this includes every grant made before ownership recording was introduced.`;s.result={action:`kept-unowned`,detail:`${c===o.canonical?`kept Pi's folder trust because ${e}`:`kept a Pi trust entry under a non-canonical project path because ${e} Pi uses the real project directory instead of this key.`} ${u}`};return}let d={...i.entries};l.record.previous.present?d[c]=l.record.previous.value:delete d[c];let f=JSON.stringify(d,null,2)+(i.trailingNewline?`
|
|
9
|
-
`:``),p=E(r);S(r,f,p===void 0?void 0:{mode:p}),i.entries=d,$(t,()=>X(t,l)),s.result={action:`removed`}}function mn(e){return be(e)||he(e)||le(e)}const hn=10485760;function gn(e,t,n,r=!1){let i=dn(e,t,n,{recordedOnly:r});switch(i.action){case`removed`:case`not-present`:return{trust:i.action};case`kept-shared`:case`kept-unowned`:return{trust:i.action,trustDetail:i.detail};case`failed`:case`refused-unreadable`:case`kept-unverified`:{let e=r?`Trust cleanup remains incomplete`:`The bridge file was left untouched`;throw Error(`Pi trust cleanup failed (${i.action}):\n${i.error}\n${e} so cleanup can be retried.`)}default:throw Error(`unhandled Pi trust cleanup result: ${i}`)}}function _n(e,t,n,r){if(e.id!==`pi`)return{kind:`not-present`};let i=gn(t,n,r,!0);return i.trust===`not-present`?{kind:`not-present`}:{kind:`removed`,...i}}function vn(e,t,n,r,i){let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=je(a);if(o.kind===`not-present`)return _n(e,t,n,i);if(o.kind===`declined`)return o;let s=De(e,t,n,o.path);if(s.kind===`absent`||s.kind===`no-entry`)return _n(e,t,n,i);if(s.kind===`decline`)return{kind:`declined`,reason:s.reason};if(!mn(s.entry))return{kind:`left-foreign`};let c=e.serverName(t);if(e.format===`file`){let e=gn(t,n,i);try{Le(a,{force:!0})}catch(t){throw e.trustDetail?Error(`${t instanceof Error?t.message:String(t)}\n${e.trustDetail}`,{cause:t}):t}return{kind:`removed`,...e}}return e.format===`toml`?xn(o.path,c):e.format===`yaml`?bn(o.path,e.topLevelKey,c):yn(o.path,e.topLevelKey,e.serverMapSubKey,c)}function yn(e,t,n,r){let i;try{i=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:w(e)}}if(Buffer.byteLength(i,`utf-8`)>hn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=xe(i,ke(t,n,r));return o?(S(e,a,{mode:E(e)}),{kind:`removed`}):{kind:`not-present`}}function bn(e,t,n){let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:w(e)}}if(Buffer.byteLength(r,`utf-8`)>hn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Ue.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=se(a);a.trim()===``||a.endsWith(`
|
|
10
|
-
`)?c.endsWith(`
|
|
11
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
12
|
-
`).replace(/\n/g,`\r
|
|
13
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&S(e,u,{mode:E(e)}),{kind:`removed`}}function xn(e,t){let n=ye();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:w(e)}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=se(a),s=a.trim()===``||a.endsWith(`
|
|
14
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
15
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
16
|
-
`).replace(/\n/g,`\r
|
|
17
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&S(e,u,{mode:E(e)}),{kind:`removed`}}function Sn(e,t){let n=i[e];return n===null?null:O(t,...n.split(`/`),C.discovery,`SKILL.md`)}function Cn(e,t){let n=Sn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!ae(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=te(`discovery`,{checkDesktop:!0});return ue(D(n),t),{editorId:e,label:e,action:ce(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function wn(e){return j(O(e,...`.agents/skills`.split(`/`),C.discovery))?!0:f.some(t=>{let n=Sn(t,e);return n!==null&&j(D(n))})}function Tn(e,t){let n=Sn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=D(n);try{return j(n)?(ue(r,t),Le(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function En(e){return e===`opencode`?we:Ee}function Dn(e,t,n){let r=T[e],i=En(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=Te(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function On(e,t,n=[]){let r=j(O(e,C[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function kn(e,t){let n=me.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=a.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:s}));return[...n,...r]}function An(e,t,n,r){let i=ie(e,kn(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function jn(e,t){let n=(t??L()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function Mn(e,t){let n=T[e];return fe(n,``,t)&&!ve(n,``,t)}function Nn(e,t,n,r,i){let a=T[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?jn(o,r):void 0,c=De(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&Mn(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];be(r)&&i.push(`reclaim-permissive`),he(r)&&i.push(`pre-approval-exact`),En(e)(r)&&i.push(`injection-functional`);let o=_e(a,n);return i.length>0&&(o!==null&&Ce(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:Oe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function Pn(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=y(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:On(O(n,s),`discovery`,An(n,i,e.agent,`global`));let a=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=i[a];return e===null||n===void 0?null:ae(n).some(e=>e.editorId===a)?On(O(n,e),`discovery`,An(n,i,a,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=d[a];return e===null?null:On(O(t,e),`project`,An(t,d,a,`project`))}case`editor-user-config`:return Nn(a,e.strictness,t,n);case`editor-project-config`:{let r=T[a].projectConfigPath?.(t);return r===void 0?null:Nn(a,e.strictness,t,n,r)}}}}export{Qe as C,qe as E,Xe as S,Ge as T,ct as _,Cn as a,R as b,an as c,ut as d,lt as f,_t as g,gt as h,wn as i,W as l,ht as m,Dn as n,vn as o,U as p,Tn as r,sn as s,Pn as t,ot as u,it as v,$e as w,et as x,at as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-7TSDKFEO-BGeceqqc.mjs";import"./chunk-2TRDZQLB-bwBxC32K.mjs";import{t as e}from"./chunk-YMMW5UAP-B7swMNER.mjs";export{e as rgCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import"./chunk-24IMIIXA-Dj5K6qOb.mjs";import{t as e}from"./chunk-ZZO3UDB3-Dr2Q2MNF.mjs";export{e as sedCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import"./chunk-A5O5YHGN-BRMz0iFo.mjs";import"./chunk-24IMIIXA-Dj5K6qOb.mjs";import{t as e}from"./chunk-XKWWSDBF-CiyukTrj.mjs";export{e as sqlite3Command};
|
package/dist/src-CMSKsmsA.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-COpgRhOl.mjs";import"./src-CbDiPIIp.mjs";import"./init-CFqa1MvX.mjs";import"./registry-probes-DwE2ywLj.mjs";import"./start-Bs7pMN0A.mjs";import{n as e}from"./loader-CpSE6Pb3.mjs";import"./preview-W1qLrOTN.mjs";import"./repair-mcp-configs-CnuXQsDL.mjs";export{e as loadConfig};
|
package/dist/src-CbDiPIIp.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{Bf as t,Da as n,G as r,Gf as i,Kf as a,Oa as o,Qf as s,U as c,W as l,Yf as u,Zf as d,al as f,dl as p,fl as m,l as h,ll as g,np as _,nu as v,ol as y,op as b,pl as ee,ru as x,tp as S,u as te,vd as C}from"./md-manager-BGnqyqi1-COpgRhOl.mjs";import{Ai as w,As as ne,Bs as T,Ca as E,Di as re,Do as D,Ds as O,Ei as k,Fs as A,Gs as j,Ha as ie,Ji as M,Ls as ae,Nt as N,Oi as P,Os as oe,Ps as F,Qt as se,Rs as I,Xi as ce,_r as le,ba as ue,bi as de,ii as fe,ks as pe,m as me,pi as L,pr as he,qo as ge,rr as _e,sa as ve,zs as ye}from"./dist-Br5t34YL.mjs";import{t as be}from"./yazl-BBz29IQN.mjs";import{ct as xe,gt as Se,ht as Ce,mt as we,pt as Te,st as Ee,wt as De}from"./init-CFqa1MvX.mjs";import{T as Oe,l as ke,u as Ae}from"./registry-probes-DwE2ywLj.mjs";import{c as je}from"./colors-r_owlCuY.mjs";import{t as Me}from"./is-object-BGze3w87.mjs";import{n as Ne}from"./constants-qWODYpdZ.mjs";import"./loader-CpSE6Pb3.mjs";import"./preview-W1qLrOTN.mjs";import{execFile as Pe,execSync as Fe,spawnSync as Ie}from"node:child_process";import{basename as R,dirname as z,isAbsolute as Le,join as B,relative as Re,resolve as V,sep as H,win32 as ze}from"node:path";import{closeSync as Be,cpSync as Ve,createWriteStream as He,existsSync as U,lstatSync as Ue,mkdirSync as W,mkdtempSync as We,openSync as Ge,readFileSync as G,readSync as Ke,readdirSync as K,readlinkSync as qe,realpathSync as Je,rmSync as Ye,rmdirSync as Xe,statSync as Ze,writeFileSync as q}from"node:fs";import{arch as Qe,freemem as $e,homedir as J,hostname as et,platform as tt,release as nt,tmpdir as rt,totalmem as it,type as at,uptime as ot}from"node:os";import{createHash as st}from"node:crypto";import{readFile as ct,readdir as lt,stat as ut}from"node:fs/promises";function dt(e,t){let n=t.map(e=>[j(e),e]);for(let t of e){let e=j(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function ft(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=dt([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=dt(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function pt(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 mt=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function ht(e,t,n=le){if(e!==void 0&&!mt.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let gt=null;function _t(e){gt=e}function vt(){return gt??process.cwd()}const yt=`Open Knowledge`;function bt(e={}){let t=e.platformName??process.platform,n=e.productName??s().productName;return Ee(t).join(xe({...e,platformName:t}),n)}function xt(e={}){let t=e.platformName??process.platform,n=e.home??J(),r=e.env??process.env,i=Ee(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,`${s().packageName.replaceAll(`/`,``)}-updater`)}function St(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 Ct(e){let t=B(e,`state.json`);if(!U(t))return[];let n;try{n=JSON.parse(G(t,`utf-8`))}catch{return[]}return St(n)??[]}function wt(e){let t=B(e,`state.json`);if(!U(t))return!1;try{return St(JSON.parse(G(t,`utf-8`)))!==null}catch{return!1}}const Tt=8192;function Et(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 Dt(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const Ot=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function kt(e){return e.replace(Ot,`$1"[REDACTED-DEVICE-ID]"`)}function At(e){return kt(Dt(e))}const jt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Mt(e){if(typeof e!=`string`)return null;let t=jt.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 Nt(e){let t=Ge(e,`r`);try{let e=Buffer.alloc(Tt),n=0,r=!1;for(;n<Tt;){let i=Ke(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{Be(t)}}function Pt(e){try{let t=Nt(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:Mt(a)}}catch{return{kind:`unreadable`}}}function Ft(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function It(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=Ze(n).mtimeMs}catch{continue}if(r<i)continue;let c=Pt(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!Ft(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 Lt=`state/os-termination-evidence.json`,Rt=6048e5,zt=/openknowledge/i,Bt=u.map(e=>_(a[e]));function Vt(e={}){return(t,n)=>new Promise(r=>{try{Pe(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ht(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ht(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 Ut(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 Wt(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 Gt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function Kt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function qt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Jt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Yt(e,t){let n=t.indexOf(`
|
|
3
|
-
`);if(n===-1)return null;let r,i;try{r=Jt(JSON.parse(t.slice(0,n))),i=Jt(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=Jt(e);t===null||typeof t.name!=`string`||!Ft(t.name)||a.push({name:t.name,pid:qt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:qt(t.rpages),lifetimeMaxPages:qt(t.lifetimeMax)})}let o=Mt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:qt(Jt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?Ft(i.largestProcess):null,ownedProcesses:a}}const Xt=/^JetsamEvent-.*\.ips$/;function Zt(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 Qt(e,t){let n=Wt(`darwin`,`macos-jetsam`,[B(e,`JetsamEvent-*.ips`)]),r;try{r=await lt(e)}catch(e){return Gt(n,e.code??`unknown`)}let i=Zt(await Promise.all(r.filter(e=>Xt.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await ut(B(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-Rt,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=Yt(t,await ct(B(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return Kt(n)}const $t=[`--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`],en=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],tn=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,nn=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,rn=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function an(e,t){let n=new Set,r;try{r=await lt(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!rn.test(a))continue;let r=B(e,a);try{if(t.getTime()-(await ut(r)).mtimeMs>Rt)continue;for(let e of(await ct(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 on(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:zt.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 sn(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
5
|
-
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=tn.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!zt.test(s)){n+=1;continue}let c=on(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function cn(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
6
|
-
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=tn.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=nn.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 ln(e,t,n){let r=cn(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await an(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 un(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function dn(e,t,n){let r=Wt(`linux`,`linux-journal`,[`journalctl ${$t.join(` `)}`,`journalctl ${en.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...$t]),e(`journalctl`,[...en])]),o=[];if(un(i)){let e=sn(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: ${Ut(i)}`);if(un(a)){let e=await ln(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: ${Ut(a)}`);return o.length===2?Gt(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:Kt(r)}const fn={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},pn={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function mn(e){return e===`System`?fn:pn}function hn(e){let t=`System[(${Object.keys(mn(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${Rt}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${Bt.map(e=>`Data='${e}'`).join(` or `)}]]`}function gn(e){return[`qe`,e,`/q:${hn(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function _n(e){return ze.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function vn(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function yn(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function bn(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>vn(e[1]??``).trim())}function xn(e,t){let n=mn(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=bn(o,`Data`),u=bn(o,`Name`),d=[...l,...u].some(e=>zt.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!==``&&!yn(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Sn(e,t){let n=_n(t),r=[`System`,`Application`],i=Wt(`win32`,`windows-event-log`,r.map(e=>`${n} ${gn(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,gn(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${Ut(t)}`);continue}let n=xn(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?Gt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:Kt(i)}async function Cn(e={}){let t=e.platform??process.platform,n=e.runCommand??Vt(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return Qt(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return dn(n,r,e.desktopLogsDir??B(A(),`logs`));case`win32`:return Sn(n,e.systemRoot??process.env.SystemRoot);default:return{...Wt(t,null,[]),outcome:`unsupported`}}}const wn={schemaVersion:1,outcome:`not-collected`};function Tn(e){return`${JSON.stringify(e??wn,null,2)}\n`}const En={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system and user journals`,"windows-event-log":`Windows event logs`};function Dn(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 ${En[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function On(){return B(A(),`bug-reports`)}function kn(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=On(),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 An(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function jn(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`))?st(`sha256`).update(V(e)).digest(`hex`).slice(0,12):null}function Mn(){let e={timestamp:new Date().toISOString(),platform:tt(),osType:at(),osRelease:nt(),hostname:`[redacted]`,uptime:ot(),freeMem:$e(),totalMem:it(),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`,ge({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 Nn=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Pn(e){let t=R(e);return Nn.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Fn(e,t){return Bn(e,t).files}const In=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Ln(e,t=Ae){let n=B(e,`${t}.ShipIt`);if(!U(n))return[];let r;try{r=K(n)}catch{return[]}return In.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).map(e=>{let t=B(n,e.entry);return{path:t,suffix:e.suffix,mtimeMs:Rn(t)}}).sort((e,t)=>t.mtimeMs-e.mtimeMs||t.suffix-e.suffix).slice(0,4).map(e=>e.path))}function Rn(e){try{return Ze(e).mtimeMs}catch{return 0}}function zn(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 Bn(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(Pn),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=>!Pn(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Vn(e){let t=B(e,`.ok`,`local`);return U(t)?{files:[`server.lock`,p,y].map(e=>B(t,e)).filter(e=>U(e))}:{files:[]}}function Hn(e,t,n){let r=F(e),i=[],a=[];for(let e of t){let t=B(r,e),o=B(n,e),s=U(t);s&&i.push(t),U(o)&&(s?a:i).push(o)}return{files:i,legacyFiles:a}}function Un(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#${st(`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 Wn(e){let t=e.revealDocNames?e.content:Un(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=o(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function Y(e){for(let t of e.files)try{let n=G(t,`utf8`);Wn({zipfile:e.zipfile,name:`${e.prefix}/${R(t)}`,content:t.endsWith(`.ips`)?At(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 Gn(t){let{redact:r,outputPath:i,logger:a}=t,o=t.revealDocNames??!1,s=t.userLogsDir??B(A(),`logs`),c=t.projectDir?jn(t.projectDir,a):null;W(z(i),{recursive:!0}),a?.info({projectSlug:c},`gathering diagnostic data`);let l=Mn();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:d}=Bn(c,s),{files:p}=t.projectDir?Vn(t.projectDir):{files:[]},{files:m,legacyFiles:h}=t.projectDir?Hn(t.projectDir,[g.logsCurrent,g.logsPrevious],B(t.projectDir,`.ok`,`local`,`logs`)):{files:[],legacyFiles:[]},{files:_,legacyFiles:v}=t.projectDir?Hn(t.projectDir,[ee],B(t.projectDir,`.ok`,`local`)):{files:[],legacyFiles:[]},y=t.shipItLogFiles??[],b=t.diagnosticReports?.files??[];a?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:d,lockFileCount:p.length+_.length+v.length,localSinkFileCount:m.length+h.length,shipItLogFileCount:y.length,diagnosticReportCount:b.length},`files collected`);let x=[],S=[],{ZipFile:C}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),w=new C;Y({zipfile:w,files:[...u,...y],prefix:`logs`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:[...p,..._],prefix:`lockdir`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:m,prefix:`local-logs`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:h,prefix:`legacy/local-logs`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:v,prefix:`legacy/lockdir`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:t.bugReportLedgerFiles??[],prefix:te,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a}),Y({zipfile:w,files:b,prefix:`diagnostic-reports`,redact:r,revealDocNames:o,bundleFiles:S,redactions:x,logger:a});for(let e of t.extraFiles??[])try{let t=G(e.sourcePath),n=`extra/${e.zipName??R(e.sourcePath)}`;w.addBuffer(t,n),S.push(n);let r=An(e,n);r!==null&&x.push(r)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Wn({zipfile:w,name:`note.txt`,content:t.note,redact:r,revealDocNames:o,bundleFiles:S,redactions:x});let ne=new Set(b.map(e=>`diagnostic-reports/${R(e)}`)),T=S.filter(e=>ne.has(e)),E=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Et(t.diagnosticReports,T.length);w.addBuffer(Buffer.from(`${E}\n`,`utf8`),`state/diagnostic-reports-status.txt`),S.push(`state/diagnostic-reports-status.txt`),Wn({zipfile:w,name:Lt,content:Tn(t.osTerminationEvidence),redact:r,revealDocNames:!0,bundleFiles:S,redactions:x});let re=JSON.stringify(l,null,2);w.addBuffer(Buffer.from(re,`utf8`),`sysinfo.json`),S.push(`sysinfo.json`);let D={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:c,files:S,redactions:x,sysinfo:l};w.addBuffer(Buffer.from(JSON.stringify(D,null,2),`utf8`),`MANIFEST.json`);let O=x.reduce((e,t)=>e+t.lineCount,0),k=new Set(y.map(e=>`logs/${R(e)}`)),j=S.filter(e=>k.has(e)),ie=new Set((t.bugReportLedgerFiles??[]).map(e=>`${te}/${R(e)}`)),M=S.filter(e=>ie.has(e)),ae=c?S.filter(e=>e.startsWith(`logs/`)&&!Pn(e)&&!k.has(e)):[],N=T.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.`]:[],P=N.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...N]:[`Redaction was disabled for this bundle; file contents are unmodified.`],oe=[`# Bug Report Bundle`,``,`Generated: ${D.generatedAt}`,`Project: ${c??`(unscoped)`}`,...t.projectDir?[`Project diagnostic source: ${f(`logs`,`projects`)} (current product only).`]:[],`Discipline version: ${D.disciplineVersion}`,``,`## Contents`,``,...S.map(e=>`- ${e}`),``,`## Privacy`,``,...ae.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:`,...ae.map(e=>`- ${e}`),``]:[],...j.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:`,...j.map(e=>`- ${e}`),``]:[],...T.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:`,...T.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:`,`- ${Lt}`,``]:[],...M.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:`,...M.map(e=>`- ${e}`),``]:[],...r?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${n.join(`, `)}`,O>0?`${O} line(s) were scrubbed across ${x.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...N,``,`This bundle is safe to attach to a GitHub issue.`]:P].join(`
|
|
7
|
-
`);w.addBuffer(Buffer.from(oe,`utf8`),`README.md`),w.end();let F=He(i);return w.outputStream.pipe(F),await new Promise((e,t)=>{F.on(`close`,e),F.on(`error`,t)}),a?.info({bundlePath:i,fileCount:S.length,redactionCount:O},`bundle written`),{zipPath:i,summary:{projectSlug:c,files:S,redactions:x,redactedLineCount:O,generatedAt:D.generatedAt}}}var Kn=C(),qn=e(be(),1),X=e(je(),1);function Jn(e){let t=T(`user`,e,e);return I({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Yn({home:e=J(),env:t=process.env}={}){let n=Jn(e),{override:r,preferenceList:i}=ye(t),{locale:a,source:o}=ft({override:r,storedPreference:n,supportedLocales:x,preferenceList:i,autoDetectableLocales:v});return{preference:n,locale:a,source:o,systemLanguages:i}}function Xn(e){let t=new Set([e]);try{t.add(Je.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 Zn(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function Qn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $n(e,t){if(typeof e==`string`)return Zn(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>$n(e,t));if(!Qn(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=$n(i,t);return n}function er(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=$n(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
10
|
-
`)}\n`:a.join(`
|
|
11
|
-
`);q(e,o)}function tr(e,t){let n=G(e,`utf-8`);if(n.trim().length!==0)try{let r=$n(JSON.parse(n),t),i=n.endsWith(`
|
|
12
|
-
`)?`
|
|
13
|
-
`:``;q(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Zn(n,t.contentDirSpellings);r!==n&&q(e,r)}}function nr(e,t){let n=G(e,`utf-8`),r=Zn(n,t.contentDirSpellings);r!==n&&q(e,r)}function rr(e){try{return K(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>B(e,t.name))}catch{return[]}}const ir=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function ar(e){return/\.log\.\d+$/.test(e)}function or(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||ar(e)}const sr=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function cr(e){let t={contentDirSpellings:Xn(e.contentDir)};for(let n of sr)for(let r of rr(B(e.stagingDir,n)))or(r)?er(r,t):r.endsWith(`.json`)?tr(r,t):nr(r,t);for(let n of rr(B(e.stagingDir,`state`))){let e=R(n);n.endsWith(`.jsonl`)?er(n,t):ir.has(e)?tr(n,t):nr(n,t)}}const lr=[`.ok`,`local`,`telemetry`],ur=[`.ok`,`local`,`logs`],dr=[`.ok`,`local`,`loss-capture`],fr=g.spansCurrent,pr=g.spansPrevious,mr=g.logsCurrent,hr=g.logsPrevious,gr=`loss-current.jsonl`,_r=`loss-prev.jsonl`;function vr(e){return B(e,...dr,gr)}function yr(e){return B(e,...dr,_r)}const br=1e3;async function xr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(br)});return t.ok?await t.text():null}catch{return null}}async function Sr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(br)});return t.ok?await t.text():null}catch{return null}}async function Cr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(br)});return t.ok?await t.text():null}catch{return null}}function wr(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 Tr(e){let t=B(e,`.git`,`ok`);if(!U(t))return null;let n=Ie(`git`,[`-C`,t,`log`,`--oneline`,`-50`],ge({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Er(e){let t=B(e,`.git`,`ok`);if(!U(t))return null;let n=Ie(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],ge({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Dr(){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 Or(){return{nodeVersion:process.version,platform:tt(),arch:Qe()}}function kr(){return process.env.OTEL_SDK_DISABLED===`false`}function Ar(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jr(e){if(!U(e))return{};let t;try{t=(0,Kn.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(!Ar(t))return{};let n=t.telemetry;if(!Ar(n))return{};let r=n.localSink;return Ar(r)?r:{}}function Mr(e){return typeof e==`boolean`?e:void 0}function Nr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Pr(e){if(Ar(e))return Nr(e.maxBytes)}function Fr(e){let t=jr(T(`project`,e)),n=jr(T(`project-local`,e));return{enabled:Mr(n.enabled)??Mr(t.enabled)??!0,spansMaxBytes:Pr(n.spans)??Pr(t.spans)??52428800,logsMaxBytes:Pr(n.logs)??Pr(t.logs)??26214400}}function Ir(e){return st(`sha256`).update(e).digest(`hex`)}function Lr(e){let t=G(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const Rr=[`"doc.name"`,`"docName"`];function zr(e){let t=G(e,`utf-8`),n=0;for(let e of Rr){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function Z(e,t){if(!U(e))return!1;try{return W(z(t),{recursive:!0}),e.endsWith(`.ips`)?q(t,At(G(e,`utf-8`))):Ve(e,t),!0}catch{return!1}}function Q(e,t,n,r){let i=U(e);Z(e,B(n,r)),Z(t,i?B(n,`legacy`,r):B(n,r))}function Br(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 Vr=new Set([`.jsonl`]);function Hr(e){let t=e.lastIndexOf(`.`);return t!==-1&&Vr.has(e.slice(t))}const Ur=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Wr(e){if(ar(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Ur.has(e.slice(t))}function Gr(e){let t=[];for(let n of Br(e)){let r=Kr(e,n);if(!Wr(r))continue;let{redacted:i,patterns:a,lineCount:s}=o(G(n,`utf-8`));a.length!==0&&(q(n,i),t.push({file:r,lineCount:s,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Kr(e,t){return Re(e,t).split(H).join(`/`)}async function qr(e){let t=V(e.contentDir),n=V(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??xr,a=r.fetchAgentEffects??Sr,o=r.fetchWatcherRecent??Cr,s=r.readShadowHead??Tr,c=r.readCheckpointRefs??Er,l=r.now??(()=>new Date),u=r.okVersion??(()=>Ne),d=r.readDesktopEnv??Dr,h=r.readLanguage??Yn,g=r.readRuntime??Or,_=r.isOtlpPushEnabled??kr,v=We(B(rt(),`ok-bundle-`));try{W(B(v,`telemetry`),{recursive:!0}),W(B(v,`logs`),{recursive:!0}),W(B(v,`state`),{recursive:!0}),Q(pe(n),B(n,...lr,fr),v,B(`telemetry`,fr)),Q(ne(n),B(n,...lr,pr),v,B(`telemetry`,pr)),Q(O(n),B(n,...ur,mr),v,B(`logs`,mr)),Q(oe(n),B(n,...ur,hr),v,B(`logs`,hr));for(let t of e.userLogFiles??[])Z(t,B(v,`logs`,R(t)));for(let t of e.userStateFiles??[])Z(t,B(v,te,R(t)));let b=0;for(let t of e.diagnosticReports?.files??[])Z(t,B(v,`diagnostic-reports`,R(t)))&&(b+=1);let x=B(n,`.ok`,`local`),S=B(x,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(U(S)){Z(S,B(v,`state`,`server.lock`));try{let e=G(S,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(q(B(v,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&q(B(v,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=wr(n);e!==null&&q(B(v,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&q(B(v,`state`,`shadow-head.txt`),E);let re=c(t);re!==null&&q(B(v,`state`,`checkpoint-refs.txt`),re),Z(vr(n),B(v,`state`,gr)),Z(yr(n),B(v,`state`,_r)),Q(ae(n),B(x,ee),v,`state/last-spawn-error.log`),Z(B(x,m),B(v,`state`,m)),Z(B(x,p),B(v,`state`,p)),Z(B(x,y),B(v,`state`,y));let D=g(),k=d(),A=h(),j={ok:{version:u(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:k,language:A}};q(B(v,`state`,`runtime.json`),`${JSON.stringify(j,null,2)}\n`);let ie=C===`running`?`running
|
|
15
|
-
`:`not-running (${w})\n`;q(B(v,`state`,`server-status.txt`),ie);let M=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Et(e.diagnosticReports,b);if(q(B(v,`state`,`diagnostic-reports-status.txt`),`${M}\n`),q(B(v,Lt),Tn(e.osTerminationEvidence)),e.processDir&&U(e.processDir)){let t=B(v,`process`);W(t,{recursive:!0}),Ve(e.processDir,t,{recursive:!0})}let N=e.redact===!0;N&&(cr({stagingDir:v,contentDir:t}),cr({stagingDir:B(v,`legacy`),contentDir:t})),e.note&&q(B(v,`note.txt`),e.note);let P=null;e.scrubSecrets===!0&&(P=Gr(v));for(let t of e.extraFiles??[]){let e=t.zipName??R(t.sourcePath);if(!Z(t.sourcePath,B(v,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=An(t,`extra/${e}`);n!==null&&(P??={redactions:[],redactedLineCount:0},P.redactions.push(n),P.redactedLineCount+=n.lineCount)}let F=Fr(n),se=Br(v),I=[],ce=0,le=0;for(let e of se){let t=Kr(v,e),n=Ze(e).size,r=Hr(t)?Lr(e):0;I.push({path:t,bytes:n,lines:r}),ce+=n;let i=t.startsWith(`legacy/`)?t.slice(7):t;(i.startsWith(`telemetry/`)||i.startsWith(`logs/`))&&(le+=zr(e))}let ue={applied:N};P!==null&&(ue.secretScrub=P);let de={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:D.nodeVersion,platform:D.platform,arch:D.arch},host:{desktop:k,language:A},contentDir:{pathSha256:Ir(t),absolutePath:N?`<CONTENT_DIR>`:t},telemetry:{localSink:{...F,directory:f(`logs`,`projects`)},otlpPushEnabled:_()},redaction:ue,serverStatus:C,files:I};q(B(v,`manifest.json`),`${JSON.stringify(de,null,2)}\n`);let fe=Xn(t),me=se.some(e=>{try{let t=G(e,`utf-8`);return fe.some(e=>t.includes(e))}catch{return!1}}),L={stagedDiagnosticReports:b,totalBytes:ce,fileCount:I.length,docNameCount:le,contentDirVisible:me,redacted:N},he=!1;return{stagingDir:v,manifest:de,summary:L,cleanup:()=>{he||(he=!0,Ye(v,{recursive:!0,force:!0}))}}}catch(e){throw Ye(v,{recursive:!0,force:!0}),e}}async function Jr(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 qn.ZipFile,a=Br(t.stagingDir);for(let e of a){let n=Kr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=He(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Yr(e,t){let n=B(e,`.ok`,`config.yml`);if(U(n))try{let t=(0,Kn.parse)(G(n,`utf-8`)),r=Me(t)?t.content:void 0,i=Me(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 Xr(e,t,n,r,i,a){let o=jn(t,e.logger),s=await qr({contentDir:Yr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...Fn(o,e.userLogsDir??B(A(),`logs`)),...Ln(e.cachesDir??B(J(),`Library`,`Caches`))],userStateFiles:zn(e.bugReportsDir??On()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{W(z(e.outputPath),{recursive:!0}),await Jr({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 Zr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Dr,r=e.readLanguage??Yn,i=()=>It(e.diagnosticReportsDir??B(J(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Xr(e,t,n,r,i(),await Cn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await Gn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Ln(e.cachesDir??B(J(),`Library`,`Caches`)),bugReportLedgerFiles:zn(e.bugReportsDir??On()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await Cn(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=P(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,text:i}}let o=a&&typeof a==`object`?a:{},s=ue(o),c=s&&!fe(o,n);if(!a||typeof a!=`object`||!de(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=D(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=se(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,readBootInstant:n.readBootInstant,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function Qr(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function $r(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${w()}`:`records only the host ${ke(e.hostname)}, not this machine's ${et()}`}function ei(e){return e===`win32`?`USERPROFILE`:`HOME`}function ti(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${d()} stop\` confirm it from any home folder.`:``}function ni(e,t){let n=`\`${d()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${ei(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${ti(e)}`}function ri(e,t){let n=d();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${ei(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${ti(e)}`}function ii(e){return`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} and retry cleanup.`}function ai(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?ri(n,t):`If ${ke(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${ii(r)}`}function oi(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${Qr(e.pid)}. 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.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${ii(n)}`:`Cannot verify shutdown: the server lock at ${n} ${$r(e.lock)}. ${ai(e,t)}`}function si(e){return e.replace(/:\d+$/,``)}function ci(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:si(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:si(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:si(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 li=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function ui(e,t=process.platform,n=process.env){return r(b(),e,t,n.XDG_CONFIG_HOME)}function di(){return l(b())}function fi(){let e=b();if(e===`stable`)return li;let t=c(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const pi={existsSync:e=>U(e),readFileSync:(e,t)=>G(e,t),lstatSync:e=>Ue(e),readlinkSync:e=>qe(e)};function mi(e,t=pi,n=process.platform,i=process.env){let a=b(),o=ui(e,n,i),s=r(a,e),c=t.existsSync(o)?o:a===`stable`&&n===`linux`&&t.existsSync(s)?s:null;if(c===null)return null;try{let e=JSON.parse(t.readFileSync(c,`utf8`));return e?.version===1?e:null}catch{return null}}function hi(e){let t=e.replace(fi(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function gi(e,t,n=pi){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const _i=[{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`}],vi=[...N.map(e=>me[e]),`open-knowledge`];function yi(e){if(!Le(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 bi(e,t){let n=Re(e,t);if(n.startsWith(`..`)||Le(n))return!1;let r=e;for(let e of n.split(H)){r=B(r,e);try{if(!Ue(r).isDirectory())return!1}catch{return!1}}return!0}function xi(e,t){try{return K(e).every(n=>t.has(B(e,n)))}catch{return!1}}function Si(e){let t=yi(e),n=[],r=[],i=new Set;for(let e of _i){let a=B(t,e.hostDir,`skills`);if(!bi(t,a))continue;let o=vi.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(;xi(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 Ci(e){try{if(!Ue(e).isDirectory())return!1;let t=K(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function wi(e){let t=new Set,n=new Set;for(let r of _i){let i=B(e,r.hostDir,`skills`);for(let e of vi)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 Ti(e,t){let n=yi(e),r=wi(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(bi(n,e)&&Ci(e))try{Ye(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(bi(n,e))try{Xe(e),a.push(e)}catch{}return a}function Ei(e){let n=yi(e),r=[];for(let e of N){let i=me[e];r.push({path:B(n,`.agents`,`skills`,i),bundleId:e,scope:`central`});for(let a of t)r.push({path:B(n,a.skillsRoot,i),bundleId:e,scope:`host`,hostDir:a.hostDir})}return r}function Di(e,t){let n=[];for(let r of Ei(e))if(r.bundleId===t)try{Ye(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 Oi(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${Ce(e)} readProcessStart=${t}`}function ki(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{Te(n,r),t.onNativeFailure?.({kind:e,reason:we(n,r)})};try{let i=!1,a=Se(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:Oi(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,Ce(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function Ai(e,t={}){return ve(e,{platform:t.platform,readNative:e=>ki(e,{onNativeFailure:t.onNativeFailure})})}function ji(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${f(`logs`)}. `:``)}function Mi(e){let t=new Set;return E(n=>{let r=[],i=ki(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??Oe())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Ni(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Pi(e,t=Date.now()){if(e===null)return`—`;let n=pt(e,t);return n===`unknown`?`—`:n}function Fi(e){let t=z(e);return R(e)===`local`&&R(t)===`.ok`?z(t):R(e)===`.ok`?t:null}function Ii(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Fi(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`&&k(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:he(n),command:n,isDesktop:Ni(n)}}function Li(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`:case`reused-pid`:return`stale`;default:return t}}const Ri=new Set([`running`,`desktop`,`foreign`,`unverified`]);function zi(e){switch(e){case`running`:return X.default.green(e);case`desktop`:return X.default.blue(e);case`foreign`:return X.default.cyan(e);case`unverified`:case`stale`:return X.default.yellow(e)}}function Bi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Vi(e){return`${Bi(e.server.usage)} | ${Bi(e.ui?.usage??null)}`}function Hi(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Ui(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??`—`,Hi(e),Vi(e),Li(e),String(e.server.pid),Pi(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=zi(Li(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=X.default.dim(`To stop a server: ${d()} stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
16
|
-
`)}async function Wi(e={}){let t=e.discover??_e,n=e.inspect??(e=>$(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??M,a=e.resolveUsage??ce,o=await t(),s=[];for(let e of o){let t=n(e),r=Ii(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Li(e)}));r(JSON.stringify(e,null,2));return}r(Ui(e.all?s:s.filter(e=>Ri.has(Li(e)))))}function Gi(){return new De(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale 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 Wi({all:t.all===!0||e===`all`,json:t.json===!0})})}async function Ki(e,t=Oe()){let n=$(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=re(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function qi(e,t={}){return ea(e,t.isAlive??L)?{targets:[{name:`server`,pid:e.lock.pid,port:e.lock.port}],lock:e.lock}:{targets:[]}}function Ji(e){try{return b()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function Yi(e){let t=e.inspect??(()=>$(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),a=e.error??(e=>console.error(e)),o=e.probeClients??Ki,s=e.logger??Oe(),c=e.platform??process.platform,l=t(),u=qi(l,{isAlive:e.isAlive}),{lock:f}=u,p=[],m=[],h=(t,n)=>{s?.warn({lockDir:e.lockDir,lockPath:n.lockPath,lockPid:n.pid,platform:c,cause:n.cause,...`nativeFailures`in n&&n.nativeFailures.length>0?{nativeFailures:n.nativeFailures}:{}},`stop declined: lock holder identity unverified`),m.push({target:t,error:Qi(n,s!==void 0),unverified:n})},g=()=>{if(p.length>0){let e=p.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);r(`Stopped: ${e}`)}if(s?.info({lockDir:e.lockDir,signalled:p.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:m.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),m.length>0){let e=m.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `);a(`Failed to stop: ${e}`)}return{stopped:p,failed:m,hadTargets:!0}};if(l.status===`unverified-owner`){let{pid:e,lockPath:t}=l;return h({name:`server`,pid:e},{cause:`unverified-owner`,pid:e,lockPath:t}),g()}if(f===void 0)return r(`No running open-knowledge processes.`),s?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let _=l.status===`alive`||l.status===`foreign-host`?l.lock.channel:void 0;if(e.force!==!0&&typeof _==`string`&&_.length>0){let t=e.selfChannel??Ji(s);if(t!==void 0&&_!==t)return a(`Not stopping: the server at ${e.lockDir} belongs to ${S(_)}. `+(_===`dev`?`Stop it from that dev build, or run \`${i} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),s?.warn({lockDir:e.lockDir,holderChannel:_,selfChannel:t,pids:u.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:_}}}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:u.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}for(let t of u.targets){let i=[],o=(e.readProcessStart??Ai)(t.pid,{platform:c,onNativeFailure:e=>{i.push(e)}}),s=se(f,{isAlive:e.isAlive??L,readProcessStart:()=>o,refuseHolderStartedAfterLock:e.refuseHolderStartedAfterLock,platform:c,readBootInstant:e.readBootInstant});switch(s.verdict){case`writer`:try{n(t.pid,`SIGTERM`),p.push(t)}catch(e){m.push({target:t,error:e instanceof Error?e.message:String(e)})}break;case`gone`:r(`${t.name} (pid=${t.pid}) had already exited`);break;case`replaced`:a(`Process ${t.pid} is no longer the server that wrote ${l.lockPath}; it was not signalled. Run \`${d()} clean\` to remove the stale lock.`);break;case`unverified`:h(t,Xi(s.cause,{pid:t.pid,lockPath:l.lockPath,lock:f,platform:c,nativeFailures:i}));break;default:return s}}return g()}function Xi(e,t){let{pid:n,lockPath:r}=t;switch(e){case`foreign-host`:return{cause:e,pid:n,lockPath:r,lock:t.lock,platform:t.platform};case`unverified-owner`:return{cause:e,pid:n,lockPath:r};default:return{cause:e,pid:n,lockPath:r,platform:t.platform,nativeFailures:t.nativeFailures}}}const Zi=`it was not signalled, and --force does not override this check.`;function Qi(e,t){let{pid:n,lockPath:r}=e;switch(e.cause){case`foreign-host`:{let{lock:t}=e;return typeof t.machineId==`string`?`The server lock at ${r} ${$r(t)}, so process ${n}, which is running on this machine, cannot be confirmed as the server that wrote it; ${Zi} ${ni(t,e.platform)}`:`The server lock at ${r} ${$r(t)}, and the start of process ${n}, which is running on this machine, does not confirm it as the server that wrote the lock; ${Zi} If ${ke(t.hostname)} is another machine, stop the server there. If it is an earlier name of this machine, confirm that process ${n} is an OpenKnowledge server before ending it yourself, and once no OpenKnowledge server is running for this project, remove ${r}.`}case`unverified-owner`:return`The server lock at ${r} ${Qr(n)}, so it cannot be confirmed as the server that wrote the lock; ${Zi} Check whether process ${n} is an OpenKnowledge server, and if it is, stop it yourself. Do not remove the lock file while that process is running.`;default:{let n=$i(e,Zi,`Once you have confirmed no OpenKnowledge server is running for this project, remove ${r}.`,t);return e.cause===`writer-identity-unrecorded`?`${n} A server you start again with this release records its machine ID, so \`${d()} stop\` can confirm it.`:n}}}function $i(e,t,n,r){let{pid:i,lockPath:a,platform:o,nativeFailures:s}=e,c=`Before ending process ${i} yourself, confirm that it is an OpenKnowledge server.`;switch(e.cause){case`process-start-unreadable`:return`Could not read when process ${i} started, so it cannot be confirmed as the server that wrote ${a}; ${t} `+ji({platform:o,pid:i,nativeFailures:s,causeRecorded:r})+`${c} ${n}`;case`process-start-incomparable`:return`The start of process ${i} cannot be compared with the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-start-mismatch`:return`Process ${i} started before the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-started-after-lock`:return`Process ${i} started after the server lock at ${a} was written, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`recorded-start-in-future`:return`The server lock at ${a} records a start later than the current time on this machine, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;case`writer-identity-unrecorded`:return`The server lock at ${a} records neither a machine ID nor a process start, as locks written by version 0.25.0 and earlier do, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;default:return e.cause}}function ea(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function ta(e,t=L){let n=await _e(),r=null;for(let i of n){let n=$(i,`server`);if(ea(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}function na(e){(e.failed.length>0||e.declined!==void 0)&&(process.exitCode=1)}async function ra(e,t){let n=await Yi({lockDir:e,force:t});return na(n),n}function ia(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 \`${d()} ps\` to list them`}.`}async function aa(e){let t=await _e(),n=0;for(let r of t)r!==e&&ea($(r,`server`),L)&&n++;return n}function oa(e){return new De(`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, Beta or a dev build run from source) 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=ie(process.cwd()),n=[],i=await Yi({lockDir:t,force:r,log:e=>n.push(e)});if(i.hadTargets){for(let e of n)console.log(e);na(i)}else{let e=await aa(t);console.log(ia(process.cwd(),e,{listingFollows:e>0})),e>0&&await Wi({})}return}if(i===`all`){let e=await _e();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)ea($(n,`server`),L)&&(await ra(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 ta(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await ra(t,r);return}let a=V(vt(),i),o=ie(a),s=[],c=await Yi({lockDir:o,force:r,log:e=>s.push(e)});if(na(c),c.hadTargets)for(let e of s)console.log(e);else console.log(ia(a,await aa(o)))})}export{It as A,Zr as C,On as D,kn as E,Ct as F,wt as I,vt as L,yt as M,xt as N,Cn as O,bt as P,_t as R,$ as S,Jr as T,hi as _,Gi as a,$r as b,Ti as c,Ei as d,li as f,mi as g,di as h,oa as i,Et as j,Dn as k,Si as l,ui as m,Ki as n,Ai as o,gi as p,Yi as r,Mi as s,$i as t,Di as u,ci as v,qr as w,oi as x,ai as y,ht as z};
|
package/dist/start-Bs7pMN0A.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{C as e,Fl as t,I as n,Q as r,Z as i,Zf as a,i as o,zd as s}from"./md-manager-BGnqyqi1-COpgRhOl.mjs";import{Bs as c,Ei as l,Ki as u,Rs as d,ji as f,k as p,mi as m,ws as h}from"./dist-Br5t34YL.mjs";import{Et as g,R as _,Tt as v,Z as y,b,dt as x,wt as S,x as C,z as w}from"./init-CFqa1MvX.mjs";import{C as T,a as E,c as ee,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as F,t as I}from"./registry-probes-DwE2ywLj.mjs";import{n as te}from"./constants-qWODYpdZ.mjs";import{execFileSync as L,spawn as R}from"node:child_process";import{basename as z,dirname as B,resolve as V}from"node:path";import{existsSync as H,realpathSync as ne}from"node:fs";import{homedir as re,tmpdir as ie}from"node:os";import{rm as ae}from"node:fs/promises";import{setTimeout as oe}from"node:timers/promises";const se=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ce={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function le(e,t={}){let{login:n}=t,r=t._exec??L,i=U(t._fileExists??H),a=e?[`--hostname`,e]:[];if(n){let e=W(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=W(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function U(e){return[`gh`,...se.filter(e)]}function W(e,t,n){for(let r of t)try{let t=e(r,n,ce).toString().trim();if(t.length>0)return t}catch{}}function ue(e,t={}){let n=t._exec??L,r=U(t._fileExists??H),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=W(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=de(a,e);if(t)return t}let o=W(n,r,i);if(o!==void 0){let e=ge(o);if(e.length>0)return e}}function G(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function de(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=G(G(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=G(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const fe=/Logged in to \S+ account (\S+) \(/,pe=/(?:Failed to log in to|Timeout trying to log in to) \S+/,me=/^\s*-\s*Active account:\s*true\s*$/,he=/\u001b\[[0-9;]*m/g;function ge(e){let t=[],n;for(let r of e.split(`
|
|
2
|
-
`)){let e=r.replace(he,``),i=fe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(pe.test(e)){n=void 0;continue}n&&me.test(e)&&(n.active=!0)}return t}const _e={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function K(){return{action:`failed`,errorId:`write-failed`}}function q(){return{action:`skipped-missing`,errorId:`surface-missing`}}function J(e,t,n){h(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function Y(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ve(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 ye(e,t,n,r,i){let a=y[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&h(`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`),ve(o.kind)}catch(i){return h(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),K()}}async function be(e,t,n){if(y[e].scope!==`global`)return q();if(n===`absent`)return ye(e,``,t.home,void 0,t.env);let r=(await C({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return K();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return q();case`skipped-flag`:return Y();default:return K()}}function xe(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return q();if(n===`absent`)return ye(e,t.cwd,t.home,r,t.env);let i=b(y[e],t.cwd,_e,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return K()}}function Se(e,t,n){let r=t.home??re();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return q();case`failed`:return J(e,t.path,t.error),K()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`failed`:return J(e,i.path,i.error),K()}}function Ce(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 q();case`failed`:return J(e,n.path,n.error),K()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return q();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return J(e,r.path,r.error),K()}}function we(e){return t=>{if(t.pathId===void 0)return Y();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return Y();switch(n.kind){case`editor-user-config`:return be(n.editor,e,t.desired);case`editor-project-config`:return xe(n.editor,e,t.desired);case`editor-project-skill-root`:return Ce(n.editor,e,t.desired);case`editor-user-skill-root`:return Se(n.editor,e,t.desired)}}}function Te(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function Ee(e){if(e===`server`)return e;throw new v(`--only must be 'server'`)}function De(e=H,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[V(t,`public`),V(t,`../../app/dist`),V(t,`../../../app/dist`)];return e(V(t,`../../app.asar`))&&n.push(V(t,`../../app`)),n.find(t=>e(t))}function Oe(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 ke(e){if(e===`off`)return`off`;if(!t.test(e))throw new v(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function Ae(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function je(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Me(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||Ae(e.host))&&e.isTTY}function Ne(e,t){let n;try{n=new URL(t)}catch{throw new v(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new v(`${e} must be an http(s) origin (got: ${t})`);return t}function Pe(e){return Ne(`--external-url`,e)}function Fe(e){let t=z(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var X=class extends Error{cwd;constructor(e){super(`This directory isn't set up yet. Run \`${a()} init\` first, then \`${a()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=e}},Z=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 ${a()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=e}};function Q(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?V(e):null}},a=V(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(B(a));o=e===null?null:V(e,z(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&B(o)===s&&z(o).startsWith(`ok-ephemeral-`)}function Ie(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Q(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${p}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Le(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 $(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:c,dirname:l,resolve:d}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:h,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-DFlcDcjF.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?l(w):void 0,D=w?c(w):void 0,O,k=!1;if(E!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Q(O))throw new Z(O);o(d(O,`.ok`,`config.yml`))||y(O,E)}else O=h(E),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Q(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 ae(O,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!C){if(!i&&!m(n))throw new X(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CnuXQsDL.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-BGnKoX_8.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 te=T(),L=f(),R;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`)}R=await p({config:t,contentDir:P,projectDir:O??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:le,detectGhAccounts:ue,tokenStore:te,embeddingsKeyStore:L,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)=>M(e,t),probePiAcpBridge:e=>ee(e),ensurePiAcpBridge:(e,t)=>F(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:re(),env:process.env};return{probe:I(e),execute:we(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Le(N===void 0?n:Ie(n,N),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let z=R.destroy,B=k?async(...e)=>{try{await z(...e)}finally{await j()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:P,port:R.port,ready:R.ready,degraded:R.degraded}}function Re(e,t,n=()=>d({absPath:c(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function ze(e){if(e===`browser`||e===`app`)return e;throw new v(`--mode must be 'browser' or 'app'`)}function Be(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function Ve(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 He(t,a){let s=Re(t,a.singleFile),c=Be(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=Fe(m);let h;try{h=i(process.env)}catch(e){throw e instanceof o&&(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=a.bind!==void 0&&a.bind.length>0?a.bind:void 0,y=process.env.HOST,b=y!==void 0&&y.trim()!==``?y:void 0,x=r(g),S=v??(_||b===void 0?[...x.bind]:[b]);je({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=a.externalUrl,E=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=a.port===void 0?void 0:Number(a.port),D=h.overrides.find(e=>e.envVar===`PORT`)?.value,O=ee??D??s.server?.port,k=Oe({explicitDir:a.reactShellDistDir,only:a.only,findBundledDir:De}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await $({config:s,cwd:m,host:C,port:O,bind:w,...a.serveContentAssets===void 0?{}:{serveContentAssets:a.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(a.idleShutdown??E.idleShutdown),serverRuntime:E,...a.singleFile?{singleFile:a.singleFile}:{},...a.projectDir?{projectDir:a.projectDir}:{},...a.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof X&&(console.error(f(e.message)),process.exit(1)),e instanceof Z&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-DFlcDcjF.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitProbeTimeoutError||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)),Ge(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await Ue({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>oe(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=We(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=Ke(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=Ve(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await j.destroy(`external-signal`,{signal:e})}catch(e){console.error(`${f(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${j.port}`,F=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${j.port}`:void 0,I=P;console.log(l({name:`open-knowledge`,version:te,localUrl:I,networkUrl:F,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let L={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Me({openBrowser:a.openBrowser!==!1&&E.openBrowser,explicitOn:a.openBrowser!==!1&&g.server?.openBrowser===!0,host:C,isTTY:process.stdout.isTTY===!0,ephemeral:a.singleFile!==void 0,only:a.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-BgcinSRG.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function Ue(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:l(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function We(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 \`${a()} stop\` first if you want a fresh server.`]}function Ge(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function Ke(e,t,n){let r=n.ServerAuthorityCollisionError;if(r!==void 0&&e instanceof r)return e.message;let i=n.ServerAuthorityRegistryError;if(i!==void 0&&e instanceof i)return e.message;let o=n.ProcessLockFileError;if(o!==void 0&&e instanceof o)return e.message;let s=n.ServerLockCollisionError;if(s===void 0||!(e instanceof s))return null;try{let e=n.readServerLock(n.resolveLockDir(t)),r=a();return e?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${r} stop\`.`:`OpenKnowledge server is already running on this project — check \`${r} status\` or \`${r} stop\`.`}catch{return null}}function qe(e){return new S(`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)`,Ee).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)`,ke).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,ze).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 g(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new g(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new g(`--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).`,Pe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
|
-
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
|
-
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=j(D());if(n.available){k({spawn:R},n);return}console.error(O(n.reason)),process.exit(1)}await He(n,t)})}export{Ke as C,ue as D,le as E,qe as S,Le as T,Be as _,We as a,Me as b,Q as c,ke as d,Ee as f,Re as g,Ue as h,Fe as i,Ge as l,Te as m,X as n,Ve as o,De as p,$ as r,Ae as s,Z as t,Pe as u,Oe as v,Ie as w,je as x,He as y};
|
package/dist/start-Dx5wqmPM.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-Bs7pMN0A.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import{n as e}from"./chunk-HKLCLINH-BHo2f5d2.mjs";export{e as tarCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-CWQS3NFK-BbpS-dVt.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import{n as e}from"./chunk-Z6LRHWXI-B5pNb54L.mjs";export{e as timeCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-DXB73IDG-DFy9txNR.mjs";import{t as e}from"./chunk-OCLXQMOG-BgcVHeKY.mjs";export{e as touchCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import"./chunk-24IMIIXA-Dj5K6qOb.mjs";import"./chunk-PXTK5WE2-D43s5Y84.mjs";import"./chunk-7TSDKFEO-BGeceqqc.mjs";import"./chunk-KRBPSX3W-DXuvylLd.mjs";import"./chunk-DBKNVD4L-BquVyNve.mjs";import{t as e}from"./chunk-3BS5SKQH-C9C8uLJE.mjs";export{e as xanCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-DXB73IDG-DFy9txNR.mjs";import{n as e}from"./chunk-TOMNU26N-CPb3jib2.mjs";export{e as xargsCommand};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-DXB73IDG-DFy9txNR.mjs";import"./chunk-5QMZ5MUS-BuB3i_B5.mjs";import"./chunk-24IMIIXA-Dj5K6qOb.mjs";import"./chunk-PXTK5WE2-D43s5Y84.mjs";import"./chunk-7TSDKFEO-BGeceqqc.mjs";import"./chunk-KRBPSX3W-DXuvylLd.mjs";import{t as e}from"./chunk-6Z5SFZXK-CiQN8zZ8.mjs";export{e as yqCommand};
|