@inkeep/open-knowledge 0.88.12-beta.0 → 0.88.12
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-CHOXNBzz.mjs → cli-CfWjK1ym.mjs} +57 -57
- package/dist/cli.mjs +1 -1
- package/dist/config-schema.json +0 -25
- package/dist/config.user.schema.json +0 -25
- package/dist/constants-mS0PdPwD.mjs +1 -0
- package/dist/dist-By4Q8HCV.mjs +2227 -0
- package/dist/dist-Ttulen40.mjs +1 -0
- package/dist/index.d.mts +0 -3
- package/dist/index.mjs +245 -343
- package/dist/{init-D7ht1hAb.mjs → init-BSw-61hy.mjs} +8 -8
- package/dist/init-DJaf3PYS.mjs +1 -0
- package/dist/{launch-json-removal-FsYm5bTy.mjs → launch-json-removal-BK6LlndC.mjs} +1 -1
- package/dist/{loader-txqXuZkh.mjs → loader-By5YZXpa.mjs} +1 -1
- package/dist/loader-DElTEkt_.mjs +1 -0
- package/dist/{lzma-Ciwelb1t.mjs → lzma-B6QS2aZK.mjs} +2 -2
- package/dist/{md-manager-BGnqyqi1-DCCfgLfC.mjs → md-manager-BGnqyqi1-B5Gyjk_N.mjs} +143 -142
- package/dist/{open-browser-Bb2-wy79.mjs → open-browser-kL892VYi.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-Dpv-rYA5.mjs → preview-BD_1OoUq.mjs} +1 -1
- package/dist/preview-BJYi7yUi.mjs +1 -0
- package/dist/public/assets/{AccountSection-Duudie77.js → AccountSection-B8ISmC61.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-BFhSaloX.js → ActivityModeContent-Da8d4Pw_.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-GAQfaIq7.js → AddPropertiesButton-GHwogTgD.js} +1 -1
- package/dist/public/assets/{AgentConnectionsSection-DYtfZ4WI.js → AgentConnectionsSection-C4coYzmt.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-BnXkJkLz.js → AgentDiffPane-D_NqZYXa.js} +1 -1
- package/dist/public/assets/{AgentIconCluster-B9rTFji5.js → AgentIconCluster-6RCoigPZ.js} +1 -1
- package/dist/public/assets/AppMenubar-DZbYKPxT.js +1 -0
- package/dist/public/assets/{AttachmentsSection-H2HNwBzb.js → AttachmentsSection-CBUQjLvV.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-o8i3gLwL.js → CodeMirrorPropInput-CPRRmBkJ.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-a1UGdVsB.js → ContentRulesSection-CmZHvXvb.js} +1 -1
- package/dist/public/assets/{DocumentContext-DqUuPSJl.js → DocumentContext-BKoh5zZq.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-Cxfu8vc1.js → EditorModeToggle-BWiwJofe.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BSFJkNBJ.js → ExcalidrawDocEditor-D4r0IaYE.js} +1 -1
- package/dist/public/assets/FeedbackForm-Dn_eq77_.js +1 -0
- package/dist/public/assets/{GraphPanel-HRPYLSN9.js → GraphPanel-DBwMPvu9.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-Bmn1unrq.js → ImportSkillDialog-CCuiGAWL.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-DrHVesDA.js → LinkPreviewsSection-BpSTXHQd.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-CH0JB3FB.js → LintConfigEditor-C8Zrekgq.js} +1 -1
- package/dist/public/assets/{LintingSection-CnZdwesC.js → LintingSection-Czqug2mL.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-BPI-_chz.js → ManagedArtifactProperties-BQZJIbCZ.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DzEOvtda.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-BpxupGz-.js → MermaidDocEditor-1Vww-7BG.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-D-Rln6zh.js → NetworkAccessSection-B9Nt3yhN.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuItem-N6xIhi4p.js → OpenInAgentMenuItem-D0YuEr4G.js} +1 -1
- package/dist/public/assets/{ProjectTemplatesSection-CjX7q09w.js → ProjectTemplatesSection-BGHJfURv.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-Kh_HFzCs.js → PropertyDisplayRow-Dd4PTg43.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-DSLDhsry.js → PublishToGitHubDialog-D-mMG2oj.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-ksF-0806.js → SchemaConfigEditor-C4TB3Onn.js} +1 -1
- package/dist/public/assets/{SearchSection-B0BR_xQy.js → SearchSection-DtepUbSd.js} +1 -1
- package/dist/public/assets/{SessionsHost-CWOp3w3X.js → SessionsHost-D9WJzh7y.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BS4WQcpY.js → SettingsDialogBody-CHzfbT0j.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-DGv07ytG.js → ShareReceiveMissDialog-klM8X0JD.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-CpsFAIPJ.js → SkillInstallMenu-B45UDmOd.js} +1 -1
- package/dist/public/assets/{SkillPluginBundleDialog-CingGivw.js → SkillPluginBundleDialog-26H_hV9A.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-USvBm9UK.js → SkillToolbarControls-CDG-Ns7O.js} +1 -1
- package/dist/public/assets/{SkillsManagerSection-1FLLRX0x.js → SkillsManagerSection-BMAj32UM.js} +1 -1
- package/dist/public/assets/{SourceEditor-BgFJdC3x.js → SourceEditor-CN1q4kL6.js} +1 -1
- package/dist/public/assets/{SpellingSettings-CDk5F0uz.js → SpellingSettings-BnekUXi0.js} +1 -1
- package/dist/public/assets/{SyncSection-_5olS0th.js → SyncSection-DHbLCTly.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-Ba3iUAco.js → SyncStatusBadge-C-SximYs.js} +1 -1
- package/dist/public/assets/{TemplateRow-Cs_8LNHD.js → TemplateRow-CHung0e5.js} +1 -1
- package/dist/public/assets/{TerminalLaunchContext-BiKZKemG.js → TerminalLaunchContext-B-4BsXHi.js} +1 -1
- package/dist/public/assets/{TerminalPanel-BZDwVc-Y.js → TerminalPanel-DEeIEH1K.js} +1 -1
- package/dist/public/assets/{TerminalSection-EfwpofBq.js → TerminalSection-CYLWKi_8.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CYc01P_j.js → TerminalWindowApp-D4BpK4rs.js} +1 -1
- package/dist/public/assets/{TextDocEditor-DXAWUTX-.js → TextDocEditor-BmvFCTwu.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-DSJaRBB-.js → ThemePluginSection-htJshVsF.js} +1 -1
- package/dist/public/assets/{ThreadView-C5yxNlst.js → ThreadView-0O42FKbZ.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DlmD2E-E.js → TimelineDiffPane-BpWLh_76.js} +1 -1
- package/dist/public/assets/{agent-connections-DofjYVxj.js → agent-connections-3h0-CznI.js} +1 -1
- package/dist/public/assets/{client-version-Bf2iRqGU.js → client-version-CfYIPv8m.js} +1 -1
- package/dist/public/assets/{comment-chips-DnVeee4D.js → comment-chips-Dp42V9cR.js} +1 -1
- package/dist/public/assets/config-provider-DX7dmJxA.js +4 -0
- package/dist/public/assets/config-schema-BFeDYLCd.js +1 -0
- package/dist/public/assets/context-menu-D6QSuT0b.js +1 -0
- package/dist/public/assets/{doc-undo-manager-B4DcQrQB.js → doc-undo-manager-B7LFEuAG.js} +1 -1
- package/dist/public/assets/dropdown-menu-5XqyQTVx.js +1 -0
- package/dist/public/assets/field-controls-lq4qcuvr.js +1 -0
- package/dist/public/assets/{field-controls-pq-AYiCQ.js → field-controls-uK27_e3u.js} +1 -1
- package/dist/public/assets/globals-LvHcnSk0.css +1 -0
- package/dist/public/assets/{index-7PTB0URg.js → index-Bl4Bu-9G.js} +107 -107
- package/dist/public/assets/{lint-config-client-CZ22hfd5.js → lint-config-client-D7WzQSDg.js} +1 -1
- package/dist/public/assets/{lint-plugins-Cf5g-Z--.js → lint-plugins-CTVrugZN.js} +1 -1
- package/dist/public/assets/{markdown-lint-D13AGXjm.js → markdown-lint-DwFRnZJ_.js} +2 -2
- package/dist/public/assets/{markdownlint-rule-browser-BIpAh6PU.js → markdownlint-rule-browser-DBy2EH_P.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-CrBdBGbd.js → pending-receive-nav-store-Bar3sGpE.js} +1 -1
- package/dist/public/assets/{preferred-session-events-CVoAUx8-.js → preferred-session-events-BwbAHIwl.js} +1 -1
- package/dist/public/assets/{progress-C1W-tvDC.js → progress-vp8dAYq8.js} +1 -1
- package/dist/public/assets/saved-themes-client-DX5dCXi5.js +1 -0
- package/dist/public/assets/{schema-section-Bn1HnUE0.js → schema-section-Cp00yQR2.js} +1 -1
- package/dist/public/assets/{select-BsDvTs6I.js → select-Bx_fIuqY.js} +1 -1
- package/dist/public/assets/{selection-context-CEEtGLdd.js → selection-context-BkNNdwZo.js} +1 -1
- package/dist/public/assets/{src-BjC5FSTO.js → src-DpR2KWk7.js} +1 -1
- package/dist/public/assets/{tabs-C958Luf9.js → tabs-BmABRF8o.js} +1 -1
- package/dist/public/assets/{tag-pill-input-DNcSO6rN.js → tag-pill-input-B6OegoPJ.js} +1 -1
- package/dist/public/assets/{telemetry-impl-Ccc0F1pQ.js → telemetry-impl-VcoKkyoe.js} +1 -1
- package/dist/public/assets/{telemetry-startup-BoeKP8Zc.js → telemetry-startup-Ct-Ggaf_.js} +1 -1
- package/dist/public/assets/toggle-group-B7p69Qfd.js +1 -0
- package/dist/public/assets/{typing-burst-detector-Br5ssjBk.js → typing-burst-detector-CfcUMy65.js} +1 -1
- package/dist/public/assets/{uninstall-SVMQWWzy.js → uninstall-BRba0hi_.js} +1 -1
- package/dist/public/assets/{use-activity-panel-C0CGEm7W.js → use-activity-panel-BICf-aDx.js} +1 -1
- package/dist/public/assets/{use-open-skill-Br25_0Zs.js → use-open-skill-CF2Tc73x.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-B5u6V0Yi.js → use-terminal-enabled-NNs5m9F6.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-C3GRFvG6.js → use-timeline-entry-diff-CTTA8NII.js} +1 -1
- package/dist/public/index.html +35 -35
- package/dist/public/uninstall.html +3 -3
- package/dist/{registry-probes-D3TQ7oxm.mjs → registry-probes-B_znYoKV.mjs} +2 -2
- package/dist/{removal-file-path-C743cSZA.mjs → removal-file-path-SJD59h2s.mjs} +1 -1
- package/dist/{repair-launch-json-C_3EMufn.mjs → repair-launch-json-strY7zZu.mjs} +1 -1
- package/dist/{repair-mcp-configs-B0FADin9.mjs → repair-mcp-configs-DI0oY4QB.mjs} +1 -1
- package/dist/schemas/v0/config.user.schema.json +0 -25
- package/dist/src-3BiP_zs6.mjs +16 -0
- package/dist/src-DGiVUSy2.mjs +1 -0
- package/dist/start-Bjt8sGOE.mjs +1 -0
- package/dist/{start-B0AH-f5N.mjs → start-CrxINPHY.mjs} +3 -3
- package/dist/{tar-MZQD7NO4-D-JBnhvQ.mjs → tar-MZQD7NO4-ljX84Spn.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-DyVp9M0Z.mjs +0 -1
- package/dist/dist-BSNy29T3.mjs +0 -2326
- package/dist/dist-Bfg_JABr.mjs +0 -1
- package/dist/init-DwPDs2bS.mjs +0 -1
- package/dist/loader-Btt-HfCX.mjs +0 -1
- package/dist/preview-uebUIBVB.mjs +0 -1
- package/dist/public/assets/AppMenubar-DTwFx6E3.js +0 -1
- package/dist/public/assets/FeedbackForm-OQoJz7rc.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-DiuSEg5U.js +0 -1
- package/dist/public/assets/config-provider-f9PDyLDl.js +0 -4
- package/dist/public/assets/config-schema-DM88r6Wp.js +0 -1
- package/dist/public/assets/context-menu-DFxnhV9i.js +0 -1
- package/dist/public/assets/dropdown-menu-DH6UNmuX.js +0 -1
- package/dist/public/assets/field-controls-C_LUFJDr.js +0 -1
- package/dist/public/assets/globals-m_KFV1Tp.css +0 -1
- package/dist/public/assets/saved-themes-client-B4QZmuf_.js +0 -1
- package/dist/public/assets/toggle-group-aEGkM0EG.js +0 -1
- package/dist/src-5bKhSF8L.mjs +0 -1
- package/dist/src-Cn5ytgj-.mjs +0 -16
- package/dist/start-COZO7HSH.mjs +0 -1
- /package/dist/public/assets/{globals-B0TGTCQa.js → globals-C_rdkif1.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{s as r}from"./constants-upload-DZP-sCdl.js";import{S as i,a,d as o,f as s,g as c,i as l,p as u,t as d,u as f,v as p,x as m,y as h}from"./schemas-CxFhJLAM.js";import{c as g,l as _,u as v}from"./share-D-LUU2aX-rZ2lBHef.js";import{r as y}from"./_envelope-DuFpUEag-Beu481Zb.js";import{Ct as ee,F as b,I as x,L as S,M as C,Mt as w,N as T,P as E,Tt as D,j as O,wt as te}from"./schemas-api-WgoIuF0H.js";import{t as k}from"./doc-extensions-CcO7K8uD-DG9uHV54.js";import{t as ne}from"./constants-github-B7yhDvQc.js";import{_ as re,g as A,h as j,y as ie}from"./use-apply-config-color-theme-CTtLraO9.js";import{u as ae}from"./use-apply-config-language-9fLQZCsK.js";var M=Symbol.for(`@inkeep/open-knowledge/field-registry`),N=globalThis;N[M]===void 0&&(N[M]=i());var P=N[M];function oe(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=se(t)?P.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function se(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}var ce=[`markdownlint`,`frontmatter`,`okf`],le=[`missing`,`invalid`];function ue(e){return e.frontmatterScope!==void 0}[...ce];var de=[`off`,`warning`,`error`],F=`warning`,fe=[`error`,`warning`];function pe(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&(w(e.getIn(r,!0))||e.deleteIn(r))}}function me(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){pe(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}pe(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function I(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var L={provider:d(ne).register(P,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Declares that this git host is a GitHub Enterprise Server instance, so OpenKnowledge treats its remotes the way it treats github.com (OpenKnowledge credential handling, the push-permission check, share links, and the default host for `ok auth`). 'github' is the only accepted value today. A host that is not declared here and is not github.com is treated as a generic git remote, so OpenKnowledge leaves the machine's own git credentials alone and does not check push permission. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. The declaration takes effect when OpenKnowledge next starts."})},he=Object.fromEntries(Object.entries(L).map(([e,t])=>[e,t.optional().catch(void 0)])),ge=Object.fromEntries(Object.entries(L).map(([e,t])=>[e,t.nullish()])),_e=o(he).catch({});c(p(),o(L).partial());var ve=o({git:o({hosts:c(p(),o(ge).nullish()).nullish()}).nullish()});function ye(e){let t=ve.safeParse(e);return t.success?null:{code:`SCHEMA_INVALID`,issues:t.error.issues.map(I)}}var be=u({prefix:p().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,{message:`prefix must start with a letter and use only letters, digits, _ and -`}),url:p().regex(/^https?:\/\/[^\s<>]*<num>[^\s<>]*$/,{message:`url must be an http or https URL containing <num>`})});l(be);var xe=be.nullable().catch(null),Se=p().refine(e=>{try{let t=new URL(e);return t.protocol===`https:`&&t.origin===e&&!t.hostname.includes(`*`)}catch{return!1}},`Expected a canonical credential-free HTTPS origin: lowercase hostname, no default port, trailing slash, path, query, fragment or wildcard`),Ce=l(Se),we=Se.nullable().catch(null),Te=o({skills:o({trustedPrivateOrigins:Ce.nullish()}).nullish()});function Ee(e){let t=Te.safeParse(e);return t.success?null:{code:`SCHEMA_INVALID`,issues:t.error.issues.map(I)}}function De(){return Object.fromEntries(ee.map(e=>[e,p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${te[e]}, as a #rrggbb hex string.`}).optional()]))}function Oe(){return re.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var R=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),z=52428800,B=26214400,ke=12582912,V=`https://api.openai.com/v1`,H=`text-embedding-3-small`,U=96e3,W=3e4,Ae=2048,je=16384e3,Me=6e5,G=Object.freeze([`127.0.0.1`]),Ne=/^[1-9]\d*(s|m|h)$/,Pe=/^https?:\/\//,Fe=24550;function Ie(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function Le(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&Ie(e)?null:`insecure-scheme`}function K(e){let t=e.trim();return t===``?r:t}function Re(e){let t=K(e);return t===`.`?`/`:t.startsWith(`./`)||t.startsWith(`/`)?t:`/${t}`}var ze=[`filename`],Be=/\{\{([^{}\n]+?)\}\}/g;function Ve(e){return ze.includes(e)}function q(e){let t=[],n=0;for(let r of e.matchAll(Be)){let i=r.index;i>n&&t.push({kind:`text`,text:e.slice(n,i),start:n});let a=(r[1]??``).trim();t.push(Ve(a)?{kind:`variable`,text:r[0],start:i,name:a}:{kind:`unknown-variable`,text:r[0],start:i,name:a}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n),start:n}),t}function He(e){return e.filter(e=>e.kind===`variable`).length}function Ue(e){let t=q(e),n=t.flatMap(e=>e.kind===`unknown-variable`?[e.text]:[]);return n.length>0?{kind:`unknown-variable`,variables:n}:t.some(e=>e.kind===`text`&&(e.text.includes(`{{`)||e.text.includes(`}}`)))?{kind:`unclosed-braces`}:e.split(`/`).some(e=>He(q(e))>1)?{kind:`repeated-variable`}:null}function We(e,t){return q(e).map(e=>e.kind===`variable`?t[e.name]:e.text).join(``)}function Ge(e){let t=e.toLowerCase(),n=k.find(e=>t.endsWith(e));return n?e.slice(0,-n.length):``}function Ke(e,t){let n=t.lastIndexOf(`/`),r=n===-1?``:t.slice(0,n),i=Ge(t.slice(n+1)),a=K(e),o=We(i===``&&He(q(a))>0?`./`:a,{filename:i}),s=o.startsWith(`./`),c=s?o.slice(2):o;return[...s?[r]:[],...c.split(`/`)].filter(e=>e!==``&&e!==`.`).join(`/`)}var qe=`must not contain '..' segments, NUL bytes, backslashes, or drive letters`;function Je(e){let t=K(e);if(t.includes(`\0`)||t.includes(`\\`))return!1;let n=t.split(`/`),r=n.find(e=>e!==``&&e!==`.`);return!(r!==void 0&&/^[A-Za-z]:/.test(r)||n.some(e=>e===`..`))}var Ye=/[<>:"\\|?*]/;function J(e){return{params:e}}function Xe(e){return q(e).some(e=>e.kind===`text`&&/[{}]/.test(e.text))}var Ze=p().refine(e=>e.trim()!==``,J({kind:`empty`})).refine(e=>!Ye.test(e),J({kind:`reserved-character`})).refine(Je,J({kind:`outside-project`})).refine(e=>e===e.trim(),J({kind:`surrounding-space`})).refine(e=>e.startsWith(`./`)||e.startsWith(`/`),J({kind:`missing-prefix`})).refine(e=>!e.includes(`//`),J({kind:`empty-folder-name`})).refine(e=>e===`./`||e===`/`||!e.endsWith(`/`),J({kind:`trailing-slash`})).superRefine((e,t)=>{let n=Ue(e);n&&t.addIssue({code:`custom`,params:n})}).refine(e=>!Xe(e),J({kind:`single-brace`})),Qe={empty:!0,"outside-project":!0,"reserved-character":!0,"surrounding-space":!0,"missing-prefix":!0,"empty-folder-name":!0,"trailing-slash":!0,"single-brace":!0,"unknown-variable":!0,"unclosed-braces":!0,"repeated-variable":!0};function $e(e){if(typeof e!=`object`||!e||!(`kind`in e))return!1;let{kind:t}=e;return typeof t!=`string`||!Object.hasOwn(Qe,t)?!1:t!==`unknown-variable`||`variables`in e&&Array.isArray(e.variables)}function et(e){let t=Ze.safeParse(e);if(t.success)return null;let[n]=t.error.issues,r=n?.code===`custom`?n.params:void 0;if($e(r))return r;throw Error(`Attachment folder path check failed without a known problem kind: ${n?.message}`)}var tt=o({content:o({dir:p().register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:p().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets, and MCP write assets given a bare file name, are stored. The path must start with './' (relative to the current document) or '/' (relative to the content root): './' colocates beside the current document; './subdir' targets a subfolder next to it; '/' targets the content root; '/folder' targets a fixed folder under the content root. '{{filename}}' expands to the current document's name without its extension, so the default './{{filename}}.assets' keeps each document's files in its own folder. An upload whose parent is not a Markdown document, such as an MCP write asset given a bare file name, ignores {{filename}} and is placed as with './', which for a bare file name is the content root. A bare name such as 'attachments', saved by older versions, is read as '/attachments'. A path with an unknown variable refuses uploads until it is fixed. Whitespace-only values are treated as the default.`}).refine(Je,{message:`Invalid attachment folder path: ${qe}.`}).default(r)}).default({dir:`.`,attachmentFolderPath:r}),appearance:o({theme:d([`light`,`dark`,`system`]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:d([`system`,...ae]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${Oe()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${Oe()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:o({name:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:d([`dark`,`light`]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...De()}).optional(),preview:o({autoOpen:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:o({showHiddenFiles:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillGroups:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Group skills in the sidebar by where they came from — the publisher they were imported from, or the plugin that ships them. Skills you authored stay ungrouped at the top of their scope. Per-machine (project-local) — not shared with collaborators.`}).default(!0),pinnedProjectSkills:l(p()).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Project-scope skills pinned to the top of the Skills sidebar, by name. A pinned skill also keeps its normal row, so a provenance group still lists everything from its source. Per-machine (project-local) — not shared with collaborators.`}).default([]),pinnedGlobalSkills:l(p()).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Global-scope skills pinned to the top of the Skills sidebar, by name. Stored per USER rather than per project, so a pinned global skill follows you into every project.`}).default([])}).optional()}).default({preview:{autoOpen:!0}}),editor:o({wordWrap:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:o({autoApproveOkTools:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools for agents launched from the built-in terminal (plus `ok open` on Claude) and for in-app Agents-panel chats with any ACP agent. Destructive tools (delete/move/share/install/import) still prompt. Per-machine personal preference (user scope)."}).default(!0),browserTools:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Give in-app Claude Code and Codex chats a browser they can drive (Playwright MCP, started through npx from OpenKnowledge's own folder with a fresh in-memory profile), so an agent can open pages, click, and take screenshots. Every browser action asks for approval, with no option to always allow it, unless the agent's own mode or permission settings skip approvals. Needs Google Chrome and Node.js. Off by default; takes effect for chats started after the change. Per-machine personal preference (user scope).`}).default(!1)}).default({autoApproveOkTools:!0,browserTools:!1}),autoSync:o({mode:d(v).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`What this machine syncs on a schedule for this project: 'off' (Manual — nothing scheduled; the manual pull/push actions still work), 'follow' (Auto, pull only — scheduled pulls, never a scheduled push; 'pull' is accepted as a legacy alias), or 'full' (Auto, pull and push — bidirectional). Explicit user-triggered pushes work in every mode. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:d(_).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),pullIntervalSeconds:s().int().min(30).max(g).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pulls while autoSync.mode is follow or full (default 30). Per-machine (project-local) — not shared.`}).optional().catch(void 0),pushIntervalSeconds:s().int().min(30).max(g).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pushes while autoSync.mode is full (default 60). Ignored in every other mode, which never pushes on a schedule. Each cycle with pending edits authors a commit, so a shorter interval means more, smaller commits in the repo's shared history. Per-machine (project-local) — not shared.`}).optional().catch(void 0),default:h([a(),d(v)]).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),skills:o({trustedPrivateOrigins:l(we).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Canonical HTTPS origins allowed to serve website skills from private network addresses. Empty by default: website skills require public addresses. Set only in user global.yml, never project configuration or acquisition requests. Use a lowercase hostname and omit credentials, default port 443, trailing slash, path, query, fragment and wildcards. Include nondefault ports when required. Invalid entries are ignored with located config diagnostics; valid siblings remain approved. TLS certificate and hostname checks still apply.`}).default([]).catch([])}).default({trustedPrivateOrigins:[]}),git:o({hosts:c(p(),_e).register(P,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Per-git-host declarations, keyed by hostname (for example ghes.example.com). Each entry says how OpenKnowledge should treat remotes on that host; today the only key an entry carries is `provider`. Hosts absent from this map are treated as generic git remotes. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. Declarations take effect when OpenKnowledge next starts."}).default({}).catch({})}).default({hosts:{}}),terminal:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null),shell:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Absolute Windows shell executable override for the in-app terminal. PowerShell, cmd.exe, and Git Bash support OpenKnowledge-managed launches (agent chat tabs and fixed commands such as Resolve in terminal or Install Slidev) and dropped-file path insertion. A different existing executable remains usable for plain terminal tabs and shows a capability notice; requested agent and command launches open only the plain shell without running the agent or command, and dropped-file paths are refused. Empty values use automatic shell discovery. Per-machine (project-local), human-managed, and never shared via git, clone, or sync.`}).optional()}).default({enabled:null}),slides:o({enabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:o({localSink:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write per-project diagnostic spans + logs under the user-level OpenKnowledge logs directory for `ok diagnose bundle`. Files stay local unless shared, including in a support bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:o({maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(z)}).default({maxBytes:z}),logs:o({maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(B)}).default({maxBytes:B}),attributeDenylist:l(p()).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...R])}).default({enabled:!0,spans:{maxBytes:z},logs:{maxBytes:B},attributeDenylist:[...R]}),skillInstallReports:o({enabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default off; when it is on, the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables still turn it off.`}).default(!1)}).default({enabled:!1})}).default({localSink:{enabled:!0,spans:{maxBytes:z},logs:{maxBytes:B},attributeDenylist:[...R]},skillInstallReports:{enabled:!1}}),lossCapture:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(ke)}).default({enabled:!0,maxBytes:ke}),bridge:o({backgroundThrottle:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:o({semantic:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (stored in secrets.yml in the OpenKnowledge home folder); it is sent to whichever endpoint this names."}).default(V),model:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(H),dimensions:s().int().positive().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:s().min(0).max(1).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional(),maxBatchSize:s().int().min(1).max(Ae).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Maximum number of text chunks sent in one indexing request (1–2048, default 96). The ceiling follows OpenAI's input-array limit; other providers may impose different limits. Larger requests may still be split by the character budget. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(96).catch(96),maxBatchChars:s().int().min(1).max(je).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Approximate cumulative character budget per indexing request (1–16384000, default 96000). A single chunk can exceed this budget. OpenAI separately caps total input at 300000 tokens per request; this character budget does not enforce that limit, and high values can produce rejected requests. Other providers have their own limits. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(U).catch(U),docTimeoutMs:s().int().min(1).max(Me).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Timeout in milliseconds for each indexing request attempt (1–600000, default 30000). A request can retry four times, and a failed grouped request can trigger individual-document requests. There is no total indexing-pass deadline: large timeouts can delay newly queued work for hours. The query timeout remains 8 seconds per attempt. Changing it preserves cached vectors and applies to the next indexing pass; an in-progress pass keeps its current timeout. Invalid values use the default and are reported by ok config validate and server logs.`}).default(W).catch(W)}).default({enabled:!1,baseUrl:V,model:H,maxBatchSize:96,maxBatchChars:U,docTimeoutMs:W})}).default({semantic:{enabled:!1,baseUrl:V,model:H,maxBatchSize:96,maxBatchChars:U,docTimeoutMs:W}}),contentRules:o({markdownlint:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:l(u({appliesTo:h([p(),l(p())]).optional(),file:p(),enabled:a().optional()})).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:c(p(),a()).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:u({index:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:o({links:d(de).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(F),fileTreeIndicators:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0),suppressLogLinkAdvisories:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether unresolved links in the reserved change-history documents (lowercase-stemmed log.md / log.mdx at any depth, where the extension's case does not matter and the stem's does) are omitted from broken-link advisories: the Problems panel, file-tree indicators, source diagnostics, audits, and agent write/edit results. Default true. Raw link views still show them, and LOG.md, Log.md, and every other stem spelling are ordinary documents.`}).default(!0)}).default({links:F,fileTreeIndicators:!0,suppressLogLinkAdvisories:!0}),autolinks:l(xe).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Turn ticket references into links; today they apply to Agents-panel chat messages. Each entry pairs a `prefix` (for example `PRD-`) with a `url` template containing `<num>` (for example `https://linear.app/inkeep/issue/PRD-<num>`); the prefix followed by digits links to that URL with the digits in place of `<num>`. Matching is case-sensitive. An invalid entry is skipped with a warning and the others still apply. Shared with collaborators (project scope, `.ok/config.yml`)."}).default([]).catch([]),linkPreviews:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor, and a status card when you hover a GitHub pull request or issue link in an agent chat. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata, and hovering a GitHub reference asks the GitHub host's API for it, signed in as you when a GitHub sign-in is available — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),server:o({port:s().int().min(1).max(65535).register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Read at server start; changing it requires a restart.`}).optional(),bind:l(p().min(1)).min(1).register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...G]),externalUrl:m({protocol:/^https?$/}).regex(Pe).register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — its host joins the Host/Origin allowlists (external-Host + CORS admission). Unset by default: the server admits only loopback Hosts. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Read at server start; changing it requires a restart.`}).optional(),allowExternal:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. A non-loopback server.bind without allowExternal: true is refused at boot with a one-line fix; a server.externalUrl without it boots (a committed externalUrl never arms exposure on clones — but it is project-scoped, so its host still joins the Host/Origin allowlists there), but requests carrying forwarding headers (X-Forwarded-For etc.) are refused until consent is given — proxy tolerance requires both keys. Default off. The server has no authentication of its own, so only consent behind an authenticating edge. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:h([f(`off`),p().regex(Ne)]).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' for a loopback-only, unexposed server; 'off' otherwise — a non-loopback bind, or a loopback bind declared externally reachable (server.allowExternal + server.externalUrl), stays up, because a remote agent keeps it busy over /mcp, which the idle timer does not count. Residual case the derivation cannot see: a loopback server reached by remote agents with no server.externalUrl (e.g. behind a same-box reverse proxy) still idles at 30m — set 'off' by hand. Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...G],allowExternal:!1})});function nt(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function rt(e,t){let n=e;for(let e of t){n=nt(n);let t=n?._zod?.def?.shape;if(!t){let e=n?._zod?.def;if(e?.type!==`record`)return;n=e.valueType;continue}if(n=t[String(e)],n===void 0)return}return n}function it(e,t){let n=rt(e,t);if(n!==void 0)return oe(n)}var at=n(),Y=e(t(),1),X=null,Z=new Set;function ot(){return X}function st(e){let t=e!==null&&e.length>0?e:null;if(t!==X){X=t;for(let e of Z)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function ct(e){return Z.add(e),()=>{Z.delete(e)}}function lt(){return(0,Y.useSyncExternalStore)(ct,ot,ot)}function Q(e){return{authoritative:e,themes:A,warnings:[],truncated:!1}}function ut(e){let{scheme:t}=e;return{id:e.id,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function dt(e,t){return{id:e,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function $(e,t,n={}){console.warn(JSON.stringify({event:`ok-saved-theme-request-failed`,action:e,result:t,...n.status===void 0?{}:{status:n.status},...n.error===void 0?{}:{errorName:n.error instanceof Error?n.error.name:`UnknownError`}}))}async function ft(e={}){let t=e.request??globalThis.fetch;try{let n=await t(`/api/saved-themes`,{signal:e.signal});if(!n.ok)return $(`list`,`http-error`,{status:n.status}),Q(!1);let r=S.safeParse(await n.json());if(!r.success)return console.warn(`[themes] saved-themes response failed schema validation`,r.error.issues),Q(!1);let i=[],a=[];for(let e of r.data.themes)e.ok?i.push(ut(e)):a.push({filename:e.filename,id:e.id,code:e.code,...e.conflictingFilenames?{conflictingFilenames:e.conflictingFilenames}:{}});return{authoritative:!0,themes:i.length===0?A:[...A,...i],warnings:a,truncated:r.data.truncated}}catch(t){return e.signal?.aborted||$(`list`,`request-error`,{error:t}),Q(!1)}}function pt(e){switch(e.detail){case`empty`:case`too-long`:case`invalid-chars`:return e.detail;default:return}}async function mt(e,t={}){let n=C.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=T.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=y.safeParse(t);if(!i.success)return{ok:!1,reason:`unexpected`};if(i.data.type===`urn:ok:error:theme-name-taken`)return{ok:!1,reason:`name-taken`};if(i.data.type===`urn:ok:error:theme-name-invalid`){let e=pt(i.data);return e?{ok:!1,reason:`name-invalid`,detail:e}:{ok:!1,reason:`name-invalid`}}return{ok:!1,reason:`unexpected`}}catch(e){return $(`save`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function ht(e,t={}){let n=b.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=x.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=y.safeParse(t);return i.success&&i.data.type===`urn:ok:error:not-found`?{ok:!1,reason:`not-found`}:{ok:!1,reason:`unexpected`}}catch(e){return $(`update`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function gt(e,t={}){if(!ie(e).ok)return{ok:!1,reason:`unexpected`};let n=t.request??globalThis.fetch;try{let t=await n(`/api/saved-theme?${new URLSearchParams({id:e})}`,{method:`DELETE`}),r=await t.json().catch(()=>null);if(!t.ok)return{ok:!1,reason:`unexpected`};let i=O.safeParse(r);if(!i.success)return{ok:!1,reason:`unexpected`};if(!i.data.existed)return{ok:!0,existed:!1};let a=E.safeParse(i.data.scheme);return a.success?{ok:!0,existed:!0,filename:i.data.filename,scheme:a.data}:{ok:!1,reason:`unexpected`}}catch(e){return $(`delete`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}var _t=(0,Y.createContext)(null);function vt(e){let t=(0,at.c)(21),{children:n}=e,r=lt(),[i,a]=(0,Y.useState)(St),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(`custom`),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[0]=g):g=t[0];let _=(0,Y.useRef)(g),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v={},t[1]=v):v=t[1];let[y,ee]=(0,Y.useState)(v),b=(0,Y.useRef)(0),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=0,t=null,n=!1,r=null,i,o=[250,1e3,4e3],c=()=>{i!==void 0&&clearTimeout(i),i=void 0},u=()=>{if(t)return n=!0,t;let i=e,o=(async()=>{let t;do{n=!1;let o=b.current,u=new AbortController;r=u;let{authoritative:d,...f}=await ft({signal:u.signal});if(i!==e)return!1;t=d,d?(c(),o===b.current&&a(f),s(!0),l(!1)):l(!0)}while(n);return t})().finally(()=>{t===o&&(t=null)});return t=o,o};return{refresh:u,startAutomaticRetry:()=>{e+=1;let a=e;r?.abort(),r=null,t=null,n=!1,c();let s=async t=>{let n=await u();a!==e||n||t>=o.length||(i=setTimeout(()=>void s(t+1),o[t]))};return s(0),()=>{a===e&&(e+=1,r?.abort(),r=null,t=null,n=!1,c())}}}},t[2]=x):x=t[2];let[S]=(0,Y.useState)(x),C=S.refresh,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=new Map,t=(t,n)=>{let r=(e.get(t)??Promise.resolve()).then(n,n),i=r.then(xt,bt);return e.set(t,i),i.finally(()=>{e.get(t)===i&&e.delete(t)}),r},n=(e,t,n)=>{b.current+=1;let r=dt(e,t);a(t=>({...t,themes:t.themes.some(t=>t.id===e)?t.themes.map(t=>t.id===e?r:t):[...t.themes,r],warnings:t.warnings.filter(t=>t.id!==e&&(n===void 0||t.filename!==n))}))};return{updateTheme:e=>t(e.id,async()=>{let t=await ht(e);return t.ok&&n(e.id,e.scheme,t.filename),t}),deleteTheme:e=>t(e,async()=>{let t=await gt(e);if(t.ok){let t={..._.current,[e]:(_.current[e]??0)+1};_.current=t,ee(t),b.current+=1,a(t=>({...t,themes:t.themes.filter(t=>t.id!==e),warnings:t.warnings.filter(t=>t.id!==e)}))}return t}),restoreTheme:e=>t(e.id,async()=>{let t=await mt({name:e.name,stem:e.stem,scheme:e.scheme,extension:e.extension});return t.ok&&n(t.id,e.scheme,t.filename),t})}},t[3]=w):w=t[3];let[T]=(0,Y.useState)(w),E;t[4]===S?E=t[5]:(E=()=>S.startAutomaticRetry(),t[4]=S,t[5]=E);let D;t[6]!==S||t[7]!==r?(D=[S,r],t[6]=S,t[7]=r,t[8]=D):D=t[8],(0,Y.useEffect)(E,D);let O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e){if(e===null){p(!1);return}d(e),p(!0),h(yt)},t[9]=O):O=t[9];let te=O,k;return t[10]!==n||t[11]!==i||t[12]!==u||t[13]!==c||t[14]!==o||t[15]!==T||t[16]!==C||t[17]!==f||t[18]!==m||t[19]!==y?(k=(0,Y.createElement)(_t,{value:{...i,loaded:o,loadError:c,refresh:C,...T,editingThemeId:u,themeIncarnations:y,themeEditorOpen:f,themeEditorOpenNonce:m,selectThemeToEdit:te}},n),t[10]=n,t[11]=i,t[12]=u,t[13]=c,t[14]=o,t[15]=T,t[16]=C,t[17]=f,t[18]=m,t[19]=y,t[20]=k):k=t[20],k}function yt(e){return e+1}function bt(){}function xt(){}function St(){return Q(!1)}function Ct(){let e=(0,Y.use)(_t);if(!e)throw Error(`useSavedThemes must be used within <SavedThemesProvider />`);return e}export{oe as A,I as C,le as D,F as E,fe as O,q as S,Ee as T,me as _,it as a,Re as b,tt as c,U as d,H as f,Ae as g,je as h,lt as i,ue as k,V as l,Me as m,Ct as n,rt as o,Fe as p,st as r,ze as s,vt as t,W as u,Ke as v,ye as w,Le as x,et as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{t as r}from"./compiler-runtime-BfE3aGVn.js";import{t as i}from"./utils-CPqDy6Hr.js";import{t as a}from"./dist-BsJYDohW.js";import{c as o,i as s,l as c,o as l}from"./dist-DTFuvKje.js";import{t as u}from"./dist-uiDX6Nr9.js";import{n as d,r as f,t as p}from"./dist-BKgU0kag.js";var m=e(n(),1),h=t(),g=`Toggle`,_=m.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,u]=s({prop:n,onChange:i,defaultProp:r??!1,caller:g});return(0,h.jsx)(c.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:l(e.onClick,()=>{e.disabled||u(!o)})})});_.displayName=g;var v=_,y=`ToggleGroup`,[b,x]=o(y,[f]),S=f(),C=m.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,h.jsx)(E,{...r,ref:t});if(n===`multiple`)return(0,h.jsx)(D,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${y}\``)});C.displayName=y;var[w,T]=b(y),E=m.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,c]=s({prop:n,defaultProp:r??``,onChange:i,caller:y});return(0,h.jsx)(w,{scope:e.__scopeToggleGroup,type:`single`,value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:c,onItemDeactivate:m.useCallback(()=>c(``),[c]),children:(0,h.jsx)(A,{...a,ref:t})})}),D=m.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,c]=s({prop:n,defaultProp:r??[],onChange:i,caller:y}),l=m.useCallback(e=>c((t=[])=>[...t,e]),[c]),u=m.useCallback(e=>c((t=[])=>t.filter(t=>t!==e)),[c]);return(0,h.jsx)(w,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:l,onItemDeactivate:u,children:(0,h.jsx)(A,{...a,ref:t})})});C.displayName=y;var[O,k]=b(y),A=m.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...l}=e,f=S(n),p=u(o),m={role:`group`,dir:p,...l};return(0,h.jsx)(O,{scope:n,rovingFocus:i,disabled:r,children:i?(0,h.jsx)(d,{asChild:!0,...f,orientation:a,dir:p,loop:s,children:(0,h.jsx)(c.div,{...m,ref:t})}):(0,h.jsx)(c.div,{...m,ref:t})})}),j=`ToggleGroupItem`,M=m.forwardRef((e,t)=>{let n=T(j,e.__scopeToggleGroup),r=k(j,e.__scopeToggleGroup),i=S(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=m.useRef(null);return r.rovingFocus?(0,h.jsx)(p,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,h.jsx)(N,{...s,ref:t})}):(0,h.jsx)(N,{...s,ref:t})});M.displayName=j;var N=m.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=T(j,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,h.jsx)(_,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),P=C,F=M,I=r(),L=a(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`,segmented:`text-muted-foreground hover:bg-muted-foreground/10 data-[state=on]:bg-background data-[state=on]:shadow-sm data-[state=on]:text-foreground dark:data-[state=on]:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}});function R(e){let t=(0,I.c)(14),n,r,a,o;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4]):({className:n,variant:a,size:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o);let s=a===void 0?`default`:a,c=o===void 0?`default`:o,l;t[5]!==n||t[6]!==c||t[7]!==s?(l=i(L({variant:s,size:c,className:n})),t[5]=n,t[6]=c,t[7]=s,t[8]=l):l=t[8];let u;return t[9]!==r||t[10]!==c||t[11]!==l||t[12]!==s?(u=(0,h.jsx)(v,{"data-slot":`toggle`,"data-variant":s,"data-size":c,className:l,...r}),t[9]=r,t[10]=c,t[11]=l,t[12]=s,t[13]=u):u=t[13],u}var z=m.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function B(e){let t=(0,I.c)(29),n,r,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7]):({className:r,variant:l,size:o,spacing:s,orientation:c,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l);let u=s===void 0?0:s,d=c===void 0?`horizontal`:c,f;t[8]===u?f=t[9]:(f={"--gap":u},t[8]=u,t[9]=f);let p=f,m;t[10]===r?m=t[11]:(m=i(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,r),t[10]=r,t[11]=m);let g;t[12]!==d||t[13]!==o||t[14]!==u||t[15]!==l?(g={variant:l,size:o,spacing:u,orientation:d},t[12]=d,t[13]=o,t[14]=u,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==n||t[18]!==g?(_=(0,h.jsx)(z.Provider,{value:g,children:n}),t[17]=n,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==d||t[21]!==a||t[22]!==o||t[23]!==u||t[24]!==p||t[25]!==m||t[26]!==_||t[27]!==l?(v=(0,h.jsx)(P,{"data-slot":`toggle-group`,"data-variant":l,"data-size":o,"data-spacing":u,"data-orientation":d,style:p,className:m,...a,children:_}),t[20]=d,t[21]=a,t[22]=o,t[23]=u,t[24]=p,t[25]=m,t[26]=_,t[27]=l,t[28]=v):v=t[28],v}function V(e){let t=(0,I.c)(19),n,r,a,o,s;t[0]===e?(n=t[1],r=t[2],a=t[3],o=t[4],s=t[5]):({className:r,children:n,variant:o,size:s,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=s);let c=o===void 0?`default`:o,l=s===void 0?`default`:s,u=m.use(z),d=u.variant||c,f=u.size||l,p=u.spacing,g;t[6]!==r||t[7]!==u.size||t[8]!==u.variant||t[9]!==l||t[10]!==c?(g=i(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t text-muted-foreground data-[state=on]:text-foreground`,L({variant:u.variant||c,size:u.size||l}),r),t[6]=r,t[7]=u.size,t[8]=u.variant,t[9]=l,t[10]=c,t[11]=g):g=t[11];let _;return t[12]!==n||t[13]!==u.spacing||t[14]!==a||t[15]!==d||t[16]!==f||t[17]!==g?(_=(0,h.jsx)(F,{"data-slot":`toggle-group-item`,"data-variant":d,"data-size":f,"data-spacing":p,className:g,...a,children:n}),t[12]=n,t[13]=u.spacing,t[14]=a,t[15]=d,t[16]=f,t[17]=g,t[18]=_):_=t[18],_}export{V as n,R as r,B as t};
|
package/dist/src-5bKhSF8L.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./md-manager-BGnqyqi1-DCCfgLfC.mjs";import"./src-Cn5ytgj-.mjs";import"./init-D7ht1hAb.mjs";import"./token-store-Bmb3_0hU.mjs";import"./start-B0AH-f5N.mjs";import"./registry-probes-D3TQ7oxm.mjs";import{n as e}from"./loader-txqXuZkh.mjs";import"./preview-Dpv-rYA5.mjs";import"./repair-mcp-configs-B0FADin9.mjs";export{e as loadConfig};
|
package/dist/src-Cn5ytgj-.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-tZXQYakl.mjs";import{C as t,E as n,L as r,M as i,N as a,O as o,S as s,d as c,k as l,x as u}from"./constants-ok-dir-DZ25OS9-.mjs";import{Da as d,G as f,Oa as p,Rl as m,U as h,W as g,l as _,sf as v,u as ee,zl as y}from"./md-manager-BGnqyqi1-DCCfgLfC.mjs";import{$r as b,As as x,Bs as te,Cs as S,Es as C,Hi as w,Ia as T,Is as E,Ls as D,Nt as O,Os as ne,Qt as k,Rs as A,Si as re,Ss as ie,Vo as j,Vs as ae,Wi as M,_a as N,bi as oe,ci as P,fr as se,js as F,ks as ce,m as le,ma as ue,mi as de,nr as I,ta as fe,wi as pe,ws as me,xi as he,xo as ge,xs as _e,zs as ve}from"./dist-BSNy29T3.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-D7ht1hAb.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-D3TQ7oxm.mjs";import{n as Pe}from"./constants-DyVp9M0Z.mjs";import"./loader-txqXuZkh.mjs";import"./preview-Dpv-rYA5.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=>[E(e),e]);for(let t of e){let e=E(t);if(e===null)continue;let r=n.find(([t])=>t===e);if(r!==void 0)return r[1]}}function 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
|
-
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function Gt(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 Kt(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function qt(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function Jt(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Yt(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Xt(e,t){let n=t.indexOf(`
|
|
3
|
-
`);if(n===-1)return null;let r,i;try{r=Yt(JSON.parse(t.slice(0,n))),i=Yt(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=Yt(e);t===null||typeof t.name!=`string`||!It(t.name)||a.push({name:t.name,pid:Jt(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:Jt(t.rpages),lifetimeMaxPages:Jt(t.lifetimeMax)})}let o=Nt(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:Jt(Yt(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?It(i.largestProcess):null,ownedProcesses:a}}const Zt=/^JetsamEvent-.*\.ips$/;function Qt(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 $t(e,t){let n=Gt(`darwin`,`macos-jetsam`,[z(e,`JetsamEvent-*.ips`)]),r;try{r=await ot(e)}catch(e){return Kt(n,e.code??`unknown`)}let i=Qt(await Promise.all(r.filter(e=>Zt.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=Xt(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 qt(n)}const en=[`--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`],tn=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],nn=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,rn=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,an=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function on(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(!an.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
|
-
`)){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 sn(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 cn(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
5
|
-
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=nn.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!Bt.test(s)){n+=1;continue}let c=sn(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function ln(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
6
|
-
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=nn.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=rn.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function un(e,t,n){let r=ln(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await on(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function dn(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function fn(e,t,n){let r=Gt(`linux`,`linux-journal`,[`journalctl ${en.join(` `)}`,`journalctl ${tn.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...en]),e(`journalctl`,[...tn])]),o=[];if(dn(i)){let e=cn(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${Wt(i)}`);if(dn(a)){let e=await un(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${Wt(a)}`);return o.length===2?Kt(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:qt(r)}const pn={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},mn={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function hn(e){return e===`System`?pn:mn}function gn(e){let t=`System[(${Object.keys(hn(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${zt}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${Vt.map(e=>`Data='${e}'`).join(` or `)}]]`}function _n(e){return[`qe`,e,`/q:${gn(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function vn(e){return Le.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function yn(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function bn(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function xn(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>yn(e[1]??``).trim())}function Sn(e,t){let n=hn(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=xn(o,`Data`),u=xn(o,`Name`),d=[...l,...u].some(e=>Bt.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!bn(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function Cn(e,t){let n=vn(t),r=[`System`,`Application`],i=Gt(`win32`,`windows-event-log`,r.map(e=>`${n} ${_n(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,_n(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${Wt(t)}`);continue}let n=Sn(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?Kt(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:qt(i)}async function wn(e={}){let t=e.platform??process.platform,n=e.runCommand??Ht(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return $t(e.macosReportsDir??`/Library/Logs/DiagnosticReports`,r);case`linux`:return fn(n,r,e.desktopLogsDir??z(xe(),`logs`));case`win32`:return Cn(n,e.systemRoot??process.env.SystemRoot);default:return{...Gt(t,null,[]),outcome:`unsupported`}}}const Tn={schemaVersion:1,outcome:`not-collected`};function En(e){return`${JSON.stringify(e??Tn,null,2)}\n`}const Dn={"macos-jetsam":`macOS low-memory reports`,"linux-journal":`system and user journals`,"windows-event-log":`Windows event logs`};function On(e){let t=[`${e.windowDays}d`,`${e.events.length} kept`,`${e.foreignIgnored} other-process record(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&t.push(`${e.droppedOverCap} older dropped over cap`);let n=e.source?` from ${Dn[e.source]}`:``,r=e.unavailableReason?`, ${e.unavailableReason}`:``;return`${e.outcome}${n}${r} (${t.join(`; `)})`}function kn(){return z(xe(),`bug-reports`)}function An(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=kn(),r=`${t}-bugreport`,i=z(n,`${r}.zip`);for(let e=2;H(i);e+=1)i=z(n,`${r}-${e}.zip`);return i}function jn(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function Mn(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let e=W(n,`utf8`).match(/^\s*name:\s*['"]?(.+?)['"]?\s*$/m);if(e?.[1])return e[1]}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml for project slug; using path-hash fallback`)}return H(z(e,`.ok`))?ct(`sha256`).update(B(e)).digest(`hex`).slice(0,12):null}function Nn(){let e={timestamp:new Date().toISOString(),platform:$e(),osType:rt(),osRelease:et(),hostname:`[redacted]`,uptime:it(),freeMem:Ze(),totalMem:nt(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ut(`sw_vers -productVersion 2>/dev/null`,j({encoding:`utf8`})).trim()}catch{}try{let t=z(__dirname,`..`,`..`,`package.json`);H(t)&&(e.okVersion=JSON.parse(W(t,`utf8`)).version)}catch{}return e}const Pn=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Fn(e){let t=L(e);return Pn.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function In(e,t){return Vn(e,t).files}const Ln=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Rn(e,t=Ne){let n=z(e,`${t}.ShipIt`);if(!H(n))return[];let r;try{r=G(n)}catch{return[]}return Ln.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).map(e=>{let t=z(n,e.entry);return{path:t,suffix:e.suffix,mtimeMs:zn(t)}}).sort((e,t)=>t.mtimeMs-e.mtimeMs||t.suffix-e.suffix).slice(0,4).map(e=>e.path))}function zn(e){try{return Ye(e).mtimeMs}catch{return 0}}function Bn(e){if(!H(e))return[];try{let t=new Map;for(let n of G(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-_.length):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>z(e,t))}catch{return[]}}function Vn(e,t){if(!H(t))return{files:[],excludedByProjectSlug:0};let n=G(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>z(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Fn),i=[],a=r.filter(t=>{try{return W(t,`utf8`).includes(`"project":"${e}"`)}catch{return i.push(t),!1}});if(a.length===0)return{files:n,excludedByProjectSlug:0};let o=new Set([...a,...i]);return{files:n.filter(e=>!Fn(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Hn(e){let t=z(e,`.ok`,`local`);return H(t)?{files:[`server.lock`,ve,D].map(e=>z(t,e)).filter(e=>H(e))}:{files:[]}}function Un(e,t,n){let r=C(e),i=[],a=[];for(let e of t){let t=z(r,e),o=z(n,e),s=H(t);s&&i.push(t),H(o)&&(s?a:i).push(o)}return{files:i,legacyFiles:a}}function Wn(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${ct(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function Gn(e){let t=e.revealDocNames?e.content:Wn(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=p(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function J(e){for(let t of e.files)try{let n=W(t,`utf8`);Gn({zipfile:e.zipfile,name:`${e.prefix}/${L(t)}`,content:t.endsWith(`.ips`)?jt(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function Kn(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??z(xe(),`logs`),s=t.projectDir?Mn(t.projectDir,i):null;U(R(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let l=Nn();l.desktop=t.desktop??null,l.language=t.language??null;let{files:u,excludedByProjectSlug:f}=Vn(s,o),{files:p}=t.projectDir?Hn(t.projectDir):{files:[]},{files:m,legacyFiles:h}=t.projectDir?Un(t.projectDir,[A.logsCurrent,A.logsPrevious],z(t.projectDir,`.ok`,`local`,`logs`)):{files:[],legacyFiles:[]},{files:g,legacyFiles:_}=t.projectDir?Un(t.projectDir,[ae],z(t.projectDir,`.ok`,`local`)):{files:[],legacyFiles:[]},v=t.shipItLogFiles??[],y=t.diagnosticReports?.files??[];i?.info({logFileCount:u.length,logFilesExcludedByProjectSlug:f,lockFileCount:p.length+g.length+_.length,localSinkFileCount:m.length+h.length,shipItLogFileCount:v.length,diagnosticReportCount:y.length},`files collected`);let b=[],x=[],{ZipFile:te}=await import(`./yazl-BsCX6KWo.mjs`).then(t=>e(t.default,1)),S=new te;J({zipfile:S,files:[...u,...v],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:[...p,...g],prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:m,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:h,prefix:`legacy/local-logs`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:_,prefix:`legacy/lockdir`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:t.bugReportLedgerFiles??[],prefix:ee,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i}),J({zipfile:S,files:y,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:x,redactions:b,logger:i});for(let e of t.extraFiles??[])try{let t=W(e.sourcePath),n=`extra/${e.zipName??L(e.sourcePath)}`;S.addBuffer(t,n),x.push(n);let r=jn(e,n);r!==null&&b.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Gn({zipfile:S,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:x,redactions:b});let C=new Set(y.map(e=>`diagnostic-reports/${L(e)}`)),w=x.filter(e=>C.has(e)),T=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:Dt(t.diagnosticReports,w.length);S.addBuffer(Buffer.from(`${T}\n`,`utf8`),`state/diagnostic-reports-status.txt`),x.push(`state/diagnostic-reports-status.txt`),Gn({zipfile:S,name:Rt,content:En(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:x,redactions:b});let E=JSON.stringify(l,null,2);S.addBuffer(Buffer.from(E,`utf8`),`sysinfo.json`),x.push(`sysinfo.json`);let D={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:x,redactions:b,sysinfo:l};S.addBuffer(Buffer.from(JSON.stringify(D,null,2),`utf8`),`MANIFEST.json`);let O=b.reduce((e,t)=>e+t.lineCount,0),ne=new Set(v.map(e=>`logs/${L(e)}`)),k=x.filter(e=>ne.has(e)),re=new Set((t.bugReportLedgerFiles??[]).map(e=>`${ee}/${L(e)}`)),ie=x.filter(e=>re.has(e)),j=s?x.filter(e=>e.startsWith(`logs/`)&&!Fn(e)&&!ne.has(e)):[],M=w.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],N=M.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...M]:[`Redaction was disabled for this bundle; file contents are unmodified.`],oe=[`# Bug Report Bundle`,``,`Generated: ${D.generatedAt}`,`Project: ${s??`(unscoped)`}`,...t.projectDir?[`Project diagnostic source: ${c(`logs`,`projects`)} (current product only).`]:[],`Discipline version: ${D.disciplineVersion}`,``,`## Contents`,``,...x.map(e=>`- ${e}`),``,`## Privacy`,``,...j.length>0?[`Scope: some collected logs are user-wide rather than project-scoped.`,`These are written once per machine per day and can contain activity`,`from other projects open on this machine, including captured console`,`output:`,...j.map(e=>`- ${e}`),``]:[],...k.length>0?[`Installer logs: written by the macOS update helper rather than by`,`OpenKnowledge itself, and machine-wide rather than scoped to any one`,`project. They record the install and update history of this app on`,`this machine. Only this app is collected, never other applications`,`that use the same update mechanism:`,...k.map(e=>`- ${e}`),``]:[],...w.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...w.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system's own logs, covering`,`the last 7 days, to explain an exit the app could not record itself. On`,`macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${Rt}`,``]:[],...ie.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...ie.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${d.join(`, `)}`,O>0?`${O} line(s) were scrubbed across ${b.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...M,``,`This bundle is safe to attach to a GitHub issue.`]:N].join(`
|
|
7
|
-
`);S.addBuffer(Buffer.from(oe,`utf8`),`README.md`),S.end();let P=Be(r);return S.outputStream.pipe(P),await new Promise((e,t)=>{P.on(`close`,e),P.on(`error`,t)}),i?.info({bundlePath:r,fileCount:x.length,redactionCount:O},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:x,redactions:b,redactedLineCount:O,generatedAt:D.generatedAt}}}var qn=u(),Jn=e(ye(),1),Y=e(Ae(),1);function Yn(e){let t=F(`user`,e,e);return x({absPath:t,sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Xn({home:e=q(),env:t=process.env}={}){let n=Yn(e),{override:r,preferenceList:i}=ce(t),{locale:a,source:o}=pt({override:r,storedPreference:n,supportedLocales:y,preferenceList:i,autoDetectableLocales:m});return{preference:n,locale:a,source:o,systemLanguages:i}}function Zn(e){let t=new Set([e]);try{t.add(Ke.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function Qn(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function $n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function er(e,t){if(typeof e==`string`)return Qn(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>er(e,t));if(!$n(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=er(i,t);return n}function tr(e,t){let n=W(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
8
|
-
`),i=n.split(`
|
|
9
|
-
`),a=[];for(let e=0;e<i.length;e++){let n=i[e]??``;if(e!==i.length-1||n!==``){if(n.length===0){a.push(``);continue}try{let e=er(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
10
|
-
`)}\n`:a.join(`
|
|
11
|
-
`);K(e,o)}function nr(e,t){let n=W(e,`utf-8`);if(n.trim().length!==0)try{let r=er(JSON.parse(n),t),i=n.endsWith(`
|
|
12
|
-
`)?`
|
|
13
|
-
`:``;K(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Qn(n,t.contentDirSpellings);r!==n&&K(e,r)}}function rr(e,t){let n=W(e,`utf-8`),r=Qn(n,t.contentDirSpellings);r!==n&&K(e,r)}function ir(e){try{return G(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>z(e,t.name))}catch{return[]}}const ar=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function or(e){return/\.log\.\d+$/.test(e)}function sr(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||or(e)}const cr=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function lr(e){let t={contentDirSpellings:Zn(e.contentDir)};for(let n of cr)for(let r of ir(z(e.stagingDir,n)))sr(r)?tr(r,t):r.endsWith(`.json`)?nr(r,t):rr(r,t);for(let n of ir(z(e.stagingDir,`state`))){let e=L(n);n.endsWith(`.jsonl`)?tr(n,t):ar.has(e)?nr(n,t):rr(n,t)}}const ur=[`.ok`,`local`,`telemetry`],dr=[`.ok`,`local`,`logs`],fr=[`.ok`,`local`,`loss-capture`],pr=A.spansCurrent,mr=A.spansPrevious,hr=A.logsCurrent,gr=A.logsPrevious,_r=`loss-current.jsonl`,vr=`loss-prev.jsonl`;function yr(e){return z(e,...fr,_r)}function br(e){return z(e,...fr,vr)}const xr=1e3;async function Sr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}async function Cr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}async function wr(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(xr)});return t.ok?await t.text():null}catch{return null}}function Tr(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
14
|
-
`)}\n`:null}catch{return null}}function Er(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=dt(`git`,[`-C`,t,`log`,`--oneline`,`-50`],j({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Dr(e){let t=z(e,`.git`,`ok`);if(!H(t))return null;let n=dt(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],j({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Or(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function kr(){return{nodeVersion:process.version,platform:$e(),arch:Xe()}}function Ar(){return process.env.OTEL_SDK_DISABLED===`false`}function jr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mr(e){if(!H(e))return{};let t;try{t=(0,qn.parse)(W(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!jr(t))return{};let n=t.telemetry;if(!jr(n))return{};let r=n.localSink;return jr(r)?r:{}}function Nr(e){return typeof e==`boolean`?e:void 0}function Pr(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Fr(e){if(jr(e))return Pr(e.maxBytes)}function Ir(e){let t=Mr(F(`project`,e)),n=Mr(F(`project-local`,e));return{enabled:Nr(n.enabled)??Nr(t.enabled)??!0,spansMaxBytes:Fr(n.spans)??Fr(t.spans)??52428800,logsMaxBytes:Fr(n.logs)??Fr(t.logs)??26214400}}function Lr(e){return ct(`sha256`).update(e).digest(`hex`)}function Rr(e){let t=W(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const zr=[`"doc.name"`,`"docName"`];function Br(e){let t=W(e,`utf-8`),n=0;for(let e of zr){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function X(e,t){if(!H(e))return!1;try{return U(R(t),{recursive:!0}),e.endsWith(`.ips`)?K(t,jt(W(e,`utf-8`))):ze(e,t),!0}catch{return!1}}function Z(e,t,n,r){let i=H(e);X(e,z(n,r)),X(t,i?z(n,`legacy`,r):z(n,r))}function Vr(e){let t=[],n=e=>{let r=G(e,{withFileTypes:!0});for(let i of r){let r=z(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const Hr=new Set([`.jsonl`]);function Ur(e){let t=e.lastIndexOf(`.`);return t!==-1&&Hr.has(e.slice(t))}const Wr=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function Gr(e){if(or(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&Wr.has(e.slice(t))}function Kr(e){let t=[];for(let n of Vr(e)){let r=qr(e,n);if(!Gr(r))continue;let{redacted:i,patterns:a,lineCount:o}=p(W(n,`utf-8`));a.length!==0&&(K(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function qr(e,t){return Ie(e,t).split(V).join(`/`)}async function Jr(e){let t=B(e.contentDir),n=B(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Sr,a=r.fetchAgentEffects??Cr,o=r.fetchWatcherRecent??wr,s=r.readShadowHead??Er,l=r.readCheckpointRefs??Dr,u=r.now??(()=>new Date),d=r.okVersion??(()=>Pe),f=r.readDesktopEnv??Or,p=r.readLanguage??Xn,m=r.readRuntime??kr,h=r.isOtlpPushEnabled??Ar,g=He(z(tt(),`ok-bundle-`));try{U(z(g,`telemetry`),{recursive:!0}),U(z(g,`logs`),{recursive:!0}),U(z(g,`state`),{recursive:!0}),Z(S(n),z(n,...ur,pr),g,z(`telemetry`,pr)),Z(me(n),z(n,...ur,mr),g,z(`telemetry`,mr)),Z(_e(n),z(n,...dr,hr),g,z(`logs`,hr)),Z(ie(n),z(n,...dr,gr),g,z(`logs`,gr));for(let t of e.userLogFiles??[])X(t,z(g,`logs`,L(t)));for(let t of e.userStateFiles??[])X(t,z(g,ee,L(t)));let _=0;for(let t of e.diagnosticReports?.files??[])X(t,z(g,`diagnostic-reports`,L(t)))&&(_+=1);let v=z(n,`.ok`,`local`),y=z(v,`server.lock`),b=`not-running`,x=`no server.lock`,C=null;if(H(y)){X(y,z(g,`state`,`server.lock`));try{let e=W(y,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?C=t.port:x=`lock present but no port`}catch{x=`lock present but unparseable`}}if(C!==null){let e=await i(C);e===null?x=`agent-presence endpoint at :${C} unreachable`:(K(z(g,`state`,`agent-presence.json`),e),b=`running`,x=``);let t=await a(C);t!==null&&K(z(g,`state`,`agent-effects.json`),t);let n=await o(C);if(n!==null){let e=Tr(n);e!==null&&K(z(g,`state`,`watcher-recent.jsonl`),e)}}let w=s(t);w!==null&&K(z(g,`state`,`shadow-head.txt`),w);let T=l(t);T!==null&&K(z(g,`state`,`checkpoint-refs.txt`),T),X(yr(n),z(g,`state`,_r)),X(br(n),z(g,`state`,vr)),Z(ne(n),z(v,ae),g,`state/last-spawn-error.log`),X(z(v,te),z(g,`state`,te)),X(z(v,ve),z(g,`state`,ve)),X(z(v,D),z(g,`state`,D));let E=m(),O=f(),k=p(),A={ok:{version:d(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:O,language:k}};K(z(g,`state`,`runtime.json`),`${JSON.stringify(A,null,2)}\n`);let re=b===`running`?`running
|
|
15
|
-
`:`not-running (${x})\n`;K(z(g,`state`,`server-status.txt`),re);let j=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:Dt(e.diagnosticReports,_);if(K(z(g,`state`,`diagnostic-reports-status.txt`),`${j}\n`),K(z(g,Rt),En(e.osTerminationEvidence)),e.processDir&&H(e.processDir)){let t=z(g,`process`);U(t,{recursive:!0}),ze(e.processDir,t,{recursive:!0})}let M=e.redact===!0;M&&(lr({stagingDir:g,contentDir:t}),lr({stagingDir:z(g,`legacy`),contentDir:t})),e.note&&K(z(g,`note.txt`),e.note);let N=null;e.scrubSecrets===!0&&(N=Kr(g));for(let t of e.extraFiles??[]){let e=t.zipName??L(t.sourcePath);if(!X(t.sourcePath,z(g,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=jn(t,`extra/${e}`);n!==null&&(N??={redactions:[],redactedLineCount:0},N.redactions.push(n),N.redactedLineCount+=n.lineCount)}let oe=Ir(n),P=Vr(g),se=[],F=0,ce=0;for(let e of P){let t=qr(g,e),n=Ye(e).size,r=Ur(t)?Rr(e):0;se.push({path:t,bytes:n,lines:r}),F+=n;let i=t.startsWith(`legacy/`)?t.slice(7):t;(i.startsWith(`telemetry/`)||i.startsWith(`logs/`))&&(ce+=Br(e))}let le={applied:M};N!==null&&(le.secretScrub=N);let ue={schemaVersion:2,createdAt:u().toISOString(),ok:{version:d(),nodeVersion:E.nodeVersion,platform:E.platform,arch:E.arch},host:{desktop:O,language:k},contentDir:{pathSha256:Lr(t),absolutePath:M?`<CONTENT_DIR>`:t},telemetry:{localSink:{...oe,directory:c(`logs`,`projects`)},otlpPushEnabled:h()},redaction:le,serverStatus:b,files:se};K(z(g,`manifest.json`),`${JSON.stringify(ue,null,2)}\n`);let de=Zn(t),I=P.some(e=>{try{let t=W(e,`utf-8`);return de.some(e=>t.includes(e))}catch{return!1}}),fe={stagedDiagnosticReports:_,totalBytes:F,fileCount:se.length,docNameCount:ce,contentDirVisible:I,redacted:M},pe=!1;return{stagingDir:g,manifest:ue,summary:fe,cleanup:()=>{pe||(pe=!0,qe(g,{recursive:!0,force:!0}))}}}catch(e){throw qe(g,{recursive:!0,force:!0}),e}}async function Yr(e){let{collected:t,outputPath:n}=e,r=R(n);if(!H(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Jn.ZipFile,a=Vr(t.stagingDir);for(let e of a){let n=qr(t.stagingDir,e);i.addFile(e,n)}i.end();let o=Be(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function Xr(e,t){let n=z(e,`.ok`,`config.yml`);if(H(n))try{let t=(0,qn.parse)(W(n,`utf-8`)),r=je(t)?t.content:void 0,i=je(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return B(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return B(e)}async function Zr(e,t,n,r,i,a){let o=Mn(t,e.logger),s=await Jr({contentDir:Xr(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...In(o,e.userLogsDir??z(xe(),`logs`)),...Rn(e.cachesDir??z(q(),`Library`,`Caches`))],userStateFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{U(R(e.outputPath),{recursive:!0}),await Yr({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function Qr(e){let{projectDir:t}=e,n=e.readDesktopEnv??Or,r=e.readLanguage??Xn,i=()=>Lt(e.diagnosticReportsDir??z(q(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return Zr(e,t,n,r,i(),await wn(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await Kn({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Rn(e.cachesDir??z(q(),`Library`,`Caches`)),bugReportLedgerFiles:Bn(e.bugReportsDir??kn()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await wn(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}function Q(e,t,n={}){let r=re(e,t),i;try{i=W(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r,text:i}}let o=a&&typeof a==`object`?a:{},s=ue(o),c=s&&!b(o,n);if(!a||typeof a!=`object`||!de(a.pid))return{status:`corrupt`,lockPath:r,text:i,...c?{foreignHost:!0}:{}};let l=ge(a),{pid:u}=l;if(c)return{status:`foreign-host`,lockPath:r,lock:l};let d=k(l,{isAlive:n.isAlive,readProcessStart:n.readProcessStart,readBootInstant:n.readBootInstant,sameMachine:s});switch(d.verdict){case`gone`:return{status:`dead-pid`,lockPath:r,lock:l,text:i};case`replaced`:return{status:`reused-pid`,lockPath:r,lock:l,text:i};case`unverified`:return d.cause===`unverified-owner`?{status:`unverified-owner`,lockPath:r,pid:u}:{status:`alive`,lockPath:r,lock:l};case`writer`:return{status:`alive`,lockPath:r,lock:l};default:return d}}function $r(e){return`does not record its owning machine, and its recorded process ${e} is still running on this machine`}function ei(e){return typeof e.machineId==`string`?`records a machine ID different from the one in ${pe()}`:`records only the host ${Me(e.hostname)}, not this machine's ${Qe()}`}function ti(e){return e===`win32`?`USERPROFILE`:`HOME`}function ni(e){return e.processStart===void 0?` This lock records no process start; a server started by this release records one, which lets \`${o()} stop\` confirm it from any home folder.`:``}function ri(e,t){let n=`\`${o()} stop\``;return`If the server was started on this machine from another account, run ${n} as that account. If it was started from this account with a different home folder, run ${n} with \`${ti(t)}\` set to that folder. Otherwise stop it from the machine that owns the lock.${ni(e)}`}function ii(e,t){let n=o();return`If the server was started on this machine from another account, run \`${n} stop\` as that account while it is running, or \`${n} clean\` once it has exited. If it was started from this account with a different home folder, run the same command with \`${ti(t)}\` set to that folder. Otherwise run the same command on the machine that owns the lock.${ni(e)}`}function ai(e){return`Confirm that no OpenKnowledge server is using this directory on the owning machine or any other machine sharing it. Only then remove the stale lock file at ${e} and retry cleanup.`}function oi(e,t=process.platform){let{lock:n,lockPath:r}=e;return`${typeof n.machineId==`string`?ii(n,t):`If ${Me(n.hostname)} is another machine, stop OpenKnowledge there; if it is an earlier name of this machine, stop OpenKnowledge here if it is still running.`} ${ai(r)}`}function si(e,t=process.platform){let{lockPath:n}=e;return e.status===`unverified-owner`?`Cannot verify shutdown: the server lock at ${n} ${$r(e.pid)}. Check whether process ${e.pid} is an OpenKnowledge server. If it is, stop it and retry. Do not remove the lock file while that process is running.`:e.status===`corrupt`?`Cannot verify shutdown: the server lock at ${n} records a machine ID or host name that is not this machine's, so its server may run on another machine, or on this one from another account, with a different home folder, or under an earlier host name. Stop OpenKnowledge wherever it was started. ${ai(n)}`:`Cannot verify shutdown: the server lock at ${n} ${ei(e.lock)}. ${oi(e,t)}`}function ci(e){return e.replace(/:\d+$/,``)}function li(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:ci(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}const ui=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function di(e,t=process.platform,n=process.env){return f(r(),e,t,n.XDG_CONFIG_HOME)}function fi(){return g(r())}function pi(){let e=r();if(e===`stable`)return ui;let t=h(e);return RegExp(`^# >>> ${t} >>>\\n[\\s\\S]*?^# <<< ${t} <<<\\n?`,`m`)}const mi={existsSync:e=>H(e),readFileSync:(e,t)=>W(e,t),lstatSync:e=>Ve(e),readlinkSync:e=>Ge(e)};function hi(e,t=mi,n=process.platform,i=process.env){let a=r(),o=di(e,n,i),s=f(a,e),c=t.existsSync(o)?o:a===`stable`&&n===`linux`&&t.existsSync(s)?s:null;if(c===null)return null;try{let e=JSON.parse(t.readFileSync(c,`utf8`));return e?.version===1?e:null}catch{return null}}function gi(e){let t=e.replace(pi(),``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function _i(e,t,n=mi){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}const vi=[{hostDir:`.adal`,pruneRoot:`.adal`},{hostDir:`.aider-desk`,pruneRoot:`.aider-desk`},{hostDir:`.astrbot/data`,pruneRoot:`.astrbot`},{hostDir:`.augment`,pruneRoot:`.augment`},{hostDir:`.autohand`,pruneRoot:`.autohand`},{hostDir:`.bob`,pruneRoot:`.bob`},{hostDir:`.codeartsdoer`,pruneRoot:`.codeartsdoer`},{hostDir:`.codebuddy`,pruneRoot:`.codebuddy`},{hostDir:`.codeium/windsurf`,pruneRoot:`.codeium`},{hostDir:`.codemaker`,pruneRoot:`.codemaker`},{hostDir:`.codestudio`,pruneRoot:`.codestudio`},{hostDir:`.commandcode`,pruneRoot:`.commandcode`},{hostDir:`.config/crush`,pruneRoot:`.config/crush`},{hostDir:`.config/devin`,pruneRoot:`.config/devin`},{hostDir:`.config/goose`,pruneRoot:`.config/goose`},{hostDir:`.config/kimchi/harness`,pruneRoot:`.config/kimchi`},{hostDir:`.continue`,pruneRoot:`.continue`},{hostDir:`.factory`,pruneRoot:`.factory`},{hostDir:`.forge`,pruneRoot:`.forge`},{hostDir:`.grok`,pruneRoot:`.grok`},{hostDir:`.iflow`,pruneRoot:`.iflow`},{hostDir:`.inferencesh`,pruneRoot:`.inferencesh`},{hostDir:`.jazz`,pruneRoot:`.jazz`},{hostDir:`.junie`,pruneRoot:`.junie`},{hostDir:`.kilocode`,pruneRoot:`.kilocode`},{hostDir:`.kiro`,pruneRoot:`.kiro`},{hostDir:`.kode`,pruneRoot:`.kode`},{hostDir:`.lingma`,pruneRoot:`.lingma`},{hostDir:`.mcpjam`,pruneRoot:`.mcpjam`},{hostDir:`.moxby`,pruneRoot:`.moxby`},{hostDir:`.mux`,pruneRoot:`.mux`},{hostDir:`.neovate`,pruneRoot:`.neovate`},{hostDir:`.ona`,pruneRoot:`.ona`},{hostDir:`.openhands`,pruneRoot:`.openhands`},{hostDir:`.pochi`,pruneRoot:`.pochi`},{hostDir:`.qoder`,pruneRoot:`.qoder`},{hostDir:`.qoder-cn`,pruneRoot:`.qoder-cn`},{hostDir:`.qwen`,pruneRoot:`.qwen`},{hostDir:`.reasonix`,pruneRoot:`.reasonix`},{hostDir:`.roo`,pruneRoot:`.roo`},{hostDir:`.rovodev`,pruneRoot:`.rovodev`},{hostDir:`.snowflake/cortex`,pruneRoot:`.snowflake`},{hostDir:`.tabnine/agent`,pruneRoot:`.tabnine`},{hostDir:`.terramind`,pruneRoot:`.terramind`},{hostDir:`.tinycloud`,pruneRoot:`.tinycloud`},{hostDir:`.trae`,pruneRoot:`.trae`},{hostDir:`.trae-cn`,pruneRoot:`.trae-cn`},{hostDir:`.vibe`,pruneRoot:`.vibe`},{hostDir:`.zcode`,pruneRoot:`.zcode`},{hostDir:`.zencoder`,pruneRoot:`.zencoder`}],yi=[...O.map(e=>le[e]),`open-knowledge`];function bi(e){if(!Fe(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=B(e);if(t===V||R(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function xi(e,t){let n=Ie(e,t);if(n.startsWith(`..`)||Fe(n))return!1;let r=e;for(let e of n.split(V)){r=z(r,e);try{if(!Ve(r).isDirectory())return!1}catch{return!1}}return!0}function Si(e,t){try{return G(e).every(n=>t.has(z(e,n)))}catch{return!1}}function Ci(e){let t=bi(e),n=[],r=[],i=new Set;for(let e of vi){let a=z(t,e.hostDir,`skills`);if(!xi(t,a))continue;let o=yi.map(e=>z(a,e)).filter(e=>H(e));n.push(...o);for(let e of o)i.add(e);let s=z(t,e.pruneRoot),c=a;for(;Si(c,i)&&(r.push(c),i.add(c),c!==s);){let e=R(c);if(e===c||e===t||!e.startsWith(t+V))break;c=e}}return{skillDirs:n,emptyDirs:r}}function wi(e){try{if(!Ve(e).isDirectory())return!1;let t=G(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function Ti(e){let t=new Set,n=new Set;for(let r of vi){let i=z(e,r.hostDir,`skills`);for(let e of yi)t.add(z(i,e));let a=z(e,r.pruneRoot),o=i;for(;n.add(o),o!==a;){let t=R(o);if(t===o||t===e||!t.startsWith(e+V))break;o=t}}return{skillDirs:t,emptyDirs:n}}function Ei(e,t){let n=bi(e),r=Ti(n),i=[...t.skillDirs.filter(e=>!r.skillDirs.has(e)),...t.emptyDirs.filter(e=>!r.emptyDirs.has(e))];if(i.length>0)throw Error(`refusing skill cleanup — ${i.length} path(s) outside the known legacy set: ${i.join(`, `)}`);let a=[];for(let e of t.skillDirs)if(xi(n,e)&&wi(e))try{qe(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(xi(n,e))try{Je(e),a.push(e)}catch{}return a}function Di(e){let t=bi(e),n=[];for(let e of O){let r=le[e];n.push({path:z(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of v)n.push({path:z(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function Oi(e,t){let n=[];for(let r of Di(e))if(r.bundleId===t)try{qe(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function ki(e){if(!e||typeof e!=`object`)return String(e);let t=typeof e.readProcessStart;return`${we(e)} readProcessStart=${t}`}function Ai(e,t={}){if(!Number.isSafeInteger(e)||e<=0||e>4294967295)return null;let n=t.arch??process.arch,r=(e,n,r)=>{Ee(n,r),t.onNativeFailure?.({kind:e,reason:Te(n,r)})};try{let i=!1,a=Ce(t.nativeResolver,(e,t)=>{i=!0,r(`unavailable`,e,t)});if(!a||typeof a!=`object`||!(`readProcessStart`in a)||typeof a.readProcessStart!=`function`){let e;return e=a==null?i?`no usable binding was returned`:`the addon was not found`:ki(a),r(`unavailable`,`the Windows native addon (native-config.win32-${n}-msvc.node) did not load or does not export readProcessStart`,e),null}let o=a.readProcessStart(e);return typeof o==`number`&&Number.isSafeInteger(o)&&o>=0?o:(r(`unavailable`,`readProcessStart returned an invalid value`,we(o)),null)}catch(e){return r(`query-failed`,`readProcessStart failed`,e),null}}function ji(e,t={}){return fe(e,{platform:t.platform,readNative:e=>Ai(e,{onNativeFailure:t.onNativeFailure})})}function Mi(e){let{platform:t,pid:n,nativeFailures:r,causeRecorded:i}=e,a=r.some(e=>{switch(e.kind){case`unavailable`:return!0;case`query-failed`:return!1;default:return e.kind}}),o=r.length===0?``:a?`Reinstall OpenKnowledge to restore the Windows component that verifies process identity. `:`The Windows component loaded but the operating system refused the query, so reinstalling will not help; retry from an account that can inspect that process. `;return(t===`linux`?`Linux reads the process start from /proc/${n}/stat and /proc/stat; restore read access to /proc and retry. `:t===`darwin`?`macOS reads the process start with ps, and that read failed, as it does inside some sandboxes; retry from a shell where ps can run. `:t===`win32`?o:``)+(r.length>0&&i?`The failure detail is recorded in the CLI log under ${c(`logs`)}. `:``)}function Ni(e){let t=new Set;return N(n=>{let r=[],i=Ai(n,{onNativeFailure:e=>{r.push(e)}});for(let i of new Set(r.map(e=>e.kind)))t.has(i)||(t.add(i),(e??ke())?.warn({event:`process-start-native-failure`,lockPid:n,kind:i,reasons:r.filter(e=>e.kind===i).map(e=>e.reason)},`the Windows process-start query failed, so lock holders cannot be verified; later failures of this kind are not recorded again`));return i})}function Pi(e){return e!=null&&e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function Fi(e,t=Date.now()){if(e===null)return`—`;let n=mt(e,t);return n===`unknown`?`—`:n}function Ii(e){let t=R(e);return L(e)===`local`&&L(t)===`.ok`?R(t):L(e)===`.ok`?t:null}function Li(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`||t.status===`read-error`)return null;if(t.status===`unverified-owner`)return{directory:Ii(e),server:{port:null,status:t.status,pid:t.pid,startedAt:null,usage:null},ui:null,hostname:null,lockPath:t.lockPath,binary:null,command:null,isDesktop:!1};let i=t.lock,a=t.status===`alive`&&oe(i)?{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r}:null;return{directory:i.worktreeRoot,server:{port:i.port,status:t.status,pid:i.pid,startedAt:i.startedAt,usage:r},ui:a,hostname:i.hostname,lockPath:t.lockPath,binary:n==null?null:se(n),command:n,isDesktop:Pi(n)}}function Ri(e){let t=e.server.status;switch(t){case`unverified-owner`:return`unverified`;case`alive`:return e.isDesktop?`desktop`:`running`;case`foreign-host`:return e.isDesktop?`desktop`:`foreign`;case`dead-pid`:case`reused-pid`:return`stale`;default:return t}}const zi=new Set([`running`,`desktop`,`foreign`,`unverified`]);function Bi(e){switch(e){case`running`:return Y.default.green(e);case`desktop`:return Y.default.blue(e);case`foreign`:return Y.default.cyan(e);case`unverified`:case`stale`:return Y.default.yellow(e)}}function Vi(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function Hi(e){return`${Vi(e.server.usage)} | ${Vi(e.ui?.usage??null)}`}function Ui(e){return`${e.server.port===null?`—`:e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function Wi(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>[e.directory??`—`,Ui(e),Hi(e),Ri(e),String(e.server.pid),Fi(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),s=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=Bi(Ri(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),c=Y.default.dim(`To stop a server: ${o()} stop <port|pid|directory|all>`);return[a,...s,``,c].join(`
|
|
16
|
-
`)}async function Gi(e={}){let t=e.discover??I,n=e.inspect??(e=>Q(e,`server`)),r=e.log??(e=>console.log(e)),i=e.resolveCommand??w,a=e.resolveUsage??M,o=await t(),s=[];for(let e of o){let t=n(e),r=Li(e,t,t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`||t.status===`read-error`||t.status===`unverified-owner`||t.status===`reused-pid`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Ri(e)}));r(JSON.stringify(e,null,2));return}r(Wi(e.all?s:s.filter(e=>zi.has(Ri(e)))))}function Ki(){return new Oe(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale entries`).option(`--all`,`Include stale entries (foreign and unverified entries already show)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await Gi({all:t.all===!0||e===`all`,json:t.json===!0})})}async function qi(e,t=ke()){let n=Q(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=he(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function Ji(e,t={}){return ea(e,t.isAlive??P)?{targets:[{name:`server`,pid:e.lock.pid,port:e.lock.port}],lock:e.lock}:{targets:[]}}function Yi(e){try{return r()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function $(e){let t=e.inspect??(()=>Q(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),a=e.error??(e=>console.error(e)),c=e.probeClients??qi,l=e.logger??ke(),u=e.platform??process.platform,d=t(),f=Ji(d,{isAlive:e.isAlive}),{lock:p}=f,m=[],h=[],g=(t,n)=>{l?.warn({lockDir:e.lockDir,lockPath:n.lockPath,lockPid:n.pid,platform:u,cause:n.cause,...`nativeFailures`in n&&n.nativeFailures.length>0?{nativeFailures:n.nativeFailures}:{}},`stop declined: lock holder identity unverified`),h.push({target:t,error:Qi(n,l!==void 0),unverified:n})},_=()=>{if(m.length>0){let e=m.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);r(`Stopped: ${e}`)}if(l?.info({lockDir:e.lockDir,signalled:m.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:h.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),h.length>0){let e=h.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `);a(`Failed to stop: ${e}`)}return{stopped:m,failed:h,hadTargets:!0}};if(d.status===`unverified-owner`){let{pid:e,lockPath:t}=d;return g({name:`server`,pid:e},{cause:`unverified-owner`,pid:e,lockPath:t}),_()}if(p===void 0)return r(`No running open-knowledge processes.`),l?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let v=d.status===`alive`||d.status===`foreign-host`?d.lock.channel:void 0;if(e.force!==!0&&typeof v==`string`&&v.length>0){let t=e.selfChannel??Yi(l);if(t!==void 0&&v!==t)return a(`Not stopping: the server at ${e.lockDir} belongs to ${i(v)}. `+(v===`dev`?`Stop it from that dev build, or run \`${s} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),l?.warn({lockDir:e.lockDir,holderChannel:v,selfChannel:t,pids:f.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:v}}}if(e.force!==!0){let t=await c(e.lockDir,l);if(t!==null&&t>0)return a(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),l?.warn({lockDir:e.lockDir,clients:t,pids:f.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}for(let t of f.targets){let i=[],s=(e.readProcessStart??ji)(t.pid,{platform:u,onNativeFailure:e=>{i.push(e)}}),c=k(p,{isAlive:e.isAlive??P,readProcessStart:()=>s,refuseHolderStartedAfterLock:e.refuseHolderStartedAfterLock,platform:u,readBootInstant:e.readBootInstant});switch(c.verdict){case`writer`:try{n(t.pid,`SIGTERM`),m.push(t)}catch(e){h.push({target:t,error:e instanceof Error?e.message:String(e)})}break;case`gone`:r(`${t.name} (pid=${t.pid}) had already exited`);break;case`replaced`:a(`Process ${t.pid} is no longer the server that wrote ${d.lockPath}; it was not signalled. Run \`${o()} clean\` to remove the stale lock.`);break;case`unverified`:g(t,Xi(c.cause,{pid:t.pid,lockPath:d.lockPath,lock:p,platform:u,nativeFailures:i}));break;default:return c}}return _()}function Xi(e,t){let{pid:n,lockPath:r}=t;switch(e){case`foreign-host`:return{cause:e,pid:n,lockPath:r,lock:t.lock,platform:t.platform};case`unverified-owner`:return{cause:e,pid:n,lockPath:r};default:return{cause:e,pid:n,lockPath:r,platform:t.platform,nativeFailures:t.nativeFailures}}}const Zi=`it was not signalled, and --force does not override this check.`;function Qi(e,t){let{pid:n,lockPath:r}=e;switch(e.cause){case`foreign-host`:{let{lock:t}=e;return typeof t.machineId==`string`?`The server lock at ${r} ${ei(t)}, so process ${n}, which is running on this machine, cannot be confirmed as the server that wrote it; ${Zi} ${ri(t,e.platform)}`:`The server lock at ${r} ${ei(t)}, and the start of process ${n}, which is running on this machine, does not confirm it as the server that wrote the lock; ${Zi} If ${Me(t.hostname)} is another machine, stop the server there. If it is an earlier name of this machine, confirm that process ${n} is an OpenKnowledge server before ending it yourself, and once no OpenKnowledge server is running for this project, remove ${r}.`}case`unverified-owner`:return`The server lock at ${r} ${$r(n)}, so it cannot be confirmed as the server that wrote the lock; ${Zi} Check whether process ${n} is an OpenKnowledge server, and if it is, stop it yourself. Do not remove the lock file while that process is running.`;default:{let n=$i(e,Zi,`Once you have confirmed no OpenKnowledge server is running for this project, remove ${r}.`,t);return e.cause===`writer-identity-unrecorded`?`${n} A server you start again with this release records its machine ID, so \`${o()} stop\` can confirm it.`:n}}}function $i(e,t,n,r){let{pid:i,lockPath:a,platform:o,nativeFailures:s}=e,c=`Before ending process ${i} yourself, confirm that it is an OpenKnowledge server.`;switch(e.cause){case`process-start-unreadable`:return`Could not read when process ${i} started, so it cannot be confirmed as the server that wrote ${a}; ${t} `+Mi({platform:o,pid:i,nativeFailures:s,causeRecorded:r})+`${c} ${n}`;case`process-start-incomparable`:return`The start of process ${i} cannot be compared with the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-start-mismatch`:return`Process ${i} started before the start recorded in ${a}, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`process-started-after-lock`:return`Process ${i} started after the server lock at ${a} was written, so it cannot be confirmed as the server that wrote the lock; ${t} ${c} ${n}`;case`recorded-start-in-future`:return`The server lock at ${a} records a start later than the current time on this machine, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;case`writer-identity-unrecorded`:return`The server lock at ${a} records neither a machine ID nor a process start, as locks written by version 0.25.0 and earlier do, so process ${i} cannot be confirmed as the server that wrote it; ${t} ${c} ${n}`;default:return e.cause}}function ea(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}async function ta(e,t=P){let n=await I(),r=null;for(let i of n){let n=Q(i,`server`);if(ea(n,t)){if(n.lock.port===e)return i;r===null&&n.lock.pid===e&&(r=i)}}return r}function na(e){(e.failed.length>0||e.declined!==void 0)&&(process.exitCode=1)}async function ra(e,t){let n=await $({lockDir:e,force:t});return na(n),n}function ia(e,t,n={}){return t===0?`Nothing was running for ${e}, and no other open-knowledge servers are running.`:`Nothing was running for ${e}. ${t} other open-knowledge server${t===1?` is`:`s are`} running${n.listingFollows===!0?``:` — run \`${o()} ps\` to list them`}.`}async function aa(e){let t=await I(),n=0;for(let r of t)r!==e&&ea(Q(r,`server`),P)&&n++;return n}function oa(e){return new Oe(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the enclosing project — run it from anywhere inside the project. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).option(`--force`,`Stop even when the server belongs to another OpenKnowledge app (Stable, Beta or a dev build run from source) or editor windows or agents are still connected to it`).action(async(t,n)=>{let r=n.force===!0,i=t.length===0?void 0:t.join(` `);if(i===void 0){e();let t=T(process.cwd()),n=[],i=await $({lockDir:t,force:r,log:e=>n.push(e)});if(i.hadTargets){for(let e of n)console.log(e);na(i)}else{let e=await aa(t);console.log(ia(process.cwd(),e,{listingFollows:e>0})),e>0&&await Gi({})}return}if(i===`all`){let e=await I();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e)ea(Q(n,`server`),P)&&(await ra(n,r),t++);t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(i)){let e=Number.parseInt(i,10),t=await ta(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}await ra(t,r);return}let a=B(yt(),i),o=T(a),s=[],c=await $({lockDir:o,force:r,log:e=>s.push(e)});if(na(c),c.hadTargets)for(let e of s)console.log(e);else console.log(ia(a,await aa(o)))})}export{Lt as A,Qr as C,kn as D,An as E,wt as F,Tt as I,yt as L,bt as M,St as N,wn as O,xt as P,vt as R,Q as S,Yr as T,gi as _,Ki as a,ei as b,Ei as c,Di as d,ui as f,hi as g,fi as h,oa as i,Dt as j,On as k,Ci as l,di as m,qi as n,ji as o,_i as p,$ as r,Ni as s,$i as t,Oi as u,li as v,Jr as w,si as x,oi as y,gt as z};
|
package/dist/start-COZO7HSH.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e,m as t,p as n,r}from"./start-B0AH-f5N.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|
|
File without changes
|