@inkeep/open-knowledge 0.89.0-beta.4 → 0.89.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-CVutw-Ge.mjs → cli-BJKFRq8q.mjs} +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/constants-CQAf3dMS.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/init-Cl3xQKi3.mjs +1 -0
- package/dist/{init-BtSdPRZj.mjs → init-O1DiQtaI.mjs} +2 -2
- package/dist/{launch-json-removal-panALLvt.mjs → launch-json-removal-TP1Yz9FJ.mjs} +1 -1
- package/dist/{loader-vYvM0FyZ.mjs → loader-BNFA7yiJ.mjs} +1 -1
- package/dist/loader-DP7X3Yq9.mjs +1 -0
- package/dist/{preview-CwkR6mf7.mjs → preview-CIZOpyLN.mjs} +1 -1
- package/dist/preview-oDjkIcX_.mjs +1 -0
- package/dist/public/assets/{AccountSection-Bl0zHJ1V.js → AccountSection-CjfH7U4r.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-CPbzm55g.js → ActivityModeContent-C6yrSIW_.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-BbpYdLi_.js → AddPropertiesButton-BXz7FdCC.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-Dquma2nV.js → AgentDiffPane-BuA0qrhe.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-T2wk1SgS.js → AttachmentsSection-BJHhhBx0.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-7-J_YDOD.js → CodeMirrorPropInput-GUpCwcMl.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-CfTx-bwo.js → ContentRulesSection-C3vQM-Rf.js} +1 -1
- package/dist/public/assets/{DocumentContext-BlPKGaDS.js → DocumentContext-D1hZMYYZ.js} +5 -5
- package/dist/public/assets/{EditorModeToggle-a-EpM0RH.js → EditorModeToggle-D7Vsb2HL.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-U1Aqe1lR.js → ExcalidrawDocEditor-COIentW7.js} +1 -1
- package/dist/public/assets/FeedbackForm-CYCpSclE.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-CHpWI1b_.js → ImportSkillDialog-C89n1Eez.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-BzqfReey.js → LinkPreviewsSection-5eQBE3z2.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-DuZYyDlw.js → LintConfigEditor-BGgBsEWq.js} +1 -1
- package/dist/public/assets/{LintingSection-YtYequX0.js → LintingSection-CQeFSRZs.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-BqfFU0ei.js → ManagedArtifactProperties-DodNLLCQ.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-vrALBlQV.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-CJcmE5bR.js → MermaidDocEditor-lyGwo627.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-4uynDoMD.js → NetworkAccessSection-G8TFYLiY.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-B_NKzaPp.js → PropertyDisplayRow-wgeDut3G.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-CJ93AB4X.js → PublishToGitHubDialog-BEwmQUAV.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-CKoZ64U_.js → SchemaConfigEditor-Biug_m3P.js} +1 -1
- package/dist/public/assets/{SearchSection-Czo1LlpF.js → SearchSection-weEXWdYD.js} +1 -1
- package/dist/public/assets/{SessionsHost-dhKLi8A7.js → SessionsHost-CPZXRLpe.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-CfTyTfpf.js → SettingsDialogBody-C1r5Z8cW.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-3B6Uq5IF.js → ShareReceiveMissDialog-yYfzZbu2.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-DovhEBEv.js → SkillToolbarControls-G5eWXOmA.js} +1 -1
- package/dist/public/assets/{SourceEditor-QGMgA3_Y.js → SourceEditor-CxYDmNie.js} +1 -1
- package/dist/public/assets/{SyncSection-C8sh_2wL.js → SyncSection-CtZQEJlp.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-XtHl-j5M.js → SyncStatusBadge-CL1pVLOe.js} +1 -1
- package/dist/public/assets/{TerminalSection-BBukQG-t.js → TerminalSection-d7ViHElr.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BsqkFwCw.js → TerminalWindowApp-rjaPEqgx.js} +1 -1
- package/dist/public/assets/{TextDocEditor-BKDlicTQ.js → TextDocEditor-_lsofMyi.js} +1 -1
- package/dist/public/assets/{ThreadView-DqsWOAeS.js → ThreadView-Dl2A2jYG.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-4iDamKwj.js → TimelineDiffPane-A6vWborK.js} +1 -1
- package/dist/public/assets/{client-version-ByZrpwsp.js → client-version-CSRUm7UD.js} +1 -1
- package/dist/public/assets/{comment-chips-BVz3vFEK.js → comment-chips-DAb7AzqN.js} +1 -1
- package/dist/public/assets/{config-provider-B9klwXzJ.js → config-provider-BsVNDQRf.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-D2--IGq0.js → doc-undo-manager-ezF_YLPp.js} +1 -1
- package/dist/public/assets/{index-xUea82Vb.js → index-DQAlPp5D.js} +7 -7
- package/dist/public/assets/{lint-plugins-B3S-5wB_.js → lint-plugins-aHWRIW7O.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-Oj7oNAYc.js → pending-receive-nav-store-BkV2wFAV.js} +1 -1
- package/dist/public/assets/{preferred-session-events-CKp8N52r.js → preferred-session-events-BMONFEGJ.js} +1 -1
- package/dist/public/assets/{progress-DekIJvba.js → progress-CJ5xSWEU.js} +1 -1
- package/dist/public/assets/{selection-context-AhdN7m_Z.js → selection-context-DHrx8Vet.js} +1 -1
- package/dist/public/assets/{src-CcljdSVc.js → src-BvSrrcu3.js} +1 -1
- package/dist/public/assets/{telemetry-impl-DcJiO6QI.js → telemetry-impl-BvGXK7Sb.js} +1 -1
- package/dist/public/assets/{telemetry-startup-D3MXN7Uc.js → telemetry-startup-BUMMGL55.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-DlhP62sL.js → typing-burst-detector-COzCipml.js} +1 -1
- package/dist/public/assets/{use-activity-panel-wH_8RgY8.js → use-activity-panel-coLFk8EH.js} +1 -1
- package/dist/public/assets/{use-open-skill-D-H1keX2.js → use-open-skill-DyowdYuP.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-DuI3b-nA.js → use-terminal-enabled-CJOb_gCQ.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-C3hOYRss.js → use-timeline-entry-diff-OY1cdtje.js} +1 -1
- package/dist/public/index.html +19 -19
- package/dist/{registry-probes-IgODudvT.mjs → registry-probes-DJzPV21f.mjs} +1 -1
- package/dist/{removal-file-path-DKlPTfZe.mjs → removal-file-path-CBJw_2D_.mjs} +1 -1
- package/dist/{repair-launch-json-DWsa6YOP.mjs → repair-launch-json-D6VmmqTF.mjs} +1 -1
- package/dist/{repair-mcp-configs-CL1PEAAh.mjs → repair-mcp-configs-UL3O5C7j.mjs} +1 -1
- package/dist/src-0M3w5Pk6.mjs +1 -0
- package/dist/{src-DP_cRFds.mjs → src-BQpq6uPC.mjs} +1 -1
- package/dist/{start-BpbIXDCc.mjs → start-DiS4vLnG.mjs} +2 -2
- package/dist/start-yrDQvgXW.mjs +1 -0
- package/package.json +5 -5
- package/dist/constants-DWf0KQP1.mjs +0 -1
- package/dist/init-1hhORWA2.mjs +0 -1
- package/dist/loader-D6cwZbpL.mjs +0 -1
- package/dist/preview-CltAhGjc.mjs +0 -1
- package/dist/public/assets/FeedbackForm-DeT3cztC.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-uImd3Fh_.js +0 -1
- package/dist/src-RhIwS_cj.mjs +0 -1
- package/dist/start-Soa4VO1R.mjs +0 -1
package/dist/public/index.html
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
-->
|
|
87
87
|
<script>(() => { try { const raw = localStorage.getItem('ok-language-v1'); if (!raw) return; const o = JSON.parse(raw); if (typeof o?.locale !== 'string' || !/^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{2,8})*$/.test(o.locale)) return; document.documentElement.lang = o.locale; document.documentElement.dir = o.dir === 'rtl' ? 'rtl' : 'ltr'; } catch {} })();</script>
|
|
88
88
|
<style>html { background-color: #fafafa } html.dark { background-color: #0b0b0b }</style>
|
|
89
|
-
<script type="module" crossorigin src="./assets/index-
|
|
89
|
+
<script type="module" crossorigin src="./assets/index-DQAlPp5D.js"></script>
|
|
90
90
|
<link rel="modulepreload" crossorigin href="./assets/chunk-CYidjpOJ.js">
|
|
91
91
|
<link rel="modulepreload" crossorigin href="./assets/react-f2sANaYj.js">
|
|
92
92
|
<link rel="modulepreload" crossorigin href="./assets/react-dom-DPxgxlDT.js">
|
|
@@ -127,14 +127,14 @@
|
|
|
127
127
|
<link rel="modulepreload" crossorigin href="./assets/dist-BGzUo_18.js">
|
|
128
128
|
<link rel="modulepreload" crossorigin href="./assets/messages-BneNCe6E.js">
|
|
129
129
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-language-atbAm0cM.js">
|
|
130
|
-
<link rel="modulepreload" crossorigin href="./assets/client-version-
|
|
130
|
+
<link rel="modulepreload" crossorigin href="./assets/client-version-CSRUm7UD.js">
|
|
131
131
|
<link rel="modulepreload" crossorigin href="./assets/dist-Nvb76hAm.js">
|
|
132
132
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-theme-CYFG76sS.js">
|
|
133
133
|
<link rel="modulepreload" crossorigin href="./assets/use-apply-config-color-theme-UYP8FtjI.js">
|
|
134
134
|
<link rel="modulepreload" crossorigin href="./assets/css-color-to-hex-CWNe6sew.js">
|
|
135
135
|
<link rel="modulepreload" crossorigin href="./assets/constants-upload-DZP-sCdl.js">
|
|
136
136
|
<link rel="modulepreload" crossorigin href="./assets/saved-themes-client-BNonffrJ.js">
|
|
137
|
-
<link rel="modulepreload" crossorigin href="./assets/config-provider-
|
|
137
|
+
<link rel="modulepreload" crossorigin href="./assets/config-provider-BsVNDQRf.js">
|
|
138
138
|
<link rel="modulepreload" crossorigin href="./assets/dist-Dc8tD1th.js">
|
|
139
139
|
<link rel="modulepreload" crossorigin href="./assets/ccount-s_UaBrax.js">
|
|
140
140
|
<link rel="modulepreload" crossorigin href="./assets/lib-CZXZ01YL.js">
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
<link rel="modulepreload" crossorigin href="./assets/documents-fetch-ZX1mUge_.js">
|
|
158
158
|
<link rel="modulepreload" crossorigin href="./assets/note-window-mode-CI3Yju9B.js">
|
|
159
159
|
<link rel="modulepreload" crossorigin href="./assets/structural-freshness-C6rR7cV3-VXiZX15w.js">
|
|
160
|
-
<link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-
|
|
160
|
+
<link rel="modulepreload" crossorigin href="./assets/CodeMirrorPropInput-GUpCwcMl.js">
|
|
161
161
|
<link rel="modulepreload" crossorigin href="./assets/dist-CSCUSbQc.js">
|
|
162
162
|
<link rel="modulepreload" crossorigin href="./assets/dist-DTFuvKje.js">
|
|
163
163
|
<link rel="modulepreload" crossorigin href="./assets/dist-CRjqnzU7.js">
|
|
@@ -241,19 +241,19 @@
|
|
|
241
241
|
<link rel="modulepreload" crossorigin href="./assets/storage-scope-BDcuM4d_.js">
|
|
242
242
|
<link rel="modulepreload" crossorigin href="./assets/use-workspace-BTtr5NT8.js">
|
|
243
243
|
<link rel="modulepreload" crossorigin href="./assets/utils-random-uuid-CE1X6bNM.js">
|
|
244
|
-
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-
|
|
244
|
+
<link rel="modulepreload" crossorigin href="./assets/DocumentContext-D1hZMYYZ.js">
|
|
245
245
|
<link rel="modulepreload" crossorigin href="./assets/dist-BKgU0kag.js">
|
|
246
246
|
<link rel="modulepreload" crossorigin href="./assets/dist-d2WYntJB.js">
|
|
247
247
|
<link rel="modulepreload" crossorigin href="./assets/dist-C0nuYMFu.js">
|
|
248
248
|
<link rel="modulepreload" crossorigin href="./assets/dropdown-menu-DH6UNmuX.js">
|
|
249
|
-
<link rel="modulepreload" crossorigin href="./assets/comment-chips-
|
|
249
|
+
<link rel="modulepreload" crossorigin href="./assets/comment-chips-DAb7AzqN.js">
|
|
250
250
|
<link rel="modulepreload" crossorigin href="./assets/file-tree-adapter-BD1Le0QE.js">
|
|
251
251
|
<link rel="modulepreload" crossorigin href="./assets/tool-list-format-ahklHT7Z.js">
|
|
252
252
|
<link rel="modulepreload" crossorigin href="./assets/acp-thread-protocol-EC8X7m2Z.js">
|
|
253
253
|
<link rel="modulepreload" crossorigin href="./assets/image-attachment-Chp6ejuJ.js">
|
|
254
254
|
<link rel="modulepreload" crossorigin href="./assets/workspace-paths-BjilyZF6.js">
|
|
255
255
|
<link rel="modulepreload" crossorigin href="./assets/acp-tool-call-input-B6Z0o0iM.js">
|
|
256
|
-
<link rel="modulepreload" crossorigin href="./assets/progress-
|
|
256
|
+
<link rel="modulepreload" crossorigin href="./assets/progress-CJ5xSWEU.js">
|
|
257
257
|
<link rel="modulepreload" crossorigin href="./assets/radio-group-G1GR05Rb.js">
|
|
258
258
|
<link rel="modulepreload" crossorigin href="./assets/separator-D7s_9ZwH.js">
|
|
259
259
|
<link rel="modulepreload" crossorigin href="./assets/toggle-group-aEGkM0EG.js">
|
|
@@ -262,15 +262,15 @@
|
|
|
262
262
|
<link rel="modulepreload" crossorigin href="./assets/markdown-lint-DYkBgJHq.js">
|
|
263
263
|
<link rel="modulepreload" crossorigin href="./assets/format-DUHlUJ5L.js">
|
|
264
264
|
<link rel="modulepreload" crossorigin href="./assets/braces--g9Mwtim.js">
|
|
265
|
-
<link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-
|
|
265
|
+
<link rel="modulepreload" crossorigin href="./assets/PropertyDisplayRow-wgeDut3G.js">
|
|
266
266
|
<link rel="modulepreload" crossorigin href="./assets/grip-vertical-DNbkgWZL.js">
|
|
267
267
|
<link rel="modulepreload" crossorigin href="./assets/SkillCostValue-D-VQUaZz.js">
|
|
268
268
|
<link rel="modulepreload" crossorigin href="./assets/textarea-DkcNoPBJ.js">
|
|
269
|
-
<link rel="modulepreload" crossorigin href="./assets/selection-context-
|
|
269
|
+
<link rel="modulepreload" crossorigin href="./assets/selection-context-DHrx8Vet.js">
|
|
270
270
|
<link rel="modulepreload" crossorigin href="./assets/lint-config-client-B7GJyltx.js">
|
|
271
271
|
<link rel="modulepreload" crossorigin href="./assets/use-skills-CHU2m8ND.js">
|
|
272
272
|
<link rel="modulepreload" crossorigin href="./assets/folder-config-api-C6LhS3Cf.js">
|
|
273
|
-
<link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-
|
|
273
|
+
<link rel="modulepreload" crossorigin href="./assets/ManagedArtifactProperties-DodNLLCQ.js">
|
|
274
274
|
<link rel="modulepreload" crossorigin href="./assets/arrow-up-right-nJaICi16.js">
|
|
275
275
|
<link rel="modulepreload" crossorigin href="./assets/git-merge-VDBzSZBV.js">
|
|
276
276
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-BVQchE6b.js">
|
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
<link rel="modulepreload" crossorigin href="./assets/use-conflicts-DBMds-hY.js">
|
|
282
282
|
<link rel="modulepreload" crossorigin href="./assets/use-git-sync-status-DB3RSBj5.js">
|
|
283
283
|
<link rel="modulepreload" crossorigin href="./assets/use-settings-route-BGtkup9E.js">
|
|
284
|
-
<link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-
|
|
284
|
+
<link rel="modulepreload" crossorigin href="./assets/SyncStatusBadge-CL1pVLOe.js">
|
|
285
285
|
<link rel="modulepreload" crossorigin href="./assets/cursor-pH0WlPzE.js">
|
|
286
286
|
<link rel="modulepreload" crossorigin href="./assets/agent-registry-UV4Vx43J.js">
|
|
287
287
|
<link rel="modulepreload" crossorigin href="./assets/RegisteredAgentIcon-uXi2oPSE.js">
|
|
@@ -305,18 +305,18 @@
|
|
|
305
305
|
<link rel="modulepreload" crossorigin href="./assets/agent-launcher-labels-CKD6Vuny.js">
|
|
306
306
|
<link rel="modulepreload" crossorigin href="./assets/terminal-cli-display-CHuCou07.js">
|
|
307
307
|
<link rel="modulepreload" crossorigin href="./assets/open-managed-artifact-tab-BcMHQbeA.js">
|
|
308
|
-
<link rel="modulepreload" crossorigin href="./assets/use-open-skill-
|
|
308
|
+
<link rel="modulepreload" crossorigin href="./assets/use-open-skill-DyowdYuP.js">
|
|
309
309
|
<link rel="modulepreload" crossorigin href="./assets/platform-labels-DDy1ouuX.js">
|
|
310
310
|
<link rel="modulepreload" crossorigin href="./assets/clipboard-adapter-FO6gFDPG.js">
|
|
311
|
-
<link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-
|
|
311
|
+
<link rel="modulepreload" crossorigin href="./assets/AddPropertiesButton-BXz7FdCC.js">
|
|
312
312
|
<link rel="modulepreload" crossorigin href="./assets/case-sensitive-DIxypOE0.js">
|
|
313
313
|
<link rel="modulepreload" crossorigin href="./assets/chevron-left-C5T97PNU.js">
|
|
314
314
|
<link rel="modulepreload" crossorigin href="./assets/lint-plugin-meta-CtDE2R0v.js">
|
|
315
315
|
<link rel="modulepreload" crossorigin href="./assets/wrench-DmtZXcHB.js">
|
|
316
316
|
<link rel="modulepreload" crossorigin href="./assets/panel-eNhYruJz.js">
|
|
317
|
-
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-
|
|
317
|
+
<link rel="modulepreload" crossorigin href="./assets/typing-burst-detector-COzCipml.js">
|
|
318
318
|
<link rel="modulepreload" crossorigin href="./assets/miss-dialog-store-CsiJb9Ou.js">
|
|
319
|
-
<link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-
|
|
319
|
+
<link rel="modulepreload" crossorigin href="./assets/pending-receive-nav-store-BkV2wFAV.js">
|
|
320
320
|
<link rel="modulepreload" crossorigin href="./assets/target-navigation-intent-D_irC8wr.js">
|
|
321
321
|
<link rel="modulepreload" crossorigin href="./assets/terminal-launch-events-CJnkcylC.js">
|
|
322
322
|
<link rel="modulepreload" crossorigin href="./assets/contact-email-store-B_5aVbhf.js">
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
<link rel="modulepreload" crossorigin href="./assets/package-PkCmIx3S.js">
|
|
326
326
|
<link rel="modulepreload" crossorigin href="./assets/panel-right-open-D4M8nGPT.js">
|
|
327
327
|
<link rel="modulepreload" crossorigin href="./assets/overlay-layers-CKMAjef3.js">
|
|
328
|
-
<link rel="modulepreload" crossorigin href="./assets/preferred-session-events-
|
|
328
|
+
<link rel="modulepreload" crossorigin href="./assets/preferred-session-events-BMONFEGJ.js">
|
|
329
329
|
<link rel="modulepreload" crossorigin href="./assets/panel-right-close-Bsh1pCmh.js">
|
|
330
330
|
<link rel="modulepreload" crossorigin href="./assets/rotate-ccw-DeMl2ou7.js">
|
|
331
331
|
<link rel="modulepreload" crossorigin href="./assets/square-pen-DU3t-IcD.js">
|
|
@@ -335,13 +335,13 @@
|
|
|
335
335
|
<link rel="modulepreload" crossorigin href="./assets/dist-DMhg0Xyd.js">
|
|
336
336
|
<link rel="modulepreload" crossorigin href="./assets/dist-ucvNbATJ.js">
|
|
337
337
|
<link rel="modulepreload" crossorigin href="./assets/text-viewer-languages-CDBOzWaI.js">
|
|
338
|
-
<link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-
|
|
338
|
+
<link rel="modulepreload" crossorigin href="./assets/EditorModeToggle-D7Vsb2HL.js">
|
|
339
339
|
<link rel="modulepreload" crossorigin href="./assets/ImageAttachments-BGB1Xeig.js">
|
|
340
340
|
<link rel="modulepreload" crossorigin href="./assets/TemplateRow-DGghua5F.js">
|
|
341
341
|
<link rel="modulepreload" crossorigin href="./assets/ConfigSharingInfoTooltip-CJywmyrk.js">
|
|
342
342
|
<link rel="modulepreload" crossorigin href="./assets/RowDisclosure-BpaiWVwL.js">
|
|
343
343
|
<link rel="modulepreload" crossorigin href="./assets/project-paths-Cq56bh9f.js">
|
|
344
|
-
<link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-
|
|
344
|
+
<link rel="modulepreload" crossorigin href="./assets/PublishToGitHubDialog-BEwmQUAV.js">
|
|
345
345
|
<link rel="modulepreload" crossorigin href="./assets/use-installed-clis-BZPKReyc.js">
|
|
346
346
|
<link rel="modulepreload" crossorigin href="./assets/ReportBugMenuTrigger-B3r2VnaW.js">
|
|
347
347
|
<link rel="modulepreload" crossorigin href="./assets/SkillModeBanner-BLTTRSBJ.js">
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
<link rel="modulepreload" crossorigin href="./assets/alert-BEwM2iOp.js">
|
|
360
360
|
<link rel="modulepreload" crossorigin href="./assets/input-group-CBuVp6zh.js">
|
|
361
361
|
<link rel="modulepreload" crossorigin href="./assets/use-skill-origin-Aw9Y3_sH.js">
|
|
362
|
-
<link rel="modulepreload" crossorigin href="./assets/use-terminal-enabled-
|
|
362
|
+
<link rel="modulepreload" crossorigin href="./assets/use-terminal-enabled-CJOb_gCQ.js">
|
|
363
363
|
<link rel="modulepreload" crossorigin href="./assets/catalog-C1Qnqxzu.js">
|
|
364
364
|
<link rel="modulepreload" crossorigin href="./assets/agent-presence-DU3TT-KP.js">
|
|
365
365
|
<link rel="modulepreload" crossorigin href="./assets/auth-prompt-store-Br5SQeuk.js">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{C as r,E as i,L as a,M as o,N as s,P as c,w as l,x as u}from"./constants-ok-dir-DZ25OS9-.mjs";import{$d as d,Qd as f,Xd as p,Ya as m,pd as h,tf as g}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Ho as _,Ns as v,Ps as y,ka as ee,m as b,nr as te,rs as x}from"./dist-Bi-hqCKx.mjs";import{s as S,y as ne}from"./fs-find-project-root-BYV07wjn.mjs";import{A as re,B as ie,E as C,F as ae,M as w,N as T,S as oe,T as se,Y as ce,Z as E,at as le,b as ue,et as de,f as fe,ft as pe,it as me,j as he,k as D,lt as ge,nt as _e,ot as ve,p as ye,rt as be,s as xe,ut as Se,y as Ce}from"./init-BtSdPRZj.mjs";import{o as we}from"./token-store-Bmb3_0hU.mjs";import{t as Te}from"./is-object-BGze3w87.mjs";import{t as Ee}from"./removal-file-path-DKlPTfZe.mjs";import{basename as O,dirname as k,join as A,resolve as j,win32 as De}from"node:path";import{accessSync as Oe,constants as M,existsSync as N,lstatSync as P,mkdirSync as ke,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as Ae,rmdirSync as je,statSync as R,unlinkSync as Me}from"node:fs";import{homedir as z}from"node:os";import{createHash as Ne}from"node:crypto";import{spawn as Pe}from"node:child_process";import{setTimeout as Fe}from"node:timers/promises";import{isDeepStrictEqual as Ie}from"node:util";function Le(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Re(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function ze(e){return _({detached:!0,stdio:`ignore`,shell:!1,env:Le(e)})}function Be(e,t,n={}){let r=(n.spawn??Pe)(e,[...t],ze(n.env??process.env));return r.unref(),r}function Ve(e,t,n={}){let r=n.spawn??Pe,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],ze(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Re(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Re(e))}})}const He=r.stable.appId,B=i,Ue=[`stable`,`beta`];function We(e,t,n=e=>console.error(e)){try{return a(e,t)}catch(r){let i=a({...e,[l]:void 0},t);return n(`Treating this CLI as ${o(i)} for this command: ${r instanceof Error?r.message:String(r)}`),i}}function V(e){return Ue.includes(e)||!B.includes(e)?Ue:[e,...Ue]}function Ge(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:r[e.product].protocolScheme}}function Ke(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return R(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function qe(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:B.find(t=>e.endsWith(`/${r[t].productName}.app`))??t}}}let n=e.homeDir??z();for(let i of V(t)){let{productName:t}=r[i];for(let r of[A(n,`Applications`),`/Applications`]){let n=A(r,`${t}.app`);if(Je(e,A(n,`Contents`,`MacOS`,t)))return{path:n,product:i}}}return null}function Je(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function Ye(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=B.find(t=>e.execPath.toLowerCase().endsWith(`\\${s(r[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let i of V(t))for(let t of c(r[i])){let a=De.join(n,`Programs`,t,s(r[i]));if(Je(e,a))return{path:a,product:i}}return null}function Xe(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=B.find(t=>e.execPath.endsWith(`/${r[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of V(t)){let{productName:t,linuxExecutableName:i}=r[n],a=`/opt/${t}/${i}`;if(Je(e,a))return{path:a,product:n}}return null}function Ze(e){let t=We(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`?qe(e,t):e.platform===`win32`?Ye(e,t):Xe(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 Qe(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`){Be(`open`,[`-a`,s],{spawn:e.spawn});return}Be(s,[],{spawn:e.spawn})}function $e(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).`}}var et=u();function H(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 tt(e){return Ne(`sha256`).update(e).digest(`hex`)}function U(e){return A(ne(j(e)),`pi-trust`)}function nt(e,t){return A(U(e),tt(j(t)))}function rt(e,t,n){return A(nt(e,t),`${tt(n)}.json`)}var W=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${H(e)} ${H(t)}; ${H(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function G(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 W(e,`could not ${t}: ${i}`,a,n)}function K(e){let t;try{t=P(e)}catch(t){if(t.code===`ENOENT`)return!1;throw G(e,`be inspected`,t)}if(!t.isDirectory())throw new W(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function it(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function at(e,t){if(!Te(e)||!it(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==j(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==j(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==j(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!Te(e.previous))throw new W(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&&it(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&it(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new W(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 ot(e,t,n){let r;try{r=P(n)}catch(e){throw G(n,`be inspected`,e)}if(!r.isFile())throw new W(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=F(n,`utf8`)}catch(e){throw G(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new W(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=at(a,n);if(o.cwd!==j(t)||n!==rt(e,t,o.canonicalTrustPath))throw new W(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 st(e,t){let{record:n,path:r}=t;for(let t of[U(e),nt(e,n.cwd)])if(!K(t))throw new W(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=ot(e,n.cwd,r);if(!Ie(i.record,n))throw new W(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function ct(e,t,n,r,i){let a={version:1,cwd:j(t),configuredTrustPath:j(n),canonicalTrustPath:j(r),state:`pending`,previous:i},o=rt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Ie(at(JSON.parse(s),o),a))throw new W(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);K(U(e)),K(k(o));try{ke(k(o),{recursive:!0,mode:448})}catch(e){throw G(k(o),`be created`,e)}let c;try{c=P(o,{throwIfNoEntry:!1})}catch(e){throw G(o,`be inspected`,e)}if(c)throw new W(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{S(o,s,{mode:384})}catch(e){throw G(o,`be written`,e)}return{path:o,record:a}}function lt(e,t){let n=st(e,t);if(n.record.state!==`pending`)throw new W(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 G(n.path,`be committed`,e)}return{path:n.path,record:r}}function q(e,t){if(!K(U(e)))return[];let n=nt(e,t);if(!K(n))return[];let r;try{r=I(n).sort()}catch(e){throw G(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>ot(e,t,A(n,r)))}function J(e,t){let n=st(e,t);try{Me(n.path)}catch(e){throw G(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),U(e)])try{je(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw G(t,`be removed after reconciling its grant`,e)}}var ut=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),dt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),ft=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}})),pt=n(((t,n)=>{var r=e(`fs`),i=ut(),a=dt(),o=ft(),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(`
|
|
1
|
+
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{C as r,E as i,L as a,M as o,N as s,P as c,w as l,x as u}from"./constants-ok-dir-DZ25OS9-.mjs";import{$d as d,Qd as f,Xd as p,Ya as m,pd as h,tf as g}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Ho as _,Ns as v,Ps as y,ka as ee,m as b,nr as te,rs as x}from"./dist-Bi-hqCKx.mjs";import{s as S,y as ne}from"./fs-find-project-root-BYV07wjn.mjs";import{A as re,B as ie,E as C,F as ae,M as w,N as T,S as oe,T as se,Y as ce,Z as E,at as le,b as ue,et as de,f as fe,ft as pe,it as me,j as he,k as D,lt as ge,nt as _e,ot as ve,p as ye,rt as be,s as xe,ut as Se,y as Ce}from"./init-O1DiQtaI.mjs";import{o as we}from"./token-store-Bmb3_0hU.mjs";import{t as Te}from"./is-object-BGze3w87.mjs";import{t as Ee}from"./removal-file-path-CBJw_2D_.mjs";import{basename as O,dirname as k,join as A,resolve as j,win32 as De}from"node:path";import{accessSync as Oe,constants as M,existsSync as N,lstatSync as P,mkdirSync as ke,readFileSync as F,readdirSync as I,realpathSync as L,rmSync as Ae,rmdirSync as je,statSync as R,unlinkSync as Me}from"node:fs";import{homedir as z}from"node:os";import{createHash as Ne}from"node:crypto";import{spawn as Pe}from"node:child_process";import{setTimeout as Fe}from"node:timers/promises";import{isDeepStrictEqual as Ie}from"node:util";function Le(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Re(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function ze(e){return _({detached:!0,stdio:`ignore`,shell:!1,env:Le(e)})}function Be(e,t,n={}){let r=(n.spawn??Pe)(e,[...t],ze(n.env??process.env));return r.unref(),r}function Ve(e,t,n={}){let r=n.spawn??Pe,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],ze(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Re(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Re(e))}})}const He=r.stable.appId,B=i,Ue=[`stable`,`beta`];function We(e,t,n=e=>console.error(e)){try{return a(e,t)}catch(r){let i=a({...e,[l]:void 0},t);return n(`Treating this CLI as ${o(i)} for this command: ${r instanceof Error?r.message:String(r)}`),i}}function V(e){return Ue.includes(e)||!B.includes(e)?Ue:[e,...Ue]}function Ge(e){return e.bundlePath===void 0?null:{bundlePath:e.bundlePath,protocolScheme:r[e.product].protocolScheme}}function Ke(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return R(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function qe(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:B.find(t=>e.endsWith(`/${r[t].productName}.app`))??t}}}let n=e.homeDir??z();for(let i of V(t)){let{productName:t}=r[i];for(let r of[A(n,`Applications`),`/Applications`]){let n=A(r,`${t}.app`);if(Je(e,A(n,`Contents`,`MacOS`,t)))return{path:n,product:i}}}return null}function Je(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function Ye(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=B.find(t=>e.execPath.toLowerCase().endsWith(`\\${s(r[t]).toLowerCase()}`));if(t)return{path:e.execPath,product:t}}let n=e.env.LOCALAPPDATA;if(n)for(let i of V(t))for(let t of c(r[i])){let a=De.join(n,`Programs`,t,s(r[i]));if(Je(e,a))return{path:a,product:i}}return null}function Xe(e,t){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=B.find(t=>e.execPath.endsWith(`/${r[t].linuxExecutableName}`));if(t)return{path:e.execPath,product:t}}for(let n of V(t)){let{productName:t,linuxExecutableName:i}=r[n],a=`/opt/${t}/${i}`;if(Je(e,a))return{path:a,product:n}}return null}function Ze(e){let t=We(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`?qe(e,t):e.platform===`win32`?Ye(e,t):Xe(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 Qe(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`){Be(`open`,[`-a`,s],{spawn:e.spawn});return}Be(s,[],{spawn:e.spawn})}function $e(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).`}}var et=u();function H(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 tt(e){return Ne(`sha256`).update(e).digest(`hex`)}function U(e){return A(ne(j(e)),`pi-trust`)}function nt(e,t){return A(U(e),tt(j(t)))}function rt(e,t,n){return A(nt(e,t),`${tt(n)}.json`)}var W=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${H(e)} ${H(t)}; ${H(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function G(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 W(e,`could not ${t}: ${i}`,a,n)}function K(e){let t;try{t=P(e)}catch(t){if(t.code===`ENOENT`)return!1;throw G(e,`be inspected`,t)}if(!t.isDirectory())throw new W(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function it(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function at(e,t){if(!Te(e)||!it(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==j(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==j(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==j(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!Te(e.previous))throw new W(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&&it(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&it(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new W(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 ot(e,t,n){let r;try{r=P(n)}catch(e){throw G(n,`be inspected`,e)}if(!r.isFile())throw new W(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=F(n,`utf8`)}catch(e){throw G(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new W(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=at(a,n);if(o.cwd!==j(t)||n!==rt(e,t,o.canonicalTrustPath))throw new W(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 st(e,t){let{record:n,path:r}=t;for(let t of[U(e),nt(e,n.cwd)])if(!K(t))throw new W(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=ot(e,n.cwd,r);if(!Ie(i.record,n))throw new W(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function ct(e,t,n,r,i){let a={version:1,cwd:j(t),configuredTrustPath:j(n),canonicalTrustPath:j(r),state:`pending`,previous:i},o=rt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Ie(at(JSON.parse(s),o),a))throw new W(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);K(U(e)),K(k(o));try{ke(k(o),{recursive:!0,mode:448})}catch(e){throw G(k(o),`be created`,e)}let c;try{c=P(o,{throwIfNoEntry:!1})}catch(e){throw G(o,`be inspected`,e)}if(c)throw new W(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{S(o,s,{mode:384})}catch(e){throw G(o,`be written`,e)}return{path:o,record:a}}function lt(e,t){let n=st(e,t);if(n.record.state!==`pending`)throw new W(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 G(n.path,`be committed`,e)}return{path:n.path,record:r}}function q(e,t){if(!K(U(e)))return[];let n=nt(e,t);if(!K(n))return[];let r;try{r=I(n).sort()}catch(e){throw G(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>ot(e,t,A(n,r)))}function J(e,t){let n=st(e,t);try{Me(n.path)}catch(e){throw G(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),U(e)])try{je(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw G(t,`be removed after reconciling its grant`,e)}}var ut=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),dt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),ft=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}})),pt=n(((t,n)=>{var r=e(`fs`),i=ut(),a=dt(),o=ft(),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(`
|
|
2
2
|
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);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=S),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){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))}}})),mt=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}})),ht=n((e=>{var t=mt();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}}})),gt=n(((e,t)=>{t.exports=ht()})),_t=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`)})),vt=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=_t(),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)}}})),yt=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})),bt=n(((t,n)=>{let r=e(`path`),i=pt(),a=gt(),o=vt(),s=yt(),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})),xt=n(((e,t)=>{let n=pt();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}})),St=t(n(((e,t)=>{let n=bt(),{toPromise:r,toSync:i,toSyncOptions:a}=xt();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 Ct=5e3;function wt(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 ${Ct}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Tt(e,t){we()?.warn(t,e)}function Et(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 Dt(e,t,n){await v(`${t}.ok.lock`,async()=>{let t=performance.now()+Ct,r;for(;;)try{r=await St.default.lock(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Fe(wt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Et(i,e)},{onWarn:Tt})}function Ot(e,t,n){y(`${t}.ok.lock`,()=>{let t=performance.now()+Ct,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=St.default.lockSync(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,wt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Et(a,e)},{onWarn:Tt})}const kt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var At=class extends Error{name=`PiResourceInspectionError`};function Y(e){let t;try{t=P(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=R(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new At(w(`missing-symlink-target`),{cause:e}):e}return Oe(e,M.R_OK|(n.isDirectory()?M.X_OK:0)),!0}function jt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Mt(e,t,n){let r=e;try{let i=L(e),a;r=t;try{a=L(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=j(t)}let o=A(a,`.agents`,`skills`),s=[];for(let e of kt)r=A(i,`.pi`,e),Y(r)&&s.push(r);if(r=A(i,`.pi`,`extensions`),Y(r))for(let t of I(r).sort()){let i=A(r,t);j(n)!==A(j(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[A(i,`.pi`,`skills`),A(i,`.agents`,`skills`)])if(e!==o&&(r=e,Y(e)))for(let t of I(e).sort())jt(t)||s.push(A(e,t));let c=k(i);for(;c!==i;){r=A(c,`.agents`,`skills`),r!==o&&Y(r)&&s.push(r);let e=k(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${H(r)}: ${e instanceof At?e.message:w(T(e))}`}}}function Nt(e,t,n){let r=j(e),i=ge({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:E.pi.projectConfigPath(r),trustPath:A(i,`trust.json`)}}function X(e){try{let t=L(e);return R(t).isDirectory()?(Oe(t,M.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${H(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${H(e)} could not be resolved or accessed: ${H(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function Pt(e){let t=X(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${H(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function Ft(e,t,n){let r=xe(E.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return me(i)?{state:`own-current`,text:a}:C(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function It(e,t){let n;try{n=F(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:T(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return Te(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
3
3
|
`)}:{state:`unreadable`,reason:`invalid-json`}}function Lt(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 w(e)}}function Z(e,t){return{kind:`refused`,error:`trust store ${H(e)}: ${Lt(t)}`}}function Q(e){let t=Ee(e);try{switch(t.kind){case`declined`:return Z(e,t.reason);case`ready`:return{kind:`ready`,path:L(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=k(e),r=[O(e)],i=P(n,{throwIfNoEntry:!1});for(;!i;){let t=k(n);if(t===n)return Z(e,`unavailable-root`);r.unshift(O(n)),n=t,i=P(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:A(L(n),...r)}}catch(t){return Z(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:T(t))}}catch(t){return Z(e,T(t))}}function Rt(e,t){let n=Q(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?Z(e,`path-changed`):n}function zt(e,t,n){let r=Nt(e,t,n),i=X(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=Ft(r.cwd,r.bridgePath,t).state,o=Q(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:It(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:Bt(r.bridgePath).displayNames}}function Bt(e){let t=k(e),n=O(e);try{return{displayNames:I(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>H(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function Vt(e,t={mode:`published`},n,r,i){let a=Nt(e,n,r),o=X(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 ${H(i)} no longer matches the current directory ${H(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=Ft(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=se(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=ue(E.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:H(e.error)}}let l=await Ht(a.trustPath,o.project,n??z());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function Ht(e,t,n){let r=t.canonical,i=Q(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{ke(k(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Dt(e,i.path,()=>{let o=Pt(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=Rt(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=It(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=Z(e,c.reason).error;return}let l=$(n,()=>{let t=q(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&J(n,t),ct(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?`
|
|
4
4
|
`:``),f=D(s.path);S(s.path,d,f===void 0?void 0:{mode:f}),$(n,()=>lt(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}return a}function Ut(e){let t=[],n=e;try{for(;;){if(P(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=L(n);return R(e).isDirectory()?(Oe(e,M.X_OK),A(e,...t)):void 0}let e=k(n);if(e===n)return;t.unshift(O(n)),n=e}}catch{return}}function Wt(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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,N as t}from"./init-
|
|
1
|
+
import{C as e,N as t}from"./init-O1DiQtaI.mjs";import{lstatSync as n,statSync as r}from"node:fs";function i(i){let a;try{a=n(i).isSymbolicLink()}catch(e){return e.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:t(e)}}let o=e(i);if(o.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!r(o.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(e){return{kind:`declined`,reason:a&&e.code===`ENOENT`?`missing-symlink-target`:t(e)}}return{kind:`ready`,path:o.writePath,symlink:a}}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
1
|
+
import{t as e}from"./launch-json-removal-TP1Yz9FJ.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-
|
|
1
|
+
import{E as e}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Y as t,Z as n,b as r,et as i,it as a,p as o,tt as s}from"./init-O1DiQtaI.mjs";import{homedir as c}from"node:os";function l(e){let{priorCommand:t,priorArgs:n}=u(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function u(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function d(e){let r=e.logger??h,i=e.home??c(),a=[];if(e.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of t){let t=n[o],s=f(()=>t.configPath(``,i));if(s!==null&&a.push(p({scope:`user`,editorId:o,target:t,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),t.projectConfigPath){let n=t.projectConfigPath,i=f(()=>n(e.projectDir));i!==null&&a.push(p({scope:`project`,editorId:o,target:t,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function f(e){try{return e()}catch{return null}}function p(t){let n={scope:t.scope,editorId:t.editorId,configPath:t.configPath},c=o(t.target,t.cwd,t.home,t.configPathOverride);if(c===null)return{...n,outcome:`no-entry`};if(t.target.format===`file`){if(a(c))return{...n,outcome:`canonical`}}else{let a=e(c);if(a.kind===`recognized`&&a.disposition===`keep`){let e=s(c,i(t.target,t.cwd));if(e.length===0)return{...n,outcome:`canonical`};let a=m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0,pruneOnly:!0},t.home,t.configPathOverride));return(a.outcome===`repaired`||a.outcome===`canonical`)&&t.logger({event:a.outcome===`repaired`?`mcp-config-repair-pruned`:`mcp-config-repair-prune-unchanged`,severity:a.outcome===`repaired`?`info`:`warn`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,keys:e}),a.outcome===`canonical`?{...n,outcome:`prune-unchanged`}:a}if(a.kind===`declined`&&t.scope===`project`)return t.logger({event:`mcp-config-repair-skipped-foreign`,severity:`info`,scope:t.scope,editorId:t.editorId,configPath:t.configPath,reason:a.reason}),{...n,outcome:`foreign`,reason:a.reason}}return t.logger({...l({scope:t.scope,surface:`cli-repair`,editorId:t.editorId,configPath:t.configPath,priorEntry:c}),severity:`info`}),m(t,n,r(t.target,t.cwd,{mode:`published`,skipAvailabilityCheck:!0},t.home,t.configPathOverride))}function m(e,t,n){if(n.action===`failed`){let r=n.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:r}),{...t,outcome:`write-failed`,error:r}}return n.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,severity:`warn`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:n.declineReason}),{...t,outcome:`declined`,reason:n.declineReason}):n.action===`skipped-flag`?{...t,outcome:`canonical`}:{...t,outcome:`repaired`}}function h(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{u as n,d as repairMcpConfigs,l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import"./src-BQpq6uPC.mjs";import"./init-O1DiQtaI.mjs";import"./token-store-Bmb3_0hU.mjs";import"./start-DiS4vLnG.mjs";import"./registry-probes-DJzPV21f.mjs";import{n as e}from"./loader-BNFA7yiJ.mjs";import"./preview-CIZOpyLN.mjs";import"./repair-mcp-configs-UL3O5C7j.mjs";export{e as loadConfig};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{C as t,E as n,L as r,M as i,N as a,O as o,S as s,d as c,k as l,x as u}from"./constants-ok-dir-DZ25OS9-.mjs";import{Da as d,G as f,Oa as p,Rl as m,U as h,W as g,l as _,sf as v,u as ee,zl as y}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{$t as b,As as x,Bs as te,Ci as S,Cs as ne,Ds as C,Gi as re,Ho as w,Hs as ie,La as T,Ls as E,Ms as D,Pt as O,Rs as k,Si as A,So as j,Ss as ae,Ti as M,Ts as oe,Ui as N,Vs as se,ei as ce,ha as le,hi as ue,js as de,ks as fe,li as P,m as pe,na as me,pr as he,rr as F,va as ge,ws as _e,xi as ve,zs as I}from"./dist-Bi-hqCKx.mjs";import{t as ye}from"./yazl-BBz29IQN.mjs";import{t as be,y as L}from"./fs-find-project-root-BYV07wjn.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-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{C as t,E as n,L as r,M as i,N as a,O as o,S as s,d as c,k as l,x as u}from"./constants-ok-dir-DZ25OS9-.mjs";import{Da as d,G as f,Oa as p,Rl as m,U as h,W as g,l as _,sf as v,u as ee,zl as y}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{$t as b,As as x,Bs as te,Ci as S,Cs as ne,Ds as C,Gi as re,Ho as w,Hs as ie,La as T,Ls as E,Ms as D,Pt as O,Rs as k,Si as A,So as j,Ss as ae,Ti as M,Ts as oe,Ui as N,Vs as se,ei as ce,ha as le,hi as ue,js as de,ks as fe,li as P,m as pe,na as me,pr as he,rr as F,va as ge,ws as _e,xi as ve,zs as I}from"./dist-Bi-hqCKx.mjs";import{t as ye}from"./yazl-BBz29IQN.mjs";import{t as be,y as L}from"./fs-find-project-root-BYV07wjn.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-O1DiQtaI.mjs";import{o as Oe}from"./token-store-Bmb3_0hU.mjs";import{c as ke}from"./colors-r_owlCuY.mjs";import{t as Ae}from"./is-object-BGze3w87.mjs";import{l as je,u as Me}from"./registry-probes-DJzPV21f.mjs";import{n as Ne}from"./constants-CQAf3dMS.mjs";import"./loader-BNFA7yiJ.mjs";import"./preview-CIZOpyLN.mjs";import{basename as R,dirname as z,isAbsolute as Pe,join as B,relative as Fe,resolve as V,sep as H,win32 as Ie}from"node:path";import{closeSync as Le,cpSync as Re,createWriteStream as ze,existsSync as U,lstatSync as Be,mkdirSync as W,mkdtempSync as Ve,openSync as He,readFileSync as G,readSync as Ue,readdirSync as K,readlinkSync as We,realpathSync as Ge,rmSync as Ke,rmdirSync as qe,statSync as Je,writeFileSync as q}from"node:fs";import{arch as Ye,freemem as Xe,homedir as J,hostname as Ze,platform as Qe,release as $e,tmpdir as et,totalmem as tt,type as nt,uptime as rt}from"node:os";import{readFile as it,readdir as at,stat as ot}from"node:fs/promises";import{createHash as st}from"node:crypto";import{execFile as ct,execSync as lt,spawnSync as ut}from"node:child_process";function dt(e,t){let n=t.map(e=>[E(e),e]);for(let t of e){let e=E(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=be){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??l().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,`${l().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=He(e,`r`);try{let e=Buffer.alloc(Tt),n=0,r=!1;for(;n<Tt;){let i=Ue(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{Le(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=Je(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=n.map(e=>a(t[e]));function Vt(e={}){return(t,n)=>new Promise(r=>{try{ct(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
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
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 at(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 ot(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 it(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 at(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 ot(r)).mtimeMs>Rt)continue;for(let e of(await it(r,`utf8`)).split(`
|
|
4
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(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{O as e}from"./constants-ok-dir-DZ25OS9-.mjs";import{C as t,I as n,Q as r,Z as i,hl as a,i as o,pd as s}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Ei as c,Ms as l,Vi as u,js as d,k as f,xi as p,ys as m}from"./dist-Bi-hqCKx.mjs";import{n as h}from"./fs-find-project-root-BYV07wjn.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-
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){m(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=P(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&m(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return m(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await C({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=b(y[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??re();if(n===`absent`){let t=F(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new v(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!a.test(e))throw new v(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new 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 Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(t){super(`This directory isn't set up yet. Run \`${e()} init\` first, then \`${e()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=t}},X=class extends Error{projectDir;constructor(t){super(`--project-dir must be a throwaway ${f}* directory under the OS temp dir. Refusing to write ephemeral session state into ${t}. Omit --project-dir to let ${e()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=t}};function Z(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${f}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:d,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-8R56vWE-.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?d(w):void 0,O=w?l(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Z(k))throw new X(k);o(f(k,`.ok`,`config.yml`))||y(k,E)}else k=m(E),A=!0}let M=async()=>{if(!(!A||k===void 0)){if(!Z(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!h(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-CL1PEAAh.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-DWsa6YOP.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(s(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(k??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:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:O,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>N(e,t),probePiAcpBridge:e=>D(e),ensurePiAcpBridge:(e,t)=>ee(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:I(e),execute:Te(e),userSkillPresentAnywhere:j}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(P===void 0?n:Le(n,P),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await M(),e}let z=R.destroy,B=A?async(...e)=>{try{await z(...e)}finally{await M()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function ze(e,t,n=()=>d({absPath:l(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new v(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(e,a){let s=ze(e,a.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=i(process.env)}catch(e){throw e instanceof o&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=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]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=a.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
1
|
+
import{O as e}from"./constants-ok-dir-DZ25OS9-.mjs";import{C as t,I as n,Q as r,Z as i,hl as a,i as o,pd as s}from"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import{Ei as c,Ms as l,Vi as u,js as d,k as f,xi as p,ys as m}from"./dist-Bi-hqCKx.mjs";import{n as h}from"./fs-find-project-root-BYV07wjn.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-O1DiQtaI.mjs";import{i as T}from"./token-store-Bmb3_0hU.mjs";import{a as E,c as D,d as O,g as k,h as A,i as j,m as M,n as N,o as P,r as F,s as ee,t as I}from"./registry-probes-DJzPV21f.mjs";import{n as te}from"./constants-CQAf3dMS.mjs";import{basename as L,dirname as R,resolve as z}from"node:path";import{existsSync as B,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{execFileSync as oe,spawn as se}from"node:child_process";import{setTimeout as ce}from"node:timers/promises";const le=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],ue={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function V(e,t={}){let{login:n}=t,r=t._exec??oe,i=H(t._fileExists??B),a=e?[`--hostname`,e]:[];if(n){let e=U(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=U(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function H(e){return[`gh`,...le.filter(e)]}function U(e,t,n){for(let r of t)try{let t=e(r,n,ue).toString().trim();if(t.length>0)return t}catch{}}function de(e,t={}){let n=t._exec??oe,r=H(t._fileExists??B),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=U(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=U(n,r,i);if(o!==void 0){let e=_e(o);if(e.length>0)return e}}function W(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function fe(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=W(W(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=W(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const pe=/Logged in to \S+ account (\S+) \(/,me=/(?:Failed to log in to|Timeout trying to log in to) \S+/,he=/^\s*-\s*Active account:\s*true\s*$/,ge=/\u001b\[[0-9;]*m/g;function _e(e){let t=[],n;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){m(`agent-integrations-apply`).warn({editor:e,path:t,reason:n},`skill write failed`)}function J(){return{action:`skipped-unsupported`,errorId:`no-writer`}}function ye(e){switch(e){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`left-foreign`:return{action:`skipped-foreign`,errorId:`foreign-artifact`};case`declined`:return{action:`declined`,errorId:`write-declined`}}}function be(e,t,n,r,i){let a=y[e];try{let o=P(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&m(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return m(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(y[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await C({editors:[e],home:t.home,replaceEntry:!0})).find(t=>t.editorId===e);if(r===void 0)return G();switch(r.action){case`written`:case`overwritten`:return{action:r.action};case`declined`:return{action:`declined`,errorId:`write-declined`};case`skipped-missing`:return K();case`skipped-flag`:return J();default:return G()}}function Se(e,t,n){let r=y[e].projectConfigPath?.(t.cwd);if(r===void 0)return K();if(n===`absent`)return be(e,t.cwd,t.home,r,t.env);let i=b(y[e],t.cwd,ve,void 0,r);switch(i.action){case`written`:case`overwritten`:return{action:i.action};case`declined`:return{action:`declined`,errorId:`write-declined`};default:return G()}}function Ce(e,t,n){let r=t.home??re();if(n===`absent`){let t=F(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=E(e,r);switch(i.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`failed`:return q(e,i.path,i.error),G()}}function we(e,t,n){if(n===`absent`){let n=_(y[e],t.cwd);switch(n.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,n.path,n.error),G()}}let r=w(y[e],t.cwd);switch(r.action){case`written`:return{action:`written`};case`overwritten`:return{action:`overwritten`};case`skipped-unsupported`:return K();case`skipped-prerequisite`:return{action:`skipped-prerequisite`,errorId:`dependency-failed`};case`failed`:return q(e,r.path,r.error),G()}}function Te(e){return t=>{if(t.pathId===void 0)return J();let n=s(t.pathId);if(n===null||n.kind===`central-skill-store`)return J();switch(n.kind){case`editor-user-config`:return xe(n.editor,e,t.desired);case`editor-project-config`:return Se(n.editor,e,t.desired);case`editor-project-skill-root`:return we(n.editor,e,t.desired);case`editor-user-skill-root`:return Ce(n.editor,e,t.desired)}}}function Ee(e,t){return e.bind?.[0]??t.HOST??`127.0.0.1`}function De(e){if(e===`server`)return e;throw new v(`--only must be 'server'`)}function Oe(e=B,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[z(t,`public`),z(t,`../../app/dist`),z(t,`../../../app/dist`)];return e(z(t,`../../app.asar`))&&n.push(z(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!a.test(e))throw new v(`--idle-shutdown must be 'off' or a duration like 90s, 30m, 2h`);return e}function je(e){return e===`localhost`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}function Me(e){return!e.flagBindSet&&!e.okBindSet&&e.hostEnvSet&&e.fileBindCount>1}function Ne(e){return!e.openBrowser||e.ephemeral||e.only===`server`||!e.servesUi?!1:(e.explicitOn||je(e.host))&&e.isTTY}function Pe(e,t){let n;try{n=new URL(t)}catch{throw new 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 Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=L(e).replace(/[^\x20-\x7E]/g,``).trim().slice(0,64);return`open-knowledge-server ${t.length>0?t:`unknown`}`}var Y=class extends Error{cwd;constructor(t){super(`This directory isn't set up yet. Run \`${e()} init\` first, then \`${e()} start\` again.`),this.name=`OkDirMissingError`,this.cwd=t}},X=class extends Error{projectDir;constructor(t){super(`--project-dir must be a throwaway ${f}* directory under the OS temp dir. Refusing to write ephemeral session state into ${t}. Omit --project-dir to let ${e()} start create (and clean up) its own.`),this.name=`EphemeralProjectDirNotThrowawayError`,this.projectDir=t}};function Z(e,t={}){let n=t.tmpdirFn??ie,r=t.realpathFn??ne,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?z(e):null}},a=z(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(R(a));o=e===null?null:z(e,L(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&R(o)===s&&L(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>ae(e,{recursive:!0,force:!0})){return async()=>{try{await e()}finally{if(Z(t))try{await n(t)}catch(e){process.stderr.write(`[start] ephemeral temp dir reap failed for ${t}: ${e instanceof Error?e.message:String(e)}\n`)}else process.stderr.write(`[start] leaving ${t} in place: only ${f}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:d,resolve:f}=await import(`node:path`),{bootServer:p,createEphemeralProjectDir:m,getLogger:g,resolveContentDir:_,resolveLockDir:v,seedEphemeralProjectDir:y,waitForServerLockDrain:b}=await import(`./dist-8R56vWE-.mjs`),S=e.log??g(`start`),C=e.singleFile!==void 0,w=C?u(e.singleFile).canonicalFilePath:void 0,E=w?d(w):void 0,O=w?l(w):void 0,k,A=!1;if(E!==void 0){if(e.projectDir!==void 0){if(k=e.projectDir,!Z(k))throw new X(k);o(f(k,`.ok`,`config.yml`))||y(k,E)}else k=m(E),A=!0}let M=async()=>{if(!(!A||k===void 0)){if(!Z(k)){S.warn({ephemeralProjectDir:k},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await ae(k,{recursive:!0,force:!0})}catch(e){S.warn({err:e,ephemeralProjectDir:k},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},P=k;if(!C){if(!i&&!h(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?S.debug({event:e},`[start] reclaim sweep event`):S.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-UL3O5C7j.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-D6VmmqTF.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){S.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let F=E??_(t,n);!C&&!o(F)&&(s(F,{recursive:!0}),S.info({contentDir:F},`Created content directory`));let te=T(),L=c(),R;try{{let e=v(k??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:F,projectDir:k??n,contentRoot:C?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:V,detectGhAccounts:de,tokenStore:te,embeddingsKeyStore:L,mcpTomlEditor:x(),...C?{ephemeral:!0,singleDocRelPath:O,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>N(e,t),probePiAcpBridge:e=>D(e),ensurePiAcpBridge:(e,t)=>ee(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:k??n,home:re(),env:process.env};return{probe:I(e),execute:Te(e),userSkillPresentAnywhere:j}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(P===void 0?n:Le(n,P),{log:S,exit:e.idleExit})},log:S,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await M(),e}let z=R.destroy,B=A?async(...e)=>{try{await z(...e)}finally{await M()}}:z;return{httpServer:R.httpServer,destroy:B,lockDir:R.lockDir,contentDir:F,port:R.port,ready:R.ready,degraded:R.degraded}}function ze(e,t,n=()=>d({absPath:l(`user`,process.cwd()),sideline:!1,warn:()=>{}}).value){return t===void 0?e:n()}function Be(e){if(e===`browser`||e===`app`)return e;throw new v(`--mode must be 'browser' or 'app'`)}function Ve(e){return e.OK_CONSOLE_LEVEL!==void 0||e.LOG_LEVEL!==void 0?null:`warn`}function He(e){let t=[`Stopping OpenKnowledge…`,`Saving pending changes and releasing the server lock — this can take a few seconds.`];return e===`SIGINT`&&t.push(`Press Ctrl+C again to force quit.`),t}async function Ue(e,a){let s=ze(e,a.singleFile),c=Ve(process.env);c!==null&&(process.env.OK_CONSOLE_LEVEL=c);let{renderBanner:l}=await import(`./banner-kywHhVaC.mjs`),{accent:u,dim:d,error:f,warning:p}=await import(`./colors-SgU3JHQu.mjs`),m=process.cwd();process.title=Ie(m);let h;try{h=i(process.env)}catch(e){throw e instanceof o&&(console.error(f(e.message)),process.exit(78)),e}for(let e of h.diagnostics)console.warn(p(`[config] ${e.message}`));let g=t(s,h.layer),_=h.overrides.some(e=>e.envVar===`OK_BIND`),v=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]);Me({flagBindSet:v!==void 0,okBindSet:_,hostEnvSet:b!==void 0,fileBindCount:x.bind.length})&&console.warn(p(`[config] HOST=${b} overrides server.bind — dropping the file-configured addresses (${x.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let C=S[0]??`127.0.0.1`,w=S,T=a.externalUrl,E=r(t(g,{server:{bind:w,...T===void 0?{}:{externalUrl:T}}}));if(E.allowExternal&&(!E.loopbackOnly||E.externalUrl)){let e=E.externalUrl??E.bind.join(`, `);console.warn(p([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
3
|
`)))}let D=a.port===void 0?void 0:Number(a.port),O=h.overrides.find(e=>e.envVar===`PORT`)?.value,k=D??O??s.server?.port,A=ke({explicitDir:a.reactShellDistDir,only:a.only,findBundledDir:Oe}),j=A.dir;A.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let M;try{M=await Q({config:s,cwd:m,host:C,port:k,bind:w,...a.serveContentAssets===void 0?{}:{serveContentAssets:a.serveContentAssets},...j?{reactShellDistDir:j}:{},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 Y&&(console.error(f(e.message)),process.exit(1)),e instanceof X&&(console.error(f(e.message)),process.exit(1));let t=await import(`./dist-8R56vWE-.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)),Ke(e,t,m)){let e=t.resolveLockDir(m),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>ce(e),timeoutMs:3e3,pollIntervalMs:50})}catch(e){process.stderr.write(`[start] spawn-or-reuse: lock poll failed (${e instanceof Error?e.message:String(e)}) — falling back to the collision message\n`)}if(n!==null){let[e,...t]=Ge(n);console.log(u(e));for(let e of t)console.log(d(e));process.exit(0)}}let n=$(e,m,t);n!==null&&(console.error(f(n)),process.exit(1)),console.error(`${f(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let N=!1,P=async e=>{if(N)return;N=!0;let[t,...n]=He(e);console.log(u(`\n${t}`));for(let e of n)console.log(d(` ${e}`));try{await M.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`,()=>{P(`SIGINT`)}),process.once(`SIGTERM`,()=>{P(`SIGTERM`)});let F=`http://${C.includes(`:`)&&!C.startsWith(`[`)?`[${C}]`:C}:${M.port}`,ee=C===`0.0.0.0`||C===`::`?`http://0.0.0.0:${M.port}`:void 0,I=F;console.log(l({name:`open-knowledge`,version:te,localUrl:I,networkUrl:ee,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`};M.ready.then(async()=>{if(M.degraded.length>0){console.log();for(let e of M.degraded){let t=L[e]??`${e} (check server logs for details)`;console.warn(` ${p(`⚠`)} ${p(e)}: ${d(t)}`)}console.log()}if(Ne({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:j!==void 0})){let{openBrowser:e}=await import(`./open-browser-zFYM6iXO.mjs`);e(I)}}).catch(e=>{console.error(` ${f(`Server initialization failed:`)} ${e instanceof Error?e.message:String(e)}`)})}async function We(e){let t=e.now()+e.timeoutMs,n=e.readServerLock();for(;n!==null&&n.draining!==!0&&n.port<=0&&e.now()<t;)await e.sleep(e.pollIntervalMs),n=e.readServerLock();return n===null||n.draining===!0||n.port<=0?null:p(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function Ge(t){return[`${t.kind===`mcp-spawned`?`An MCP-spawned OpenKnowledge server is already running on this project`:`OpenKnowledge is already running on this project`} (pid ${t.pid}).`,` ${t.url}`,`Leaving it running — run \`${e()} stop\` first if you want a fresh server.`]}function Ke(e,t,n){let r=t.ServerLockCollisionError;if(r!==void 0&&e instanceof r)return!0;let i=t.ServerAuthorityCollisionError;if(i===void 0||!(e instanceof i))return!1;try{return e.existing.scope.kind===`tree`&&ne.native(n)===e.existing.projectDir}catch{return!1}}function $(t,n,r){let i=r.ServerAuthorityCollisionError;if(i!==void 0&&t instanceof i)return t.message;let a=r.ServerAuthorityRegistryError;if(a!==void 0&&t instanceof a)return t.message;let o=r.ProcessLockFileError;if(o!==void 0&&t instanceof o)return t.message;let s=r.ServerLockCollisionError;if(s===void 0||!(t instanceof s))return null;try{let t=r.readServerLock(r.resolveLockDir(n)),i=e();return t?.kind===`mcp-spawned`?`An MCP-spawned server holds this lock; it should release on idle-shutdown (~30 min). Or run \`${i} stop\`.`:`OpenKnowledge server is already running on this project — check \`${i} status\` or \`${i} stop\`.`}catch{return null}}function qe(e){return new 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)`,De).option(`--idle-shutdown <duration>`,`Shut the server down after this long with no connected clients ('off', or a duration like 90s, 30m, 2h; default 30m)`,Ae).option(`--mode <mode>`,`Force dispatch mode: 'browser' or 'app'`,Be).option(`--serve-content-assets`,`Serve content assets from this server (now the default; kept for compatibility)`).option(`--react-shell-dist-dir <path>`,`Serve React shell from <path>`).addOption(new 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).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=M(O());if(n.available){A({spawn:se},n);return}console.error(k(n.reason)),process.exit(1)}await Ue(n,t)})}export{$ as C,de as D,V as E,qe as S,Re as T,Ve as _,Ge as a,Ne as b,Z as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,Y as n,He as o,Oe as p,Q as r,je as s,X as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-DiS4vLnG.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.89.
|
|
3
|
+
"version": "0.89.1-beta.0",
|
|
4
4
|
"description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knowledge-base",
|
|
@@ -65,17 +65,17 @@
|
|
|
65
65
|
"@parcel/watcher": "^2.5.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@inkeep/open-knowledge-app": "0.89.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.89.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.89.1-beta.0",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.89.1-beta.0",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.89.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.89.1-beta.0",
|
|
72
72
|
"@types/node": "^24.7.0",
|
|
73
73
|
"@types/proper-lockfile": "^4.1.4",
|
|
74
74
|
"@types/yazl": "^3.3.1",
|
|
75
75
|
"ajv": "^8.18.0",
|
|
76
76
|
"ajv-formats": "^3.0.1",
|
|
77
77
|
"tsdown": "^0.22.14",
|
|
78
|
-
"tsrs": "0.
|
|
78
|
+
"tsrs": "0.20.0-ts7.1.0-beta",
|
|
79
79
|
"typescript": "~7.0.2"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BW5Abi4P.mjs";var e=`0.89.0-beta.4`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/init-1hhORWA2.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-Bi-hqCKx.mjs";import{v as e}from"./init-BtSdPRZj.mjs";export{e as runInit};
|
package/dist/loader-D6cwZbpL.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-vYvM0FyZ.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CwkR6mf7.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-xUea82Vb.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-BqfFU0ei.js";export{e as ManagedArtifactProperties};
|
package/dist/src-RhIwS_cj.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BW5Abi4P.mjs";import"./src-DP_cRFds.mjs";import"./init-BtSdPRZj.mjs";import"./token-store-Bmb3_0hU.mjs";import"./start-BpbIXDCc.mjs";import"./registry-probes-IgODudvT.mjs";import{n as e}from"./loader-vYvM0FyZ.mjs";import"./preview-CwkR6mf7.mjs";import"./repair-mcp-configs-CL1PEAAh.mjs";export{e as loadConfig};
|
package/dist/start-Soa4VO1R.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-BpbIXDCc.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|