@inkeep/open-knowledge 0.79.3-beta.0 → 0.79.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +68 -70
- package/dist/constants-CNxoEQ5b.mjs +1 -0
- package/dist/{dist-Bt-cb2ik.mjs → dist-Cmgb0r3p.mjs} +472 -472
- package/dist/dist-DzdGKL8W.mjs +1 -0
- package/dist/index.mjs +188 -188
- package/dist/{init-H4L4PCDm.mjs → init-D_DKMj1s.mjs} +14 -14
- package/dist/init-DsGKNoaN.mjs +1 -0
- package/dist/{launch-json-removal-DAf1fKWA.mjs → launch-json-removal-CMIL2ikQ.mjs} +1 -1
- package/dist/loader-DAk_l84X.mjs +1 -0
- package/dist/{loader-gbJWrT9X.mjs → loader-N7jiS4w0.mjs} +1 -1
- package/dist/native/native-config.win32-arm64-msvc.node +0 -0
- package/dist/native/native-config.win32-x64-msvc.node +0 -0
- package/dist/{open-browser-Co1psphf.mjs → open-browser-CNVUL-A_.mjs} +1 -1
- package/dist/preview-CRnYd6sw.mjs +1 -0
- package/dist/{preview-CMgnC4UA.mjs → preview-wLB8OL2o.mjs} +1 -1
- package/dist/public/assets/{ActivityModeContent--2lvtA3c.js → ActivityModeContent-CwiUBgGI.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-C-iLRZ1e.js → AddPropertiesButton-B5wgFBcs.js} +2 -2
- package/dist/public/assets/{AgentDiffPane-D6x5wd4h.js → AgentDiffPane-DCr3QWvF.js} +1 -1
- package/dist/public/assets/{BugReportHistory-DSKcw3JQ.js → BugReportHistory-BQMbH-qH.js} +1 -1
- package/dist/public/assets/{BugReportHistoryDialog-N-Ap1hJt.js → BugReportHistoryDialog-BRdfOcWv.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-C6PE1vK2.js → CodeMirrorPropInput-CjC1gT00.js} +1 -1
- package/dist/public/assets/{ConsentDialogBody-NBiDlYMd.js → ConsentDialogBody-DWjU5hm4.js} +1 -1
- package/dist/public/assets/{DeleteConfirmationDialog-DYyGQK4Z.js → DeleteConfirmationDialog-CJJ8Xo5u.js} +1 -1
- package/dist/public/assets/{DiffViewBoundary-_HbzD0gR.js → DiffViewBoundary-BGdnGPRv.js} +1 -1
- package/dist/public/assets/{DocumentContext-DjP4XRJx.js → DocumentContext-Dlldf3A6.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-BOmmVDPD.js → EditorModeToggle-CUFvhR2v.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-C6j7G_kd.js → EnableSyncConfirmDialog-DfwumFEb.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CAYMSmAF.js → ExcalidrawDocEditor-CylNX2Db.js} +1 -1
- package/dist/public/assets/FeedbackForm-CXLWTOXd.js +1 -0
- package/dist/public/assets/{GraphPanel-BMOYeFVW.js → GraphPanel-BQaGu4a5.js} +1 -1
- package/dist/public/assets/{ImageAttachments-CIgN2ICo.js → ImageAttachments-Cooc1nca.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-BXsrd5h-.js → ImportSkillDialog-DSya0fK3.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-D5DY2Ucg.js → LintConfigEditor-BsTgh8nL.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-CVIYFnTZ.js +1 -0
- package/dist/public/assets/ManagedArtifactProperties-DCWlX1Qg.js +1 -0
- package/dist/public/assets/{McpConsentDialogBody-Dj5qWFur.js → McpConsentDialogBody-BGioo7-j.js} +1 -1
- package/dist/public/assets/{Mermaid-BG4D_HOk.js → Mermaid-DP2in8wt.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-CWmiEhhJ.js → MermaidDocEditor-634q13Qg.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-CrxEj3M3.js → PropertyDisplayRow-B_AEbfI7.js} +2 -2
- package/dist/public/assets/{ReportBugDialogBody-C-53A-0F.js → ReportBugDialogBody-Bb5if0pW.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-29birQ-y.js → ReportBugMenuTrigger-DHmYILeX.js} +1 -1
- package/dist/public/assets/{RowDisclosure-roWTy1cj.js → RowDisclosure-B78fx5s2.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-DbbukpG5.js → SchemaConfigEditor-D6Ve-pbq.js} +1 -1
- package/dist/public/assets/{SessionsHost-CKvXoA48.js → SessionsHost-Cdic3R-Y.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-PbyK1LoL.js → SettingsDialogBody-UKT3bDul.js} +1 -1
- package/dist/public/assets/{ShareBranchSwitchDialog-KJzH1_kA.js → ShareBranchSwitchDialog-DE7uyxww.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-CLkMfCLe.js → ShareReceiveDialog-D8d3_-15.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-CLVrxv3V.js → ShareReceiveMissDialog-Bx29cMNb.js} +1 -1
- package/dist/public/assets/{SkillForkDialog-Cg2OBoX4.js → SkillForkDialog-ho4FUABV.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-DBCnHXH-.js → SkillInstallMenu-DpmMcdPv.js} +1 -1
- package/dist/public/assets/{SkillOriginInline-kzOBcIFc.js → SkillOriginInline-DmEjQplu.js} +2 -2
- package/dist/public/assets/{SkillToolbarControls-DltyfwOH.js → SkillToolbarControls-miZURo1o.js} +1 -1
- package/dist/public/assets/{SkillUpdateConflictDialog-kz67-4EX.js → SkillUpdateConflictDialog-BTP9zIit.js} +1 -1
- package/dist/public/assets/{SlidesToolbarControls-CAxEUrS2.js → SlidesToolbarControls-CUfeiKej.js} +1 -1
- package/dist/public/assets/{SourceEditor-DLEw1wic.js → SourceEditor-DCGr3Oun.js} +1 -1
- package/dist/public/assets/{TerminalPanel-Cb8KkKGX.js → TerminalPanel-DDye0ppp.js} +1 -1
- package/dist/public/assets/{TerminalStartingNotice-BbwsOE78.js → TerminalStartingNotice-CANxPK71.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-BXIexfq8.js → TerminalWindowApp-C9GosoJU.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DeqaHCag.js → TextDocEditor-Dy2g4z9H.js} +1 -1
- package/dist/public/assets/{ThreadView-D1YayNv3.js → ThreadView-CPLHpCdR.js} +17 -17
- package/dist/public/assets/{TimelineDiffPane-BCk40u8c.js → TimelineDiffPane-9-8JYbua.js} +1 -1
- package/dist/public/assets/{agent-connection-status-BKDHFOP-.js → agent-connection-status-BTfitB3U.js} +1 -1
- package/dist/public/assets/{alert-Bqwsa0Kr.js → alert-Cp5DpEia.js} +1 -1
- package/dist/public/assets/{alert-dialog-CqqfqWNT.js → alert-dialog-BJIyfEVh.js} +1 -1
- package/dist/public/assets/{auth-state-cache-COORa9sc.js → auth-state-cache-CIg70qGh.js} +1 -1
- package/dist/public/assets/{badge-lmgHBfMn.js → badge-MuddhvBr.js} +1 -1
- package/dist/public/assets/button-HKX9wT1K.js +1 -0
- package/dist/public/assets/{calendar-BR8UVbAy.js → calendar-DLVK4LG7.js} +1 -1
- package/dist/public/assets/{client-version-yBzdRoMs.js → client-version-DA4kJKPj.js} +1 -1
- package/dist/public/assets/{comment-chips-BGRnR7X7.js → comment-chips-Cnc9lZ6c.js} +1 -1
- package/dist/public/assets/{config-provider-CTHdqAYx.js → config-provider-owr5M3NH.js} +1 -1
- package/dist/public/assets/{dialog-BfHNtxM9.js → dialog-Q2r_wm4I.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-DxMjEKx4.js → doc-undo-manager-CaLoly49.js} +1 -1
- package/dist/public/assets/{field-BLH6hVAa.js → field-Cy222HIR.js} +1 -1
- package/dist/public/assets/globals-uZ5VipkR.css +1 -0
- package/dist/public/assets/image-attachment-IlVZ-iwe.js +1 -0
- package/dist/public/assets/index-CFr0XcXQ.js +2205 -0
- package/dist/public/assets/{input-group-Brp49uT-.js → input-group-D4IQIBdt.js} +1 -1
- package/dist/public/assets/{markdownlint-rule-browser-D5yxtwtH.js → markdownlint-rule-browser-DYxq-YWd.js} +1 -1
- package/dist/public/assets/messages-8is2no75.js +1 -0
- package/dist/public/assets/messages-BAuq9QNn.js +1 -0
- package/dist/public/assets/messages-BMB7_c7y.js +1 -0
- package/dist/public/assets/messages-C2mWhO6K.js +1 -0
- package/dist/public/assets/messages-CRnQAmA5.js +1 -0
- package/dist/public/assets/messages-CpKrli-X.js +1 -0
- package/dist/public/assets/messages-CuQCs__I.js +1 -0
- package/dist/public/assets/messages-DUAWetuM.js +1 -0
- package/dist/public/assets/messages-EThDD2lc.js +1 -0
- package/dist/public/assets/messages-JIbrz5bw.js +1 -0
- package/dist/public/assets/messages-eVBmDYMt.js +1 -0
- package/dist/public/assets/messages-tmp_OA3I.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-CQL0bv5o.js → pending-receive-nav-store-ru8vEtq1.js} +1 -1
- package/dist/public/assets/{preferred-session-events-BEpzXSN8.js → preferred-session-events-Dhjm0Z1H.js} +1 -1
- package/dist/public/assets/{progress-C8ijsHox.js → progress-0Dfq8VnS.js} +1 -1
- package/dist/public/assets/{project-paths-B-FMrj5U.js → project-paths-CDhA3hJy.js} +1 -1
- package/dist/public/assets/{selection-context-LrE0_TTe.js → selection-context-4lSNiVN-.js} +1 -1
- package/dist/public/assets/{src-BxNPgEkh.js → src-C5n8TKJq.js} +1 -1
- package/dist/public/assets/{tabs-C7_T-n4e.js → tabs-BnFGmv6I.js} +1 -1
- package/dist/public/assets/{tag-pill-input-B28iAFxa.js → tag-pill-input-BQX-_Adc.js} +1 -1
- package/dist/public/assets/{telemetry-impl-CDsHOhvm.js → telemetry-impl-BjW04TM-.js} +1 -1
- package/dist/public/assets/{telemetry-startup-D-KW_NaP.js → telemetry-startup-BS9CaXrj.js} +1 -1
- package/dist/public/assets/{terminal-launch-events-E89-i5D1.js → terminal-launch-events-Dmdb2rMF.js} +1 -1
- package/dist/public/assets/{toggle-group-BxIyZnUJ.js → toggle-group-ZKcYQ5bn.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BI7H8DPb.js → typing-burst-detector-BEdXQddD.js} +2 -2
- package/dist/public/assets/{uninstall-C5hq5xn8.js → uninstall-DXJMPkVq.js} +1 -1
- package/dist/public/assets/{use-activity-panel-D1MJ-kqr.js → use-activity-panel-CngLVlKx.js} +1 -1
- package/dist/public/assets/{use-apply-config-language-DBt73Gpy.js → use-apply-config-language-DgBG2Y3l.js} +2 -2
- package/dist/public/assets/{use-installed-clis-F-bc0S3Y.js → use-installed-clis-BzQZdtk_.js} +2 -2
- package/dist/public/assets/{use-open-skill-BBxnHzMv.js → use-open-skill-B-WzAe13.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BePo4VDS.js → use-terminal-enabled-Dd55GJPP.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-Cpz7ybaB.js → use-timeline-entry-diff-D9Fyk7np.js} +1 -1
- package/dist/public/index.html +40 -40
- package/dist/public/uninstall.html +7 -7
- package/dist/registry-probes-V6HkuVVa.mjs +17 -0
- package/dist/{removal-file-path-DiyOqKix.mjs → removal-file-path-CSUwOdaZ.mjs} +1 -1
- package/dist/{repair-launch-json-CK7gSieg.mjs → repair-launch-json-CHU3DQHD.mjs} +1 -1
- package/dist/{repair-mcp-configs-B2IwckuL.mjs → repair-mcp-configs-BhdagblW.mjs} +1 -1
- package/dist/src-CXxDQ4LC.mjs +1 -0
- package/dist/{src-7sNhM-_B.mjs → src-DPs9CRCY.mjs} +5 -5
- package/dist/{start-DYrDwaUD.mjs → start-C8VxoPil.mjs} +3 -3
- package/dist/start-Du6cCuDw.mjs +1 -0
- package/package.json +5 -5
- package/dist/constants-wVFbQ-W8.mjs +0 -1
- package/dist/dist-CZBCHPnO.mjs +0 -1
- package/dist/init-CqGfdMuB.mjs +0 -1
- package/dist/loader-BK3wGq2e.mjs +0 -1
- package/dist/preview-DPQ4BPLK.mjs +0 -1
- package/dist/public/assets/FeedbackForm-t3IG2SJR.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-BnJzcs6f.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-sumfs_C-.js +0 -1
- package/dist/public/assets/button-BeFNZANd.js +0 -1
- package/dist/public/assets/globals-Dg-24adS.css +0 -1
- package/dist/public/assets/image-attachment-C1B_QOlM.js +0 -1
- package/dist/public/assets/index-CWenCiFy.js +0 -2205
- package/dist/public/assets/messages-5nYhcGbk.js +0 -1
- package/dist/public/assets/messages-8wkpGWDl.js +0 -1
- package/dist/public/assets/messages-BE3F6wPf.js +0 -1
- package/dist/public/assets/messages-BYW3-b5z.js +0 -1
- package/dist/public/assets/messages-CE30qzpn.js +0 -1
- package/dist/public/assets/messages-CKBxrXnZ.js +0 -1
- package/dist/public/assets/messages-C_LttG3X.js +0 -1
- package/dist/public/assets/messages-Cd3H31Oo.js +0 -1
- package/dist/public/assets/messages-D-bBxZfD.js +0 -1
- package/dist/public/assets/messages-DLuudO75.js +0 -1
- package/dist/public/assets/messages-DoYSqXZ-.js +0 -1
- package/dist/public/assets/messages-nwFoZCFs.js +0 -1
- package/dist/registry-probes-DCe3rWZ7.mjs +0 -17
- package/dist/src-DZ44CKon.mjs +0 -1
- package/dist/start-DaOK3zKh.mjs +0 -1
- /package/dist/public/assets/{globals-BXFJsup3.js → globals-DS9_Iy6h.js} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./rolldown-runtime-tZXQYakl.mjs";import{Gd as r,Gl as i,Jd as a,Qu as o,Uu as s,Yd as c,Zd as l,it as u,no as d,qd as f,ro as p}from"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import{Bn as m,En as h,Go as g,Wo as _,ko as v,m as y,mo as ee,na as b,tr as te,zo as x}from"./dist-Bt-cb2ik.mjs";import{$ as ne,A as re,J as ie,M as S,O as C,P as ae,R as oe,T as se,X as w,at as ce,ct as le,d as ue,dt as de,f as fe,it as pe,j as me,k as he,lt as ge,nt as _e,o as ve,rt as T,tt as ye,v as be,w as xe,x as Se,y as Ce}from"./init-H4L4PCDm.mjs";import{t as we}from"./is-object-BGze3w87.mjs";import{t as Te}from"./removal-file-path-DiyOqKix.mjs";import{spawn as Ee}from"node:child_process";import{basename as E,dirname as D,join as O,resolve as k,win32 as De}from"node:path";import{accessSync as Oe,constants as A,existsSync as j,lstatSync as M,mkdirSync as ke,readFileSync as N,readdirSync as P,realpathSync as F,rmSync as Ae,rmdirSync as je,statSync as I,unlinkSync as Me,writeFileSync as Ne}from"node:fs";import{homedir as L}from"node:os";import{createHash as Pe}from"node:crypto";import{isDeepStrictEqual as Fe}from"node:util";import{setTimeout as Ie}from"node:timers/promises";var Le=s();let Re;function ze(){return Re}function Be(e,t){if(t!==void 0&&t.length>0)return t;try{return te(e)?.rootPath}catch{return}}function Ve(e){let t=Be(e.cwd,e.configuredProjectName),n=h({name:`cli`,project:t});return Re=n,n.info({command:e.command,cwd:e.cwd,project:t},`cli command started`),n}const R=`open-knowledge`;function z(e){try{e()}catch{}}var He=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(R,e).getPassword()}catch(t){return z(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return z(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return z(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(R,e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(R,e).deletePassword()}catch{}}},B=class{backend=`file`;authFile;constructor(e){this.authFile=e??O(L(),`.ok`,`auth.yml`)}read(){if(!j(this.authFile))return{};try{let e=N(this.authFile,`utf-8`);return(0,Le.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=D(this.authFile);j(t)||ke(t,{recursive:!0,mode:448}),Ne(this.authFile,(0,Le.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},Ue=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ~/.ok/auth.yml to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function We(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(R,`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
2
|
-
`),z(()=>t?.onBackendSelected?.({backend:`keyring`})),new Ue(new He(t?.onKeychainRead),new B(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (~/.ok/auth.yml) — OS keychain unavailable: ${r}\n`),z(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new B(e)}}function Ge(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (~/.ok/auth.yml)\n`),r(new B(e))},n)});try{return await Promise.race([We(e),r])}catch{return new B(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function Ke(e){let t=Ge(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}function qe(e){let t=Ge(e);return{backend:`file`,async get(e){return(await t()).get(e)},async set(e,n,r,i){return(await t()).set(e,n,r,i)},async clear(e){return(await t()).clear(e)}}}async function Je(e,t){let n=[],r=new B(t);await r.get(e)!=null&&(await r.clear(e),n.push(`file`));let i;try{let{Entry:t}=await import(`@napi-rs/keyring`);new t(R,`__probe__`);let r,a=await new He(e=>{e.kind===`read-error`&&(r=e.error??`read-error`)}).get(e);if(r!==void 0)i=r;else if(a!=null)try{new t(R,e).deletePassword(),n.push(`keychain`)}catch(e){i=e instanceof Error?e.name:`delete-error`}}catch{}return{touched:n,keychainError:i}}function Ye(e){let t={...e};return delete t.ELECTRON_RUN_AS_NODE,t}function Xe(e){let t=e?.code;return t===`ENOENT`||t===`EACCES`||t===`EPERM`?{ok:!1,reason:`not-installed`}:{ok:!1,reason:`spawn-error`}}function Ze(e){return ee({detached:!0,stdio:`ignore`,shell:!1,env:Ye(e)})}function Qe(e,t,n={}){let r=(n.spawn??Ee)(e,[...t],Ze(n.env??process.env));return r.unref(),r}function $e(e,t,n={}){let r=n.spawn??Ee,i=n.timeoutMs??2e3;return new Promise(a=>{let o=!1,s=e=>{o||(o=!0,a(e))},c=setTimeout(()=>s({ok:!1,reason:`timeout`}),i);try{let i=r(e,[...t],Ze(n.env??process.env));i.once(`error`,e=>{clearTimeout(c),s(Xe(e))}),i.once(`spawn`,()=>{clearTimeout(c),s({ok:!0})});try{i.unref()}catch{}}catch(e){clearTimeout(c),s(Xe(e))}})}const et=u.stable.appId,V=[u.stable,u.beta];function tt(){return{platform:process.platform,env:process.env,execPath:process.execPath,isTTY:process.stdout.isTTY,statSync:e=>{try{return I(e,{throwIfNoEntry:!1})??null}catch{return null}}}}function nt(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`){let t=/(.+?\.app)\/Contents\/MacOS\//.exec(e.execPath);if(t?.[1])return t[1]}let t=e.homeDir??L();for(let n of V)for(let r of[O(t,`Applications`),`/Applications`]){let t=O(r,`${n.productName}.app`);if(rt(e,O(t,`Contents`,`MacOS`,n.productName)))return t}return null}function rt(e,t){try{let n=e.statSync(t);return n?typeof n.isFile==`function`&&n.isFile():!1}catch{return!1}}function it(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&V.find(t=>e.execPath.toLowerCase().endsWith(`\\${d(t).toLowerCase()}`)))return e.execPath;let t=e.env.LOCALAPPDATA;if(t)for(let n of V)for(let r of p(n)){let i=De.join(t,`Programs`,r,d(n));if(rt(e,i))return i}return null}function at(e){if(e.env.ELECTRON_RUN_AS_NODE===`1`&&V.find(t=>e.execPath.endsWith(`/${t.linuxExecutableName}`)))return e.execPath;for(let t of V){let n=`/opt/${t.productName}/${t.linuxExecutableName}`;if(rt(e,n))return n}return null}function ot(e){if(e.env.OK_FORCE_BROWSER===`1`)return{available:!1,reason:`force-browser`};if(e.platform!==`darwin`&&e.platform!==`win32`&&e.platform!==`linux`)return{available:!1,reason:`unsupported-platform`};let t;try{t=e.platform===`darwin`?nt(e):e.platform===`win32`?it(e):at(e)}catch{return{available:!1,reason:`stat-error`}}return t?e.env.OK_FORCE_DESKTOP===`1`?{available:!0,reason:`available`,bundlePath:t}:!(e.isTTY===!0||e.platform===`win32`&&e.isTTY===void 0&&!e.env.CI)||e.env.SSH_CONNECTION||e.env.SSH_TTY||e.platform===`linux`&&!e.env.DISPLAY&&!e.env.WAYLAND_DISPLAY?{available:!1,reason:`headless`,bundlePath:t}:{available:!0,reason:`available`,bundlePath:t}:{available:!1,reason:`no-bundle`}}function st(e,t){let n=e.log??(e=>console.error(e)),r=e.platform??process.platform;n("Launching OpenKnowledge desktop (use `ok start` for the browser server, or `OK_FORCE_BROWSER=1` to always skip)");let i=t?.bundlePath;if(!i){n(`Desktop launch skipped: no resolved desktop executable (caller bug).`);return}if(r===`darwin`){Qe(`open`,[`-a`,i],{spawn:e.spawn});return}Qe(i,[],{spawn:e.spawn})}function ct(e=`no-bundle`){switch(e){case`no-bundle`:return`Desktop app not found (checked the standard install locations for this OS). Install it from https://openknowledge.ai/download, or omit --mode for browser mode.`;case`darwin-only`:case`unsupported-platform`:return`Desktop app is not available on this platform. Use --mode=browser, or omit --mode for the server fallback.`;case`headless`:return`Desktop launch is gated in headless contexts (CI, SSH, non-TTY stdout). Set OK_FORCE_DESKTOP=1 to override, or use --mode=browser.`;case`force-browser`:return`OK_FORCE_BROWSER=1 is set — desktop dispatch is disabled. Unset it to use --mode=app.`;case`stat-error`:return`Failed to inspect the desktop install (filesystem error). Check permissions or use --mode=browser.`;case`available`:return`Desktop app appears available but launch dispatch did not fire (caller bug).`}}function 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 lt(e){return Pe(`sha256`).update(e).digest(`hex`)}function U(e){return O(k(e),`.ok`,`pi-trust`)}function ut(e,t){return O(U(e),lt(k(t)))}function dt(e,t,n){return O(ut(e,t),`${lt(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=M(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 ft(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function pt(e,t){if(!we(e)||!ft(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==k(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==k(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==k(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!we(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&&ft(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&ft(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new 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 mt(e,t,n){let r;try{r=M(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=N(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=pt(a,n);if(o.cwd!==k(t)||n!==dt(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 ht(e,t){let{record:n,path:r}=t;for(let t of[U(e),ut(e,n.cwd)])if(!K(t))throw new W(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=mt(e,n.cwd,r);if(!Fe(i.record,n))throw new W(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function gt(e,t,n,r,i){let a={version:1,cwd:k(t),configuredTrustPath:k(n),canonicalTrustPath:k(r),state:`pending`,previous:i},o=dt(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Fe(pt(JSON.parse(s),o),a))throw new W(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);K(U(e)),K(D(o));try{ke(D(o),{recursive:!0,mode:448})}catch(e){throw G(D(o),`be created`,e)}let c;try{c=M(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{x(o,s,{mode:384})}catch(e){throw G(o,`be written`,e)}return{path:o,record:a}}function _t(e,t){let n=ht(e,t);if(n.record.state!==`pending`)throw new W(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{x(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw G(n.path,`be committed`,e)}return{path:n.path,record:r}}function q(e,t){if(!K(U(e)))return[];let n=ut(e,t);if(!K(n))return[];let r;try{r=P(n).sort()}catch(e){throw G(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>mt(e,t,O(n,r)))}function J(e,t){let n=ht(e,t);try{Me(n.path)}catch(e){throw G(n.path,`be removed after reconciling its grant`,e)}for(let t of[D(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 vt=n(((t,n)=>{var r=e(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),yt=n(((t,n)=>{var r=e(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),bt=n(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),xt=n(((t,n)=>{var r=e(`fs`),i=vt(),a=yt(),o=bt(),s=e(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
3
|
-
GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),e(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=re,e.createWriteStream=ie;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);b=g.ReadStream,x=g.WriteStream}var _=e.ReadStream;_&&(b.prototype=Object.create(_.prototype),b.prototype.open=te);var v=e.WriteStream;v&&(x.prototype=Object.create(v.prototype),x.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var ee=x;Object.defineProperty(e,"FileWriteStream",{get:function(){return ee},set:function(e){ee=e},enumerable:!0,configurable:!0});function b(e,t){return this instanceof b?(_.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function te(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function x(e,t){return this instanceof x?(v.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function ne(){var e=this;C(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function re(t,n){return new e.ReadStream(t,n)}function ie(t,n){return new e.WriteStream(t,n)}var S=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 S(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),St=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),Ct=n((e=>{var t=St();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),wt=n(((e,t)=>{t.exports=Ct()})),Tt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Et=n(((t,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=Tt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),Dt=n(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Ot=n(((t,n)=>{let r=e(`path`),i=xt(),a=wt(),o=Et(),s=Dt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),kt=n(((e,t)=>{let n=xt();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),At=t(n(((e,t)=>{let n=Ot(),{toPromise:r,toSync:i,toSyncOptions:a}=kt();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const jt=5e3;function Mt(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${jt}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Nt(e,t){ze()?.warn(t,e)}function Pt(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function Ft(e,t,n){await _(`${t}.ok.lock`,async()=>{let t=performance.now()+jt,r;for(;;)try{r=await At.default.lock(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ie(Mt(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}Pt(i,e)},{onWarn:Nt})}function It(e,t,n){g(`${t}.ok.lock`,()=>{let t=performance.now()+jt,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=At.default.lockSync(D(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,Mt(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}Pt(a,e)},{onWarn:Nt})}const Lt=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Rt=class extends Error{name=`PiResourceInspectionError`};function Y(e){let t;try{t=M(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=I(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Rt(me(`missing-symlink-target`),{cause:e}):e}return Oe(e,A.R_OK|(n.isDirectory()?A.X_OK:0)),!0}function zt(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function Bt(e,t,n){let r=e;try{let i=F(e),a;r=t;try{a=F(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=k(t)}let o=O(a,`.agents`,`skills`),s=[];for(let e of Lt)r=O(i,`.pi`,e),Y(r)&&s.push(r);if(r=O(i,`.pi`,`extensions`),Y(r))for(let t of P(r).sort()){let i=O(r,t);k(n)!==O(k(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[O(i,`.pi`,`skills`),O(i,`.agents`,`skills`)])if(e!==o&&(r=e,Y(e)))for(let t of P(e).sort())zt(t)||s.push(O(e,t));let c=D(i);for(;c!==i;){r=O(c,`.agents`,`skills`),r!==o&&Y(r)&&s.push(r);let e=D(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${H(r)}: ${e instanceof Rt?e.message:me(S(e))}`}}}function Vt(e,t,n){let r=k(e),i=le({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:w.pi.projectConfigPath(r),trustPath:O(i,`trust.json`)}}function X(e){try{let t=F(e);return I(t).isDirectory()?(Oe(t,A.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 Ht(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 Ut(e,t,n){let r=ve(w.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 T(i)?{state:`own-current`,text:a}:se(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function Wt(e,t){let n;try{n=N(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:S(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 we(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
4
|
-
`)}:{state:`unreadable`,reason:`invalid-json`}}function Gt(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return me(e)}}function Z(e,t){return{kind:`refused`,error:`trust store ${H(e)}: ${Gt(t)}`}}function Q(e){let t=Te(e);try{switch(t.kind){case`declined`:return Z(e,t.reason);case`ready`:return{kind:`ready`,path:F(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=D(e),r=[E(e)],i=M(n,{throwIfNoEntry:!1});for(;!i;){let t=D(n);if(t===n)return Z(e,`unavailable-root`);r.unshift(E(n)),n=t,i=M(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:O(F(n),...r)}}catch(t){return Z(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:S(t))}}catch(t){return Z(e,S(t))}}function Kt(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 qt(e,t,n){let r=Vt(e,t,n),i=X(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=Ut(r.cwd,r.bridgePath,t).state,o=Q(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:Wt(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:Jt(r.bridgePath).displayNames}}function Jt(e){let t=D(e),n=E(e);try{return{displayNames:P(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>H(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function Yt(e,t={mode:`published`},n,r,i){let a=Vt(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=Ut(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=xe(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=Ce(w.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 Xt(a.trustPath,o.project,n??L());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function Xt(e,t,n){let r=t.canonical,i=Q(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{ke(D(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await Ft(e,i.path,()=>{let o=Ht(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=Kt(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=Wt(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),gt(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
|
|
5
|
-
`:``),f=C(s.path);x(s.path,d,f===void 0?void 0:{mode:f}),$(n,()=>_t(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}return a}function Zt(e){let t=[],n=e;try{for(;;){if(M(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=F(n);return I(e).isDirectory()?(Oe(e,A.X_OK),O(e,...t)):void 0}let e=D(n);if(e===n)return;t.unshift(E(n)),n=e}}catch{return}}function Qt(e){let t={"not-present":0,removed:1,"kept-unowned":2,"kept-shared":3,"kept-unverified":4,"refused-unreadable":5,failed:6},n=e.reduce((e,n)=>t[n.action]>t[e.action]?n:e,{action:`not-present`}),r=e.flatMap(e=>e.error??[]),i=e.flatMap(e=>e.detail??[]);return r.length>0?{action:n.error===void 0?`failed`:n.action,error:[...r,...i].join(`
|
|
6
|
-
`)}:n.detail===void 0?n:{...n,detail:i.join(`
|
|
7
|
-
`)}}function $t(e,t,n,r={}){let i=Vt(e,t,n),a=t??L(),o=X(i.cwd),s=o.kind===`refused`&&r.recordedOnly?Zt(i.cwd):void 0,c=o.kind===`ready`?o.project.canonical:s,l;try{l=$(a,()=>{let e=q(a,i.cwd);return c===void 0||c===i.cwd?e:[...q(a,c),...e]})}catch(e){return{action:`failed`,error:H(e instanceof Error?e.message:String(e))}}if(l.length===0&&r.recordedOnly)return o.kind===`ready`||s!==void 0?{action:`not-present`}:{action:`kept-unverified`,error:`${o.error}. OpenKnowledge could not verify whether this path refers to a project with recorded Pi trust; cleanup was left pending. Retry once the project path can be resolved to check again.`};if(o.kind===`refused`){if(l.length===0)return{action:`kept-unverified`,error:o.error};let e=l.map(({path:e,record:t})=>`key ${H(JSON.stringify(t.cwd))}; configured store ${H(JSON.stringify(t.configuredTrustPath))}; recorded destination ${H(JSON.stringify(t.canonicalTrustPath))}; ownership record ${H(JSON.stringify(e))} (${t.state})`);return{action:`kept-unverified`,error:[`${o.error}. OpenKnowledge kept these Pi trust ownership records; current trust decisions were not checked:`,...e,`To review manually, close Pi, verify the intended store against its recorded destination, and inspect only the exact key. A pending record does not prove setup completed or ownership of a current grant. If you choose to undo a current true decision, restore the recorded previous value, or remove that key only when no previous entry was recorded. Preserve other current decisions; parent-folder and global trust settings still apply.`].join(`
|
|
8
|
-
`)}}let u=Bt(o.project.canonical,a,w.pi.projectConfigPath(o.project.canonical));if(u.kind===`unreadable`)return{action:`kept-unverified`,error:u.error};let d=u.kind===`shared`?u.paths:[],f=[],p=new Map,m=(e,t)=>{let n=p.get(e);if(!n){let t=Q(e);if(t.kind===`refused`){f.push({action:`refused-unreadable`,error:t.error});return}n={trustPath:e,resolved:t,keys:new Map},p.set(e,n)}if(t){if(n.resolved.path!==t.record.canonicalTrustPath){f.push({action:`refused-unreadable`,error:`Pi trust store ${H(e)} no longer points to its recorded destination ${H(t.record.canonicalTrustPath)}; restore the intended file location or symlink, then retry`});return}n.keys.set(t.record.cwd,{cwd:t.record.cwd,mode:`recorded`,receipt:t})}};for(let e of l)m(e.record.configuredTrustPath,e);m(i.trustPath);for(let e of p.values()){for(let t of[o.project.canonical,i.cwd])e.keys.has(t)||e.keys.set(t,{cwd:t,mode:`inspect`,receipt:l.find(n=>n.record.cwd===t&&n.record.canonicalTrustPath===e.resolved.path)});f.push(en(e,a,d,o.project))}return Qt(f)}function $(e,t){try{return t()}catch(t){throw t instanceof W?t:Error(`Could not access OpenKnowledge's Pi trust ownership records at ${H(O(e,`.ok`,`pi-trust`))}: ${H(t instanceof Error?t.message:String(t))}. Check the records and their permissions, then retry.`,{cause:t})}}function en(e,t,n,r){let{trustPath:i,resolved:a}=e,o=[...e.keys.values()];if(!o.some(e=>e.mode===`recorded`)&&a.kind===`missing`)return{action:`not-present`};if(a.kind===`missing`)try{M(D(a.path))}catch(e){return{action:`failed`,error:`The recorded Pi trust directory ${H(D(a.path))} is unavailable: ${H(e instanceof Error?e.message:String(e))}. Restore access to its parent directory or mounted drive, then retry; the ownership record was kept.`}}let s=[],c={result:{action:`not-present`}};try{It(i,a.path,()=>{let e=Ht(r);if(e){c.result={action:`kept-unverified`,error:e};return}let l=Kt(i,a);if(l.kind===`refused`){c.result={action:`refused-unreadable`,error:l.error};return}let u=Wt(l,r.canonical);if(u.state===`unreadable`){c.result={action:`refused-unreadable`,error:Z(i,u.reason).error};return}let d=o.map(e=>({cwd:e.cwd,mode:e.mode,expectedConfiguredPath:e.receipt?.record.configuredTrustPath,receipt:$(t,()=>q(t,e.cwd).find(e=>e.record.canonicalTrustPath===l.path))}));if(d.some(e=>e.receipt&&e.receipt.record.configuredTrustPath!==e.expectedConfiguredPath)){c.result={action:`failed`,error:`The Pi trust ownership record changed during cleanup; retry to read its current location.`};return}for(let e of d){try{tn(e,t,i,l.path,u,n,r,c)}catch(t){let n=H(t instanceof Error?t.message:String(t)),r=t instanceof W?``:`; retry to check its current state.`;s.push({action:`failed`,error:`Pi trust entry ${H(JSON.stringify(e.cwd))} in ${H(i)} could not be reconciled: ${n}${r}`})}s.push(c.result),c.result={action:`not-present`}}})}catch(e){s.push({action:`failed`,error:H(e instanceof Error?e.message:String(e))})}return Qt([...s,c.result])}function tn(e,t,n,r,i,a,o,s){let{cwd:c,receipt:l}=e;if(i.entries[c]!==!0){l&&e.mode===`recorded`&&$(t,()=>J(t,l)),s.result={action:`not-present`};return}let u=`To remove this grant manually, close Pi and remove only the ${H(JSON.stringify(c))} entry from ${H(n)}; parent-folder and global trust settings still apply.`;if(a.length>0&&c===o.canonical){let n=`kept Pi's folder trust because other resources still need it: ${a.slice(0,3).map(e=>H(JSON.stringify(e))).join(`, `)}${a.length>3?` (+${a.length-3} more)`:``}. ${u} Removing this grant may stop Pi from loading those resources, including any not listed here.`;s.result={action:`kept-shared`,detail:n},l&&e.mode===`recorded`&&$(t,()=>J(t,l)),s.result={action:`kept-shared`,detail:`${n} ${l?e.mode===`recorded`?`OpenKnowledge has relinquished this grant and will not revoke it on later cleanup runs.`:`OpenKnowledge kept the existing ownership record; cleanup of its recorded location remains incomplete.`:`OpenKnowledge has no ownership record for this grant and will not revoke it on later cleanup runs.`}`};return}if(e.mode===`inspect`||!l||l.record.state===`pending`){let e=l?l.record.state===`pending`?`its ownership record is pending after an interrupted setup; completion cannot be verified. Re-running setup or cleanup does not reconcile this record while the folder remains trusted.`:`OpenKnowledge must reconcile its recorded location at ${H(l.record.configuredTrustPath)} before removing it.`:`no OpenKnowledge ownership record exists; this includes every grant made before ownership recording was introduced.`;s.result={action:`kept-unowned`,detail:`${c===o.canonical?`kept Pi's folder trust because ${e}`:`kept a Pi trust entry under a non-canonical project path because ${e} Pi uses the real project directory instead of this key.`} ${u}`};return}let d={...i.entries};l.record.previous.present?d[c]=l.record.previous.value:delete d[c];let f=JSON.stringify(d,null,2)+(i.trailingNewline?`
|
|
9
|
-
`:``),p=C(r);x(r,f,p===void 0?void 0:{mode:p}),i.entries=d,$(t,()=>J(t,l)),s.result={action:`removed`}}function nn(e){return T(e)||pe(e)||se(e)}const rn=10485760;function an(e,t,n,r=!1){let i=$t(e,t,n,{recordedOnly:r});switch(i.action){case`removed`:case`not-present`:return{trust:i.action};case`kept-shared`:case`kept-unowned`:return{trust:i.action,trustDetail:i.detail};case`failed`:case`refused-unreadable`:case`kept-unverified`:{let e=r?`Trust cleanup remains incomplete`:`The bridge file was left untouched`;throw Error(`Pi trust cleanup failed (${i.action}):\n${i.error}\n${e} so cleanup can be retried.`)}default:throw Error(`unhandled Pi trust cleanup result: ${i}`)}}function on(e,t,n,r){if(e.id!==`pi`)return{kind:`not-present`};let i=an(t,n,r,!0);return i.trust===`not-present`?{kind:`not-present`}:{kind:`removed`,...i}}function sn(e,t,n,r,i){let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=Te(a);if(o.kind===`not-present`)return on(e,t,n,i);if(o.kind===`declined`)return o;let s=ve(e,t,n,o.path);if(s.kind===`absent`||s.kind===`no-entry`)return on(e,t,n,i);if(s.kind===`decline`)return{kind:`declined`,reason:s.reason};if(!nn(s.entry))return{kind:`left-foreign`};let c=e.serverName(t);if(e.format===`file`){let e=an(t,n,i);try{Ae(a,{force:!0})}catch(t){throw e.trustDetail?Error(`${t instanceof Error?t.message:String(t)}\n${e.trustDetail}`,{cause:t}):t}return{kind:`removed`,...e}}return e.format===`toml`?un(o.path,c):e.format===`yaml`?ln(o.path,e.topLevelKey,c):cn(o.path,e.topLevelKey,e.serverMapSubKey,c)}function cn(e,t,n,r){let i;try{i=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:S(e)}}if(Buffer.byteLength(i,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=re(i,be(t,n,r));return o?(x(e,a,{mode:C(e)}),{kind:`removed`}):{kind:`not-present`}}function ln(e,t,n){let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:S(e)}}if(Buffer.byteLength(r,`utf-8`)>rn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,Le.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=he(a);a.trim()===``||a.endsWith(`
|
|
10
|
-
`)?c.endsWith(`
|
|
11
|
-
`)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
|
|
12
|
-
`).replace(/\n/g,`\r
|
|
13
|
-
`));let u=`${i?``:``}${c}`;return u!==r&&x(e,u,{mode:C(e)}),{kind:`removed`}}function un(e,t){let n=de();if(n.backend===`fallback`)return{kind:`declined`,reason:`no-native-writer`};let r;try{r=N(e,`utf-8`)}catch(e){return{kind:`declined`,reason:S(e)}}let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=he(a),s=a.trim()===``||a.endsWith(`
|
|
14
|
-
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
15
|
-
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
16
|
-
`).replace(/\n/g,`\r
|
|
17
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&x(e,u,{mode:C(e)}),{kind:`removed`}}function dn(e,t){let n=c[e];return n===null?null:O(t,...n.split(`/`),y.discovery,`SKILL.md`)}function fn(e,t){let n=dn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!m(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=b(`discovery`,{checkDesktop:!0});return ae(D(n),t),{editorId:e,label:e,action:oe(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function pn(e){return j(O(e,...`.agents/skills`.split(`/`),y.discovery))?!0:r.some(t=>{let n=dn(t,e);return n!==null&&j(D(n))})}function mn(e,t){let n=dn(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=D(n);try{return j(n)?(ae(r,t),Ae(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function hn(e){return e===`opencode`?ce:_e}function gn(e,t,n){let r=w[e],i=hn(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=fe(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}function _n(e,t,n=[]){let r=j(O(e,y[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function vn(e,t){let n=ie.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=l.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:i}));return[...n,...r]}function yn(e,t,n,r){let i=v(e,vn(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function bn(e,t){let n=(t??L()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function xn(e,t){let n=w[e];return Se(n,``,t)&&!ue(n,``,t)}function Sn(e,t,n,r,i){let a=w[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?bn(o,r):void 0,c=ve(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&xn(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];T(r)&&i.push(`reclaim-permissive`),pe(r)&&i.push(`pre-approval-exact`),hn(e)(r)&&i.push(`injection-functional`);let o=ne(a,n);return i.length>0&&(o!==null&&ye(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:ge(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function Cn(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=o(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:_n(O(n,i),`discovery`,yn(n,c,e.agent,`global`));let s=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=c[s];return e===null||n===void 0?null:m(n).some(e=>e.editorId===s)?_n(O(n,e),`discovery`,yn(n,c,s,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=a[s];return e===null?null:_n(O(t,e),`project`,yn(t,a,s,`project`))}case`editor-user-config`:return Sn(s,e.strictness,t,n);case`editor-project-config`:{let r=f[s];return r===null?null:Sn(s,e.strictness,t,n,O(t,r))}}}}export{We as _,fn as a,ze as b,qt as c,ot as d,st as f,Je as g,$e as h,pn as i,et as l,Qe as m,gn as n,sn as o,ct as p,mn as r,Yt as s,Cn as t,tt as u,Ke as v,Ve as x,qe as y};
|
package/dist/src-DZ44CKon.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-BWyJhS5F.mjs";import"./init-H4L4PCDm.mjs";import"./registry-probes-DCe3rWZ7.mjs";import"./src-7sNhM-_B.mjs";import"./start-DYrDwaUD.mjs";import{n as e}from"./loader-gbJWrT9X.mjs";import"./preview-CMgnC4UA.mjs";import"./cli.mjs";import"./repair-mcp-configs-B2IwckuL.mjs";export{e as loadConfig};
|
package/dist/start-DaOK3zKh.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-DYrDwaUD.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
File without changes
|