@inkeep/open-knowledge 0.88.9-beta.2 → 0.88.9-beta.4
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-78ggxS9d.mjs → cli-CApr5vJh.mjs} +6 -6
- package/dist/cli.mjs +1 -1
- package/dist/constants-Ca_9Ar85.mjs +1 -0
- package/dist/{dist-CjMvnZHW.mjs → dist-C5NH8F7J.mjs} +502 -502
- package/dist/{dist-B9j8kAKZ.mjs → dist-eiP2xn_A.mjs} +1 -1
- package/dist/index.mjs +167 -167
- package/dist/init-D8_giXgq.mjs +1 -0
- package/dist/{init-tZZEMY57.mjs → init-_MYjUgbc.mjs} +2 -2
- package/dist/{launch-json-removal-CkdStqp0.mjs → launch-json-removal-Dmz2x-7W.mjs} +1 -1
- package/dist/loader-CIxtIlMB.mjs +1 -0
- package/dist/{loader-CLzWCnTU.mjs → loader-D0z63VhQ.mjs} +1 -1
- package/dist/{md-manager-BGnqyqi1-DnGz4mVK.mjs → md-manager-BGnqyqi1-B5Gyjk_N.mjs} +149 -149
- package/dist/{open-browser-XevLmN33.mjs → open-browser-Bdh6sD0e.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-d9Xj2oz-.mjs → preview-DlbLi7gD.mjs} +1 -1
- package/dist/preview-h0nWv2-p.mjs +1 -0
- package/dist/public/assets/{AccountSection-bHRNk_V5.js → AccountSection-WnZI9Y4X.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-CIBAyqCQ.js → ActivityModeContent-BW34hghR.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-DS9uZkTx.js → AddPropertiesButton-Yxk08VnZ.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-C5u3b_w4.js → AgentDiffPane-BtR2fIQk.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-Cwylv9cJ.js → AttachmentsSection-DheSSdwi.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-D7GY-vsi.js → CodeMirrorPropInput-CTxnGgD1.js} +69 -69
- package/dist/public/assets/{ContentRulesSection-B-WyS9la.js → ContentRulesSection-m1yJ_5W5.js} +1 -1
- package/dist/public/assets/DocumentContext-tPl3222n.js +110 -0
- package/dist/public/assets/EditorModeToggle-CgAxXc9n.js +1 -0
- package/dist/public/assets/{ExcalidrawDocEditor-B5uqWx0E.js → ExcalidrawDocEditor-BDPLX-a4.js} +1 -1
- package/dist/public/assets/FeedbackForm-DqkKWe5H.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-zw_ii5QI.js → ImportSkillDialog-DeVO4S8O.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-CVctoQ7Q.js → LinkPreviewsSection-bEPxLhlm.js} +1 -1
- package/dist/public/assets/LintConfigEditor-D65vodB4.js +1 -0
- package/dist/public/assets/LintingSection-BOCmIlCP.js +1 -0
- package/dist/public/assets/ManagedArtifactProperties-13jOCHuP.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-C9jhSWMF.js → ManagedArtifactProperties-BHfiDMNo.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-5jiPIdAL.js → MermaidDocEditor-DLd-f9Xs.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-B9sx911F.js → NetworkAccessSection-BAjeEdGd.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-2eko2YVG.js → PropertyDisplayRow-B2Ye_A12.js} +1 -1
- package/dist/public/assets/PublishToGitHubDialog-Bx6_BCDO.js +1 -0
- package/dist/public/assets/{SchemaConfigEditor-DFLRZpKw.js → SchemaConfigEditor-DV1Y294T.js} +1 -1
- package/dist/public/assets/{SearchSection-B5ODJxFu.js → SearchSection-oHyCW1cw.js} +1 -1
- package/dist/public/assets/{SessionsHost-tfaJ-irn.js → SessionsHost-Cr8QROmn.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-XoqrDmag.js → SettingsDialogBody-SDayK0GJ.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-Dkl4VORm.js → ShareReceiveMissDialog-Dz2l51c8.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-CMbrDecI.js → SkillToolbarControls-11TOzdmT.js} +1 -1
- package/dist/public/assets/{SourceEditor-h5yPfEoM.js → SourceEditor-D8LleSVP.js} +1 -1
- package/dist/public/assets/{SpellingSettings-D184toob.js → SpellingSettings-BnekUXi0.js} +1 -1
- package/dist/public/assets/{SyncSection-IgN0JEiL.js → SyncSection-D9HwTuQH.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-BNYfSyo3.js → SyncStatusBadge-DlXMIfnP.js} +1 -1
- package/dist/public/assets/{TerminalSection-Bq9pWdqB.js → TerminalSection-B-1W5J1j.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-C9qqlU_B.js → TerminalWindowApp-CHt3oCGP.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DnOJUyur.js → TextDocEditor-DTtAO6MS.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-BJho-OPX.js → ThemePluginSection-htJshVsF.js} +1 -1
- package/dist/public/assets/{ThreadView-CyuW42aX.js → ThreadView-DjPpy_DW.js} +7 -7
- package/dist/public/assets/{TimelineDiffPane-Yt6mGPXb.js → TimelineDiffPane-Cu-wZdGq.js} +1 -1
- package/dist/public/assets/{client-version-DJxwS4jI.js → client-version-CsPDy_mS.js} +1 -1
- package/dist/public/assets/{comment-chips-BDz0jvV-.js → comment-chips-0VDCgiLf.js} +2 -2
- package/dist/public/assets/{config-provider-BdqYLWTk.js → config-provider-PZhtKwZ4.js} +1 -1
- package/dist/public/assets/config-schema-BFeDYLCd.js +1 -0
- package/dist/public/assets/{doc-undo-manager-BS8LDmSB.js → doc-undo-manager-Cjle_cou.js} +1 -1
- package/dist/public/assets/field-controls-lq4qcuvr.js +1 -0
- package/dist/public/assets/{field-controls-BE-gXCyP.js → field-controls-uK27_e3u.js} +1 -1
- package/dist/public/assets/ime-composition-CjypcBXs.js +1 -0
- package/dist/public/assets/index-BtXMY-lm.js +2209 -0
- package/dist/public/assets/{lint-config-client-Bpn28Gqc.js → lint-config-client-D7WzQSDg.js} +1 -1
- package/dist/public/assets/{lint-plugins-Df0iB6ZL.js → lint-plugins-BgXd5eb3.js} +1 -1
- package/dist/public/assets/{markdown-lint-DyGTskus.js → markdown-lint-DwFRnZJ_.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-CiuM3Wwm.js → markdownlint-rule-browser-DBy2EH_P.js} +1 -1
- package/dist/public/assets/messages-B-J4Z2Yr.js +1 -0
- package/dist/public/assets/messages-BB8d9jn4.js +1 -0
- package/dist/public/assets/messages-BY7FXc1p.js +1 -0
- package/dist/public/assets/messages-BiYVPcog.js +1 -0
- package/dist/public/assets/messages-C7Sj-spy.js +1 -0
- package/dist/public/assets/messages-CBV_8Tbx.js +1 -0
- package/dist/public/assets/messages-CIQENxYJ.js +1 -0
- package/dist/public/assets/{messages-BG06D2oG.js → messages-CLhrlR3j.js} +1 -1
- package/dist/public/assets/messages-CYZHw0xR.js +1 -0
- package/dist/public/assets/messages-CjUTocV-.js +1 -0
- package/dist/public/assets/messages-DVWfLKLP.js +1 -0
- package/dist/public/assets/messages-DlnDJqXj.js +1 -0
- package/dist/public/assets/messages-GTtZSPU8.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-PoNyEtCJ.js → pending-receive-nav-store-yu2l0rmr.js} +1 -1
- package/dist/public/assets/{preferred-session-events-DRwedC4l.js → preferred-session-events-AxKg0Sw4.js} +1 -1
- package/dist/public/assets/{progress-CIBZtkMN.js → progress-COboqCdt.js} +3 -3
- package/dist/public/assets/{saved-themes-client-BV81hPag.js → saved-themes-client-DX5dCXi5.js} +1 -1
- package/dist/public/assets/{schema-section-DIb5umEe.js → schema-section-Cp00yQR2.js} +1 -1
- package/dist/public/assets/{selection-context-BKZrCaCI.js → selection-context-CqPsJN1K.js} +1 -1
- package/dist/public/assets/{src-jt9_T0XO.js → src-bjWQtRl1.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DfZfc6Af.js → tag-pill-input-B6OegoPJ.js} +1 -1
- package/dist/public/assets/{telemetry-impl-DvVUQZKW.js → telemetry-impl-CnTOH7Vq.js} +1 -1
- package/dist/public/assets/{telemetry-startup-CnaVjI19.js → telemetry-startup-DEDQn7NX.js} +1 -1
- package/dist/public/assets/typing-burst-detector-CKGqqUho.js +6 -0
- package/dist/public/assets/{uninstall-DHlBU1US.js → uninstall-BRba0hi_.js} +1 -1
- package/dist/public/assets/{use-activity-panel-B2645ugD.js → use-activity-panel-CjQtwblB.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-N3OMaFbH.js → use-apply-config-language-9fLQZCsK.js} +2 -2
- package/dist/public/assets/{use-open-skill-BuK_lWsT.js → use-open-skill-wBK1EQdE.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BXPeoDBJ.js → use-terminal-enabled-ZJDRhsBW.js} +1 -1
- package/dist/public/assets/use-timeline-entry-diff-CliAvkzA.js +7 -0
- package/dist/public/index.html +26 -26
- package/dist/public/uninstall.html +3 -3
- package/dist/{registry-probes-Bh1Qy3qZ.mjs → registry-probes-D0Wp5e7Z.mjs} +1 -1
- package/dist/{removal-file-path-cvkiBibT.mjs → removal-file-path-yLPrekRN.mjs} +1 -1
- package/dist/{repair-launch-json-DyuTwfkz.mjs → repair-launch-json-EuA85m8g.mjs} +1 -1
- package/dist/{repair-mcp-configs-DbiwUJCR.mjs → repair-mcp-configs-C7yBPBvC.mjs} +1 -1
- package/dist/src-BA_wxupY.mjs +1 -0
- package/dist/{src-DA0Ksa-7.mjs → src-xBlfQBhu.mjs} +1 -1
- package/dist/start-C1as3B3R.mjs +1 -0
- package/dist/{start-DEwAokRH.mjs → start-PPqSRW1B.mjs} +3 -3
- package/package.json +4 -4
- package/dist/constants-CLQ8X-E2.mjs +0 -1
- package/dist/init-Djx6uVIJ.mjs +0 -1
- package/dist/loader-CPoDR3tl.mjs +0 -1
- package/dist/preview-Cbc7dZii.mjs +0 -1
- package/dist/public/assets/DocumentContext-DXqn96Dj.js +0 -108
- package/dist/public/assets/EditorModeToggle-DBLccwaz.js +0 -1
- package/dist/public/assets/FeedbackForm-BFfpAR60.js +0 -1
- package/dist/public/assets/LintConfigEditor-CCyO7123.js +0 -1
- package/dist/public/assets/LintingSection-CkSQo-gu.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DffV_RLk.js +0 -1
- package/dist/public/assets/PublishToGitHubDialog-MRhU3m1O.js +0 -1
- package/dist/public/assets/config-schema-PFswUEY8.js +0 -1
- package/dist/public/assets/field-controls-CYM5AE4q.js +0 -1
- package/dist/public/assets/ime-composition-Dqv-F42e.js +0 -1
- package/dist/public/assets/index-DDdInvcw.js +0 -2209
- package/dist/public/assets/messages-AhR6hFhG.js +0 -1
- package/dist/public/assets/messages-BWf_mE1f.js +0 -1
- package/dist/public/assets/messages-CC_nyZaD.js +0 -1
- package/dist/public/assets/messages-CCpyckwF.js +0 -1
- package/dist/public/assets/messages-Caz0X-QI.js +0 -1
- package/dist/public/assets/messages-Cl664i6S.js +0 -1
- package/dist/public/assets/messages-DF-5evdp.js +0 -1
- package/dist/public/assets/messages-I4dOt3Id.js +0 -1
- package/dist/public/assets/messages-asQSLar1.js +0 -1
- package/dist/public/assets/messages-gyTavuOO.js +0 -1
- package/dist/public/assets/messages-uNPe6akt.js +0 -1
- package/dist/public/assets/messages-v-wOP1Ps.js +0 -1
- package/dist/public/assets/typing-burst-detector-CQd0s--X.js +0 -8
- package/dist/public/assets/use-timeline-entry-diff-PstJ8awU.js +0 -7
- package/dist/src-Cii4d3mM.mjs +0 -1
- package/dist/start-CkI_wBlE.mjs +0 -1
|
@@ -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{Ya as d,af as f,bd as p,cf as m,of as h,rf as g}from"./md-manager-BGnqyqi1-DnGz4mVK.mjs";import{Ms as _,Ns as v,Oa as y,Vo as ee,m as b,ns as te,tr as x}from"./dist-CjMvnZHW.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-tZZEMY57.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-cvkiBibT.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{isDeepStrictEqual as Fe}from"node:util";import{setTimeout as Ie}from"node:timers/promises";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 ee({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(!Fe(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(!Fe(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{Ya as d,af as f,bd as p,cf as m,of as h,rf as g}from"./md-manager-BGnqyqi1-B5Gyjk_N.mjs";import{Ms as _,Ns as v,Oa as y,Vo as ee,m as b,ns as te,tr as x}from"./dist-C5NH8F7J.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-_MYjUgbc.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-yLPrekRN.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{isDeepStrictEqual as Fe}from"node:util";import{setTimeout as Ie}from"node:timers/promises";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 ee({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(!Fe(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(!Fe(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 _(`${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 Ie(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){v(`${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-_MYjUgbc.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-Dmz2x-7W.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,severity:`info`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=(n.removeOwnLaunchEntryFn??e)(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,severity:`warn`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`;return s&&i({event:`launch-json-repair-removed`,severity:`info`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./md-manager-BGnqyqi1-
|
|
1
|
+
import{E as e}from"./md-manager-BGnqyqi1-B5Gyjk_N.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-_MYjUgbc.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-B5Gyjk_N.mjs";import"./src-xBlfQBhu.mjs";import"./init-_MYjUgbc.mjs";import"./token-store-Bmb3_0hU.mjs";import"./start-PPqSRW1B.mjs";import"./registry-probes-D0Wp5e7Z.mjs";import{n as e}from"./loader-D0z63VhQ.mjs";import"./preview-DlbLi7gD.mjs";import"./repair-mcp-configs-C7yBPBvC.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,Gl as p,Kl as m,Oa as h,Qc as g,U as _,W as v,Yc as y,el as b,l as x,mf as S,nl as ee,tl as te,u as ne}from"./md-manager-BGnqyqi1-
|
|
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,Gl as p,Kl as m,Oa as h,Qc as g,U as _,W as v,Yc as y,el as b,l as x,mf as S,nl as ee,tl as te,u as ne}from"./md-manager-BGnqyqi1-B5Gyjk_N.mjs";import{$r as C,As as w,Cs as T,Es as re,Hi as ie,Ia as E,Is as D,Nt as O,Os as ae,Qt as oe,Si as k,Ss as se,Vo as A,Wi as j,_a as M,bi as N,ci as P,fr as ce,js as F,ks as le,m as ue,ma as de,mi as fe,nr as I,ta as pe,wi as me,ws as he,xi as ge,xo as _e,xs as ve}from"./dist-C5NH8F7J.mjs";import{t as ye}from"./yazl-BBz29IQN.mjs";import{t as be,y as xe}from"./fs-find-project-root-BYV07wjn.mjs";import{ct as Se,gt as Ce,ht as we,mt as Te,pt as Ee,st as De,wt as Oe}from"./init-_MYjUgbc.mjs";import{o as ke}from"./token-store-Bmb3_0hU.mjs";import{c as Ae}from"./colors-r_owlCuY.mjs";import{t as je}from"./is-object-BGze3w87.mjs";import{l as Me,u as Ne}from"./registry-probes-D0Wp5e7Z.mjs";import{n as Pe}from"./constants-Ca_9Ar85.mjs";import"./loader-D0z63VhQ.mjs";import"./preview-DlbLi7gD.mjs";import{basename as L,dirname as R,isAbsolute as Fe,join as z,relative as Ie,resolve as B,sep as V,win32 as Le}from"node:path";import{closeSync as Re,cpSync as ze,createWriteStream as Be,existsSync as H,lstatSync as Ve,mkdirSync as U,mkdtempSync as He,openSync as Ue,readFileSync as W,readSync as We,readdirSync as G,readlinkSync as Ge,realpathSync as Ke,rmSync as qe,rmdirSync as Je,statSync as Ye,writeFileSync as K}from"node:fs";import{arch as Xe,freemem as Ze,homedir as q,hostname as Qe,platform as $e,release as et,tmpdir as tt,totalmem as nt,type as rt,uptime as it}from"node:os";import{readFile as at,readdir as ot,stat as st}from"node:fs/promises";import{createHash as ct}from"node:crypto";import{execFile as lt,execSync as ut,spawnSync as dt}from"node:child_process";function ft(e,t){let n=t.map(e=>[D(e),e]);for(let t of e){let e=D(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function pt(e){let{override:t,storedPreference:n,preferenceList:r,supportedLocales:i}=e,a=e.autoDetectableLocales??i;if(t!==void 0){let e=ft([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=ft(r,a);return o===void 0?{locale:`en`,source:`fallback`}:{locale:o,source:`system`}}function mt(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 ht=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`audit`,`deinit`,`auth`]);function gt(e,t,n=be){if(e!==void 0&&!ht.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let _t=null;function vt(e){_t=e}function yt(){return _t??process.cwd()}const bt=`Open Knowledge`;function xt(e={}){let t=e.platformName??process.platform,n=e.productName??l().productName;return De(t).join(Se({...e,platformName:t}),n)}function St(e={}){let t=e.platformName??process.platform,n=e.home??q(),r=e.env??process.env,i=De(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 Ct(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 wt(e){let t=z(e,`state.json`);if(!H(t))return[];let n;try{n=JSON.parse(W(t,`utf-8`))}catch{return[]}return Ct(n)??[]}function Tt(e){let t=z(e,`state.json`);if(!H(t))return!1;try{return Ct(JSON.parse(W(t,`utf-8`)))!==null}catch{return!1}}const Et=8192;function Dt(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 Ot(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const kt=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function At(e){return e.replace(kt,`$1"[REDACTED-DEVICE-ID]"`)}function jt(e){return At(Ot(e))}const Mt=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Nt(e){if(typeof e!=`string`)return null;let t=Mt.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 Pt(e){let t=Ue(e,`r`);try{let e=Buffer.alloc(Et),n=0,r=!1;for(;n<Et;){let i=We(t,e,n,Et-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{Re(t)}}function Ft(e){try{let t=Pt(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Nt(a)}}catch{return{kind:`unreadable`}}}function It(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function Lt(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=G(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=z(e,t.name),r;try{r=Ye(n).mtimeMs}catch{continue}if(r<i)continue;let c=Ft(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!It(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 Rt=`state/os-termination-evidence.json`,zt=6048e5,Bt=/openknowledge/i,Vt=n.map(e=>a(t[e]));function Ht(e={}){return(t,n)=>new Promise(r=>{try{lt(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...Ut(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function Ut(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 Wt(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
2
2
|
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function J(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function 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`||!It(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=Nt(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`?It(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=J(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await ot(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 st(z(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-zt,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 at(z(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 ot(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!rn.test(a))continue;let r=z(e,a);try{if(t.getTime()-(await st(r)).mtimeMs>zt)continue;for(let e of(await at(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:Bt.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(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,m as t,p as n,r}from"./start-PPqSRW1B.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
@@ -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,bd as a,i as o,wl as s}from"./md-manager-BGnqyqi1-
|
|
2
|
-
`)){let e=r.replace(ge,``),i=pe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if(me.test(e)){n=void 0;continue}n&&he.test(e)&&(n.active=!0)}return t}const ve={mode:`published`,skipAvailabilityCheck:!0,replaceEntry:!0};function G(){return{action:`failed`,errorId:`write-failed`}}function K(){return{action:`skipped-missing`,errorId:`surface-missing`}}function q(e,t,n){p(`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=v[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(v[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await S({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=v[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=y(v[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??ie();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=T(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=g(v[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=C(v[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=a(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 _(`--only must be 'server'`)}function Oe(e=z,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[R(t,`public`),R(t,`../../app/dist`),R(t,`../../../app/dist`)];return e(R(t,`../../app.asar`))&&n.push(R(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!s.test(e))throw new _(`--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 _(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new _(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=I(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 ${d}* 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??ae,r=t.realpathFn??re,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?R(e):null}},a=R(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(L(a));o=e===null?null:R(e,I(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&L(o)===s&&I(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>oe(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 ${d}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:d}=await import(`node:path`),{bootServer:f,createEphemeralProjectDir:p,getLogger:h,resolveContentDir:g,resolveLockDir:_,seedEphemeralProjectDir:v,waitForServerLockDrain:y}=await import(`./dist-B9j8kAKZ.mjs`),x=e.log??h(`start`),S=e.singleFile!==void 0,C=S?c(e.singleFile).canonicalFilePath:void 0,T=C?u(C):void 0,D=C?l(C):void 0,O,k=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(d(O,`.ok`,`config.yml`))||v(O,T)}else O=p(T),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Z(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await oe(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!S){if(!i&&!m(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-DbiwUJCR.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-DyuTwfkz.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??g(t,n);!S&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let ne=w(),I=ee(),L;try{{let e=_(O??n),t=Date.now(),r=await y(e);r!==`no-drain`&&x.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`)}L=await f({config:t,contentDir:P,projectDir:O??n,contentRoot:S?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:B,detectGhAccounts:U,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:b(),...S?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>te(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ie(),env:process.env};return{probe:F(e),execute:Te(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(N===void 0?n:Le(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=k?async(...e)=>{try{await R(...e)}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>f({absPath:u(`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 _(`--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:ee}=await import(`./banner-kywHhVaC.mjs`),{accent:l,dim:u,error:d,warning:f}=await import(`./colors-SgU3JHQu.mjs`),p=process.cwd();process.title=Ie(p);let m;try{m=i(process.env)}catch(e){throw e instanceof o&&(console.error(d(e.message)),process.exit(78)),e}for(let e of m.diagnostics)console.warn(f(`[config] ${e.message}`));let h=t(s,m.layer),g=m.overrides.some(e=>e.envVar===`OK_BIND`),_=a.bind!==void 0&&a.bind.length>0?a.bind:void 0,v=process.env.HOST,y=v!==void 0&&v.trim()!==``?v:void 0,b=r(h),x=_??(g||y===void 0?[...b.bind]:[y]);Me({flagBindSet:_!==void 0,okBindSet:g,hostEnvSet:y!==void 0,fileBindCount:b.bind.length})&&console.warn(f(`[config] HOST=${y} overrides server.bind — dropping the file-configured addresses (${b.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let S=x[0]??`127.0.0.1`,C=x,w=a.externalUrl,T=r(t(h,{server:{bind:C,...w===void 0?{}:{externalUrl:w}}}));if(T.allowExternal&&(!T.loopbackOnly||T.externalUrl)){let e=T.externalUrl??T.bind.join(`, `);console.warn(f([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
-
`)))}let E=a.port===void 0?void 0:Number(a.port),D=m.overrides.find(e=>e.envVar===`PORT`)?.value,O=E??D??s.server?.port,k=ke({explicitDir:a.reactShellDistDir,only:a.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Q({config:s,cwd:p,host:S,port:O,bind:C,...a.serveContentAssets===void 0?{}:{serveContentAssets:a.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(a.idleShutdown??T.idleShutdown),serverRuntime:T,...a.singleFile?{singleFile:a.singleFile}:{},...a.projectDir?{projectDir:a.projectDir}:{},...a.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof Y&&(console.error(d(e.message)),process.exit(1)),e instanceof X&&(console.error(d(e.message)),process.exit(1));let t=await import(`./dist-
|
|
1
|
+
import{O as e}from"./constants-ok-dir-DZ25OS9-.mjs";import{C as t,I as n,Q as r,Z as i,bd as a,i as o,wl as s}from"./md-manager-BGnqyqi1-B5Gyjk_N.mjs";import{Bi as c,Ti as ee,bi as l,js as u,k as d,ks as f,vs as p}from"./dist-C5NH8F7J.mjs";import{n as m}from"./fs-find-project-root-BYV07wjn.mjs";import{Et as h,R as g,Tt as _,Z as v,b as y,dt as b,wt as x,x as S,z as C}from"./init-_MYjUgbc.mjs";import{i as w}from"./token-store-Bmb3_0hU.mjs";import{a as T,c as E,d as D,g as O,h as k,i as A,m as j,n as M,o as N,r as P,s as te,t as F}from"./registry-probes-D0Wp5e7Z.mjs";import{n as ne}from"./constants-Ca_9Ar85.mjs";import{basename as I,dirname as L,resolve as R}from"node:path";import{existsSync as z,realpathSync as re}from"node:fs";import{homedir as ie,tmpdir as ae}from"node:os";import{rm as oe}from"node:fs/promises";import{execFileSync as se,spawn as ce}from"node:child_process";import{setTimeout as le}from"node:timers/promises";const ue=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],de={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function B(e,t={}){let{login:n}=t,r=t._exec??se,i=V(t._fileExists??z),a=e?[`--hostname`,e]:[];if(n){let e=H(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=H(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function V(e){return[`gh`,...ue.filter(e)]}function H(e,t,n){for(let r of t)try{let t=e(r,n,de).toString().trim();if(t.length>0)return t}catch{}}function U(e,t={}){let n=t._exec??se,r=V(t._fileExists??z),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=H(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=fe(a,e);if(t)return t}let o=H(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){p(`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=v[e];try{let o=N(a,t,n,r,i);return o.kind===`removed`&&o.trustDetail&&p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),trust:o.trust,trustDetail:o.trustDetail},`MCP config removal retained Pi folder trust`),ye(o.kind)}catch(i){return p(`agent-integrations-apply`).warn({editor:e,path:r??a.configPath(t,n),reason:i instanceof Error?i.message:String(i)},`MCP config removal failed`),G()}}async function xe(e,t,n){if(v[e].scope!==`global`)return K();if(n===`absent`)return be(e,``,t.home,void 0,t.env);let r=(await S({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=v[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=y(v[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??ie();if(n===`absent`){let t=P(e,r);switch(t.action){case`removed`:return{action:`removed`};case`not-present`:return{action:`no-op`};case`skipped-unsupported`:return K();case`failed`:return q(e,t.path,t.error),G()}}let i=T(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=g(v[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=C(v[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=a(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 _(`--only must be 'server'`)}function Oe(e=z,t=import.meta.dirname??new URL(`.`,import.meta.url).pathname){let n=[R(t,`public`),R(t,`../../app/dist`),R(t,`../../../app/dist`)];return e(R(t,`../../app.asar`))&&n.push(R(t,`../../app`)),n.find(t=>e(t))}function ke(e){if(e.explicitDir!==void 0)return{dir:e.explicitDir,missingBundle:!1};if(e.only===`server`)return{dir:void 0,missingBundle:!1};let t=e.findBundledDir();return{dir:t,missingBundle:t===void 0}}function Ae(e){if(e===`off`)return`off`;if(!s.test(e))throw new _(`--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 _(`${e} is not a valid URL: ${t}`)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw new _(`${e} must be an http(s) origin (got: ${t})`);return t}function Fe(e){return Pe(`--external-url`,e)}function Ie(e){let t=I(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 ${d}* 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??ae,r=t.realpathFn??re,i=e=>{try{return r(e)}catch(t){return t.code===`ENOENT`?R(e):null}},a=R(e),o;try{o=r(a)}catch(e){if(e.code===`ENOENT`){let e=i(L(a));o=e===null?null:R(e,I(a))}else o=null}if(o===null)return!1;let s=i(n());return s!==null&&L(o)===s&&I(o).startsWith(`ok-ephemeral-`)}function Le(e,t,n=e=>oe(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 ${d}* dirs under the OS temp dir are removed on ephemeral teardown\n`)}}}function Re(e,t={}){let n=t.exit??(e=>process.exit(e)),r=t.getActiveHandles??(()=>{let e=process._getActiveHandles;return e?e.call(process):null});return async()=>{let i=!1;try{await e()}catch(e){i=!0,t.log?.error({err:e},`idle-shutdown: destroy failed — exiting anyway`)}finally{let e=null;try{let t=r();if(t!==null){e={};for(let n of t){let t=n?.constructor?.name??`unknown`;e[t]=(e[t]??0)+1}}}catch{e=null}t.log?.info({event:`idle-shutdown-exit`,exitCode:+!!i,openHandles:e??{},handlesAvailable:e!==null},`idle-shutdown: teardown finished — exiting process`),n(+!!i)}}}async function Q(e){let{config:t,cwd:n,host:r}=e,i=e.skipAutoInit??!1,a=e.idleThresholdMs===void 0?18e5:e.idleThresholdMs,{existsSync:o,mkdirSync:s}=await import(`node:fs`),{basename:l,dirname:u,resolve:d}=await import(`node:path`),{bootServer:f,createEphemeralProjectDir:p,getLogger:h,resolveContentDir:g,resolveLockDir:_,seedEphemeralProjectDir:v,waitForServerLockDrain:y}=await import(`./dist-eiP2xn_A.mjs`),x=e.log??h(`start`),S=e.singleFile!==void 0,C=S?c(e.singleFile).canonicalFilePath:void 0,T=C?u(C):void 0,D=C?l(C):void 0,O,k=!1;if(T!==void 0){if(e.projectDir!==void 0){if(O=e.projectDir,!Z(O))throw new X(O);o(d(O,`.ok`,`config.yml`))||v(O,T)}else O=p(T),k=!0}let j=async()=>{if(!(!k||O===void 0)){if(!Z(O)){x.warn({ephemeralProjectDir:O},`[start] refusing to reap self-provisioned ephemeral dir: no longer resolves to an ok-ephemeral-* temp dir`);return}try{await oe(O,{recursive:!0,force:!0})}catch(e){x.warn({err:e,ephemeralProjectDir:O},`[start] failed to reap self-provisioned ephemeral temp dir`)}}},N=O;if(!S){if(!i&&!m(n))throw new Y(n);let t=process.env.OK_RECLAIM_DISABLE??null,r=e=>{e.severity===`info`?x.debug({event:e},`[start] reclaim sweep event`):x.warn({event:e},`[start] reclaim sweep reported a problem`)};try{let i=(e.repairMcpConfigsFn??(await import(`./repair-mcp-configs-C7yBPBvC.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&&x.warn({unhealed:i},`[start] reclaim sweep left entries it could not heal`)}catch(e){x.warn({err:e},`[start] mcp-config repair sweep failed; continuing`)}try{(e.repairLaunchJsonFn??(await import(`./repair-launch-json-EuA85m8g.mjs`)).repairLaunchJson)({projectDir:n,reclaimDisableEnv:t,logger:r})}catch(e){x.warn({err:e},`[start] launch.json repair sweep failed; continuing`)}}let P=T??g(t,n);!S&&!o(P)&&(s(P,{recursive:!0}),x.info({contentDir:P},`Created content directory`));let ne=w(),I=ee(),L;try{{let e=_(O??n),t=Date.now(),r=await y(e);r!==`no-drain`&&x.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`)}L=await f({config:t,contentDir:P,projectDir:O??n,contentRoot:S?void 0:t.content.dir,port:e.port,host:r,quiet:!1,detectGh:B,detectGhAccounts:U,tokenStore:ne,embeddingsKeyStore:I,mcpTomlEditor:b(),...S?{ephemeral:!0,singleDocRelPath:D,gitEnabled:!1,gitPreflight:()=>({ok:!0,version:`0.0.0`,resolvedPath:`git`,source:`PATH`})}:{},localOpCliArgs:[process.execPath,process.argv[1]],probeHarnessManagedMcpEntry:(e,t)=>M(e,t),probePiAcpBridge:e=>E(e),ensurePiAcpBridge:(e,t)=>te(e,void 0,void 0,void 0,t),agentIntegrations:(()=>{let e={cwd:O??n,home:ie(),env:process.env};return{probe:F(e),execute:Te(e),userSkillPresentAnywhere:A}})(),idleShutdownMs:a,...e.serverRuntime===void 0?{}:{serverRuntime:e.serverRuntime},...e.bind===void 0?{}:{bind:e.bind},skipAutoInit:!0,idleShutdownHandler:t=>{let n=t;return Re(N===void 0?n:Le(n,N),{log:x,exit:e.idleExit})},log:x,...e.serveContentAssets===void 0?{}:{serveContentAssets:e.serveContentAssets},...e.reactShellDistDir?{reactShellDistDir:e.reactShellDistDir}:{},...e.terminalAuthAvailable===!0?{terminalAuthAvailable:!0}:{}})}catch(e){throw await j(),e}let R=L.destroy,z=k?async(...e)=>{try{await R(...e)}finally{await j()}}:R;return{httpServer:L.httpServer,destroy:z,lockDir:L.lockDir,contentDir:P,port:L.port,ready:L.ready,degraded:L.degraded}}function ze(e,t,n=()=>f({absPath:u(`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 _(`--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:ee}=await import(`./banner-kywHhVaC.mjs`),{accent:l,dim:u,error:d,warning:f}=await import(`./colors-SgU3JHQu.mjs`),p=process.cwd();process.title=Ie(p);let m;try{m=i(process.env)}catch(e){throw e instanceof o&&(console.error(d(e.message)),process.exit(78)),e}for(let e of m.diagnostics)console.warn(f(`[config] ${e.message}`));let h=t(s,m.layer),g=m.overrides.some(e=>e.envVar===`OK_BIND`),_=a.bind!==void 0&&a.bind.length>0?a.bind:void 0,v=process.env.HOST,y=v!==void 0&&v.trim()!==``?v:void 0,b=r(h),x=_??(g||y===void 0?[...b.bind]:[y]);Me({flagBindSet:_!==void 0,okBindSet:g,hostEnvSet:y!==void 0,fileBindCount:b.bind.length})&&console.warn(f(`[config] HOST=${y} overrides server.bind — dropping the file-configured addresses (${b.bind.join(`, `)}). Use OK_BIND with a space-separated list to keep multiple binds.`));let S=x[0]??`127.0.0.1`,C=x,w=a.externalUrl,T=r(t(h,{server:{bind:C,...w===void 0?{}:{externalUrl:w}}}));if(T.allowExternal&&(!T.loopbackOnly||T.externalUrl)){let e=T.externalUrl??T.bind.join(`, `);console.warn(f([``,`⚠ EXTERNAL ACCESS ENABLED (server.allowExternal) — no server-side authentication.`,` This server is reachable beyond this machine (${e}). Anyone who can`,` reach it has FULL control of this knowledge base — sync, publishing, GitHub`,` credentials, and local operations (clone, sign-in, repo spawn).`,` Restrict who can reach it at the edge: a Tailscale ACL, a reverse proxy with`,` auth (Cloudflare Access, oauth2-proxy), or a firewall.`,``].join(`
|
|
3
|
+
`)))}let E=a.port===void 0?void 0:Number(a.port),D=m.overrides.find(e=>e.envVar===`PORT`)?.value,O=E??D??s.server?.port,k=ke({explicitDir:a.reactShellDistDir,only:a.only,findBundledDir:Oe}),A=k.dir;k.missingBundle&&console.warn(`bundled web UI not found — serving /api and /mcp only. Reinstall @inkeep/open-knowledge, or build packages/app in a source checkout.`);let j;try{j=await Q({config:s,cwd:p,host:S,port:O,bind:C,...a.serveContentAssets===void 0?{}:{serveContentAssets:a.serveContentAssets},...A?{reactShellDistDir:A}:{},idleThresholdMs:n(a.idleShutdown??T.idleShutdown),serverRuntime:T,...a.singleFile?{singleFile:a.singleFile}:{},...a.projectDir?{projectDir:a.projectDir}:{},...a.terminalAuth===!0?{terminalAuthAvailable:!0}:{}})}catch(e){e instanceof Y&&(console.error(d(e.message)),process.exit(1)),e instanceof X&&(console.error(d(e.message)),process.exit(1));let t=await import(`./dist-eiP2xn_A.mjs`);if((e instanceof t.GitNotAvailableError||e instanceof t.GitProbeTimeoutError||e instanceof t.GitTooOldError)&&process.exit(78),e instanceof t.ExposureConsentError&&(console.error(d(e.message)),process.exit(78)),(e instanceof t.SingleFileNotFoundError||e instanceof t.SingleFileNotAFileError||e instanceof t.SingleFileNotMarkdownError)&&(console.error(d(e.message)),process.exit(1)),(e instanceof t.MissingOkConfigError||e instanceof t.DocumentDurabilityStateError)&&(console.error(d(e.message)),process.exit(1)),Ke(e,t,p)){let e=t.resolveLockDir(p),n=null;try{n=await We({readServerLock:()=>t.readServerLock(e),now:Date.now,sleep:e=>le(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(l(e));for(let e of t)console.log(u(e));process.exit(0)}}let n=$(e,p,t);n!==null&&(console.error(d(n)),process.exit(1)),console.error(`${d(`Failed to start:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exit(1)}let M=!1,N=async e=>{if(M)return;M=!0;let[t,...n]=He(e);console.log(l(`\n${t}`));for(let e of n)console.log(u(` ${e}`));try{await j.destroy(`external-signal`,{signal:e})}catch(e){console.error(`${d(`destroy() failed:`)} ${e instanceof Error?e.stack??e.message:String(e)}`),process.exitCode=1}process.exit(process.exitCode??0)};process.once(`SIGINT`,()=>{N(`SIGINT`)}),process.once(`SIGTERM`,()=>{N(`SIGTERM`)});let P=`http://${S.includes(`:`)&&!S.startsWith(`[`)?`[${S}]`:S}:${j.port}`,te=S===`0.0.0.0`||S===`::`?`http://0.0.0.0:${j.port}`:void 0,F=P;console.log(ee({name:`open-knowledge`,version:ne,localUrl:F,networkUrl:te,nextSteps:[`Open the Editor URL in your browser to start editing.`]}));let I={"shadow-repo":`Version history and branch-switch safety unavailable`,"file-watcher":`External file changes will not sync to the editor`,"head-watcher":`Git branch switches may cause document inconsistency`};j.ready.then(async()=>{if(j.degraded.length>0){console.log();for(let e of j.degraded){let t=I[e]??`${e} (check server logs for details)`;console.warn(` ${f(`⚠`)} ${f(e)}: ${u(t)}`)}console.log()}if(Ne({openBrowser:a.openBrowser!==!1&&T.openBrowser,explicitOn:a.openBrowser!==!1&&h.server?.openBrowser===!0,host:S,isTTY:process.stdout.isTTY===!0,ephemeral:a.singleFile!==void 0,only:a.only,servesUi:A!==void 0})){let{openBrowser:e}=await import(`./open-browser-Bdh6sD0e.mjs`);e(F)}}).catch(e=>{console.error(` ${d(`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:l(n)&&n.url!==void 0?{url:n.url,kind:n.kind,pid:n.pid,servesUi:!0}:{url:n.url??`http://127.0.0.1:${n.port}`,kind:n.kind,pid:n.pid,servesUi:!1}}function 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`&&re.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 x(`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 h(`--single-file <path>`,`No-project ephemeral single-file mode: scope the server to one markdown file (git + MCP off)`).hideHelp()).addOption(new h(`--project-dir <dir>`,`Throwaway project root for --single-file (where ephemeral .ok/ state lives)`).hideHelp()).addOption(new h(`--terminal-auth`,`Tell in-app agents that this server's client can run terminal sign-ins (the desktop app passes it when it has a terminal)`).hideHelp()).option(`--external-url <url>`,`Canonical external origin clients dial (sets server.externalUrl for this run) — its host joins the Host/Origin allowlists (CORS + external-Host admission). External exposure additionally requires consent (OK_ALLOW_EXTERNAL=1 or server.allowExternal).`,Fe).action(async t=>{let n=e();if(t.only===`server`&&t.reactShellDistDir!==void 0&&(process.stderr.write(`error: option '--only server' cannot be combined with '--react-shell-dist-dir'
|
|
4
4
|
`),process.exit(2)),t.projectDir!==void 0&&t.singleFile===void 0&&(process.stderr.write(`error: option '--project-dir' requires '--single-file'
|
|
5
5
|
`),process.exit(2)),t.mode===`app`){let e=[];if(t.port!==void 0&&e.push(`--port`),t.bind!==void 0&&e.push(`--bind`),t.only!==void 0&&e.push(`--only`),t.idleShutdown!==void 0&&e.push(`--idle-shutdown`),t.openBrowser===!1&&e.push(`--no-open-browser`),t.externalUrl!==void 0&&e.push(`--external-url`),e.length>0){let t=process.env.OK_LOG_LEVEL??`info`;(t===`debug`||t===`trace`)&&console.error(`--mode=app: ignoring ${e.join(`, `)}`)}let n=j(D());if(n.available){k({spawn:ce},n);return}console.error(O(n.reason)),process.exit(1)}await Ue(n,t)})}export{$ as C,U as D,B as E,qe as S,Re as T,Ve as _,Ge as a,Ne as b,Z as c,Ae as d,De as f,ze as g,We as h,Ie as i,Ke as l,Ee as m,Y as n,He as o,Oe as p,Q as r,je as s,X as t,Fe as u,ke as v,Le as w,Me as x,Ue as y};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/open-knowledge",
|
|
3
|
-
"version": "0.88.9-beta.
|
|
3
|
+
"version": "0.88.9-beta.4",
|
|
4
4
|
"description": "Local-first, agent-friendly Markdown knowledge base with a cross-platform CLI and web editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"knowledge-base",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@parcel/watcher": "^2.5.6"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@inkeep/open-knowledge-app": "0.88.9-beta.
|
|
69
|
-
"@inkeep/open-knowledge-core": "0.88.9-beta.
|
|
68
|
+
"@inkeep/open-knowledge-app": "0.88.9-beta.4",
|
|
69
|
+
"@inkeep/open-knowledge-core": "0.88.9-beta.4",
|
|
70
70
|
"@inkeep/open-knowledge-native-config": "0.0.0",
|
|
71
|
-
"@inkeep/open-knowledge-server": "0.88.9-beta.
|
|
71
|
+
"@inkeep/open-knowledge-server": "0.88.9-beta.4",
|
|
72
72
|
"@types/node": "^24.7.0",
|
|
73
73
|
"@types/proper-lockfile": "^4.1.4",
|
|
74
74
|
"@types/yazl": "^3.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-DnGz4mVK.mjs";var e=`0.88.9-beta.2`;const t=`config.yml`,n=e;export{n,t};
|
package/dist/init-Djx6uVIJ.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-CjMvnZHW.mjs";import{v as e}from"./init-tZZEMY57.mjs";export{e as runInit};
|
package/dist/loader-CPoDR3tl.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-CLzWCnTU.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-d9Xj2oz-.mjs";export{t as formatPreviewBlock,e as previewContent};
|