@inkeep/open-knowledge 0.59.0-beta.26 → 0.59.0-beta.28

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.
Files changed (139) hide show
  1. package/dist/{acp-harness-probe-DYbo4bT-.mjs → acp-harness-probe-BioMl_fC.mjs} +2 -2
  2. package/dist/cli.mjs +61 -61
  3. package/dist/config-schema.json +2 -36
  4. package/dist/config.project.schema.json +2 -36
  5. package/dist/constants-D0ddOHQC.mjs +2 -0
  6. package/dist/{fs-traced-6G_aFzgy.mjs → fs-traced-1KTQL4h-.mjs} +6 -6
  7. package/dist/fs-traced-Dak_kryQ.mjs +1 -0
  8. package/dist/git-handle-DucRiayU.mjs +1 -0
  9. package/dist/{git-handle-BamU1o3R.mjs → git-handle-Hi0B37cf.mjs} +2 -2
  10. package/dist/index.d.mts +0 -5
  11. package/dist/index.mjs +144 -144
  12. package/dist/init-C-aTi6-U.mjs +1 -0
  13. package/dist/{init-B14cFSch.mjs → init-DPUo80Dj.mjs} +4 -4
  14. package/dist/{launch-json-removal-D9Dn9ans.mjs → launch-json-removal-D_4gAmmg.mjs} +2 -2
  15. package/dist/loader-DBo0fX7c.mjs +1 -0
  16. package/dist/{loader-DlLkJi3f.mjs → loader-LDz9zBYC.mjs} +2 -2
  17. package/dist/md-manager-BuU8asuD.mjs +2 -0
  18. package/dist/{open-browser-CD86-cP6.mjs → open-browser-8aAyMvgv.mjs} +2 -2
  19. package/dist/parse-worker.mjs +1 -1
  20. package/dist/{preview-Dr5MviTF.mjs → preview-B34Qj3q9.mjs} +2 -2
  21. package/dist/preview-DYuZMGB5.mjs +1 -0
  22. package/dist/public/assets/{ActivityModeContent-BH3nUmKi.js → ActivityModeContent-DJkcYUFG.js} +1 -1
  23. package/dist/public/assets/{AgentDiffPane-ulYiZICp.js → AgentDiffPane-QpnE2RxP.js} +1 -1
  24. package/dist/public/assets/{AgentThreadClientBinder-DyRJbgYV.js → AgentThreadClientBinder-BNxw9YWy.js} +1 -1
  25. package/dist/public/assets/{CodeMirrorPropInput-D5dluJAa.js → CodeMirrorPropInput-DlJxY2cd.js} +1 -1
  26. package/dist/public/assets/{DocumentContext-C0nL2SXC.js → DocumentContext-BI0smsxZ.js} +1 -1
  27. package/dist/public/assets/{EditorModeToggle-CPc75zv0.js → EditorModeToggle-DVfUE-Hx.js} +1 -1
  28. package/dist/public/assets/{EnableSyncConfirmDialog-_4B5kdmf.js → EnableSyncConfirmDialog-CH3AktRr.js} +1 -1
  29. package/dist/public/assets/{ExcalidrawDocEditor-C5fCyPDa.js → ExcalidrawDocEditor-HqU6SXrF.js} +1 -1
  30. package/dist/public/assets/FeedbackForm-DfjQFt_o.js +1 -0
  31. package/dist/public/assets/{GraphPanel-DjOi0m6N.js → GraphPanel-MtHSCEEc.js} +1 -1
  32. package/dist/public/assets/{ImportSkillDialog-CfhVYZbV.js → ImportSkillDialog-DqbRbXfG.js} +1 -1
  33. package/dist/public/assets/{LintConfigEditor-BJZcVBKl.js → LintConfigEditor-DQQlzcbN.js} +1 -1
  34. package/dist/public/assets/{ManagedArtifactProperties-COaU0QeT.js → ManagedArtifactProperties-CPsIQVz8.js} +1 -1
  35. package/dist/public/assets/ManagedArtifactProperties-DkmtIVIZ.js +1 -0
  36. package/dist/public/assets/{MermaidDocEditor-B6o0wQi9.js → MermaidDocEditor-UIF1Y7PM.js} +1 -1
  37. package/dist/public/assets/{PropertyDisplayRow-CRD3p4U5.js → PropertyDisplayRow-BPCVo30u.js} +1 -1
  38. package/dist/public/assets/{ReportBugDialogBody-DI4KGY6b.js → ReportBugDialogBody-BoQrLPkN.js} +1 -1
  39. package/dist/public/assets/{SchemaConfigEditor-DWv0rRAz.js → SchemaConfigEditor-D5aVltyV.js} +1 -1
  40. package/dist/public/assets/{SessionsHost-4Dzze9r3.js → SessionsHost-B0WtFo-7.js} +2 -2
  41. package/dist/public/assets/{SettingsDialogBody-DCoAb0Bd.js → SettingsDialogBody-Cbsyvnqh.js} +1 -1
  42. package/dist/public/assets/{ShareBranchSwitchDialog-DzKK9STn.js → ShareBranchSwitchDialog-DxracRWc.js} +1 -1
  43. package/dist/public/assets/{ShareReceiveDialog-DH2fH5Ep.js → ShareReceiveDialog-Cfp4wdzT.js} +1 -1
  44. package/dist/public/assets/{ShareReceiveMissDialog-DUdi0fBR.js → ShareReceiveMissDialog-DxcAaxnj.js} +1 -1
  45. package/dist/public/assets/{SkillCostValue-CcR1g_YK.js → SkillCostValue-CDg_lpMT.js} +1 -1
  46. package/dist/public/assets/{SkillEditBanner-Bygl2n7y.js → SkillEditBanner-BEG94SMV.js} +1 -1
  47. package/dist/public/assets/{SkillInstallMenu-BVG38yZJ.js → SkillInstallMenu-xkIcUjyz.js} +1 -1
  48. package/dist/public/assets/{SkillOriginInline-wsT9RocF.js → SkillOriginInline-WxvVrIDh.js} +1 -1
  49. package/dist/public/assets/{SkillToolbarControls-BpFI6ORp.js → SkillToolbarControls-BvIlOBgX.js} +1 -1
  50. package/dist/public/assets/{SlidesToolbarControls-Bli5Kfnf.js → SlidesToolbarControls-DMGLRgXN.js} +1 -1
  51. package/dist/public/assets/{SourceEditor-DinqAqAo.js → SourceEditor-BoCr54OC.js} +1 -1
  52. package/dist/public/assets/{TerminalPanel-ByZlnAVD.js → TerminalPanel-B136_x01.js} +1 -1
  53. package/dist/public/assets/{TerminalWindowApp-DQNGwwgH.js → TerminalWindowApp-C7xQ_h9C.js} +1 -1
  54. package/dist/public/assets/{TextDocEditor-CPa4xvfB.js → TextDocEditor-DZYfekpd.js} +1 -1
  55. package/dist/public/assets/{ThreadView-kSlERwEa.js → ThreadView-DenCwvfW.js} +1 -1
  56. package/dist/public/assets/{TimelineDiffPane-DXgcXY3B.js → TimelineDiffPane-XlGr0GTw.js} +1 -1
  57. package/dist/public/assets/{agent-diff-store-CK_MxQ13.js → agent-diff-store-BVPptGby.js} +1 -1
  58. package/dist/public/assets/{auth-state-cache-BIQOr5wy.js → auth-state-cache-DWZvELXg.js} +1 -1
  59. package/dist/public/assets/client-version-D2k9ZCWX.js +1 -0
  60. package/dist/public/assets/{comment-chips-DS7pK-yD.js → comment-chips-D_lOHAKs.js} +1 -1
  61. package/dist/public/assets/{config-provider-mFv1sqH4.js → config-provider-CDwrJPp7.js} +1 -1
  62. package/dist/public/assets/{dist-C1cuuJXO2.js → dist-Cjt7VASv2.js} +38 -38
  63. package/dist/public/assets/{doc-paths-Bc7iTgnL.js → doc-paths-B8neiW-a.js} +1 -1
  64. package/dist/public/assets/{documents-events-ChHRY_IT.js → documents-events-XYcpMExe.js} +1 -1
  65. package/dist/public/assets/{file-tree-adapter-Cn1x6E2_.js → file-tree-adapter-D09K46if.js} +1 -1
  66. package/dist/public/assets/{file-tree-utils-CE3Y3N48.js → file-tree-utils-D46TNM8I.js} +1 -1
  67. package/dist/public/assets/{folder-config-api-Drl7C-wY.js → folder-config-api-BF1s5fn5.js} +1 -1
  68. package/dist/public/assets/i18n-DyGGRo1x.js +1 -0
  69. package/dist/public/assets/{index-yY_6Xj9r.js → index-DVAzmNmM.js} +7 -7
  70. package/dist/public/assets/{lint-config-client-BeZysGOL.js → lint-config-client-CexP4XjM.js} +1 -1
  71. package/dist/public/assets/{markdownlint-rule-browser-B7QG3apY.js → markdownlint-rule-browser-RW_wnt3c.js} +1 -1
  72. package/dist/public/assets/{navigation-targets-dmO4e4Qm.js → navigation-targets-B81SRxAl.js} +1 -1
  73. package/dist/public/assets/{open-managed-artifact-tab-D99Uwfo7.js → open-managed-artifact-tab-ONxSWsRO.js} +1 -1
  74. package/dist/public/assets/{pending-receive-nav-store-DY9saaUe.js → pending-receive-nav-store-EbqHz-1O.js} +1 -1
  75. package/dist/public/assets/{progress-D6Zw3AMw.js → progress-BNa6s6eY.js} +1 -1
  76. package/dist/public/assets/{prop-types-CekqkyBi.js → prop-types-Bi69iPbr.js} +1 -1
  77. package/dist/public/assets/{receive-store-C4_wYBmA.js → receive-store-DvP10j_m.js} +1 -1
  78. package/dist/public/assets/{selection-context-CoupzfPD.js → selection-context-BT0IXs_k.js} +1 -1
  79. package/dist/public/assets/{skill-actions-D9yzisvl.js → skill-actions-C6XMzsRk.js} +1 -1
  80. package/dist/public/assets/{skill-scope-BNRIoNFW.js → skill-scope-D_Zsy3lJ.js} +1 -1
  81. package/dist/public/assets/{skills-api-BHNlkzLI.js → skills-api-BM2BLHCX.js} +1 -1
  82. package/dist/public/assets/{src-7eans9jB.js → src-DMrqP3nT.js} +1 -1
  83. package/dist/public/assets/{tag-pill-input-9XCv-eGc.js → tag-pill-input-BFaMBmJa.js} +1 -1
  84. package/dist/public/assets/{target-navigation-intent-BHn4lUYz.js → target-navigation-intent-CWvy9cE2.js} +1 -1
  85. package/dist/public/assets/{telemetry-impl-T0tYRMlO.js → telemetry-impl-CuZ-qtZC.js} +1 -1
  86. package/dist/public/assets/{telemetry-startup-cht6PIz2.js → telemetry-startup-CSHPwDgJ.js} +1 -1
  87. package/dist/public/assets/{terminal-cli-display-C9RSSYZZ.js → terminal-cli-display-BbYqTPWX.js} +1 -1
  88. package/dist/public/assets/{terminal-launch-events-CJ5--wwM.js → terminal-launch-events-BPjoquS2.js} +1 -1
  89. package/dist/public/assets/{terminal-telemetry-g2Rame0f.js → terminal-telemetry-DxMhdnxk.js} +1 -1
  90. package/dist/public/assets/{typing-burst-detector-HcBOgWZw.js → typing-burst-detector-B7DPFEEZ.js} +1 -1
  91. package/dist/public/assets/{uninstall-OtG696J2.js → uninstall-DDXNRWQJ.js} +1 -1
  92. package/dist/public/assets/{use-activity-panel-DA5KxLH2.js → use-activity-panel-CsxwP-4j.js} +1 -1
  93. package/dist/public/assets/{use-apply-config-color-theme-g3ghtVU3.js → use-apply-config-color-theme-cAcJ-HL5.js} +1 -1
  94. package/dist/public/assets/{use-collab-url-C0l9GQW6.js → use-collab-url-C79vcmVC.js} +1 -1
  95. package/dist/public/assets/{use-live-xterm-theme-CURX_Vkk.js → use-live-xterm-theme-D63CLflu.js} +1 -1
  96. package/dist/public/assets/{use-open-skill-qA__uomh.js → use-open-skill-BXh-h1Gy.js} +1 -1
  97. package/dist/public/assets/{use-popular-skills-CkOc4ZFI.js → use-popular-skills-Dzx69gvR.js} +1 -1
  98. package/dist/public/assets/{use-settings-route-BzQtFbVz.js → use-settings-route-DT_sDrP6.js} +1 -1
  99. package/dist/public/assets/{use-skill-origin-BM7aK7w5.js → use-skill-origin-djszP4BX.js} +1 -1
  100. package/dist/public/assets/{use-terminal-enabled-mj1HMZEE.js → use-terminal-enabled-D8pfw24f.js} +1 -1
  101. package/dist/public/assets/{use-timeline-entry-diff-eQroikMP.js → use-timeline-entry-diff-CJndzyXq.js} +1 -1
  102. package/dist/public/assets/{use-workspace-uQYd5g6N.js → use-workspace-DanpYgc9.js} +1 -1
  103. package/dist/public/index.html +45 -45
  104. package/dist/public/uninstall.html +3 -3
  105. package/dist/{repair-launch-json-BCz2SZyH.mjs → repair-launch-json-DOW2WCJo.mjs} +2 -2
  106. package/dist/{repair-mcp-configs-NcGaQH45.mjs → repair-mcp-configs-BAzttfrs.mjs} +2 -2
  107. package/dist/repair-skills-BDpRz7o1.mjs +1 -0
  108. package/dist/{repair-skills-CGrC_7UB.mjs → repair-skills-Djy2-44d.mjs} +2 -2
  109. package/dist/{resolve-project-root--qXrA21F.mjs → resolve-project-root-B2P-8M30.mjs} +3 -3
  110. package/dist/schemas/v0/config.project.schema.json +2 -36
  111. package/dist/{server-lock-BbnnWHQ-.mjs → server-lock-B131eKn8.mjs} +2 -2
  112. package/dist/server-lock-Cs4uE77d.mjs +1 -0
  113. package/dist/{skill-teardown-BOfnXWGl.mjs → skill-teardown-Dt9ANTO9.mjs} +2 -2
  114. package/dist/{sleep-CEs13Om_.mjs → sleep-DXvB05wr.mjs} +5 -5
  115. package/dist/{src-D8oYpCos.mjs → src-C7RaGUoz.mjs} +4 -4
  116. package/dist/{src-oOfi47J8.mjs → src-Cw4FdZEC.mjs} +1 -1
  117. package/dist/src-DG3uYi4g.mjs +2028 -0
  118. package/dist/{src-_JbAf6nM.mjs → src-NmTX6dJc.mjs} +104 -104
  119. package/dist/src-jBgBFohw.mjs +1 -0
  120. package/dist/start-BxDg_l3N.mjs +1 -0
  121. package/dist/start-CWLycoTz.mjs +4 -0
  122. package/package.json +5 -5
  123. package/dist/constants-BfbnQ1zg.mjs +0 -2
  124. package/dist/fs-traced-C9RP1mJ2.mjs +0 -1
  125. package/dist/git-handle-B8IJwypU.mjs +0 -1
  126. package/dist/init-CyJV_J-z.mjs +0 -1
  127. package/dist/loader-DZrXpupn.mjs +0 -1
  128. package/dist/md-manager-CE7LjnX6.mjs +0 -2
  129. package/dist/preview-8qVct0-k.mjs +0 -1
  130. package/dist/public/assets/FeedbackForm-D_sc5CWU.js +0 -1
  131. package/dist/public/assets/ManagedArtifactProperties-DqkbIYRf.js +0 -1
  132. package/dist/public/assets/client-version-B8t572qZ.js +0 -1
  133. package/dist/public/assets/i18n-BphO6l4i.js +0 -1
  134. package/dist/repair-skills-Bxm3hryZ.mjs +0 -1
  135. package/dist/server-lock-DAYx4_kR.mjs +0 -1
  136. package/dist/src-CUzcBQEu.mjs +0 -2028
  137. package/dist/src-RQsLXRLR.mjs +0 -1
  138. package/dist/start-AtCGtYSd.mjs +0 -1
  139. package/dist/start-BGvZNtV7.mjs +0 -8
@@ -592,31 +592,6 @@
592
592
  },
593
593
  "additionalProperties": {}
594
594
  },
595
- "remote": {
596
- "default": {},
597
- "type": "object",
598
- "properties": {
599
- "url": {
600
- "type": "string",
601
- "scope": "project",
602
- "agentSettable": false,
603
- "reload": "boot",
604
- "defaultScope": "project",
605
- "description": "Superseded by server.externalUrl — read only while server.externalUrl (and its deprecated server.publicUrl spelling) is absent. Public URL your tunnel gives you, e.g. https://myproject.ngrok.app. Used only with `ok start --remote` (config alone never enables remote access); its host is admitted through the Host-header allowlist. There is no server-side auth, so restrict access at the tunnel (ngrok OAuth, Cloudflare Access, Tailscale ACLs)."
606
- },
607
- "port": {
608
- "type": "integer",
609
- "minimum": 1,
610
- "maximum": 65535,
611
- "scope": "project",
612
- "agentSettable": false,
613
- "reload": "boot",
614
- "defaultScope": "project",
615
- "description": "Superseded by server.port — read only while server.port is absent. TCP port the server binds when remote access is enabled (default 24550). Fixed so the tunnel's port mapping survives restarts. Set it only on a conflict. An explicit --port still wins; the PORT env var is ignored in remote mode."
616
- }
617
- },
618
- "additionalProperties": {}
619
- },
620
595
  "server": {
621
596
  "default": {
622
597
  "bind": [
@@ -634,7 +609,7 @@
634
609
  "agentSettable": false,
635
610
  "reload": "boot",
636
611
  "defaultScope": "project",
637
- "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. Supersedes remote.port (still read while this key is absent). Read at server start; changing it requires a restart."
612
+ "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."
638
613
  },
639
614
  "externalUrl": {
640
615
  "type": "string",
@@ -643,16 +618,7 @@
643
618
  "agentSettable": false,
644
619
  "reload": "boot",
645
620
  "defaultScope": "project",
646
- "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. Supersedes server.publicUrl (its former name) and remote.url — both still read while this key is absent. Read at server start; changing it requires a restart."
647
- },
648
- "publicUrl": {
649
- "type": "string",
650
- "pattern": "^https?:\\/\\/",
651
- "scope": "project",
652
- "agentSettable": false,
653
- "reload": "boot",
654
- "defaultScope": "project",
655
- "description": "Deprecated alias of server.externalUrl (the former name of that key) — read only while server.externalUrl is absent, with identical semantics. Use server.externalUrl instead; if this config is committed and shared, keep both keys until every collaborator has upgraded (older versions read only server.publicUrl)."
621
+ "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."
656
622
  }
657
623
  },
658
624
  "additionalProperties": {}
@@ -1,2 +1,2 @@
1
- import"./src-_JbAf6nM.mjs";import{r as e}from"./logger-Dq-cRhcP.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const y=v(),b=1;function x(e){return new URL(e.url??``,`http://localhost`).searchParams}function S(e){let t=e?.code;return typeof t==`string`?t:void 0}const C=/^[A-Za-z0-9-]{8,64}$/;let w=null;function T(e){return n(e??p(),`.ok`,`machine-id`)}function E(n){if(n===void 0&&w!==null)return w;let r=T(n),i=null;try{let e=l(r,`utf-8`).trim();C.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(w=i),i}const D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===E():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==E()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:E(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??2,runtimeVersion:r.runtimeVersion??y},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(S(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){S(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e){return!Array.isArray(e.capabilities)||e.capabilities.includes(`ui`)}function $(e,t){q({lockName:`server`,lockDir:e,...t})}function ee(e){U({lockName:`server`,lockDir:e})}function te(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,E as _,Z as a,y as b,te as c,V as d,k as f,H as g,q as h,ee as i,O as l,G as m,Y as n,$ as o,W as p,Q as r,X as s,J as t,R as u,S as v,b as x,x as y};
2
- //# sourceMappingURL=server-lock-BbnnWHQ-.mjs.map
1
+ import"./src-NmTX6dJc.mjs";import{r as e}from"./logger-Dq-cRhcP.mjs";import{dirname as t,join as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{closeSync as a,existsSync as o,mkdirSync as s,openSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d,writeSync as f}from"node:fs";import{homedir as p,hostname as m}from"node:os";import{randomUUID as h}from"node:crypto";function g(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function _(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function v(){try{let e=r(t(i(import.meta.url)),`..`,`package.json`),n=JSON.parse(l(e,`utf-8`));if(typeof n.version==`string`&&n.version.length>0)return n.version}catch{}return`0.0.0-unknown`}const y=v(),b=1;function x(e){return new URL(e.url??``,`http://localhost`).searchParams}function S(e){let t=e?.code;return typeof t==`string`?t:void 0}const C=/^[A-Za-z0-9-]{8,64}$/;let w=null;function T(e){return n(e??p(),`.ok`,`machine-id`)}function E(n){if(n===void 0&&w!==null)return w;let r=T(n),i=null;try{let e=l(r,`utf-8`).trim();C.test(e)&&(i=e)}catch{}if(i===null){i=h();try{s(t(r),{recursive:!0}),d(r,`${i}\n`,{encoding:`utf-8`,mode:384})}catch(t){e(`machine-id`).warn({path:r,err:t},`Failed to persist ${r} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${t instanceof Error?t.message:String(t)}`)}}return n===void 0&&(w=i),i}const D=e(`process-lock`);var O=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`OpenKnowledge ${n} already running at ${e.url??`port ${e.port}`} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function k(e,t){return r(e,`${t}.lock`)}const A=new Map;function j(e){A.set(e,(A.get(e)??0)+1)}function M(e){let t=A.get(e);return t===void 0||t<=1?(A.delete(e),!0):(A.set(e,t-1),!1)}function N(e){return typeof e.machineId==`string`?e.machineId===E():e.hostname===m()}const P=new Set;let F=!1;function I(e){P.add(e),!F&&(F=!0,process.on(`exit`,()=>{for(let e of P)try{let t=JSON.parse(l(e,`utf-8`));if(t?.pid!==process.pid||typeof t.machineId==`string`&&t.machineId!==E()||t.machineId===void 0&&typeof t.hostname==`string`&&t.hostname!==m())continue;u(e)}catch{}}))}function L(e,t){try{let n=JSON.parse(l(e,`utf-8`));return n&&typeof n==`object`&&_(n.pid)?n:(D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return D.warn({lockPath:e},`${t} Corrupt lock file at ${e} — replacing`),null}}function R(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;s(n,{recursive:!0});let l=k(n,t),p={pid:process.pid,hostname:m(),port:r.port,...r.url!==void 0&&{url:r.url},startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,machineId:E(),...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??2,runtimeVersion:r.runtimeVersion??y},h=JSON.stringify(p,null,2);for(let e=0;e<3;e++){if(!o(l))try{let e=c(l,`wx`,384);try{f(e,h)}finally{a(e)}return j(l),I(l),z({lockName:t,lockDir:n,lockPath:l})}catch(e){if(S(e)!==`EEXIST`)throw e}let e=L(l,i);if(e){if(N(e)&&e.pid===process.pid)return d(l,h,{encoding:`utf-8`,mode:384}),j(l),I(l),z({lockName:t,lockDir:n,lockPath:l});if(g(e.pid))throw new O(e,l,t);D.warn({pid:e.pid,host:e.hostname},`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{u(l)}catch{}}throw Error(`${i} Failed to acquire ${l} after 3 attempts (concurrent acquire contention).`)}function z(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>q({lockName:t,lockDir:n}),updatePort:(e,r)=>H({lockName:t,lockDir:n,port:e,url:r})}}function B(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function V(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=B(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}function H(e){let{lockName:t,lockDir:n,port:r,url:i}=e,a=`[${t}-lock]`,s=k(n,t);if(!o(s)){D.warn({lockPath:s},`${a} Lock file missing at ${s} during port update — skipping`);return}let c;try{let e=JSON.parse(l(s,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:s},`${a} Corrupt lock at ${s} during port update — skipping`);return}c=e}catch{D.warn({lockPath:s},`${a} Unreadable lock at ${s} during port update — skipping`);return}if(c.pid===process.pid&&N(c)){c.port=r,i===void 0?delete c.url:c.url=i;try{d(s,JSON.stringify(c,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:s,err:e},`${a} Failed to update port in ${s}: ${e instanceof Error?e.message:String(e)}`)}}}function U(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=k(n,t);if((A.get(i)??0)>1)return;let a;try{let e=JSON.parse(l(i,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid)){D.warn({lockPath:i},`${r} Corrupt lock at ${i} during draining mark — skipping`);return}a=e}catch(e){S(e)!==`ENOENT`&&D.warn({lockPath:i,err:e},`${r} Unreadable lock at ${i} during draining mark — skipping: ${e instanceof Error?e.message:String(e)}`);return}if(a.pid===process.pid&&N(a)&&a.draining!==!0){a.draining=!0;try{d(i,JSON.stringify(a,null,2),{encoding:`utf-8`,mode:384})}catch(e){D.warn({lockPath:i,err:e},`${r} Failed to mark ${i} draining: ${e instanceof Error?e.message:String(e)}`)}}}function W(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return null;let i;try{let e=JSON.parse(l(r,`utf-8`));if(!e||typeof e!=`object`||!_(e.pid))return null;i=e}catch{return null}if(!N(i))return null;if(!g(i.pid)){try{u(r)}catch{}return null}return i}function G(e){let{lockName:t,lockDir:n}=e,r=k(n,t);if(!o(r))return{status:`absent`};let i;try{i=JSON.parse(l(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!_(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let s={pid:a.pid,hostname:a.hostname,port:a.port,url:typeof a.url==`string`?a.url:void 0,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,machineId:typeof a.machineId==`string`?a.machineId:void 0,draining:a.draining===!0?!0:void 0,capabilities:Array.isArray(a.capabilities)&&a.capabilities.every(e=>typeof e==`string`)?a.capabilities:void 0,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(!N(s))return{status:`stale`,lock:s};if(!g(s.pid)){try{u(r)}catch{}return{status:`stale`,lock:s}}return s.protocolVersion===void 0||s.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:s}}async function K(e){let{lockName:t,lockDir:n}=e,r=e.timeoutMs??1e4,i=e.pollIntervalMs??100,a=e.readLock??(()=>W({lockName:t,lockDir:n})),o=e.sleep??(e=>new Promise(t=>setTimeout(t,e))),s=a();if(s===null||s.draining!==!0)return`no-drain`;let c=Date.now()+r;for(;Date.now()<c;){await o(i);let e=a();if(e===null)return`released`;if(e.draining!==!0)return`no-drain`}return`timeout`}function q(e){let{lockName:t,lockDir:n,deferUnlinkToExit:r=!1}=e,i=`[${t}-lock]`,a=k(n,t);if(M(a)){if(r){U({lockName:t,lockDir:n});return}if(o(a))try{let e=JSON.parse(l(a,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||!N(e))return;u(a),P.delete(a)}catch(e){D.warn({lockPath:a,err:e},`${i} Failed to release ${a}: ${e instanceof Error?e.message:String(e)}`)}}}var J=class extends O{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function Y(e,t){try{return R({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof O&&e.lockName===`server`?new J(e.existing,e.lockPath):e}}function X(e,t,n){H({lockName:`server`,lockDir:e,port:t,url:n})}function Z(e){return W({lockName:`server`,lockDir:e})}function Q(e){return!Array.isArray(e.capabilities)||e.capabilities.includes(`ui`)}function $(e,t){q({lockName:`server`,lockDir:e,...t})}function ee(e){U({lockName:`server`,lockDir:e})}function te(e,t){return K({lockName:`server`,lockDir:e,...t})}export{_ as C,g as S,E as _,Z as a,y as b,te as c,V as d,k as f,H as g,q as h,ee as i,O as l,G as m,Y as n,$ as o,W as p,Q as r,X as s,J as t,R as u,S as v,b as x,x as y};
2
+ //# sourceMappingURL=server-lock-B131eKn8.mjs.map
@@ -0,0 +1 @@
1
+ import{i as e,o as t,s as n}from"./server-lock-B131eKn8.mjs";export{e as markServerLockDraining,t as releaseServerLock,n as updateServerLockPort};
@@ -1,2 +1,2 @@
1
- import{Fs as e}from"./src-_JbAf6nM.mjs";import{Dr as t,Tr as n}from"./src-CUzcBQEu.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{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`}],h=[...t.map(e=>n[e]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(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(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=n[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let n of e)o.push({path:a(i,n.skillsRoot,t),bundleId:r,scope:`host`,hostDir:n.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(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}`)}export{C as i,y as n,w as r,S as t};
2
- //# sourceMappingURL=skill-teardown-BOfnXWGl.mjs.map
1
+ import{Is as e}from"./src-NmTX6dJc.mjs";import{Dr as t,Tr as n}from"./src-DG3uYi4g.mjs";import{dirname as r,isAbsolute as i,join as a,relative as o,resolve as s,sep as c}from"node:path";import{existsSync as l,lstatSync as u,readdirSync as d,rmSync as f,rmdirSync as p}from"node:fs";const m=[{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`}],h=[...t.map(e=>n[e]),`open-knowledge`];function g(e){if(!i(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=s(e);if(t===c||r(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function _(e,t){let n=o(e,t);if(n.startsWith(`..`)||i(n))return!1;let r=e;for(let e of n.split(c)){r=a(r,e);try{if(!u(r).isDirectory())return!1}catch{return!1}}return!0}function v(e,t){try{return d(e).every(n=>t.has(a(e,n)))}catch{return!1}}function y(e){let t=g(e),n=[],i=[],o=new Set;for(let e of m){let s=a(t,e.hostDir,`skills`);if(!_(t,s))continue;let u=h.map(e=>a(s,e)).filter(e=>l(e));n.push(...u);for(let e of u)o.add(e);let d=a(t,e.pruneRoot),f=s;for(;v(f,o)&&(i.push(f),o.add(f),f!==d);){let e=r(f);if(e===f||e===t||!e.startsWith(t+c))break;f=e}}return{skillDirs:n,emptyDirs:i}}function b(e){try{if(!u(e).isDirectory())return!1;let t=d(e);return t.length===0||t.includes(`SKILL.md`)}catch{return!1}}function x(e){let t=new Set,n=new Set;for(let i of m){let o=a(e,i.hostDir,`skills`);for(let e of h)t.add(a(o,e));let s=a(e,i.pruneRoot),l=o;for(;n.add(l),l!==s;){let t=r(l);if(t===l||t===e||!t.startsWith(e+c))break;l=t}}return{skillDirs:t,emptyDirs:n}}function S(e,t){let n=g(e),r=x(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(_(n,e)&&b(e))try{f(e,{recursive:!0,force:!0}),a.push(e)}catch{}for(let e of t.emptyDirs)if(_(n,e))try{p(e),a.push(e)}catch{}return a}function C(r){let i=g(r),o=[];for(let r of t){let t=n[r];o.push({path:a(i,`.agents`,`skills`,t),bundleId:r,scope:`central`});for(let n of e)o.push({path:a(i,n.skillsRoot,t),bundleId:r,scope:`host`,hostDir:n.hostDir})}return o}function w(e,t){let n=[];for(let r of C(e))if(r.bundleId===t)try{f(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}`)}export{C as i,y as n,w as r,S as t};
2
+ //# sourceMappingURL=skill-teardown-Dt9ANTO9.mjs.map
@@ -177,13 +177,13 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
177
177
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){u(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(a(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=l(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(a(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(s(t.key)&&!a(t.sep,`newline`)){let e=l(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):a(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!a(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){u(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||a(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=l(c(t));d(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
178
178
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
179
179
  `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=l(c(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=l(c(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),dc=t((e=>{var t=rc(),n=Bs(),r=Vs(),i=ps(),a=q(),o=lc(),s=uc();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),fc=t((e=>{var t=rc(),n=Bs(),r=Rs(),i=Vs(),a=as(),o=q(),s=X(),c=Y(),l=Z(),u=vs();sc();var d=cc(),f=lc(),p=uc(),m=dc(),h=es();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}));const pc=new Set(Object.keys({sh:`bash`,zsh:`bash`,bash:`bash`,c:`c`,cc:`cpp`,cpp:`cpp`,cxx:`cpp`,"c++":`cpp`,h:`c`,hh:`cpp`,hpp:`cpp`,cs:`csharp`,css:`css`,less:`less`,scss:`scss`,sass:`scss`,diff:`diff`,patch:`diff`,feature:`gherkin`,go:`go`,gql:`graphql`,graphql:`graphql`,ini:`ini`,cfg:`ini`,conf:`ini`,properties:`ini`,java:`java`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,kt:`kotlin`,kts:`kotlin`,lua:`lua`,makefile:`makefile`,md:`markdown`,mdx:`markdown`,m:`objectivec`,mm:`objectivec`,pl:`perl`,pm:`perl`,php:`php`,phtml:`php`,py:`python`,pyi:`python`,pyx:`python`,r:`r`,rb:`ruby`,rs:`rust`,sql:`sql`,swift:`swift`,ts:`typescript`,tsx:`typescript`,xml:`xml`,yaml:`yaml`,yml:`yaml`})),mc=new Set([`md`,`mdx`,`mmd`,`mermaid`]),hc=new Set([...pc,`txt`,`text`,`csv`,`tsv`,`log`,`toml`,`html`,`htm`,`svg`,`vue`,`svelte`,`astro`,`lock`].filter(e=>!mc.has(e)));function gc(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:hc.has(t.slice(n+1).toLowerCase())}const _c=[`image/jpeg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`],vc=[`video/mp4`,`video/webm`,`video/ogg`],yc=[`audio/mpeg`,`audio/wav`,`audio/ogg`],bc=[`application/pdf`],xc=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`]),Sc=new Set([`mp4`,`webm`,`mov`,`m4v`,`mkv`]),Cc=new Set([`pdf`]),wc=new Set([`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`]),Tc=new Set(`pdf.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),Ec=new Set(`exe.bat.cmd.ps1.com.msi.vbs.js.jse.wsf.wsh.hta.sh.command.csh.ksh.bash.zsh.fish.desktop.action.workflow.html.htm.svg.xml.mhtml.svgz.dmg.pkg.mpkg.scpt.applescript.terminal.prefpane.webloc.inetloc.fileloc.jar.appimage.deb.rpm.msix.appx.ipa.apk.pif.scr.lnk.url`.split(`.`)),Dc=new Set(`png.jpg.jpeg.gif.webp.avif.svg.apng.heic.heif.tiff.bmp.ico.pdf.mp4.webm.mov.m4v.mkv.avi.flv.wmv.mpeg.mpg.mp3.wav.ogg.m4a.flac.aac.opus.zip.7z.tar.gz.rar.woff.woff2.ttf.otf.eot.docx.xlsx.pptx.doc.xls.ppt.odt.ods.odp.pages.numbers.key.epub.mobi.csv.tsv.txt.rtf.json.yaml.yml.xml.toml.lock.gpx.html.htm`.split(`.`)),Oc=new Set([`html`,`htm`]),kc=`sandbox allow-scripts; connect-src 'none'`,Ac=new Set(`png.jpg.jpeg.gif.webp.avif.apng.heic.heif.tiff.bmp.ico.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.json.toml.lock`.split(`.`)),jc=`same-dir`,Mc=new Set(`png.jpg.jpeg.gif.webp.avif.svg.pdf.mp4.webm.mov.m4v.mkv.mp3.wav.ogg.m4a.flac.aac.opus.docx.xlsx.pptx.doc.xls.ppt.zip.7z.tar.gz.rar.csv.tsv.rtf.json.yaml.yml.xml.txt.pages.numbers.key.odt.ods.odp.epub.mobi`.split(`.`)),Nc=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`],Pc=[`mp4`,`webm`,`mov`,`m4v`],Fc=[`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`opus`],Ic=[`pdf`],Lc=[`json`,`toml`,`lock`];function Rc(e,t,n){for(let r of t)if(!n.has(r))throw Error(`${e}: ${r} is not present in canonical upload constants`)}Rc(`SIDEBAR_IMAGE_ASSET_EXTENSIONS`,Nc,xc),Rc(`SIDEBAR_VIDEO_ASSET_EXTENSIONS`,Pc,Sc),Rc(`SIDEBAR_AUDIO_ASSET_EXTENSIONS`,Fc,wc),Rc(`SIDEBAR_PDF_ASSET_EXTENSIONS`,Ic,Cc),Rc(`FILE_ATTACHMENT_EXTENSIONS`,[...Tc],Mc),Rc(`WIKI_EMBED_EXTENSIONS`,[...Mc],Dc);const zc=new Set(Nc),Bc=new Set(Pc),Vc=new Set(Fc),Hc=new Set(Ic),Uc=new Set(Lc);Rc(`SIDEBAR_RENDERABLE_ASSET_EXTENSIONS`,[...new Set([...Nc,...Pc,...Fc,...Ic,...Lc])],Ac);const Wc=new Set([`base`,`canvas`]),Gc=new Set([`mmd`,`mermaid`]);function Kc(e){let t=e.lastIndexOf(`.`);return t<0?!1:Gc.has(e.slice(t+1).toLowerCase())}const qc=new Set([`excalidraw`]);function Jc(e){let t=e.lastIndexOf(`.`);return t<0?!1:qc.has(e.slice(t+1).toLowerCase())}const Yc=new Set([...Dc,...Wc,...Gc,...qc]);function Xc(e){let t=e.toLowerCase().replace(/^\./,``);return zc.has(t)?`image`:Bc.has(t)?`video`:Vc.has(t)?`audio`:Hc.has(t)?`pdf`:Uc.has(t)||Wc.has(t)?`text`:Gc.has(t)?`mermaid`:qc.has(t)?`excalidraw`:pc.has(t)?`text`:null}const Zc=[`en`,`zh-Hans`,`zh-Hant`,`hi`,`es`,`ar`,`fr`,`bn`,`pt-BR`,`id`,`ur`,`ko`],Qc=new Set([`ar`,`ur`]),$c=Zc.filter(e=>!Qc.has(e)),el=[`off`,`warning`,`error`],tl=`warning`,nl=[`error`,`warning`];var rl=fc();const il=[`base00`,`base01`,`base02`,`base03`,`base04`,`base05`,`base06`,`base07`,`base08`,`base09`,`base0A`,`base0B`,`base0C`,`base0D`,`base0E`,`base0F`],al={base00:`default background`,base01:`alt background — cards, popovers, sidebar`,base02:`selection background, borders`,base03:`comments, invisibles`,base04:`secondary text`,base05:`default foreground`,base06:`light foreground`,base07:`lightest foreground`,base08:`red — variables, tags, diff deleted`,base09:`orange — numbers, constants`,base0A:`yellow — classes, search highlight`,base0B:`green — strings, diff inserted`,base0C:`cyan — support, escapes, quotes`,base0D:`blue — functions, headings, accent`,base0E:`magenta — keywords, storage`,base0F:`deprecated markers, embedded tags`},ol=/^#[0-9a-fA-F]{6}$/,sl=/\P{White_Space}/u;function cl(e){return sl.test(e)}function ll(e){return typeof e==`string`&&ol.test(e)}function ul(e){let t=e.palette;return{background:t.base00,foreground:t.base05,card:t.base01,"card-foreground":t.base05,popover:t.base01,"popover-foreground":t.base05,primary:t.base0D,"primary-foreground":t.base00,secondary:t.base01,"secondary-foreground":t.base05,muted:t.base01,"muted-foreground":t.base04,accent:t.base02,"accent-foreground":t.base05,destructive:t.base08,border:t.base02,input:t.base02,ring:t.base0D,"selection-soft":t.base02,"chart-1":t.base0D,"chart-2":t.base0B,"chart-3":t.base0A,"chart-4":t.base0E,"chart-5":t.base08,sidebar:t.base01,"sidebar-foreground":t.base05,"sidebar-primary":t.base0D,"sidebar-primary-foreground":t.base00,"sidebar-accent":t.base02,"sidebar-accent-foreground":t.base0D,"sidebar-hover":t.base02,"sidebar-border":t.base02,"sidebar-ring":t.base0D,"syntax-keyword":t.base0E,"syntax-tag":t.base08,"syntax-attr":t.base0D,"syntax-string":t.base0B,"syntax-number":t.base09,"syntax-atom":t.base0C,"syntax-comment":t.base03,"syntax-func":t.base0D,"syntax-var":t.base08,"syntax-type":t.base0A,"syntax-operator":t.base05,"syntax-meta":t.base0F,"syntax-bg":t.base01,"link-color":t.base0D,"broken-link-color":t.base08,"lint-warning-color":t.base0A,"lint-error-color":t.base08,"diff-added":t.base0B,"diff-removed":t.base08,"callout-note-color":t.base0D,"callout-info-color":t.base0D,"callout-todo-color":t.base0D,"callout-abstract-color":t.base0C,"callout-tip-color":t.base0B,"callout-success-color":t.base0B,"callout-important-color":t.base0E,"callout-example-color":t.base0E,"callout-question-color":t.base0E,"callout-warning-color":t.base0A,"callout-caution-color":t.base09,"callout-danger-color":t.base09,"callout-failure-color":t.base08,"callout-bug-color":t.base08,"callout-quote-color":t.base03,...pl(t)}}const dl={black:`base00`,red:`base08`,green:`base0B`,yellow:`base0A`,blue:`base0D`,magenta:`base0E`,cyan:`base0C`,white:`base05`,brightBlack:`base03`,brightRed:`base08`,brightGreen:`base0B`,brightYellow:`base0A`,brightBlue:`base0D`,brightMagenta:`base0E`,brightCyan:`base0C`,brightWhite:`base07`},fl=Object.keys(dl);function pl(e){let t={};for(let n of fl)t[`ansi-${ml(n)}`]=e[dl[n]];return t}function ml(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}function hl(e){return JSON.stringify(e).replace(/[\u007f-\u009f\u2028\u2029\ufffe\uffff]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function gl(e){return`${[`system: "base16"`,`name: ${hl(e.name)}`,...e.author?[`author: ${hl(e.author)}`]:[],`variant: ${hl(e.variant)}`,`palette:`,...il.map(t=>` ${t}: ${hl(e.palette[t])}`)].join(`
180
- `)}\n`}function _l(e){let t;try{t=(0,rl.parse)(e,{schema:`failsafe`})}catch(e){let t=e?.linePos;return{ok:!1,error:{kind:`unparseable`,line:typeof t?.[0]?.line==`number`?t[0].line:void 0}}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,error:{kind:`not-a-scheme`}};let n=t,r=n.palette,i=r&&typeof r==`object`&&!Array.isArray(r)?r:n,a={},o=[],s=[];for(let e of il){let t=i[e]??i[e.toLowerCase()];if(t==null){o.push(e);continue}let n=vl(t);if(!n){s.push(e);continue}a[e]=n}return o.length?{ok:!1,error:{kind:`missing-slots`,slots:o}}:s.length?{ok:!1,error:{kind:`bad-hex`,slots:s}}:typeof n.name==`string`&&!cl(n.name)||typeof n.author==`string`&&!cl(n.author)?{ok:!1,error:{kind:`not-a-scheme`}}:{ok:!0,scheme:{name:typeof n.name==`string`?n.name:`Imported`,author:typeof n.author==`string`?n.author:void 0,variant:n.variant===`light`||n.variant===`dark`?n.variant:bl(a),palette:a}}}function vl(e){if(typeof e!=`string`)return null;let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),/^#[0-9a-fA-F]{3}$/.test(t)&&(t=`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`),ol.test(t)?t.toLowerCase():null}function yl(e){let t=ll(e)?e:`#000000`,n=e=>{let n=Number.parseInt(t.slice(1+e*2,3+e*2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(1)+.0722*n(2)}function bl(e){return yl(e.base00)<yl(e.base05)?`dark`:`light`}const xl={name:`Dracula`,author:`clach04 (https://github.com/clach04)`,variant:`dark`,palette:{base00:`#282a36`,base01:`#21222c`,base02:`#44475a`,base03:`#6272a4`,base04:`#9ea8c7`,base05:`#f8f8f2`,base06:`#f8f8f2`,base07:`#ffffff`,base08:`#ff5555`,base09:`#ffb86c`,base0A:`#f1fa8c`,base0B:`#50fa7b`,base0C:`#8be9fd`,base0D:`#bd93f9`,base0E:`#ff79c6`,base0F:`#993333`}},Sl={name:`Catppuccin Frappé`,author:`https://github.com/catppuccin/catppuccin`,variant:`dark`,palette:{base00:`#303446`,base01:`#292c3c`,base02:`#414559`,base03:`#51576d`,base04:`#626880`,base05:`#c6d0f5`,base06:`#f2d5cf`,base07:`#babbf1`,base08:`#e78284`,base09:`#ef9f76`,base0A:`#e5c890`,base0B:`#a6d189`,base0C:`#81c8be`,base0D:`#8caaee`,base0E:`#ca9ee6`,base0F:`#eebebe`}},Cl={name:`Catppuccin Latte`,author:`https://github.com/catppuccin/catppuccin`,variant:`light`,palette:{base00:`#eff1f5`,base01:`#e6e9ef`,base02:`#ccd0da`,base03:`#bcc0cc`,base04:`#acb0be`,base05:`#4c4f69`,base06:`#dc8a78`,base07:`#7287fd`,base08:`#d20f39`,base09:`#fe640b`,base0A:`#df8e1d`,base0B:`#40a02b`,base0C:`#179299`,base0D:`#1d62ec`,base0E:`#8839ef`,base0F:`#dd7878`}},wl={name:`Monokai`,author:`Wimer Hazenberg (http://www.monokai.nl)`,variant:`dark`,palette:{base00:`#272822`,base01:`#383830`,base02:`#49483e`,base03:`#75715e`,base04:`#a59f85`,base05:`#f8f8f2`,base06:`#f5f4f1`,base07:`#f9f8f5`,base08:`#f92672`,base09:`#fd971f`,base0A:`#f4bf75`,base0B:`#a6e22e`,base0C:`#a1efe4`,base0D:`#66d9ef`,base0E:`#ae81ff`,base0F:`#cc6633`}},Tl={name:`Gruvbox dark, medium`,author:`Dawid Kurek, morhetz (https://github.com/morhetz/gruvbox)`,variant:`dark`,palette:{base00:`#282828`,base01:`#3c3836`,base02:`#504945`,base03:`#665c54`,base04:`#bdae93`,base05:`#d5c4a1`,base06:`#ebdbb2`,base07:`#fbf1c7`,base08:`#fb4934`,base09:`#fe8019`,base0A:`#fabd2f`,base0B:`#b8bb26`,base0C:`#8ec07c`,base0D:`#83a598`,base0E:`#d3869b`,base0F:`#d65d0e`}},El={name:`Solarized Dark`,author:`Ethan Schoonover (modified by aramisgithub)`,variant:`dark`,palette:{base00:`#002b36`,base01:`#073642`,base02:`#586e75`,base03:`#657b83`,base04:`#839496`,base05:`#93a1a1`,base06:`#eee8d5`,base07:`#fdf6e3`,base08:`#dc322f`,base09:`#cb4b16`,base0A:`#b58900`,base0B:`#859900`,base0C:`#2aa198`,base0D:`#2995e1`,base0E:`#6c71c4`,base0F:`#d33682`}};function Dl(e,t,n){return{id:e,label:t,kind:n.variant,scheme:n,toTokens:()=>ul(n)}}function Ol(e,t){return{id:e,label:t,kind:`system`}}const kl=[Ol(`default`,`Default`),Dl(`dracula`,`Dracula`,xl),Dl(`catppuccin-frappe`,`Catppuccin Frappé`,Sl),Dl(`catppuccin-latte`,`Catppuccin Latte`,Cl),Dl(`monokai`,`Monokai`,wl),Dl(`gruvbox`,`Gruvbox`,Tl),Dl(`solarized`,`Solarized`,El),Ol(`custom`,`Custom`)],Al=kl.map(e=>e.id),jl=/^[a-z0-9-]{1,32}$/,Ml=/\p{M}+/gu,Nl=/['\u2019\u02bc]+/gu,Pl=/[^a-z0-9]+/g;function Fl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function Il(e){let t=e.trim();if(t.length===0)return{ok:!1,code:`empty`};let n=t.normalize(`NFKD`).replace(Ml,``).toLowerCase().replace(Nl,``).replace(Pl,`-`).replace(/^-+|-+$/g,``),r=Fl(t),i=n.length===0?`theme-${r}`:n.length<=26?n:`${n.slice(0,26-r.length-1).replace(/-+$/g,``)}-${r}`,a=Ll(i);if(!a.ok)throw Error(`Saved theme name derivation produced an invalid id`);return{ok:!0,name:t,stem:i,id:a.id}}function Ll(e){if(e.length===0)return{ok:!1,code:`empty`};let t=`saved-`+e;return jl.test(t)?{ok:!0,id:t}:{ok:!1,code:/^[a-z0-9-]+$/.test(t)?`too-long`:`invalid-chars`}}function Rl(e){if(!jl.test(e)||!e.startsWith(`saved-`))return{ok:!1};let t=e.slice(6);return t.length===0?{ok:!1}:{ok:!0,stem:t}}new Map(kl.map(e=>[e.id,e]));const zl=Symbol.for(`@inkeep/open-knowledge/field-registry`),Bl=globalThis;Bl[zl]===void 0&&(Bl[zl]=tr());const Q=Bl[zl];function Vl(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Hl(t)?Q.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Hl(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}function Ul(){return Object.fromEntries(il.map(e=>[e,L().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${al[e]}, as a #rrggbb hex string.`}).optional()]))}function Wl(){return Al.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}const Gl=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Kl=52428800,ql=26214400,Jl=12582912,Yl=`https://api.openai.com/v1`,Xl=`text-embedding-3-small`,Zl=Object.freeze([`127.0.0.1`]),Ql=/^[1-9]\d*(s|m|h)$/,$l=/^https?:\/\//,eu=24550;function tu(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 nu(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&tu(e)?null:`insecure-scheme`}function ru(e){let t=e.trim();return t===``?`./`:t}function iu(e){let t=ru(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}const au=U({content:U({dir:L().register(Q,{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:L().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(iu,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:U({theme:G([`light`,`dark`,`system`]).register(Q,{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:G([`system`,...Zc]).register(Q,{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:L().register(Q,{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 ${Wl()}, 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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:L().register(Q,{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 ${Wl()}, 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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:L().register(Q,{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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:B().register(Q,{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:U({name:L().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:L().register(Q,{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:G([`dark`,`light`]).register(Q,{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(),...Ul()}).optional(),preview:U({autoOpen:B().register(Q,{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:U({showHiddenFiles:B().register(Q,{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:B().register(Q,{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:B().register(Q,{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:B().register(Q,{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)}).optional()}).default({preview:{autoOpen:!0}}),editor:U({wordWrap:B().register(Q,{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:B().register(Q,{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:U({autoApproveOkTools:B().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:U({mode:G(qo).register(Q,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`How this machine syncs this project with its git remote: 'off' (no sync), 'follow' (one-directional — pull remote changes, never push your own; 'pull' is accepted as a legacy alias), or 'full' (bidirectional pull and push). null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:B().register(Q,{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:G(Jo).register(Q,{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(),default:W([B(),G(qo)]).register(Q,{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}),terminal:U({enabled:B().register(Q,{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)}).default({enabled:null}),slides:U({enabled:B().register(Q,{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:U({localSink:U({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:U({maxBytes:z().register(Q,{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(Kl)}).default({maxBytes:Kl}),logs:U({maxBytes:z().register(Q,{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(ql)}).default({maxBytes:ql}),attributeDenylist:V(L()).register(Q,{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([...Gl])}).default({enabled:!0,spans:{maxBytes:Kl},logs:{maxBytes:ql},attributeDenylist:[...Gl]}),skillInstallReports:U({enabled:B().register(Q,{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 on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:Kl},logs:{maxBytes:ql},attributeDenylist:[...Gl]},skillInstallReports:{enabled:!0}}),lossCapture:U({enabled:B().register(Q,{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:z().register(Q,{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(Jl)}).default({enabled:!0,maxBytes:Jl}),bridge:U({backgroundThrottle:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({semantic:U({enabled:B().register(Q,{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:L().register(Q,{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` (`~/.ok/secrets.yml`); it is sent to whichever endpoint this names."}).default(Yl),model:L().register(Q,{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(Xl),dimensions:z().int().positive().register(Q,{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:z().min(0).max(1).register(Q,{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()}).default({enabled:!1,baseUrl:Yl,model:Xl})}).default({semantic:{enabled:!1,baseUrl:Yl,model:Xl}}),contentRules:U({markdownlint:H({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:H({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:V(H({appliesTo:W([L(),V(L())]).optional(),file:L(),enabled:B().optional()})).register(Q,{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:H({enabled:B().register(Q,{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:mo(L(),B()).register(Q,{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:H({index:B().register(Q,{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:U({links:G(el).register(Q,{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(tl),fileTreeIndicators:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0)}).default({links:tl,fileTreeIndicators:!0}),linkPreviews:U({enabled:B().register(Q,{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. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata — 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}),remote:U({url:L().register(Q,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:"Superseded by server.externalUrl — read only while server.externalUrl (and its deprecated server.publicUrl spelling) is absent. Public URL your tunnel gives you, e.g. https://myproject.ngrok.app. Used only with `ok start --remote` (config alone never enables remote access); its host is admitted through the Host-header allowlist. There is no server-side auth, so restrict access at the tunnel (ngrok OAuth, Cloudflare Access, Tailscale ACLs)."}).optional(),port:z().int().min(1).max(65535).register(Q,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Superseded by server.port — read only while server.port is absent. TCP port the server binds when remote access is enabled (default 24550). Fixed so the tunnel's port mapping survives restarts. Set it only on a conflict. An explicit --port still wins; the PORT env var is ignored in remote mode.`}).optional()}).default({}),server:U({port:z().int().min(1).max(65535).register(Q,{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. Supersedes remote.port (still read while this key is absent). Read at server start; changing it requires a restart.`}).optional(),bind:V(L().min(1)).min(1).register(Q,{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([...Zl]),externalUrl:ja({protocol:/^https?$/}).regex($l).register(Q,{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. Supersedes server.publicUrl (its former name) and remote.url — both still read while this key is absent. Read at server start; changing it requires a restart.`}).optional(),publicUrl:ja({protocol:/^https?$/}).regex($l).register(Q,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Deprecated alias of server.externalUrl (the former name of that key) — read only while server.externalUrl is absent, with identical semantics. Use server.externalUrl instead; if this config is committed and shared, keep both keys until every collaborator has upgraded (older versions read only server.publicUrl).`}).optional(),allowExternal:B().register(Q,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. Once the unified server boot lands, a non-loopback server.bind or a server.externalUrl without allowExternal: true will be refused at boot with a one-line fix. Default off. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:B().register(Q,{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:W([K(`off`),L().regex(Ql)]).register(Q,{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' when every bind address is loopback, 'off' otherwise (an exposed or containerized server stays up). Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...Zl],allowExternal:!1})});r();const ou=`open-knowledge-config`;async function su(e,t,r){let a=i.getTracer(ou),o=t?{attributes:t}:{};return a.startActiveSpan(e,o,async e=>{try{return await r(e)}catch(t){throw e.recordException(t),e.setStatus({code:n.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function cu(e,t,r){let a=i.getTracer(ou),o=t?{attributes:t}:{};return a.startActiveSpan(e,o,e=>{try{return r(e)}catch(t){throw e.recordException(t),e.setStatus({code:n.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function lu(e,t){let n=i.getActiveSpan();n&&n.addEvent(e,t)}function uu(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 du(e,t){let n=e;for(let e of t){n=uu(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function fu(e,t){let n=du(e,t);if(n!==void 0)return Vl(n)}function pu(e,t){return e===`either`?!0:e===t}function mu(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=fu(au,i);a?.scope!==void 0&&(pu(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function hu(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,rl.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function gu(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)){hu(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}hu(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function _u(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}function vu(e,t){if(t.length===0)return e.contents??null;let n=e.getIn(t,!0);if((0,rl.isNode)(n))return n;for(let n=t.length-1;n>=0;n--){let r=e.getIn(t.slice(0,n),!0);if((0,rl.isNode)(r))return r}return e.contents??null}function yu(e,t){let n=1,r=1,i=Math.min(t,e.length);for(let t=0;t<i;t++)e.charCodeAt(t)===10?(n++,r=1):r++;return{line:n,column:r}}function bu(e,t,n,r,i){let a=e.split(`
180
+ `)}\n`}function _l(e){let t;try{t=(0,rl.parse)(e,{schema:`failsafe`})}catch(e){let t=e?.linePos;return{ok:!1,error:{kind:`unparseable`,line:typeof t?.[0]?.line==`number`?t[0].line:void 0}}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,error:{kind:`not-a-scheme`}};let n=t,r=n.palette,i=r&&typeof r==`object`&&!Array.isArray(r)?r:n,a={},o=[],s=[];for(let e of il){let t=i[e]??i[e.toLowerCase()];if(t==null){o.push(e);continue}let n=vl(t);if(!n){s.push(e);continue}a[e]=n}return o.length?{ok:!1,error:{kind:`missing-slots`,slots:o}}:s.length?{ok:!1,error:{kind:`bad-hex`,slots:s}}:typeof n.name==`string`&&!cl(n.name)||typeof n.author==`string`&&!cl(n.author)?{ok:!1,error:{kind:`not-a-scheme`}}:{ok:!0,scheme:{name:typeof n.name==`string`?n.name:`Imported`,author:typeof n.author==`string`?n.author:void 0,variant:n.variant===`light`||n.variant===`dark`?n.variant:bl(a),palette:a}}}function vl(e){if(typeof e!=`string`)return null;let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),/^#[0-9a-fA-F]{3}$/.test(t)&&(t=`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`),ol.test(t)?t.toLowerCase():null}function yl(e){let t=ll(e)?e:`#000000`,n=e=>{let n=Number.parseInt(t.slice(1+e*2,3+e*2),16)/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*n(0)+.7152*n(1)+.0722*n(2)}function bl(e){return yl(e.base00)<yl(e.base05)?`dark`:`light`}const xl={name:`Dracula`,author:`clach04 (https://github.com/clach04)`,variant:`dark`,palette:{base00:`#282a36`,base01:`#21222c`,base02:`#44475a`,base03:`#6272a4`,base04:`#9ea8c7`,base05:`#f8f8f2`,base06:`#f8f8f2`,base07:`#ffffff`,base08:`#ff5555`,base09:`#ffb86c`,base0A:`#f1fa8c`,base0B:`#50fa7b`,base0C:`#8be9fd`,base0D:`#bd93f9`,base0E:`#ff79c6`,base0F:`#993333`}},Sl={name:`Catppuccin Frappé`,author:`https://github.com/catppuccin/catppuccin`,variant:`dark`,palette:{base00:`#303446`,base01:`#292c3c`,base02:`#414559`,base03:`#51576d`,base04:`#626880`,base05:`#c6d0f5`,base06:`#f2d5cf`,base07:`#babbf1`,base08:`#e78284`,base09:`#ef9f76`,base0A:`#e5c890`,base0B:`#a6d189`,base0C:`#81c8be`,base0D:`#8caaee`,base0E:`#ca9ee6`,base0F:`#eebebe`}},Cl={name:`Catppuccin Latte`,author:`https://github.com/catppuccin/catppuccin`,variant:`light`,palette:{base00:`#eff1f5`,base01:`#e6e9ef`,base02:`#ccd0da`,base03:`#bcc0cc`,base04:`#acb0be`,base05:`#4c4f69`,base06:`#dc8a78`,base07:`#7287fd`,base08:`#d20f39`,base09:`#fe640b`,base0A:`#df8e1d`,base0B:`#40a02b`,base0C:`#179299`,base0D:`#1d62ec`,base0E:`#8839ef`,base0F:`#dd7878`}},wl={name:`Monokai`,author:`Wimer Hazenberg (http://www.monokai.nl)`,variant:`dark`,palette:{base00:`#272822`,base01:`#383830`,base02:`#49483e`,base03:`#75715e`,base04:`#a59f85`,base05:`#f8f8f2`,base06:`#f5f4f1`,base07:`#f9f8f5`,base08:`#f92672`,base09:`#fd971f`,base0A:`#f4bf75`,base0B:`#a6e22e`,base0C:`#a1efe4`,base0D:`#66d9ef`,base0E:`#ae81ff`,base0F:`#cc6633`}},Tl={name:`Gruvbox dark, medium`,author:`Dawid Kurek, morhetz (https://github.com/morhetz/gruvbox)`,variant:`dark`,palette:{base00:`#282828`,base01:`#3c3836`,base02:`#504945`,base03:`#665c54`,base04:`#bdae93`,base05:`#d5c4a1`,base06:`#ebdbb2`,base07:`#fbf1c7`,base08:`#fb4934`,base09:`#fe8019`,base0A:`#fabd2f`,base0B:`#b8bb26`,base0C:`#8ec07c`,base0D:`#83a598`,base0E:`#d3869b`,base0F:`#d65d0e`}},El={name:`Solarized Dark`,author:`Ethan Schoonover (modified by aramisgithub)`,variant:`dark`,palette:{base00:`#002b36`,base01:`#073642`,base02:`#586e75`,base03:`#657b83`,base04:`#839496`,base05:`#93a1a1`,base06:`#eee8d5`,base07:`#fdf6e3`,base08:`#dc322f`,base09:`#cb4b16`,base0A:`#b58900`,base0B:`#859900`,base0C:`#2aa198`,base0D:`#2995e1`,base0E:`#6c71c4`,base0F:`#d33682`}};function Dl(e,t,n){return{id:e,label:t,kind:n.variant,scheme:n,toTokens:()=>ul(n)}}function Ol(e,t){return{id:e,label:t,kind:`system`}}const kl=[Ol(`default`,`Default`),Dl(`dracula`,`Dracula`,xl),Dl(`catppuccin-frappe`,`Catppuccin Frappé`,Sl),Dl(`catppuccin-latte`,`Catppuccin Latte`,Cl),Dl(`monokai`,`Monokai`,wl),Dl(`gruvbox`,`Gruvbox`,Tl),Dl(`solarized`,`Solarized`,El),Ol(`custom`,`Custom`)],Al=kl.map(e=>e.id),jl=/^[a-z0-9-]{1,32}$/,Ml=/\p{M}+/gu,Nl=/['\u2019\u02bc]+/gu,Pl=/[^a-z0-9]+/g;function Fl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function Il(e){let t=e.trim();if(t.length===0)return{ok:!1,code:`empty`};let n=t.normalize(`NFKD`).replace(Ml,``).toLowerCase().replace(Nl,``).replace(Pl,`-`).replace(/^-+|-+$/g,``),r=Fl(t),i=n.length===0?`theme-${r}`:n.length<=26?n:`${n.slice(0,26-r.length-1).replace(/-+$/g,``)}-${r}`,a=Ll(i);if(!a.ok)throw Error(`Saved theme name derivation produced an invalid id`);return{ok:!0,name:t,stem:i,id:a.id}}function Ll(e){if(e.length===0)return{ok:!1,code:`empty`};let t=`saved-`+e;return jl.test(t)?{ok:!0,id:t}:{ok:!1,code:/^[a-z0-9-]+$/.test(t)?`too-long`:`invalid-chars`}}function Rl(e){if(!jl.test(e)||!e.startsWith(`saved-`))return{ok:!1};let t=e.slice(6);return t.length===0?{ok:!1}:{ok:!0,stem:t}}new Map(kl.map(e=>[e.id,e]));const zl=Symbol.for(`@inkeep/open-knowledge/field-registry`),Bl=globalThis;Bl[zl]===void 0&&(Bl[zl]=tr());const Q=Bl[zl];function Vl(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Hl(t)?Q.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Hl(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}function Ul(){return Object.fromEntries(il.map(e=>[e,L().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${al[e]}, as a #rrggbb hex string.`}).optional()]))}function Wl(){return Al.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}const Gl=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Kl=52428800,ql=26214400,Jl=12582912,Yl=`https://api.openai.com/v1`,Xl=`text-embedding-3-small`,Zl=Object.freeze([`127.0.0.1`]),Ql=/^[1-9]\d*(s|m|h)$/,$l=/^https?:\/\//;function eu(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 tu(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&eu(e)?null:`insecure-scheme`}function nu(e){let t=e.trim();return t===``?`./`:t}function ru(e){let t=nu(e);return t.includes(`\0`)||t.includes(`\\`)?!1:t===`/`?!0:!(t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.split(`/`).some(e=>e===`..`))}const iu=U({content:U({dir:L().register(Q,{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:L().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets are stored, relative to the content root. './' colocates beside the current document (default); '/' targets the content root; './subdir' targets a subfolder under the current document folder; 'folder' targets a fixed folder under the content root. Whitespace-only values are treated as './'.`}).refine(ru,{message:`Invalid attachment folder path: must not contain '..' segments, NUL bytes, backslashes, or OS absolute paths (use '/' for the content root).`}).default(`./`)}).default({dir:`.`,attachmentFolderPath:`./`}),appearance:U({theme:G([`light`,`dark`,`system`]).register(Q,{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:G([`system`,...Zc]).register(Q,{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:L().register(Q,{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 ${Wl()}, 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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:L().register(Q,{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 ${Wl()}, 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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:L().register(Q,{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(jl,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:B().register(Q,{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:U({name:L().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:L().register(Q,{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:G([`dark`,`light`]).register(Q,{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(),...Ul()}).optional(),preview:U({autoOpen:B().register(Q,{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:U({showHiddenFiles:B().register(Q,{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:B().register(Q,{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:B().register(Q,{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:B().register(Q,{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)}).optional()}).default({preview:{autoOpen:!0}}),editor:U({wordWrap:B().register(Q,{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:B().register(Q,{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:U({autoApproveOkTools:B().register(Q,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools (and `ok open` on Claude) for agents launched from the built-in terminal. Destructive tools (delete/move/share/install) still prompt. Per-machine personal preference (user scope)."}).default(!0)}).default({autoApproveOkTools:!0}),autoSync:U({mode:G(qo).register(Q,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`How this machine syncs this project with its git remote: 'off' (no sync), 'follow' (one-directional — pull remote changes, never push your own; 'pull' is accepted as a legacy alias), or 'full' (bidirectional pull and push). null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:B().register(Q,{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:G(Jo).register(Q,{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(),default:W([B(),G(qo)]).register(Q,{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}),terminal:U({enabled:B().register(Q,{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)}).default({enabled:null}),slides:U({enabled:B().register(Q,{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:U({localSink:U({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:U({maxBytes:z().register(Q,{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(Kl)}).default({maxBytes:Kl}),logs:U({maxBytes:z().register(Q,{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(ql)}).default({maxBytes:ql}),attributeDenylist:V(L()).register(Q,{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([...Gl])}).default({enabled:!0,spans:{maxBytes:Kl},logs:{maxBytes:ql},attributeDenylist:[...Gl]}),skillInstallReports:U({enabled:B().register(Q,{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 on; the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables also turn it off.`}).default(!0)}).default({enabled:!0})}).default({localSink:{enabled:!0,spans:{maxBytes:Kl},logs:{maxBytes:ql},attributeDenylist:[...Gl]},skillInstallReports:{enabled:!0}}),lossCapture:U({enabled:B().register(Q,{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:z().register(Q,{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(Jl)}).default({enabled:!0,maxBytes:Jl}),bridge:U({backgroundThrottle:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({enabled:B().register(Q,{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:U({semantic:U({enabled:B().register(Q,{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:L().register(Q,{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` (`~/.ok/secrets.yml`); it is sent to whichever endpoint this names."}).default(Yl),model:L().register(Q,{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(Xl),dimensions:z().int().positive().register(Q,{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:z().min(0).max(1).register(Q,{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()}).default({enabled:!1,baseUrl:Yl,model:Xl})}).default({semantic:{enabled:!1,baseUrl:Yl,model:Xl}}),contentRules:U({markdownlint:H({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:H({enabled:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:V(H({appliesTo:W([L(),V(L())]).optional(),file:L(),enabled:B().optional()})).register(Q,{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:H({enabled:B().register(Q,{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:mo(L(),B()).register(Q,{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:H({index:B().register(Q,{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:U({links:G(el).register(Q,{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(tl),fileTreeIndicators:B().register(Q,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0)}).default({links:tl,fileTreeIndicators:!0}),linkPreviews:U({enabled:B().register(Q,{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. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata — 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:U({port:z().int().min(1).max(65535).register(Q,{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:V(L().min(1)).min(1).register(Q,{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([...Zl]),externalUrl:ja({protocol:/^https?$/}).regex($l).register(Q,{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:B().register(Q,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. Once the unified server boot lands, a non-loopback server.bind or a server.externalUrl without allowExternal: true will be refused at boot with a one-line fix. Default off. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:B().register(Q,{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:W([K(`off`),L().regex(Ql)]).register(Q,{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' when every bind address is loopback, 'off' otherwise (an exposed or containerized server stays up). Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...Zl],allowExternal:!1})});r();const au=`open-knowledge-config`;async function ou(e,t,r){let a=i.getTracer(au),o=t?{attributes:t}:{};return a.startActiveSpan(e,o,async e=>{try{return await r(e)}catch(t){throw e.recordException(t),e.setStatus({code:n.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function su(e,t,r){let a=i.getTracer(au),o=t?{attributes:t}:{};return a.startActiveSpan(e,o,e=>{try{return r(e)}catch(t){throw e.recordException(t),e.setStatus({code:n.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function cu(e,t){let n=i.getActiveSpan();n&&n.addEvent(e,t)}function lu(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 uu(e,t){let n=e;for(let e of t){n=lu(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function du(e,t){let n=uu(e,t);if(n!==void 0)return Vl(n)}function fu(e,t){return e===`either`?!0:e===t}function pu(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=du(iu,i);a?.scope!==void 0&&(fu(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function mu(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,rl.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function hu(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)){mu(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}mu(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function gu(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}function _u(e,t){if(t.length===0)return e.contents??null;let n=e.getIn(t,!0);if((0,rl.isNode)(n))return n;for(let n=t.length-1;n>=0;n--){let r=e.getIn(t.slice(0,n),!0);if((0,rl.isNode)(r))return r}return e.contents??null}function vu(e,t){let n=1,r=1,i=Math.min(t,e.length);for(let t=0;t<i;t++)e.charCodeAt(t)===10?(n++,r=1):r++;return{line:n,column:r}}function yu(e,t,n,r,i){let a=e.split(`
181
181
  `),o=r-1;if(o<0||o>=a.length)return``;let s=a[o]??``,c=t-(i-1)+s.length,l=Math.max(1,Math.min(n,c)-t),u=[],d=String(o+2).length;for(let e=Math.max(0,o-1);e<=Math.min(a.length-1,o+1);e++){let t=e===o,n=t?`>`:` `,r=String(e+1).padStart(d,` `);if(u.push(`${n} ${r} | ${a[e]??``}`),t){let e=` `.repeat(2+d+3+i-1);u.push(`${e}${`^`.repeat(l)}`)}}return u.join(`
182
- `)}function xu(e){let t=vu(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=yu(e.source,r),s=(0,rl.isCollection)(t)?bu(e.source,r,r+1,a,o):bu(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const Su=H({file:L(),line:z().int().min(1),column:z().int().min(1),snippet:L().optional()}),Cu=H({path:V(W([L(),z()])),message:L(),issueCode:L(),params:mo(L(),no()).optional(),source:Su.optional()}),wu=G([`user`,`project`,`project-local`,`either`]),Tu=G([`user`,`project`,`project-local`]),Eu=H({code:K(`YAML_PARSE`),detail:L()}),Du=H({code:K(`UNREADABLE`),detail:L()}),Ou=H({code:K(`SCHEMA_INVALID`),issues:V(Cu)}),ku=H({code:K(`REMOVED_KEY`),path:V(L()),redirect:L(),source:Su.optional()}),Au=lo(`code`,[Eu,Ou,Du,H({code:K(`SCOPE_VIOLATION`),path:V(L()),expectedScope:wu,actualScope:Tu}),H({code:K(`NOT_AGENT_SETTABLE`),path:V(L())}),H({code:K(`MIXED_SCOPE`),paths:V(H({path:V(L()),scope:Tu}))}),ku,H({code:K(`WRITE_ERROR`),detail:L()}),H({code:K(`OKIGNORE_INVALID`),detail:L(),lineNumber:z().int().min(1).optional()}),H({code:K(`UNKNOWN`),message:L().optional()})]);lo(`code`,[ku,Eu,Ou,Du]);const ju=H({diagnostics:V(lo(`code`,[H({code:K(`REMOVED_KEY`),scope:Tu,file:L(),path:V(L()),redirect:L()}),H({code:K(`YAML_PARSE`),scope:Tu,file:L()}),H({code:K(`SCHEMA_INVALID`),scope:Tu,file:L()}),H({code:K(`UNREADABLE`),scope:Tu,file:L()})]))}),Mu=new Set(Au.options.map(e=>e.shape.code.value)),Nu=W([Au,U({code:L(),message:L().optional()})]);function Pu(e){return Mu.has(e.code)}function Fu(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function Iu(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function Lu(e){if(!Pu(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`UNREADABLE`:return`Could not read the file: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
182
+ `)}function bu(e){let t=_u(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=vu(e.source,r),s=(0,rl.isCollection)(t)?yu(e.source,r,r+1,a,o):yu(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const xu=H({file:L(),line:z().int().min(1),column:z().int().min(1),snippet:L().optional()}),Su=H({path:V(W([L(),z()])),message:L(),issueCode:L(),params:mo(L(),no()).optional(),source:xu.optional()}),Cu=G([`user`,`project`,`project-local`,`either`]),wu=G([`user`,`project`,`project-local`]),Tu=H({code:K(`YAML_PARSE`),detail:L()}),Eu=H({code:K(`UNREADABLE`),detail:L()}),Du=H({code:K(`SCHEMA_INVALID`),issues:V(Su)}),Ou=H({code:K(`REMOVED_KEY`),path:V(L()),redirect:L(),source:xu.optional()}),ku=lo(`code`,[Tu,Du,Eu,H({code:K(`SCOPE_VIOLATION`),path:V(L()),expectedScope:Cu,actualScope:wu}),H({code:K(`NOT_AGENT_SETTABLE`),path:V(L())}),H({code:K(`MIXED_SCOPE`),paths:V(H({path:V(L()),scope:wu}))}),Ou,H({code:K(`WRITE_ERROR`),detail:L()}),H({code:K(`OKIGNORE_INVALID`),detail:L(),lineNumber:z().int().min(1).optional()}),H({code:K(`UNKNOWN`),message:L().optional()})]);lo(`code`,[Ou,Tu,Du,Eu]);const Au=H({diagnostics:V(lo(`code`,[H({code:K(`REMOVED_KEY`),scope:wu,file:L(),path:V(L()),redirect:L()}),H({code:K(`YAML_PARSE`),scope:wu,file:L()}),H({code:K(`SCHEMA_INVALID`),scope:wu,file:L()}),H({code:K(`UNREADABLE`),scope:wu,file:L()})]))}),ju=new Set(ku.options.map(e=>e.shape.code.value)),Mu=W([ku,U({code:L(),message:L().optional()})]);function Nu(e){return ju.has(e.code)}function Pu(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function Fu(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function Iu(e){if(!Nu(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`UNREADABLE`:return`Could not read the file: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
183
183
  `))n.push(` ${e}`)}else n.push(` ${r}: ${t.message}`)}}return n.join(`
184
- `)}case`SCOPE_VIOLATION`:return[`Setting ${e.path.join(`.`)} belongs in your ${e.expectedScope} config`,`(${Fu(e.expectedScope)} — ${Iu(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${Fu(e.actualScope)}).`,`Move it to ${Fu(e.expectedScope)}.`].join(` `);case`NOT_AGENT_SETTABLE`:return[`Setting ${e.path.join(`.`)} is human-only and can't be changed by an agent.`,`Change it in the Settings pane, or edit the config.yml by hand.`].join(` `);case`MIXED_SCOPE`:return[`This change touches settings that live in different config files. Apply them one file at a time:`,e.paths.map(({path:e,scope:t})=>` ${e.join(`.`)} → ${Fu(t)} (${t})`).join(`
184
+ `)}case`SCOPE_VIOLATION`:return[`Setting ${e.path.join(`.`)} belongs in your ${e.expectedScope} config`,`(${Pu(e.expectedScope)} — ${Fu(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${Pu(e.actualScope)}).`,`Move it to ${Pu(e.expectedScope)}.`].join(` `);case`NOT_AGENT_SETTABLE`:return[`Setting ${e.path.join(`.`)} is human-only and can't be changed by an agent.`,`Change it in the Settings pane, or edit the config.yml by hand.`].join(` `);case`MIXED_SCOPE`:return[`This change touches settings that live in different config files. Apply them one file at a time:`,e.paths.map(({path:e,scope:t})=>` ${e.join(`.`)} → ${Pu(t)} (${t})`).join(`
185
185
  `)].join(`
186
186
  `);case`REMOVED_KEY`:{let t=e.path.join(`.`),n=[`${e.source?`Removed key at ${e.source.file}:${e.source.line}:${e.source.column}`:`Removed key in configuration`}: ${t}`,e.redirect];if(e.source?.snippet&&e.source.snippet.length>0)for(let t of e.source.snippet.split(`
187
187
  `))n.push(` ${t}`);return n.join(`
188
- `)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}const $="Run `ok config migrate` to strip the obsolete key automatically, or remove it by hand.",Ru=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,$].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,$].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",$].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,$].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,$].join(` `)},{path:[`server`,`host`],redirect:[`Use server.bind in .ok/config.yml instead — a list of bind addresses, e.g. [127.0.0.1]; a non-loopback bind additionally requires server.allowExternal.`,`The --host CLI flag and HOST environment variable also remain available.`,$].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,$].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,$].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,$].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running server — start one with `ok start`.",$].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,$].join(` `)},{path:[`appearance`,`sidebar`,`showAllFiles`],redirect:[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar lists every file on disk by default; dot-prefixed entries are gated by appearance.sidebar.showHiddenFiles, and appearance.sidebar.showOnlyMarkdownFiles scopes the tree down to markdown documents as a per-machine view preference.`,$].join(` `)}];function zu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bu(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!zu(n))return!1;n=n[t[e]]}return zu(n)?t[t.length-1]in n:!1}function Vu(e){let{value:t,file:n,source:r,doc:i}=e;if(!zu(t))return[];let a=[];for(let e of Ru){if(!Bu(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=xu({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}function Hu(e,t){let[n,...r]=t;if(n===void 0)return e;let i={...e};if(r.length===0)return delete i[n],i;let a=i[n];return zu(a)&&(i[n]=Hu(a,r)),i}function Uu(e){if(!zu(e))return e;let t=e;for(let e of Ru)Bu(t,e.path)&&(t=Hu(t,e.path));return t}const Wu=`v0`,Gu=`.ok/config.yml`,Ku=`local`,qu=`themes`;function Ju(e){try{let t=Intl.getCanonicalLocales(e)[0];return t===void 0?null:t}catch{return null}}function Yu(e){try{let t=Intl.getCanonicalLocales(e)[0];if(t===void 0)return null;let n=new Intl.Locale(t).maximize();return!n.language||!n.script?null:`${n.language}-${n.script}`}catch{return null}}function Xu(e){return new Promise(t=>{setTimeout(t,e)})}export{wc as $,y as $t,Kl as A,U as At,il as B,ka as Bt,cu as C,B as Ct,ql as D,fo as Dt,Xl as E,Ya as Et,iu as F,mo as Ft,nl as G,Cn as Gt,cl as H,ta as Ht,ru as I,L as It,yc as J,ke as Jt,$c as K,j as Kt,Ll as L,W as Lt,Ql as M,H as Mt,nu as N,bo as Nt,eu as O,zo as Ot,tu as P,Wo as Pt,Dc as Q,D as Qt,Il as R,no as Rt,su as S,V as St,Yl as T,lo as Tt,_l as U,jr as Ut,gl as V,ra as Vt,tl as W,tr as Wt,bc as X,Ne as Xt,_c as Y,je as Yt,vc as Z,Te as Zt,_u as _,qa as _t,Gu as a,Yc as at,du as b,Qa as bt,Ru as c,Sc as ct,ju as d,Xc as dt,O as en,jc as et,Nu as f,gc as ft,gu as g,$o as gt,xu as h,Qo as ht,Ku as i,Ac as it,Gl as j,z as jt,Zl as k,K as kt,Vu as l,Jc as lt,Pu as m,Go as mt,Ju as n,o as nn,Tc as nt,qu as o,kc as ot,Lu as p,fc as pt,Zc as q,De as qt,Yu as r,xc as rt,Wu as s,Oc as st,Xu as t,s as tn,Ec as tt,Uu as u,Kc as ut,mu as v,yo as vt,au as w,Vo as wt,lu as x,eo as xt,fu as y,G as yt,Rl as z,ja as zt};
189
- //# sourceMappingURL=sleep-CEs13Om_.mjs.map
188
+ `)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}const $="Run `ok config migrate` to strip the obsolete key automatically, or remove it by hand.",Lu=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,$].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,$].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",$].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,$].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,$].join(` `)},{path:[`server`,`host`],redirect:[`Use server.bind in .ok/config.yml instead — a list of bind addresses, e.g. [127.0.0.1]; a non-loopback bind additionally requires server.allowExternal.`,`The --bind CLI flag and HOST environment variable also remain available.`,$].join(` `)},{path:[`remote`,`url`],redirect:[`remote.url has been removed. Use server.externalUrl in .ok/config.yml instead (the public origin your tunnel serves).`,$].join(` `)},{path:[`remote`,`port`],redirect:[`remote.port has been removed. Use server.port in .ok/config.yml instead.`,$].join(` `)},{path:[`server`,`publicUrl`],redirect:[`server.publicUrl has been removed. Use server.externalUrl in .ok/config.yml instead (the same key under its current name).`,$].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,$].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,$].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,$].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,$].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running server — start one with `ok start`.",$].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,$].join(` `)},{path:[`appearance`,`sidebar`,`showAllFiles`],redirect:[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar lists every file on disk by default; dot-prefixed entries are gated by appearance.sidebar.showHiddenFiles, and appearance.sidebar.showOnlyMarkdownFiles scopes the tree down to markdown documents as a per-machine view preference.`,$].join(` `)}];function Ru(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zu(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!Ru(n))return!1;n=n[t[e]]}return Ru(n)?t[t.length-1]in n:!1}function Bu(e){let{value:t,file:n,source:r,doc:i}=e;if(!Ru(t))return[];let a=[];for(let e of Lu){if(!zu(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=bu({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}function Vu(e,t){let[n,...r]=t;if(n===void 0)return e;let i={...e};if(r.length===0)return delete i[n],i;let a=i[n];return Ru(a)&&(i[n]=Vu(a,r)),i}function Hu(e){if(!Ru(e))return e;let t=e;for(let e of Lu)zu(t,e.path)&&(t=Vu(t,e.path));return t}const Uu=`v0`,Wu=`.ok/config.yml`,Gu=`local`,Ku=`themes`;function qu(e){try{let t=Intl.getCanonicalLocales(e)[0];return t===void 0?null:t}catch{return null}}function Ju(e){try{let t=Intl.getCanonicalLocales(e)[0];if(t===void 0)return null;let n=new Intl.Locale(t).maximize();return!n.language||!n.script?null:`${n.language}-${n.script}`}catch{return null}}function Yu(e){return new Promise(t=>{setTimeout(t,e)})}export{jc as $,O as $t,Gl as A,z as At,gl as B,ra as Bt,su as C,Vo as Ct,ql as D,zo as Dt,Xl as E,fo as Et,nu as F,L as Ft,$c as G,j as Gt,_l as H,jr as Ht,Ll as I,W as It,_c as J,je as Jt,Zc as K,De as Kt,Il as L,no as Lt,tu as M,bo as Mt,eu as N,Wo as Nt,Zl as O,K as Ot,ru as P,mo as Pt,wc as Q,y as Qt,Rl as R,ja as Rt,ou as S,B as St,Yl as T,Ya as Tt,tl as U,tr as Ut,cl as V,ta as Vt,nl as W,Cn as Wt,vc as X,Te as Xt,bc as Y,Ne as Yt,Dc as Z,D as Zt,gu as _,yo as _t,Wu as a,kc as at,uu as b,eo as bt,Lu as c,Jc as ct,Au as d,gc as dt,s as en,Ec as et,Mu as f,fc as ft,hu as g,qa as gt,bu as h,$o as ht,Gu as i,Yc as it,Ql as j,H as jt,Kl as k,U as kt,Bu as l,Kc as lt,Nu as m,Qo as mt,qu as n,xc as nt,Ku as o,Oc as ot,Iu as p,Go as pt,yc as q,ke as qt,Ju as r,Ac as rt,Uu as s,Sc as st,Yu as t,o as tn,Tc as tt,Hu as u,Xc as ut,pu as v,G as vt,iu as w,lo as wt,cu as x,V as xt,du as y,Qa as yt,il as z,ka as zt};
189
+ //# sourceMappingURL=sleep-DXvB05wr.mjs.map
@@ -1,12 +1,12 @@
1
- import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,pt as n,q as r}from"./sleep-CEs13Om_.mjs";import{Cc as i,Sc as a,_o as o,at as s,ot as c}from"./src-_JbAf6nM.mjs";import{Ci as l,Pn as u,at as d,ei as f,it as p,ot as m,rt as h}from"./src-CUzcBQEu.mjs";import{D as ee,F as g,I as _,k as v}from"./fs-traced-6G_aFzgy.mjs";import{C as y,S as b,_ as x,f as S,r as C}from"./server-lock-BbnnWHQ-.mjs";import{t as w}from"./yazl-DZr4PyKA.mjs";import{b as T,h as te,m as ne}from"./resolve-project-root--qXrA21F.mjs";import{c as re}from"./colors-DSyAT9Cz.mjs";import{n as E}from"./acp-harness-probe-DYbo4bT-.mjs";import{E as D,T as ie,_ as ae,b as O,o as oe,w as k,x as se}from"./init-B14cFSch.mjs";import{n as A}from"./constants-BfbnQ1zg.mjs";import{t as j}from"./is-object-Bw0-z8qH.mjs";import"./loader-DlLkJi3f.mjs";import"./skill-teardown-BOfnXWGl.mjs";import"./preview-Dr5MviTF.mjs";import{execSync as ce,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,join as F,relative as le,resolve as I,sep as ue}from"node:path";import{cpSync as de,createWriteStream as fe,existsSync as L,lstatSync as pe,mkdirSync as R,mkdtempSync as me,readFileSync as z,readdirSync as he,readlinkSync as ge,rmSync as B,statSync as _e,writeFileSync as V}from"node:fs";import{arch as ve,freemem as ye,homedir as H,hostname as be,platform as xe,release as Se,tmpdir as Ce,totalmem as we,type as Te,uptime as Ee}from"node:os";import"node:fs/promises";import{createHash as De}from"node:crypto";var U=n();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=u){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}function Ne(){return F(H(),`.ok`,`bug-reports`)}function Pe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ne(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Fe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(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 L(F(e,`.ok`))?De(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Ie(){let e={timestamp:new Date().toISOString(),platform:xe(),osType:Te(),osRelease:Se(),hostname:`[redacted]`,uptime:Ee(),freeMem:ye(),totalMem:we(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ce(`sw_vers -productVersion 2>/dev/null`,f({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}const Le=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Re(e){let t=N(e);return Le.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ze(e,t){return He(e,t).files}const Be=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Ve(e,t=E){let n=F(e,`${t}.ShipIt`);return L(n)?Be.map(e=>F(n,e)).filter(e=>L(e)):[]}function He(e,t){if(!L(t))return{files:[],excludedByProjectSlug:0};let n=he(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Re),i=[],a=r.filter(t=>{try{return z(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=>!Re(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ue(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,s].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function We(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ge(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=i(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Ke(e){for(let t of e.files)try{Ge({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,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 qe(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??F(H(),`.ok`,`logs`),s=t.projectDir?Fe(t.projectDir,i):null;R(P(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Ie();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=He(s,o),{files:d}=t.projectDir?Ue(t.projectDir):{files:[]},{files:f}=t.projectDir?We(t.projectDir):{files:[]},p=t.shipItLogFiles??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),g=new ee;Ke({zipfile:g,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),Ke({zipfile:g,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),Ke({zipfile:g,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;g.addBuffer(t,n),h.push(n)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ge({zipfile:g,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let _=JSON.stringify(c,null,2);g.addBuffer(Buffer.from(_,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let v={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:c};g.addBuffer(Buffer.from(JSON.stringify(v,null,2),`utf8`),`MANIFEST.json`);let y=m.reduce((e,t)=>e+t.lineCount,0),b=new Set(p.map(e=>`logs/${N(e)}`)),x=h.filter(e=>b.has(e)),S=s?h.filter(e=>e.startsWith(`logs/`)&&!Re(e)&&!b.has(e)):[],C=[`# Bug Report Bundle`,``,`Generated: ${v.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${v.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...S.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:`,...S.map(e=>`- ${e}`),``]:[],...x.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:`,...x.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${a.join(`, `)}`,y>0?`${y} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
- `);g.addBuffer(Buffer.from(C,`utf8`),`README.md`),g.end();let w=fe(r);return g.outputStream.pipe(w),await new Promise((e,t)=>{w.on(`close`,e),w.on(`error`,t)}),i?.info({bundlePath:r,fileCount:h.length,redactionCount:y},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:y,generatedAt:v.generatedAt}}}var Je=e(w(),1),W=e(re(),1);function Ye(e){return _({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Xe({home:e=H(),env:n=process.env}={}){let i=Ye(e),{override:a,preferenceList:s}=ee(n),{locale:c,source:l}=o({override:a,storedPreference:i,supportedLocales:r,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Ze(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e,t){if(typeof e==`string`)return Ze(e,t.contentDir);if(Array.isArray(e))return e.map(e=>G(e,t));if(!Qe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=G(i,t);return n}function $e(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
1
+ import{o as e}from"./chunk-DTipWd-i.mjs";import{G as t,K as n,ft as r}from"./sleep-DXvB05wr.mjs";import{Cc as i,_o as a,at as o,ot as s,wc as c}from"./src-NmTX6dJc.mjs";import{Ci as l,Pn as u,at as d,ei as f,it as p,ot as m,rt as h}from"./src-DG3uYi4g.mjs";import{D as ee,F as g,I as _,k as v}from"./fs-traced-1KTQL4h-.mjs";import{C as y,S as b,_ as x,f as S,r as C}from"./server-lock-B131eKn8.mjs";import{t as w}from"./yazl-DZr4PyKA.mjs";import{b as T,h as te,m as ne}from"./resolve-project-root-B2P-8M30.mjs";import{c as re}from"./colors-DSyAT9Cz.mjs";import{n as E}from"./acp-harness-probe-BioMl_fC.mjs";import{E as D,T as ie,_ as ae,b as O,o as oe,w as k,x as se}from"./init-DPUo80Dj.mjs";import{n as A}from"./constants-D0ddOHQC.mjs";import{t as j}from"./is-object-Bw0-z8qH.mjs";import"./loader-LDz9zBYC.mjs";import"./skill-teardown-Dt9ANTO9.mjs";import"./preview-B34Qj3q9.mjs";import{execSync as ce,spawnSync as M}from"node:child_process";import{basename as N,dirname as P,join as F,relative as le,resolve as I,sep as ue}from"node:path";import{cpSync as de,createWriteStream as fe,existsSync as L,lstatSync as pe,mkdirSync as R,mkdtempSync as me,readFileSync as z,readdirSync as he,readlinkSync as ge,rmSync as B,statSync as _e,writeFileSync as V}from"node:fs";import{arch as ve,freemem as ye,homedir as H,hostname as be,platform as xe,release as Se,tmpdir as Ce,totalmem as we,type as Te,uptime as Ee}from"node:os";import"node:fs/promises";import{createHash as De}from"node:crypto";var U=r();const Oe=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function ke(e,t,n=u){if(e!==void 0&&!Oe.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let Ae=null;function je(e){Ae=e}function Me(){return Ae??process.cwd()}function Ne(){return F(H(),`.ok`,`bug-reports`)}function Pe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Ne(),r=`${t}-bugreport`,i=F(n,`${r}.zip`);for(let e=2;L(i);e+=1)i=F(n,`${r}-${e}.zip`);return i}function Fe(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let e=z(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 L(F(e,`.ok`))?De(`sha256`).update(I(e)).digest(`hex`).slice(0,12):null}function Ie(){let e={timestamp:new Date().toISOString(),platform:xe(),osType:Te(),osRelease:Se(),hostname:`[redacted]`,uptime:Ee(),freeMem:ye(),totalMem:we(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=ce(`sw_vers -productVersion 2>/dev/null`,f({encoding:`utf8`})).trim()}catch{}try{let t=F(__dirname,`..`,`..`,`package.json`);L(t)&&(e.okVersion=JSON.parse(z(t,`utf8`)).version)}catch{}return e}const Le=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function Re(e){let t=N(e);return Le.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function ze(e,t){return He(e,t).files}const Be=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function Ve(e,t=E){let n=F(e,`${t}.ShipIt`);return L(n)?Be.map(e=>F(n,e)).filter(e=>L(e)):[]}function He(e,t){if(!L(t))return{files:[],excludedByProjectSlug:0};let n=he(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>F(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(Re),i=[],a=r.filter(t=>{try{return z(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=>!Re(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ue(e){let t=F(e,`.ok`,`local`);return L(t)?{files:[`server.lock`,`last-spawn-error.log`,o].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function We(e){let t=F(e,`.ok`,`local`,`logs`);return L(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>F(t,e)).filter(e=>L(e))}:{files:[]}}function Ge(e){if(e.redact){let{redacted:t,patterns:n,lineCount:r}=c(e.content);e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name),n.length>0&&e.redactions.push({file:e.name,lineCount:r,patterns:n})}else e.zipfile.addBuffer(Buffer.from(e.content,`utf8`),e.name),e.bundleFiles.push(e.name)}function Ke(e){for(let t of e.files)try{Ge({zipfile:e.zipfile,name:`${e.prefix}/${N(t)}`,content:z(t,`utf8`),redact:e.redact,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 qe(t){let{redact:n,outputPath:r,logger:a}=t,o=t.userLogsDir??F(H(),`.ok`,`logs`),s=t.projectDir?Fe(t.projectDir,a):null;R(P(r),{recursive:!0}),a?.info({projectSlug:s},`gathering diagnostic data`);let c=Ie();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=He(s,o),{files:d}=t.projectDir?Ue(t.projectDir):{files:[]},{files:f}=t.projectDir?We(t.projectDir):{files:[]},p=t.shipItLogFiles??[];a?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length},`files collected`);let m=[],h=[],{ZipFile:ee}=await import(`./yazl-jVENrf5i.mjs`).then(t=>e(t.default,1)),g=new ee;Ke({zipfile:g,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:a}),Ke({zipfile:g,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:a}),Ke({zipfile:g,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:a});for(let e of t.extraFiles??[])try{let t=z(e.sourcePath),n=`extra/${e.zipName??N(e.sourcePath)}`;g.addBuffer(t,n),h.push(n)}catch(t){a?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&Ge({zipfile:g,name:`note.txt`,content:t.note,redact:n,bundleFiles:h,redactions:m});let _=JSON.stringify(c,null,2);g.addBuffer(Buffer.from(_,`utf8`),`sysinfo.json`),h.push(`sysinfo.json`);let v={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:h,redactions:m,sysinfo:c};g.addBuffer(Buffer.from(JSON.stringify(v,null,2),`utf8`),`MANIFEST.json`);let y=m.reduce((e,t)=>e+t.lineCount,0),b=new Set(p.map(e=>`logs/${N(e)}`)),x=h.filter(e=>b.has(e)),S=s?h.filter(e=>e.startsWith(`logs/`)&&!Re(e)&&!b.has(e)):[],C=[`# Bug Report Bundle`,``,`Generated: ${v.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${v.disciplineVersion}`,``,`## Contents`,``,...h.map(e=>`- ${e}`),``,`## Privacy`,``,...S.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:`,...S.map(e=>`- ${e}`),``]:[],...x.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:`,...x.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${i.join(`, `)}`,y>0?`${y} line(s) were scrubbed across ${m.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,``,`This bundle is safe to attach to a GitHub issue.`]:[`Redaction was disabled for this bundle; file contents are unmodified.`]].join(`
2
+ `);g.addBuffer(Buffer.from(C,`utf8`),`README.md`),g.end();let w=fe(r);return g.outputStream.pipe(w),await new Promise((e,t)=>{w.on(`close`,e),w.on(`error`,t)}),a?.info({bundlePath:r,fileCount:h.length,redactionCount:y},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:h,redactions:m,redactedLineCount:y,generatedAt:v.generatedAt}}}var Je=e(w(),1),W=e(re(),1);function Ye(e){return _({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function Xe({home:e=H(),env:r=process.env}={}){let i=Ye(e),{override:o,preferenceList:s}=ee(r),{locale:c,source:l}=a({override:o,storedPreference:i,supportedLocales:n,preferenceList:s,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:s}}function Ze(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e,t){if(typeof e==`string`)return Ze(e,t.contentDir);if(Array.isArray(e))return e.map(e=>G(e,t));if(!Qe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=G(i,t);return n}function $e(e,t){let n=z(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
3
3
  `),i=n.split(`
4
4
  `),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=G(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
5
5
  `)}\n`:a.join(`
6
6
  `))}function et(e,t){let n=z(e,`utf-8`);if(n.trim().length!==0)try{let r=G(JSON.parse(n),t),i=n.endsWith(`
7
7
  `)?`
8
8
  `:``;V(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=Ze(n,t.contentDir);r!==n&&V(e,r)}}function tt(e,t){let n=z(e,`utf-8`),r=Ze(n,t.contentDir);r!==n&&V(e,r)}function nt(e){try{return he(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>F(e,t.name))}catch{return[]}}const rt=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function it(e){return/\.log\.\d+$/.test(e)}function at(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||it(e)}function ot(e){let t={contentDir:e.contentDir};for(let n of[`telemetry`,`logs`,`process`])for(let r of nt(F(e.stagingDir,n)))at(r)?$e(r,t):r.endsWith(`.json`)?et(r,t):tt(r,t);for(let n of nt(F(e.stagingDir,`state`))){let e=N(n);n.endsWith(`.jsonl`)?$e(n,t):rt.has(e)?et(n,t):tt(n,t)}}const st=[`.ok`,`local`,`telemetry`],ct=[`.ok`,`local`,`logs`],lt=[`.ok`,`local`,`loss-capture`],ut=`spans-current.jsonl`,dt=`spans-prev.jsonl`,ft=`server-current.jsonl`,pt=`server-prev.jsonl`,mt=`loss-current.jsonl`,ht=`loss-prev.jsonl`;function gt(e){return F(e,...st,ut)}function _t(e){return F(e,...st,dt)}function vt(e){return F(e,...ct,ft)}function yt(e){return F(e,...ct,pt)}function bt(e){return F(e,...lt,mt)}function xt(e){return F(e,...lt,ht)}const St=1e3;async function Ct(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(St)});return t.ok?await t.text():null}catch{return null}}async function wt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(St)});return t.ok?await t.text():null}catch{return null}}async function Tt(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(St)});return t.ok?await t.text():null}catch{return null}}function Et(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(`
9
- `)}\n`:null}catch{return null}}function Dt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Ot(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function kt(){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 At(){return{nodeVersion:process.version,platform:xe(),arch:ve()}}function jt(){return process.env.OTEL_SDK_DISABLED===`false`}function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mt(e){if(!L(e))return{};let t;try{t=(0,U.parse)(z(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(!K(t))return{};let n=t.telemetry;if(!K(n))return{};let r=n.localSink;return K(r)?r:{}}function Nt(e){return typeof e==`boolean`?e:void 0}function Pt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function q(e){if(K(e))return Pt(e.maxBytes)}function Ft(e){let t=Mt(v(`project`,e)),n=Mt(v(`project-local`,e));return{enabled:Nt(n.enabled)??Nt(t.enabled)??!0,spansMaxBytes:q(n.spans)??q(t.spans)??52428800,logsMaxBytes:q(n.logs)??q(t.logs)??26214400}}function It(e){return De(`sha256`).update(e).digest(`hex`)}function Lt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Rt(e){let t=z(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function J(e,t){if(!L(e))return!1;try{return R(P(t),{recursive:!0}),de(e,t),!0}catch{return!1}}function Y(e){let t=[],n=e=>{let r=he(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const zt=new Set([`.jsonl`]);function Bt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}const Vt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ht(e){if(it(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Vt.has(e.slice(t))}function Ut(e){let t=[];for(let n of Y(e)){let r=Wt(e,n);if(!Ht(r))continue;let{redacted:a,patterns:o,lineCount:s}=i(z(n,`utf-8`));o.length!==0&&(V(n,a),t.push({file:r,lineCount:s,patterns:o}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Wt(e,t){return le(e,t).split(ue).join(`/`)}async function Gt(e){let t=I(e.contentDir),n=I(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ct,a=r.fetchAgentEffects??wt,o=r.fetchWatcherRecent??Tt,l=r.readShadowHead??Dt,u=r.readCheckpointRefs??Ot,d=r.now??(()=>new Date),f=r.okVersion??(()=>A),p=r.readDesktopEnv??kt,m=r.readLanguage??Xe,h=r.readRuntime??At,ee=r.isOtlpPushEnabled??jt,g=me(F(Ce(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),J(gt(n),F(g,`telemetry`,ut)),J(_t(n),F(g,`telemetry`,dt)),J(vt(n),F(g,`logs`,ft)),J(yt(n),F(g,`logs`,pt));for(let t of e.userLogFiles??[])J(t,F(g,`logs`,N(t)));let _=F(n,`.ok`,`local`),v=F(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(L(v)){J(v,F(g,`state`,`server.lock`));try{let e=z(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await i(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(V(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await a(x);t!==null&&V(F(g,`state`,`agent-effects.json`),t);let n=await o(x);if(n!==null){let e=Et(n);e!==null&&V(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(t);S!==null&&V(F(g,`state`,`shadow-head.txt`),S);let C=u(t);C!==null&&V(F(g,`state`,`checkpoint-refs.txt`),C),J(bt(n),F(g,`state`,mt)),J(xt(n),F(g,`state`,ht)),J(F(_,`last-spawn-error.log`),F(g,`state`,`last-spawn-error.log`)),J(F(_,c),F(g,`state`,c)),J(F(_,s),F(g,`state`,s));let w=h(),T=p(),te=m(),ne={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T,language:te}};V(F(g,`state`,`runtime.json`),`${JSON.stringify(ne,null,2)}\n`);let re=y===`running`?`running
9
+ `)}\n`:null}catch{return null}}function Dt(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`log`,`--oneline`,`-50`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function Ot(e){let t=F(e,`.git`,`ok`);if(!L(t))return null;let n=M(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],f({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function kt(){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 At(){return{nodeVersion:process.version,platform:xe(),arch:ve()}}function jt(){return process.env.OTEL_SDK_DISABLED===`false`}function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mt(e){if(!L(e))return{};let t;try{t=(0,U.parse)(z(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(!K(t))return{};let n=t.telemetry;if(!K(n))return{};let r=n.localSink;return K(r)?r:{}}function Nt(e){return typeof e==`boolean`?e:void 0}function Pt(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function q(e){if(K(e))return Pt(e.maxBytes)}function Ft(e){let t=Mt(v(`project`,e)),n=Mt(v(`project-local`,e));return{enabled:Nt(n.enabled)??Nt(t.enabled)??!0,spansMaxBytes:q(n.spans)??q(t.spans)??52428800,logsMaxBytes:q(n.logs)??q(t.logs)??26214400}}function It(e){return De(`sha256`).update(e).digest(`hex`)}function Lt(e){let t=z(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}function Rt(e){let t=z(e,`utf-8`),n=`"doc.name"`,r=0,i=t.indexOf(n);for(;i!==-1;)r++,i=t.indexOf(n,i+10);return r}function J(e,t){if(!L(e))return!1;try{return R(P(t),{recursive:!0}),de(e,t),!0}catch{return!1}}function Y(e){let t=[],n=e=>{let r=he(e,{withFileTypes:!0});for(let i of r){let r=F(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const zt=new Set([`.jsonl`]);function Bt(e){let t=e.lastIndexOf(`.`);return t===-1?!1:zt.has(e.slice(t))}const Vt=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`]);function Ht(e){if(it(e))return!0;let t=e.lastIndexOf(`.`);return t===-1?!1:Vt.has(e.slice(t))}function Ut(e){let t=[];for(let n of Y(e)){let r=Wt(e,n);if(!Ht(r))continue;let{redacted:i,patterns:a,lineCount:o}=c(z(n,`utf-8`));a.length!==0&&(V(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function Wt(e,t){return le(e,t).split(ue).join(`/`)}async function Gt(e){let t=I(e.contentDir),n=I(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??Ct,a=r.fetchAgentEffects??wt,c=r.fetchWatcherRecent??Tt,l=r.readShadowHead??Dt,u=r.readCheckpointRefs??Ot,d=r.now??(()=>new Date),f=r.okVersion??(()=>A),p=r.readDesktopEnv??kt,m=r.readLanguage??Xe,h=r.readRuntime??At,ee=r.isOtlpPushEnabled??jt,g=me(F(Ce(),`ok-bundle-`));try{R(F(g,`telemetry`),{recursive:!0}),R(F(g,`logs`),{recursive:!0}),R(F(g,`state`),{recursive:!0}),J(gt(n),F(g,`telemetry`,ut)),J(_t(n),F(g,`telemetry`,dt)),J(vt(n),F(g,`logs`,ft)),J(yt(n),F(g,`logs`,pt));for(let t of e.userLogFiles??[])J(t,F(g,`logs`,N(t)));let _=F(n,`.ok`,`local`),v=F(_,`server.lock`),y=`not-running`,b=`no server.lock`,x=null;if(L(v)){J(v,F(g,`state`,`server.lock`));try{let e=z(v,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?x=t.port:b=`lock present but no port`}catch{b=`lock present but unparseable`}}if(x!==null){let e=await i(x);e===null?b=`agent-presence endpoint at :${x} unreachable`:(V(F(g,`state`,`agent-presence.json`),e),y=`running`,b=``);let t=await a(x);t!==null&&V(F(g,`state`,`agent-effects.json`),t);let n=await c(x);if(n!==null){let e=Et(n);e!==null&&V(F(g,`state`,`watcher-recent.jsonl`),e)}}let S=l(t);S!==null&&V(F(g,`state`,`shadow-head.txt`),S);let C=u(t);C!==null&&V(F(g,`state`,`checkpoint-refs.txt`),C),J(bt(n),F(g,`state`,mt)),J(xt(n),F(g,`state`,ht)),J(F(_,`last-spawn-error.log`),F(g,`state`,`last-spawn-error.log`)),J(F(_,s),F(g,`state`,s)),J(F(_,o),F(g,`state`,o));let w=h(),T=p(),te=m(),ne={ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T,language:te}};V(F(g,`state`,`runtime.json`),`${JSON.stringify(ne,null,2)}\n`);let re=y===`running`?`running
10
10
  `:`not-running (${b})\n`;if(V(F(g,`state`,`server-status.txt`),re),e.processDir&&L(e.processDir)){let t=F(g,`process`);R(t,{recursive:!0}),de(e.processDir,t,{recursive:!0})}let E=e.redact===!0;E&&ot({stagingDir:g,contentDir:t}),e.note&&V(F(g,`note.txt`),e.note);let D=null;e.scrubSecrets===!0&&(D=Ut(g));for(let t of e.extraFiles??[])J(t.sourcePath,F(g,`extra`,t.zipName??N(t.sourcePath)))||r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);let ie=Ft(n),ae=Y(g),O=[],oe=0,k=0;for(let e of ae){let t=Wt(g,e),n=_e(e).size,r=Bt(t)?Lt(e):0;O.push({path:t,bytes:n,lines:r}),oe+=n,t.startsWith(`telemetry/`)&&Bt(t)&&(k+=Rt(e))}let se={applied:E};D!==null&&(se.secretScrub=D);let A={schemaVersion:2,createdAt:d().toISOString(),ok:{version:f(),nodeVersion:w.nodeVersion,platform:w.platform,arch:w.arch},host:{desktop:T,language:te},contentDir:{pathSha256:It(t),absolutePath:E?`<CONTENT_DIR>`:t},telemetry:{localSink:ie,otlpPushEnabled:ee()},redaction:se,serverStatus:y,files:O};V(F(g,`manifest.json`),`${JSON.stringify(A,null,2)}\n`);let j=ae.some(e=>{try{return z(e,`utf-8`).includes(t)}catch{return!1}}),ce={totalBytes:oe,fileCount:O.length,docNameCount:k,contentDirVisible:j,redacted:E},M=!1;return{stagingDir:g,manifest:A,summary:ce,cleanup:()=>{M||(M=!0,B(g,{recursive:!0,force:!0}))}}}catch(e){throw B(g,{recursive:!0,force:!0}),e}}async function Kt(e){let{collected:t,outputPath:n}=e,r=P(n);if(!L(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new Je.ZipFile,a=Y(t.stagingDir);for(let e of a){let n=Wt(t.stagingDir,e);i.addFile(e,n)}i.end();let o=fe(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 qt(e,t){let n=F(e,`.ok`,`config.yml`);if(L(n))try{let t=(0,U.parse)(z(n,`utf-8`)),r=j(t)?t.content:void 0,i=j(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return I(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 I(e)}async function Jt(e,t,n,r){let i=Fe(t,e.logger),a=await Gt({contentDir:qt(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...ze(i,e.userLogsDir??F(H(),`.ok`,`logs`)),...Ve(e.cachesDir??F(H(),`Library`,`Caches`))],deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{R(P(e.outputPath),{recursive:!0}),await Kt({collected:a,outputPath:e.outputPath});let t=a.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:i,files:a.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:a.manifest.createdAt}}}finally{a.cleanup()}}async function Yt(e){let{projectDir:t}=e,n=e.readDesktopEnv??kt,r=e.readLanguage??Xe;if(e.level===`full`&&t!==void 0)return Jt(e,t,n,r);let{zipPath:i,summary:a}=await qe({projectDir:t,redact:e.redact,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:Ve(e.cachesDir??F(H(),`Library`,`Caches`)),logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:i,summary:{level:e.level,systemWide:t===void 0,projectSlug:a.projectSlug,files:a.files,redactions:a.redactions,redactedLineCount:a.redactedLineCount,generatedAt:a.generatedAt}}}function Xt(e,t){if(!L(e))return{status:`missing`,lockPath:e};let n;try{n=JSON.parse(z(e,`utf-8`))}catch{return{status:`corrupt`,lockPath:e}}if(!n||typeof n!=`object`||!y(n.pid))return{status:`corrupt`,lockPath:e};let r=n;if(!(t.isAlive??b)(r.pid))return{status:`dead-pid`,lockPath:e,lock:r};if(typeof r.machineId==`string`)return r.machineId===(t.machineId??x())?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r};let i=t.host??be();return r.hostname===i?{status:`alive`,lockPath:e,lock:r}:{status:`foreign-host`,lockPath:e,lock:r}}function X(e,t,n={}){return Xt(S(e,t),n)}function Z(e,t={}){return Xt(F(e,`ui.lock`),t)}function Zt(e){return e.replace(/:\d+$/,``)}function Qt(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:Zt(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:Zt(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:Zt(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 $t=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function en(e){return F(e,`Library`,`Application Support`,`OpenKnowledge`,`path-install.json`)}const tn={existsSync:e=>L(e),readFileSync:(e,t)=>z(e,t),lstatSync:e=>pe(e),readlinkSync:e=>ge(e)};function nn(e,t=tn){let n=en(e);if(!t.existsSync(n))return null;try{let e=JSON.parse(t.readFileSync(n,`utf8`));return e?.version===1?e:null}catch{return null}}function rn(e){let t=e.replace($t,``);return{text:t,changed:t!==e,emptyAfter:t.trim()===``}}function an(e,t,n=tn){try{return n.lstatSync(e).isSymbolicLink()?n.readlinkSync(e)===t:!1}catch{return!1}}function on(e){return ne(e)||te(e)||se(e)}const sn=10*1024*1024;function cn(e,t,n,r){let i=oe(e,t,n,r);if(i.kind===`absent`||i.kind===`no-entry`)return{kind:`not-present`};if(i.kind===`decline`)return{kind:`declined`,reason:i.reason};if(!on(i.entry))return{kind:`left-foreign`};let a;try{a=r??e.configPath(t,n)}catch{return{kind:`not-present`}}let o=e.serverName(t);return e.format===`file`?(B(a,{force:!0}),{kind:`removed`}):e.format===`toml`?dn(a,o):e.format===`yaml`?un(a,e.topLevelKey,o):ln(a,e.topLevelKey,e.serverMapSubKey,o)}function ln(e,t,n,r){let i;try{i=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(i,`utf-8`)>sn)return{kind:`declined`,reason:`oversize`};let{text:a,changed:o}=D(i,ae(t,n,r));return o?(g(e,a,{mode:k(e)}),{kind:`removed`}):{kind:`not-present`}}function un(e,t,n){let r;try{r=z(e,`utf-8`)}catch{return{kind:`declined`,reason:`unparseable`}}if(Buffer.byteLength(r,`utf-8`)>sn)return{kind:`declined`,reason:`oversize`};let i=r.charCodeAt(0)===65279,a=i?r.slice(1):r,o=(0,U.parseDocument)(a);if(o.errors.length>0)return{kind:`declined`,reason:`unparseable`};let s=[t,n];if(!o.hasIn(s))return{kind:`not-present`};o.deleteIn(s);let c=o.toString(),l=ie(a);a.trim()===``||a.endsWith(`
11
11
  `)?c.endsWith(`
12
12
  `)||(c=`${c}\n`):c=c.replace(/\n+$/,``),l&&(c=c.replace(/\r\n/g,`
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,pt as n,q as r}from"./sle
17
17
  `).replace(/\n/g,`\r
18
18
  `));let u=`${i?``:``}${l}`;return u!==r&&g(e,u,{mode:k(e)}),{kind:`removed`}}function fn(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function pn(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function mn(e,t,n,r){if(t.status===`missing`||t.status===`corrupt`)return null;let i=t.lock,a=t.status===`alive`&&C(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:p(n),command:n,isDesktop:fn(n)}}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:`stale`}const hn=new Set([`running`,`desktop`,`foreign`]);function gn(e){switch(e){case`running`:return W.default.green(e);case`desktop`:return W.default.blue(e);case`foreign`:return W.default.cyan(e);case`stale`:return W.default.yellow(e)}}function _n(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function vn(e){return`${_n(e.server.usage)} | ${_n(e.ui?.usage??null)}`}function yn(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null?`—`:String(e.ui.port)}`}function bn(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,yn(e),vn(e),Q(e),String(e.server.pid),pn(e.server.startedAt),e.binary??`—`]),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=gn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=W.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
19
19
  `)}async function xn(e={}){let t=e.discover??h,n=e.inspect??X,r=e.log??(e=>console.log(e)),i=e.resolveCommand??d,a=e.resolveUsage??m,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=mn(e,t,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid));r!=null&&s.push(r)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(bn(e.all?s:s.filter(e=>hn.has(Q(e)))))}function Sn(){return new T(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await xn({all:t.all===!0||e===`all`,json:t.json===!0})})}function Cn(e,t,n={}){let r=n.isAlive??b,i=[];for(let[n,a]of[[`server`,e],[`ui`,t]])(a.status===`alive`||a.status===`foreign-host`&&r(a.lock.pid))&&i.push({name:n,pid:a.lock.pid,port:a.lock.port});return{targets:i}}function wn(e){let t=e.inspect??(t=>t===`ui`?Z(e.lockDir):X(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=Cn(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function $(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Tn(e,t=b){let n=await h(),r=null;for(let i of n){let n=X(i,`server`),a=Z(i);if($(n,t)&&n.lock.port===e||$(a,t)&&a.lock.port===e)return i;r===null&&($(n,t)&&n.lock.pid===e||$(a,t)&&a.lock.pid===e)&&(r=i)}return r}function En(e){let t=wn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Dn(e){return new T(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=wn({lockDir:l(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await xn({});return}if(n===`all`){let e=await h();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=X(n,`server`),r=Z(n);!$(e,b)&&!$(r,b)||(En(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Tn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}En(t);return}En(l(I(Me(),n)))})}export{Ne as _,$t as a,ke as b,nn as c,Z as d,X as f,Pe as g,Kt as h,cn as i,rn as l,Gt as m,Dn as n,an as o,Yt as p,Sn as r,en as s,wn as t,Qt as u,Me as v,je as y};
20
- //# sourceMappingURL=src-D8oYpCos.mjs.map
20
+ //# sourceMappingURL=src-C7RaGUoz.mjs.map
@@ -1 +1 @@
1
- import{B as e,Bs as t,Ec as n,Rs as r,W as i,Xs as a,_s as o,bs as s,g as c,v as l,xs as u}from"./src-_JbAf6nM.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Bt as w,C as T,Ca as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ea as L,Ei as R,En as z,Er as B,Et as V,F as H,Fi as U,Fn as W,Fr as G,Ft as K,G as q,Gi as J,Gn as Y,Gr as X,Gt as Z,H as Q,Hi as $,Hn as ee,Ht as te,I as ne,Ii as re,In as ie,Ir as ae,It as oe,J as se,Ji as ce,Jn as le,Jr as ue,Jt as de,K as fe,Ki as pe,Kn as me,Kr as he,Kt as ge,L as _e,Li as ve,Ln as ye,Lr as be,Lt as xe,M as Se,Mi as Ce,Mn as we,Mr as Te,Mt as Ee,N as De,Ni as Oe,Nn as ke,Nr as Ae,Nt as je,O as Me,Oi as Ne,On as Pe,Or as Fe,Ot as Ie,P as Le,Pi as Re,Pn as ze,Pr as Be,Pt as Ve,Q as He,Qi as Ue,Qn as We,Qr as Ge,Qt as Ke,R as qe,Ri as Je,Rn as Ye,Rr as Xe,Rt as Ze,S as Qe,Sa as $e,Si as et,Sn as tt,Sr as nt,St as rt,T as it,Ta as at,Ti as ot,Tn as st,Tr as ct,Tt as lt,U as ut,Ui as dt,Un as ft,Ut as pt,V as mt,Vi as ht,Vn as gt,Vt as _t,W as vt,Wi as yt,Wn as bt,Wr as xt,Wt as St,X as Ct,Xi as wt,Xn as Tt,Xr as Et,Xt as Dt,Y as Ot,Yi as kt,Yn as At,Yr as jt,Yt as Mt,Z as Nt,Zi as Pt,Zn as Ft,Zr as It,Zt as Lt,_ as Rt,_a as zt,_i as Bt,_n as Vt,_r as Ht,_t as Ut,a as Wt,aa as Gt,ai as Kt,an as qt,ar as Jt,at as Yt,b as Xt,ba as Zt,bi as Qt,bn as $t,br as en,bt as tn,c as nn,ca as rn,ci as an,cn as on,cr as sn,ct as cn,d as ln,da as un,di as dn,dn as fn,dr as pn,ea as mn,ei as hn,en as gn,er as _n,et as vn,f as yn,fa as bn,fi as xn,fn as Sn,fr as Cn,g as wn,ga as Tn,gi as En,gn as Dn,gr as On,gt as kn,h as An,ha as jn,hi as Mn,hn as Nn,hr as Pn,i as Fn,ia as In,ii as Ln,in as Rn,ir as zn,it as Bn,j as Vn,ji as Hn,jn as Un,jr as Wn,jt as Gn,k as Kn,ki as qn,kn as Jn,kr as Yn,kt as Xn,l as Zn,la as Qn,li as $n,ln as er,lr as tr,lt as nr,m as rr,ma as ir,mi as ar,mn as or,mr as sr,n as cr,na as lr,ni as ur,nn as dr,nr as fr,nt as pr,o as mr,oa as hr,oi as gr,on as _r,or as vr,ot as yr,p as br,pa as xr,pi as Sr,pn as Cr,pr as wr,q as Tr,qi as Er,qn as Dr,qr as Or,qt as kr,r as Ar,ra as jr,ri as Mr,rn as Nr,rr as Pr,rt as Fr,s as Ir,sa as Lr,si as Rr,sn as zr,sr as Br,st as Vr,t as Hr,ta as Ur,ti as Wr,tn as Gr,tr as Kr,tt as qr,u as Jr,ua as Yr,ui as Xr,un as Zr,ur as Qr,v as $r,va as ei,vi as ti,vn as ni,vr as ri,vt as ii,w as ai,wa as oi,wn as si,wr as ci,wt as li,x as ui,xa as di,xi as fi,xn as pi,xr as mi,xt as hi,y as gi,ya as _i,yi as vi,yn as yi,yr as bi,yt as xi,z as Si,zi as Ci,zn as wi,zt as Ti}from"./src-CUzcBQEu.mjs";import{C as Ei,E as Di,T as Oi,_ as ki,b as Ai,c as ji,d as Mi,g as Ni,i as Pi,l as Fi,m as Ii,n as Li,p as Ri,s as zi,t as Bi,u as Vi,v as Hi,w as Ui,x as Wi,y as Gi}from"./fs-traced-6G_aFzgy.mjs";import{a as Ki,d as qi,f as Ji,i as Yi,l as Xi,n as Zi,r as Qi,t as $i,u as ea}from"./logger-Dq-cRhcP.mjs";import{C as ta,S as na,_ as ra,a as ia,b as aa,c as oa,d as sa,f as ca,g as la,h as ua,i as da,l as fa,m as pa,n as ma,o as ha,p as ga,r as _a,s as va,t as ya,u as ba,x as xa}from"./server-lock-BbnnWHQ-.mjs";export{zt as AGENT_ID_MAX_LEN,ei as AGENT_ID_RE,Oe as AGENT_WRITE_ORIGIN,oi as AcpPermissionStore,di as AcpRegistry,Ne as AcpThreadManager,R as AgentFocusBroadcaster,ot as AgentPresenceBroadcaster,Re as AgentSessionCapacityError,U as AgentSessionManager,Ut as AutoStartDisabledError,k as BUNDLE_IDS,ci as BUNDLE_SCOPE,ct as BUNDLE_SKILL_NAME,fr as BacklinkIndex,J as CC1Broadcaster,t as CC1_CONTRACT_VERSION,Sn as CONFIG_FILENAME,Tt as CONFLICT_MARKER_RE,he as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Rt as ConfigSchema,Pt as DEFAULT_CHECKPOINT_RETENTION,dn as DEFAULT_EMBEDDINGS_DIMENSIONS,xe as DEFAULT_PACK_ID,mt as DocumentDurabilityState,xn as EMBEDDINGS_API_KEY_ENV,si as ExposureConsentError,$e as FEATURED_AGENT_IDS,Ue as FILE_SYSTEM_WRITER,_n as FILE_WATCHER_ORIGIN,Kt as FileEmbeddingsBackend,h as GIT_PREFLIGHT_FAIL_SPAN_NAME,f as GIT_UPSTREAM_WRITER,at as GitDirAccessError,Gr as GitNotAvailableError,dr as GitTooOldError,ii as HOCUSPOCUS_AUTH_REJECTION_REASONS,xi as HocuspocusAuthRejection,tn as HocuspocusAuthTokenSchema,$t as HomeProjectRootError,Ge as INSTALLED_AGENTS_SCHEMES,cn as JSON_SCHEMA_DIALECT_2020_12,r as LINEAGE_EPOCH_KEY,qe as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ze as LOG_MD_TEMPLATE,F as MANAGED_RENAME_ORIGIN,qn as MAX_ACP_THREADS,re as MAX_AGENT_SESSIONS,Hn as MCP_CONNECTION_ID_HEADER,o as MCP_SERVER_NAME,ve as MIN_EVICTABLE_IDLE_MS,Nr as MIN_GIT_VERSION,Q as MISSING_OK_CONFIG_MESSAGE,L as MalformedGitPointerError,vn as McpLogger,ut as MissingOkConfigError,Ci as OBSERVER_SYNC_ORIGIN,Cr as OK_OKIGNORE_TEMPLATE,B as ONBOARDING_BUNDLE_IDS,s as ORPHAN_MODES,n as PROTOCOL_VERSION,$i as PinoLogger,fa as ProcessLockCollisionError,Zn as ProjectGitInitError,Ie as ROLLBACK_ORIGIN,or as ROOT_GITIGNORE_TEMPLATE,aa as RUNTIME_VERSION,mn as SERVICE_WRITER,ri as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,Ti as STARTER_FOLDERS,w as STARTER_FOLDER_FRONTMATTER_FILENAME,_t as STARTER_PACKS,te as STARTER_PACK_IDS,pt as STARTER_TEMPLATES,it as STATE_MANIFEST_FILENAME,xa as STATE_SCHEMA_VERSION,a as SYSTEM_DOC_NAME,Mt as SeedPrerequisiteError,Dt as SeedRootDirError,ya as ServerLockCollisionError,Hr as SingleFileNotAFileError,cr as SingleFileNotFoundError,Ar as SingleFileNotMarkdownError,I as StateManifestError,Kr as TagIndex,P as USER_GLOBAL_BUNDLE_IDS,Xn as __getShowAllWalkStatsForTesting,b as __resetShowAllWalkStatsForTesting,ba as acquireProcessLock,ma as acquireServerLock,Je as applyAgentMarkdownWrite,le as applyExternalChange,oe as applySeed,j as assertCompatibleStateManifest,Rn as assertGitAvailable,ie as assertNeverDiskEvent,pi as assertNotHomeProjectRoot,M as attachAcpThreadSocket,kn as attachIdleShutdown,$r as bootServer,zn as buildAndOpenSkill,Nn as buildConfigYmlContent,Ot as buildExecResult,st as buildIngressPolicy,_ as buildOkMcpStdioCommand,en as buildSkillZip,St as buildStarterFolderFrontmatterYaml,Ur as buildWipTree,Fe as bundleSkillMdPath,gr as canonicalProjectKey,tt as canonicalizeForCompare,ye as classifyEvents,Bi as classifyFsPath,Rr as clearAllEmbeddingsKeys,ar as clearContributors,Z as coercePackId,c as colorFromSeed,lr as commitUpstreamImport,jr as commitWip,In as commitWipFromTree,qt as compareSemver,Wn as composeEffectiveLinterConfig,Te as composeFrontmatterSchemasConfig,Ft as containsConflictMarkers,Ye as contentHash,Mn as contributorCount,Le as countShadowObjects,H as countStaleAgentWipRefs,ne as countWipRefs,Gn as createApiExtension,V as createAssetServeMiddleware,q as createCollaborationHost,xt as createContentFilter,X as createContentFilterAsync,an as createEmbeddingsSecretStore,Fn as createEphemeralProjectDir,At as createExternalChangeHandler,yn as createFileLogger,Si as createLiveDerivedIndexExtension,Tr as createMcpHttpHandler,m as createOsProbe,De as createPersistenceExtension,T as createServer,Vn as createServerObserverExtension,$ as createStreamingErrorWriter,Zi as createTestLogger,$n as describeStoredEmbeddingsKey,wn as detectClaudeDesktopPresence,_r as detectGit,Me as detectProjectShape,Jt as detectUserSkillHosts,Fr as discoverLockDirs,G as discoverMarkdownlintConfig,gn as emitPreflightFailureSpan,Ct as encodeDocName,Nt as encodeFolderRoute,He as encodeSkillRoute,Jr as ensureProjectGit,Dn as ensureProjectSkillGitignore,dt as errorResponse,wi as evictStaleTrackerEntries,Ee as extractHeadings,Bn as extractOkBinaryPath,Pr as extractWikiLinksFromMarkdown,zr as fallbackPaths,ln as findEnclosingGitRoot,ze as findEnclosingProjectRoot,ae as findNativeMarkdownlintFile,br as flushFileLogger,hi as formatAuthRejectionWire,En as formatContributors,Bt as formatContributorsFrom,Ve as formatPackRationale,Gt as gcCheckpointRefs,qr as getCurrentMcpLogger,z as getIngressContext,fi as getLocalDir,rr as getLogFilePath,Qi as getLogger,An as getLogsDir,ra as getMachineId,Gi as getMeter,bn as getMetrics,Ai as getTracer,xr as handleCollabSocketError,Or as handleSpawnCursor,N as hasForwardingHeaders,_e as hasGcLogLatch,l as iconFromClientName,ir as incrementCollabSocketFilteredError,jn as incrementServerObserverFire,Vt as initContent,hr as initShadowRepo,Wi as initTelemetry,Xt as initToleranceTelemetryWriter,nr as installJsonSchemaDialect,Vr as installPrettyZodErrors,Yi as installTestLoggers,vr as installUserSkill,ke as isAllowedApiOrigin,Un as isAllowedWorkspaceHostHeader,pe as isConfigDoc,rt as isHocuspocusAuthRejectionReason,O as isHomeDir,Pe as isHostAdmitted,ge as isKnownPackId,Er as isLinkIndexExcludedDoc,we as isLoopbackAddress,ce as isManagedArtifactDoc,Jn as isOriginAdmitted,u as isOrphanMode,S as isPairedWriteOrigin,ue as isPathWithinDir,v as isPeerAdmitted,na as isProcessAlive,W as isProjectRoot,kt as isReservedForUserTree,C as isSelfWrite,wt as isSystemDoc,ui as isToleranceTelemetryEnabled,ta as isValidLockPid,gt as lastKnownHash,Lr as listRescueCheckpoints,kr as listStarterPacks,E as loadCustomAgents,Se as loadPrincipal,_a as lockAdvertisesUi,sa as lockBaseUrl,ca as lockFilePath,Ki as loggerFactory,Xi as logsCurrentPath,ea as logsPreviousPath,Xr as makeLazyEmbeddingsKeyStore,da as markServerLockDraining,vt as mountMcpAndApi,Li as normalizeFsPath,Yn as originGitHubHost,ni as packageVersionMajorMinor,A as parseAuthRejectionWire,on as parseGitVersion,li as parseHocuspocusAuthToken,fe as parseKeepaliveConnectionId,ee as pathToDocName,K as planSeed,Wt as prepareSingleFileOpen,Yt as processCommand,yr as processUsage,tr as readAllTargets,Qr as readBundleDecision,be as readOwnNativeRules,ga as readProcessLock,pa as readProcessLockDetailed,x as readProjectHeadState,Ln as readProjectLocalSemanticConfig,ia as readServerLock,pn as readServerPackageVersion,Cn as readSkillInstallStateSnapshot,Kn as readStateManifest,wr as readTargetRecordedAt,sr as readTargetVersion,We as reconcile,ti as recordContributor,bi as recordSkillInstallEvent,se as registerAllTools,ft as registerWrite,ua as releaseProcessLock,ha as releaseServerLock,bt as removeLastKnownHash,sn as reportSkillInstall,Tn as resetMetrics,Br as resolveBuiltinSkillHosts,i as resolveBundleEnabled,mi as resolveBundledSkillDir,et as resolveContentDir,jt as resolveCursorBinaryDefault,Et as resolveCursorSpawnInvocation,Ae as resolveEffectiveLinterConfig,Sr as resolveEmbeddingsCredential,D as resolveLockDir,Be as resolveNativeConfigForDoc,Xe as resolveNativeMarkdownlintConfig,de as resolvePack,Ir as resolvePackageVersion,Ht as resolveSkillInstallReportSettings,d as resolveUiInfo,vi as restoreContributors,gi as restoreLifecycleFromConflictsJson,ur as rewriteMarkdownLinksForDocumentRename,Mr as rewriteWikiLinksForDocumentRename,er as runAuthReposSubprocess,Zr as runAuthStatusSubprocess,Lt as runCloneSubprocess,fn as runDeviceFlowSubprocess,pr as runWithMcpLogger,Wr as safeContentPath,je as safeSubdir,rn as safetyCheckpoint,Ce as sanitizeClientName,Qn as saveInMemoryCheckpoint,Yr as saveVersion,lt as seedBasenameIndex,mr as serializeError,Ei as setActiveSpanAttributes,ht as setupServerObservers,un as shadowGit,Ui as shutdownTelemetry,qi as spansCurrentPath,Ji as spansPreviousPath,It as spawnDetached,p as splitMarkdownBlocks,Y as startWatcher,yt as streamingProblemEvent,Qt as swapContributors,Qe as teardownToleranceTelemetryWriter,_i as toBroadcasterKey,Pi as tracedAppendFileSync,zi as tracedLinkSync,ji as tracedMkdir,Fi as tracedMkdirSync,Vi as tracedRename,Mi as tracedRenameSync,Ri as tracedRmSync,Ii as tracedRmdirSync,Ni as tracedUnlinkSync,ki as tracedWriteFile,Hi as tracedWriteFileSync,ai as trustSystemCertificates,nn as untrackTrackedProjectSkillProjection,me as updateLastKnownHash,la as updateProcessLockPort,va as updateServerLockPort,Zt as validateAgentId,Ke as validateCloneInputs,nt as validateSkillZip,oa as waitForServerLockDrain,hn as withHiddenWindowsConsole,Oi as withSpan,Di as withSpanSync,Pn as writeBundleDecision,y as writeMarkdownlintRule,yi as writeRootGitignoreForNewRepo,g as writeStateManifest,On as writeTargetVersion,Dr as writeTracker};
1
+ import{B as e,Dc as t,Ss as n,Vs as r,W as i,Zs as a,g as o,v as s,vs as c,xs as l,zs as u}from"./src-NmTX6dJc.mjs";import{$ as d,$i as f,$n as p,$r as m,$t as h,A as g,Ai as _,An as v,Ar as y,At as b,B as x,Bi as S,Bn as C,Bt as w,C as T,Ca as E,Ci as D,Cn as O,Cr as k,Ct as A,D as j,Di as M,Dn as N,Dr as P,Dt as F,E as I,Ea as L,Ei as R,En as z,Er as B,Et as V,F as H,Fi as U,Fn as W,Fr as G,Ft as K,G as q,Gi as J,Gn as Y,Gr as X,Gt as Z,H as Q,Hi as $,Hn as ee,Ht as te,I as ne,Ii as re,In as ie,Ir as ae,It as oe,J as se,Ji as ce,Jn as le,Jr as ue,Jt as de,K as fe,Ki as pe,Kn as me,Kr as he,Kt as ge,L as _e,Li as ve,Ln as ye,Lr as be,Lt as xe,M as Se,Mi as Ce,Mn as we,Mr as Te,Mt as Ee,N as De,Ni as Oe,Nn as ke,Nr as Ae,Nt as je,O as Me,Oi as Ne,On as Pe,Or as Fe,Ot as Ie,P as Le,Pi as Re,Pn as ze,Pr as Be,Pt as Ve,Q as He,Qi as Ue,Qn as We,Qr as Ge,Qt as Ke,R as qe,Ri as Je,Rn as Ye,Rr as Xe,Rt as Ze,S as Qe,Sa as $e,Si as et,Sn as tt,Sr as nt,St as rt,T as it,Ta as at,Ti as ot,Tn as st,Tr as ct,Tt as lt,U as ut,Ui as dt,Un as ft,Ut as pt,V as mt,Vi as ht,Vn as gt,Vt as _t,W as vt,Wi as yt,Wn as bt,Wr as xt,Wt as St,X as Ct,Xi as wt,Xn as Tt,Xr as Et,Xt as Dt,Y as Ot,Yi as kt,Yn as At,Yr as jt,Yt as Mt,Z as Nt,Zi as Pt,Zn as Ft,Zr as It,Zt as Lt,_ as Rt,_a as zt,_i as Bt,_n as Vt,_r as Ht,_t as Ut,a as Wt,aa as Gt,ai as Kt,an as qt,ar as Jt,at as Yt,b as Xt,ba as Zt,bi as Qt,bn as $t,br as en,bt as tn,c as nn,ca as rn,ci as an,cn as on,cr as sn,ct as cn,d as ln,da as un,di as dn,dn as fn,dr as pn,ea as mn,ei as hn,en as gn,er as _n,et as vn,f as yn,fa as bn,fi as xn,fn as Sn,fr as Cn,g as wn,ga as Tn,gi as En,gn as Dn,gr as On,gt as kn,h as An,ha as jn,hi as Mn,hn as Nn,hr as Pn,i as Fn,ia as In,ii as Ln,in as Rn,ir as zn,it as Bn,j as Vn,ji as Hn,jn as Un,jr as Wn,jt as Gn,k as Kn,ki as qn,kn as Jn,kr as Yn,kt as Xn,l as Zn,la as Qn,li as $n,ln as er,lr as tr,lt as nr,m as rr,ma as ir,mi as ar,mn as or,mr as sr,n as cr,na as lr,ni as ur,nn as dr,nr as fr,nt as pr,o as mr,oa as hr,oi as gr,on as _r,or as vr,ot as yr,p as br,pa as xr,pi as Sr,pn as Cr,pr as wr,q as Tr,qi as Er,qn as Dr,qr as Or,qt as kr,r as Ar,ra as jr,ri as Mr,rn as Nr,rr as Pr,rt as Fr,s as Ir,sa as Lr,si as Rr,sn as zr,sr as Br,st as Vr,t as Hr,ta as Ur,ti as Wr,tn as Gr,tr as Kr,tt as qr,u as Jr,ua as Yr,ui as Xr,un as Zr,ur as Qr,v as $r,va as ei,vi as ti,vn as ni,vr as ri,vt as ii,w as ai,wa as oi,wn as si,wr as ci,wt as li,x as ui,xa as di,xi as fi,xn as pi,xr as mi,xt as hi,y as gi,ya as _i,yi as vi,yn as yi,yr as bi,yt as xi,z as Si,zi as Ci,zn as wi,zt as Ti}from"./src-DG3uYi4g.mjs";import{C as Ei,E as Di,T as Oi,_ as ki,b as Ai,c as ji,d as Mi,g as Ni,i as Pi,l as Fi,m as Ii,n as Li,p as Ri,s as zi,t as Bi,u as Vi,v as Hi,w as Ui,x as Wi,y as Gi}from"./fs-traced-1KTQL4h-.mjs";import{a as Ki,d as qi,f as Ji,i as Yi,l as Xi,n as Zi,r as Qi,t as $i,u as ea}from"./logger-Dq-cRhcP.mjs";import{C as ta,S as na,_ as ra,a as ia,b as aa,c as oa,d as sa,f as ca,g as la,h as ua,i as da,l as fa,m as pa,n as ma,o as ha,p as ga,r as _a,s as va,t as ya,u as ba,x as xa}from"./server-lock-B131eKn8.mjs";export{zt as AGENT_ID_MAX_LEN,ei as AGENT_ID_RE,Oe as AGENT_WRITE_ORIGIN,oi as AcpPermissionStore,di as AcpRegistry,Ne as AcpThreadManager,R as AgentFocusBroadcaster,ot as AgentPresenceBroadcaster,Re as AgentSessionCapacityError,U as AgentSessionManager,Ut as AutoStartDisabledError,k as BUNDLE_IDS,ci as BUNDLE_SCOPE,ct as BUNDLE_SKILL_NAME,fr as BacklinkIndex,J as CC1Broadcaster,r as CC1_CONTRACT_VERSION,Sn as CONFIG_FILENAME,Tt as CONFLICT_MARKER_RE,he as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Rt as ConfigSchema,Pt as DEFAULT_CHECKPOINT_RETENTION,dn as DEFAULT_EMBEDDINGS_DIMENSIONS,xe as DEFAULT_PACK_ID,mt as DocumentDurabilityState,xn as EMBEDDINGS_API_KEY_ENV,si as ExposureConsentError,$e as FEATURED_AGENT_IDS,Ue as FILE_SYSTEM_WRITER,_n as FILE_WATCHER_ORIGIN,Kt as FileEmbeddingsBackend,h as GIT_PREFLIGHT_FAIL_SPAN_NAME,f as GIT_UPSTREAM_WRITER,at as GitDirAccessError,Gr as GitNotAvailableError,dr as GitTooOldError,ii as HOCUSPOCUS_AUTH_REJECTION_REASONS,xi as HocuspocusAuthRejection,tn as HocuspocusAuthTokenSchema,$t as HomeProjectRootError,Ge as INSTALLED_AGENTS_SCHEMES,cn as JSON_SCHEMA_DIALECT_2020_12,u as LINEAGE_EPOCH_KEY,qe as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ze as LOG_MD_TEMPLATE,F as MANAGED_RENAME_ORIGIN,qn as MAX_ACP_THREADS,re as MAX_AGENT_SESSIONS,Hn as MCP_CONNECTION_ID_HEADER,c as MCP_SERVER_NAME,ve as MIN_EVICTABLE_IDLE_MS,Nr as MIN_GIT_VERSION,Q as MISSING_OK_CONFIG_MESSAGE,L as MalformedGitPointerError,vn as McpLogger,ut as MissingOkConfigError,Ci as OBSERVER_SYNC_ORIGIN,Cr as OK_OKIGNORE_TEMPLATE,B as ONBOARDING_BUNDLE_IDS,l as ORPHAN_MODES,t as PROTOCOL_VERSION,$i as PinoLogger,fa as ProcessLockCollisionError,Zn as ProjectGitInitError,Ie as ROLLBACK_ORIGIN,or as ROOT_GITIGNORE_TEMPLATE,aa as RUNTIME_VERSION,mn as SERVICE_WRITER,ri as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,Ti as STARTER_FOLDERS,w as STARTER_FOLDER_FRONTMATTER_FILENAME,_t as STARTER_PACKS,te as STARTER_PACK_IDS,pt as STARTER_TEMPLATES,it as STATE_MANIFEST_FILENAME,xa as STATE_SCHEMA_VERSION,a as SYSTEM_DOC_NAME,Mt as SeedPrerequisiteError,Dt as SeedRootDirError,ya as ServerLockCollisionError,Hr as SingleFileNotAFileError,cr as SingleFileNotFoundError,Ar as SingleFileNotMarkdownError,I as StateManifestError,Kr as TagIndex,P as USER_GLOBAL_BUNDLE_IDS,Xn as __getShowAllWalkStatsForTesting,b as __resetShowAllWalkStatsForTesting,ba as acquireProcessLock,ma as acquireServerLock,Je as applyAgentMarkdownWrite,le as applyExternalChange,oe as applySeed,j as assertCompatibleStateManifest,Rn as assertGitAvailable,ie as assertNeverDiskEvent,pi as assertNotHomeProjectRoot,M as attachAcpThreadSocket,kn as attachIdleShutdown,$r as bootServer,zn as buildAndOpenSkill,Nn as buildConfigYmlContent,Ot as buildExecResult,st as buildIngressPolicy,_ as buildOkMcpStdioCommand,en as buildSkillZip,St as buildStarterFolderFrontmatterYaml,Ur as buildWipTree,Fe as bundleSkillMdPath,gr as canonicalProjectKey,tt as canonicalizeForCompare,ye as classifyEvents,Bi as classifyFsPath,Rr as clearAllEmbeddingsKeys,ar as clearContributors,Z as coercePackId,o as colorFromSeed,lr as commitUpstreamImport,jr as commitWip,In as commitWipFromTree,qt as compareSemver,Wn as composeEffectiveLinterConfig,Te as composeFrontmatterSchemasConfig,Ft as containsConflictMarkers,Ye as contentHash,Mn as contributorCount,Le as countShadowObjects,H as countStaleAgentWipRefs,ne as countWipRefs,Gn as createApiExtension,V as createAssetServeMiddleware,q as createCollaborationHost,xt as createContentFilter,X as createContentFilterAsync,an as createEmbeddingsSecretStore,Fn as createEphemeralProjectDir,At as createExternalChangeHandler,yn as createFileLogger,Si as createLiveDerivedIndexExtension,Tr as createMcpHttpHandler,m as createOsProbe,De as createPersistenceExtension,T as createServer,Vn as createServerObserverExtension,$ as createStreamingErrorWriter,Zi as createTestLogger,$n as describeStoredEmbeddingsKey,wn as detectClaudeDesktopPresence,_r as detectGit,Me as detectProjectShape,Jt as detectUserSkillHosts,Fr as discoverLockDirs,G as discoverMarkdownlintConfig,gn as emitPreflightFailureSpan,Ct as encodeDocName,Nt as encodeFolderRoute,He as encodeSkillRoute,Jr as ensureProjectGit,Dn as ensureProjectSkillGitignore,dt as errorResponse,wi as evictStaleTrackerEntries,Ee as extractHeadings,Bn as extractOkBinaryPath,Pr as extractWikiLinksFromMarkdown,zr as fallbackPaths,ln as findEnclosingGitRoot,ze as findEnclosingProjectRoot,ae as findNativeMarkdownlintFile,br as flushFileLogger,hi as formatAuthRejectionWire,En as formatContributors,Bt as formatContributorsFrom,Ve as formatPackRationale,Gt as gcCheckpointRefs,qr as getCurrentMcpLogger,z as getIngressContext,fi as getLocalDir,rr as getLogFilePath,Qi as getLogger,An as getLogsDir,ra as getMachineId,Gi as getMeter,bn as getMetrics,Ai as getTracer,xr as handleCollabSocketError,Or as handleSpawnCursor,N as hasForwardingHeaders,_e as hasGcLogLatch,s as iconFromClientName,ir as incrementCollabSocketFilteredError,jn as incrementServerObserverFire,Vt as initContent,hr as initShadowRepo,Wi as initTelemetry,Xt as initToleranceTelemetryWriter,nr as installJsonSchemaDialect,Vr as installPrettyZodErrors,Yi as installTestLoggers,vr as installUserSkill,ke as isAllowedApiOrigin,Un as isAllowedWorkspaceHostHeader,pe as isConfigDoc,rt as isHocuspocusAuthRejectionReason,O as isHomeDir,Pe as isHostAdmitted,ge as isKnownPackId,Er as isLinkIndexExcludedDoc,we as isLoopbackAddress,ce as isManagedArtifactDoc,Jn as isOriginAdmitted,n as isOrphanMode,S as isPairedWriteOrigin,ue as isPathWithinDir,v as isPeerAdmitted,na as isProcessAlive,W as isProjectRoot,kt as isReservedForUserTree,C as isSelfWrite,wt as isSystemDoc,ui as isToleranceTelemetryEnabled,ta as isValidLockPid,gt as lastKnownHash,Lr as listRescueCheckpoints,kr as listStarterPacks,E as loadCustomAgents,Se as loadPrincipal,_a as lockAdvertisesUi,sa as lockBaseUrl,ca as lockFilePath,Ki as loggerFactory,Xi as logsCurrentPath,ea as logsPreviousPath,Xr as makeLazyEmbeddingsKeyStore,da as markServerLockDraining,vt as mountMcpAndApi,Li as normalizeFsPath,Yn as originGitHubHost,ni as packageVersionMajorMinor,A as parseAuthRejectionWire,on as parseGitVersion,li as parseHocuspocusAuthToken,fe as parseKeepaliveConnectionId,ee as pathToDocName,K as planSeed,Wt as prepareSingleFileOpen,Yt as processCommand,yr as processUsage,tr as readAllTargets,Qr as readBundleDecision,be as readOwnNativeRules,ga as readProcessLock,pa as readProcessLockDetailed,x as readProjectHeadState,Ln as readProjectLocalSemanticConfig,ia as readServerLock,pn as readServerPackageVersion,Cn as readSkillInstallStateSnapshot,Kn as readStateManifest,wr as readTargetRecordedAt,sr as readTargetVersion,We as reconcile,ti as recordContributor,bi as recordSkillInstallEvent,se as registerAllTools,ft as registerWrite,ua as releaseProcessLock,ha as releaseServerLock,bt as removeLastKnownHash,sn as reportSkillInstall,Tn as resetMetrics,Br as resolveBuiltinSkillHosts,i as resolveBundleEnabled,mi as resolveBundledSkillDir,et as resolveContentDir,jt as resolveCursorBinaryDefault,Et as resolveCursorSpawnInvocation,Ae as resolveEffectiveLinterConfig,Sr as resolveEmbeddingsCredential,D as resolveLockDir,Be as resolveNativeConfigForDoc,Xe as resolveNativeMarkdownlintConfig,de as resolvePack,Ir as resolvePackageVersion,Ht as resolveSkillInstallReportSettings,d as resolveUiInfo,vi as restoreContributors,gi as restoreLifecycleFromConflictsJson,ur as rewriteMarkdownLinksForDocumentRename,Mr as rewriteWikiLinksForDocumentRename,er as runAuthReposSubprocess,Zr as runAuthStatusSubprocess,Lt as runCloneSubprocess,fn as runDeviceFlowSubprocess,pr as runWithMcpLogger,Wr as safeContentPath,je as safeSubdir,rn as safetyCheckpoint,Ce as sanitizeClientName,Qn as saveInMemoryCheckpoint,Yr as saveVersion,lt as seedBasenameIndex,mr as serializeError,Ei as setActiveSpanAttributes,ht as setupServerObservers,un as shadowGit,Ui as shutdownTelemetry,qi as spansCurrentPath,Ji as spansPreviousPath,It as spawnDetached,p as splitMarkdownBlocks,Y as startWatcher,yt as streamingProblemEvent,Qt as swapContributors,Qe as teardownToleranceTelemetryWriter,_i as toBroadcasterKey,Pi as tracedAppendFileSync,zi as tracedLinkSync,ji as tracedMkdir,Fi as tracedMkdirSync,Vi as tracedRename,Mi as tracedRenameSync,Ri as tracedRmSync,Ii as tracedRmdirSync,Ni as tracedUnlinkSync,ki as tracedWriteFile,Hi as tracedWriteFileSync,ai as trustSystemCertificates,nn as untrackTrackedProjectSkillProjection,me as updateLastKnownHash,la as updateProcessLockPort,va as updateServerLockPort,Zt as validateAgentId,Ke as validateCloneInputs,nt as validateSkillZip,oa as waitForServerLockDrain,hn as withHiddenWindowsConsole,Oi as withSpan,Di as withSpanSync,Pn as writeBundleDecision,y as writeMarkdownlintRule,yi as writeRootGitignoreForNewRepo,g as writeStateManifest,On as writeTargetVersion,Dr as writeTracker};