@inkeep/open-knowledge 0.57.2 → 0.57.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{acp-harness-probe-CeLGZgZF.mjs → acp-harness-probe-z0kwtWNz.mjs} +2 -2
- package/dist/cli.mjs +6 -6
- package/dist/constants-BU7Q80Kc.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-D0Jw_Flt.mjs → init-CuxgCZK8.mjs} +3 -3
- package/dist/init-icHkVUwe.mjs +1 -0
- package/dist/{launch-json-removal-D7S3TARA.mjs → launch-json-removal-YpPZRaoj.mjs} +2 -2
- package/dist/loader-BP4vfYMD.mjs +1 -0
- package/dist/{loader-8jTgMHWn.mjs → loader-CpDf5eCy.mjs} +2 -2
- package/dist/{open-browser-CXZADc20.mjs → open-browser-DKdJEb2P.mjs} +2 -2
- package/dist/{preview-CsOdYI9R.mjs → preview-B9-lbB2r.mjs} +2 -2
- package/dist/preview-BGOmXIgS.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-ZdWHpW9R.js → ActivityModeContent-DtoUWb1c.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-5R8mVOBa.js → AgentDiffPane-0NV8wGXH.js} +1 -1
- package/dist/public/assets/{AgentThreadClientBinder-ChxqWHn_.js → AgentThreadClientBinder-B7BMwPdk.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-Bt-PKLsp.js → CodeMirrorPropInput-DRIXyyO3.js} +1 -1
- package/dist/public/assets/{DocumentContext-B9iq4BNd.js → DocumentContext-BzOkOcsd.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-BE5bbSlA.js → EditorModeToggle-B_J4DJWs.js} +1 -1
- package/dist/public/assets/{EnableSyncConfirmDialog-beSVOz70.js → EnableSyncConfirmDialog-CFk3AHnv.js} +1 -1
- package/dist/public/assets/FeedbackForm-srcVmSOs.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-BUFsAYfq.js → ImportSkillDialog-DVl5vnNu.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-D1WYmiU_.js → LintConfigEditor-MWJgrpYU.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-DABZzygh.js → ManagedArtifactProperties-E_X-hSBL.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-WUogeRZ9.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-BvqLgtA3.js → MermaidDocEditor-CMojAadB.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-fGfvgDmi.js → PropertyDisplayRow-nYf3Nzvv.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-obDkIsd-.js → SchemaConfigEditor-COUOzPXp.js} +1 -1
- package/dist/public/assets/{SessionsHost-B1am5Max.js → SessionsHost-BgY2S9NG.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-XCtxwjDO.js → SettingsDialogBody-NFfs-Exd.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-l_zhdKTD.js → ShareReceiveMissDialog-CX3klyil.js} +1 -1
- package/dist/public/assets/{SkillInstallMenu-BIyNr3N5.js → SkillInstallMenu-CT53ITFp.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-BWpjUjn2.js → SkillToolbarControls-D3v2Hs4j.js} +1 -1
- package/dist/public/assets/{SourceEditor-Bz5v3S3i.js → SourceEditor-CN-TUPAh.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-DD8gJu95.js → TerminalWindowApp-BZemj599.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CGA4IVxM.js → TextDocEditor-CbRGs1HT.js} +1 -1
- package/dist/public/assets/{ThreadView-xFlwNrph.js → ThreadView-BQPg9S8A.js} +8 -5
- package/dist/public/assets/{TimelineDiffPane-R_bywv7U.js → TimelineDiffPane-U-Xtvkw6.js} +1 -1
- package/dist/public/assets/{agent-diff-store-D7P2tv4j.js → agent-diff-store-iABbjLTR.js} +1 -1
- package/dist/public/assets/{auth-state-cache-Dmxci_Yi.js → auth-state-cache-ZDnOSM98.js} +1 -1
- package/dist/public/assets/{comment-chips-B8SZVYp5.js → comment-chips-DTsOTJH8.js} +1 -1
- package/dist/public/assets/{config-provider-DVTAY9Vz.js → config-provider-CFTiAtpH.js} +3 -3
- package/dist/public/assets/{follow-file-D0KRvizI.js → follow-file-BvKFjLSz.js} +1 -1
- package/dist/public/assets/i18n-B1dD_x6I.js +1 -0
- package/dist/public/assets/{index-CGCpZOtz.js → index-DAEjqhX2.js} +8 -8
- package/dist/public/assets/messages-31YqY4SS.js +1 -0
- package/dist/public/assets/messages-BVHIx_qK.js +1 -0
- package/dist/public/assets/messages-C7nddMWQ.js +1 -0
- package/dist/public/assets/{messages-Biy2FMnD.js → messages-CL4xikKQ.js} +1 -1
- package/dist/public/assets/messages-C_8WTeHE.js +1 -0
- package/dist/public/assets/{messages-H2nLj2X-.js → messages-CrwpWrRW.js} +1 -1
- package/dist/public/assets/messages-Cs6jyHNU.js +1 -0
- package/dist/public/assets/messages-D2XUrFhu.js +1 -0
- package/dist/public/assets/messages-DPWJimCT.js +1 -0
- package/dist/public/assets/messages-VnNooCHl.js +1 -0
- package/dist/public/assets/messages-e1iGNZ1R.js +1 -0
- package/dist/public/assets/messages-f9-p4BhX.js +1 -0
- package/dist/public/assets/{pending-receive-nav-store-CznOAcng.js → pending-receive-nav-store-CMgNWqay.js} +1 -1
- package/dist/public/assets/{selection-context-DVHitt8X.js → selection-context-BajeGoV5.js} +1 -1
- package/dist/public/assets/{skill-actions-Ciecrdl9.js → skill-actions-Dg0c2EFw.js} +1 -1
- package/dist/public/assets/{src-Bpz6hbcV.js → src-CJl_A7Op.js} +1 -1
- package/dist/public/assets/thread-client-CfT0-9Kx.js +1 -0
- package/dist/public/assets/{typing-burst-detector-DHCJpINv.js → typing-burst-detector-DBj9oKSQ.js} +1 -1
- package/dist/public/assets/{uninstall-BZMjlyAF.js → uninstall-Cvh4Iu4I.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DFk8Um2P.js → use-activity-panel-Bh3C3n8-.js} +1 -1
- package/dist/public/assets/{use-open-skill-NnqEgk0v.js → use-open-skill-C9ju-IL1.js} +1 -1
- package/dist/public/assets/{use-popular-skills-BZaA-ls7.js → use-popular-skills-DHiWi3V2.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-BuyfII4_.js → use-terminal-enabled-Dh008W1x.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-DQcSimR1.js → use-timeline-entry-diff-ooVH_oUf.js} +1 -1
- package/dist/public/index.html +21 -21
- package/dist/public/uninstall.html +3 -3
- package/dist/{repair-launch-json-D-Y4IbdA.mjs → repair-launch-json-BRgTZeMm.mjs} +2 -2
- package/dist/{repair-mcp-configs-BUTTfIPz.mjs → repair-mcp-configs-CYBY9hkz.mjs} +2 -2
- package/dist/repair-skills-Cw6FhG82.mjs +1 -0
- package/dist/{repair-skills-B1yLGVCl.mjs → repair-skills-DbvWHh50.mjs} +2 -2
- package/dist/{skill-teardown-CJl8M28h.mjs → skill-teardown-sZPAAcyi.mjs} +2 -2
- package/dist/{src-BbuqzOpI.mjs → src-B9IqHTFZ.mjs} +2 -2
- package/dist/src-BgAHj6S9.mjs +1 -0
- package/dist/{src-C6s1YGEs.mjs → src-BnJNsU3L.mjs} +2 -2
- package/dist/{src--C17TQmO.mjs → src-BsTo_BQp.mjs} +1 -1
- package/dist/start-B1c9LmyX.mjs +1 -0
- package/dist/{start-Uw9UGGLL.mjs → start-DA0DLWF1.mjs} +4 -4
- package/dist/{ui-CSid4Ybi.mjs → ui-CTtklN4L.mjs} +3 -3
- package/dist/{write-project-skill-G2p_hc1u.mjs → write-project-skill-CpzPK3Kr.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-DMPdZA-V.mjs +0 -2
- package/dist/init-DrSFaNwj.mjs +0 -1
- package/dist/loader-BnfuGv9T.mjs +0 -1
- package/dist/preview-ld1lLiyk.mjs +0 -1
- package/dist/public/assets/FeedbackForm-DAMqh8_y.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-LYcjZ0-Q.js +0 -1
- package/dist/public/assets/i18n-xmPTRUdA.js +0 -1
- package/dist/public/assets/messages-2b0x7qJR.js +0 -1
- package/dist/public/assets/messages-4LHyoP9C.js +0 -1
- package/dist/public/assets/messages-95-nzhW9.js +0 -1
- package/dist/public/assets/messages-CfuqAa9t.js +0 -1
- package/dist/public/assets/messages-DLenzTlL.js +0 -1
- package/dist/public/assets/messages-DkLAKTWM.js +0 -1
- package/dist/public/assets/messages-DpELtdBZ.js +0 -1
- package/dist/public/assets/messages-L9EG6wMs.js +0 -1
- package/dist/public/assets/messages-Y1T6q4nq.js +0 -1
- package/dist/public/assets/messages-o6mVf0CQ.js +0 -1
- package/dist/public/assets/thread-client-B1jXINMp.js +0 -1
- package/dist/repair-skills-nLLLv3za.mjs +0 -1
- package/dist/src-CK1WyOz0.mjs +0 -1
- package/dist/start-CEKLyQNR.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./launch-json-removal-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{t as e}from"./launch-json-removal-YpPZRaoj.mjs";import{join as t}from"node:path";function n(n){let i=n.logger??r,a=t(n.projectDir,`.claude`,`launch.json`);if(n.reclaimDisableEnv===`1`)return i({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:a,outcome:`skipped-reclaim-disabled`},repairedCount:0};let o;try{o=e(n.projectDir)}catch(e){let t=e instanceof Error?e.message:String(e);return i({event:`launch-json-repair-write-failed`,configPath:a}),{outcome:{configPath:a,outcome:`write-failed`,error:t},repairedCount:0}}let s=o.kind===`removed`||o.kind===`removed-file`;return s&&i({event:`launch-json-repair-removed`,configPath:a}),{outcome:{configPath:a,outcome:o.kind},repairedCount:+!!s}}function r(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{n as repairLaunchJson};
|
|
2
|
+
//# sourceMappingURL=repair-launch-json-BRgTZeMm.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,o as t,p as n}from"./write-project-skill-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{i as e,o as t,p as n}from"./write-project-skill-CpzPK3Kr.mjs";import{d as r,v as i}from"./init-CuxgCZK8.mjs";import{t as a}from"./mcp-migrate-event-B1gJf6bG.mjs";import{homedir as o}from"node:os";function s(n){let r=n.logger??u,i=n.home??o(),a=[];if(n.reclaimDisableEnv===`1`)return r({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of e){let e=t[o],s=c(()=>e.configPath(``,i));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:e,home:i,cwd:``,configPath:s,configPathOverride:void 0,logger:r})),e.projectConfigPath){let t=e.projectConfigPath,i=c(()=>t(n.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:e,home:void 0,cwd:n.projectDir,configPath:i,configPathOverride:i,logger:r}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(e){let t={scope:e.scope,editorId:e.editorId,configPath:e.configPath},o=r(e.target,e.cwd,e.home,e.configPathOverride);if(o===null)return{...t,outcome:`no-entry`};if(n(o))return{...t,outcome:`canonical`};e.logger(a({scope:e.scope,surface:`cli-repair`,editorId:e.editorId,configPath:e.configPath,priorEntry:o}));let s=i(e.target,e.cwd,{mode:`published`,skipAvailabilityCheck:!0},e.home,e.configPathOverride);if(s.action===`failed`){let n=s.error??`unknown write failure`;return e.logger({event:`mcp-config-repair-write-failed`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,error:n}),{...t,outcome:`write-failed`,error:n}}return s.action===`declined`?(e.logger({event:`mcp-config-repair-declined`,scope:e.scope,editorId:e.editorId,configPath:e.configPath,reason:s.declineReason}),{...t,outcome:`declined`}):{...t,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-CYBY9hkz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-DbvWHh50.mjs";export{e as repairSkills};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Os as e,W as t}from"./src-DMi2O7yV.mjs";import{Cr as n,_r as r,cr as i,fr as a,lr as o,mr as s,pr as c,wr as l,yr as u}from"./src-
|
|
1
|
+
import{Os as e,W as t}from"./src-DMi2O7yV.mjs";import{Cr as n,_r as r,cr as i,fr as a,lr as o,mr as s,pr as c,wr as l,yr as u}from"./src-BnJNsU3L.mjs";import{o as d,s as f,t as p,v as m}from"./write-project-skill-CpzPK3Kr.mjs";import{n as h,s as g,t as _}from"./colors-BsmVIwfM.mjs";import{n as v,r as y,t as b}from"./skill-teardown-sZPAAcyi.mjs";import{dirname as x,join as S,relative as C,resolve as w}from"node:path";import{existsSync as T,mkdirSync as E,readFileSync as D,readdirSync as O,rmSync as k,statSync as A,writeFileSync as j}from"node:fs";import{homedir as M}from"node:os";import{createInterface as N}from"node:readline/promises";const P={existsSync:e=>T(e),isDirectory:e=>{try{return A(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>O(e),readFileSync:e=>D(e),writeFileSync:(e,t)=>{j(e,t)},mkdirSync:(e,t)=>{E(e,t)},rmSync:(e,t)=>{k(e,t)}},F={resolveProjectBundledSkillDir:()=>u(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>u(e,{checkDesktop:!1}),readBundledVersion:()=>o(),readRecordedVersion:e=>a(e,`cli-hosts`),writeRecordedVersion:(e,t)=>s(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>r(e),readBundleDecision:(e,t)=>i(e,t),writeBundleDecision:(e,t,n)=>c(e,t,n),removeBundleFromDisk:(e,t)=>y(e,t)};function I(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function L(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(x(t),{recursive:!0}),R(e,t,n)}function R(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=S(e,r),a=S(t,r);n.isDirectory(i)?R(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function z(t,n,r){return r.existsSync(S(t,`.agents`,`skills`,n))||e.some(e=>r.existsSync(S(t,e.skillsRoot,n)))}function B(t,n,r,i,a,o){let s=[],c=S(t,`.agents`,`skills`,n),l=i.existsSync(S(t,`.agents`));if(l&&i.existsSync(c))s.push({kind:`central`,path:c,outcome:`skipped-present`});else if(l)try{L(r,c,i),s.push({kind:`central`,path:c,outcome:`written`}),a({event:`user-skill-reclaim-central-written`,scope:`user`,path:c,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`central`,path:c,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-central-failed`,scope:`user`,path:c,error:t})}for(let l of e){let e=S(t,l.hostDir),u=S(t,l.skillsRoot,n);if(u===c){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!i.existsSync(e)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-host-absent`});continue}if(i.existsSync(u)){s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`skipped-present`});continue}try{L(r,u,i),s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`written`}),a({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,preexisting:!1,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);s.push({kind:`host`,editorId:l.editorId,hostDir:l.hostDir,path:u,outcome:`failed`,error:t}),a({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:l.editorId,hostDir:l.hostDir,path:u,error:t})}}return{entries:s,anyWritten:s.some(e=>e.outcome===`written`),anyDestinationSucceeded:s.some(e=>e.outcome===`written`||e.outcome===`skipped-present`)}}function V(e,t){if(!e)return!1;try{return t.existsSync(e)?t.readFileSync(e).toString(`utf8`).includes(`# ok-mcp-`):!1}catch{return!1}}function H(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of f){let o=S(e,t.hostDir,`skills`,`open-knowledge`),s=S(o,`SKILL.md`);if(n.existsSync(s)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`present`});continue}let c=d[t.editorId]?.projectConfigPath?.(e);if(!V(c,n)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{p(o,e),L(i,o,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`created`}),r({event:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function U(e,r,i,a){let o=e=>{r.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),c;try{c=await r.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await r.readRecordedVersion(e)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of l)try{d.push({id:e,sourceDir:r.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=n[o.id],c=z(e,s,i),l=await r.readBundleDecision(e,s).catch(()=>null);if(!t(l,{installedOnDisk:c})){if(c)try{r.removeBundleFromDisk(e,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await r.writeBundleDecision(e,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(t=>z(e,n[t.id],i));if(u!==null&&u===c&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:c}),{outcome:`skipped`,reason:`version-current`};let h=[],g=d.length===l.length,_=[];for(let{id:t,sourceDir:r}of p){let o=B(e,n[t],r,i,a,c);h.push(...o.entries),_.push({id:t,anyWritten:o.anyWritten,landed:o.anyDestinationSucceeded,centralFailed:o.entries.some(e=>e.kind===`central`&&e.outcome===`failed`),hostFailed:o.entries.some(e=>e.kind===`host`&&e.outcome===`failed`)})}let v=_.some(e=>e.centralFailed),y=_.every(e=>e.landed);if(g&&y&&!v){let t=null;try{await r.writeRecordedVersion(e,c),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:c})}catch(e){t=e instanceof Error?e.message:String(e),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:c,error:t})}for(let{id:e,anyWritten:n}of _)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:t===null?n?`installed`:`skip-current`:`failed`,version:c,...t===null?{}:{reason:`state-write-failed:${t}`}})}else{g||o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:c,reason:`bundle-unresolved`});for(let{id:e,centralFailed:t,hostFailed:n}of _)!t&&!n||o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:e,outcome:`failed`,version:c,reason:n?`all-writes-failed`:`central-write-failed`})}return{outcome:`done`,version:c,entries:h}}async function W(e){let t=e.logger??I,n=e.fs??P,r=e.home??M(),i={...F,...e.deps};if(e.reclaimDisableEnv===`1`)return t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`};let a=H(e.projectDir,i,n,t),o=await U(r,i,n,t),s=v(r),c=[],l=!1,u=!1;if(s.skillDirs.length>0||s.emptyDirs.length>0)if(e.confirmLegacyCleanup&&await e.confirmLegacyCleanup(s)){try{c=b(r,s)}catch(e){u=!0,t({event:`legacy-fanout-cleanup-refused`,scope:`user`,error:e instanceof Error?e.message:String(e)})}for(let e of c)t({event:`legacy-fanout-path-removed`,scope:`user`,path:e})}else l=!0,t({event:`legacy-fanout-cleanup-declined`,scope:`user`});return{status:`done`,project:a,user:o,legacySwept:c,legacyCleanupDeclined:l,legacyCleanupFailed:u}}function G(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function K(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`present`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} present, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-present`).length,i=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,a=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} present, ${i} skipped, ${a} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return e.legacySwept.length>0?t.push(` Cleanup: removed ${e.legacySwept.length} path(s) from a pre-0.42 install.`):e.legacyCleanupFailed?t.push(` Cleanup: failed — see logs; pre-0.42 directories left in place.`):e.legacyCleanupDeclined&&t.push(` Cleanup: declined — pre-0.42 directories left in place.`),t.join(`
|
|
2
2
|
`)}function q(){return new m(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").option(`-y, --yes`,`Skip the confirmation prompt for removing directories left by a pre-0.42 install.`).action(async e=>{let t=await W({projectDir:w(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null,confirmLegacyCleanup:t=>J(t,{yes:e.yes===!0})});process.stdout.write(`${K(t)}\n`),process.exitCode=G(t)})}async function J(e,t){let n=M(),r=e=>`~/${C(n,e)}`,i=t.input??process.stdin,a=[``,_(`A previous version of OpenKnowledge installed its skill into agent tools you may never have used.`),h(`(Versions before 0.42 wrote to every host a third-party installer knew about — see issue #820.)`)];if(e.skillDirs.length>0&&a.push(``,`${_(`Remove OpenKnowledge skills:`)} ${e.skillDirs.length}`,...e.skillDirs.map(e=>` ${r(e)}`)),e.emptyDirs.length>0){let t=e.skillDirs.length>0?`Then remove these, which hold nothing else once the above are gone:`:`Remove these empty directories, left behind by that install:`;a.push(``,`${_(t)} ${e.emptyDirs.length}`,...e.emptyDirs.map(e=>` ${r(e)}`))}if(a.push(``,h(`Nothing outside these paths is touched. A directory that still holds anything is kept.`)),process.stdout.write(`${a.join(`
|
|
3
3
|
`)}\n`),t.yes)return!0;if(!i.isTTY)return process.stdout.write(`${g("Not a terminal — skipping cleanup. Re-run with `ok repair-skills --yes` to remove these.")}\n`),!1;let o=N({input:i,output:process.stdout});try{let e=(await o.question(`\n${_(`Remove them?`)} ${h(`[y/N] `)}`)).trim().toLowerCase();return e===`y`||e===`yes`}finally{o.close()}}export{q as n,W as t};
|
|
4
|
-
//# sourceMappingURL=repair-skills-
|
|
4
|
+
//# sourceMappingURL=repair-skills-DbvWHh50.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Os as e}from"./src-DMi2O7yV.mjs";import{Cr as t,wr as n}from"./src-
|
|
2
|
-
//# sourceMappingURL=skill-teardown-
|
|
1
|
+
import{Os as e}from"./src-DMi2O7yV.mjs";import{Cr as t,wr as n}from"./src-BnJNsU3L.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=[...n.map(e=>t[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 n){let n=t[r];o.push({path:a(i,`.agents`,`skills`,n),bundleId:r,scope:`central`});for(let t of e)o.push({path:a(i,t.skillsRoot,n),bundleId:r,scope:`host`,hostDir:t.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-sZPAAcyi.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-D_nNc7T_.mjs";import{gc as i,hc as a,nt as o,po as s,rt as c}from"./src-DMi2O7yV.mjs";import{Nn as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-
|
|
1
|
+
import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft as n,q as r}from"./sleep-D_nNc7T_.mjs";import{gc as i,hc as a,nt as o,po as s,rt as c}from"./src-DMi2O7yV.mjs";import{Nn as l,Zr as u,at as d,bi as f,it as p,ot as m,rt as h}from"./src-BnJNsU3L.mjs";import{D as ee,F as g,I as _,k as v}from"./fs-traced-xJfl5Rxd.mjs";import{C as y,S as b,d as x,y as S}from"./server-lock-BHY1C3dW.mjs";import{t as C}from"./yazl-DZr4PyKA.mjs";import{m as w,p as te,v as T}from"./write-project-skill-CpzPK3Kr.mjs";import{c as ne}from"./colors-BsmVIwfM.mjs";import{n as re}from"./acp-harness-probe-z0kwtWNz.mjs";import{E,T as D,_ as ie,o as O,w as k,x as ae,y as oe}from"./init-CuxgCZK8.mjs";import{n as se}from"./constants-BU7Q80Kc.mjs";import{t as A}from"./is-object-ByG7RnjH.mjs";import"./loader-CpDf5eCy.mjs";import"./skill-teardown-sZPAAcyi.mjs";import"./preview-B9-lbB2r.mjs";import{execSync as ce,spawnSync as j}from"node:child_process";import{basename as M,dirname as N,join as P,relative as le,resolve as F,sep as ue}from"node:path";import{cpSync as de,createWriteStream as fe,existsSync as I,lstatSync as pe,mkdirSync as L,mkdtempSync as me,readFileSync as R,readdirSync as z,readlinkSync as he,rmSync as B,statSync as ge,writeFileSync as V}from"node:fs";import{arch as _e,freemem as ve,homedir as H,hostname as ye,platform as be,release as xe,tmpdir as Se,totalmem as Ce,type as we,uptime as Te}from"node:os";import"node:fs/promises";import{createHash as Ee}from"node:crypto";var U=n();const De=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`,`lint`,`deinit`,`auth`]);function Oe(e,t,n=l){if(e!==void 0&&!De.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let ke=null;function Ae(e){ke=e}function je(){return ke??process.cwd()}function Me(){return P(H(),`.ok`,`bug-reports`)}function Ne(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=Me(),r=`${t}-bugreport`,i=P(n,`${r}.zip`);for(let e=2;I(i);e+=1)i=P(n,`${r}-${e}.zip`);return i}function Pe(e,t){let n=P(e,`.ok`,`config.yml`);if(I(n))try{let e=R(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 I(P(e,`.ok`))?Ee(`sha256`).update(F(e)).digest(`hex`).slice(0,12):null}function Fe(){let e={timestamp:new Date().toISOString(),platform:be(),osType:we(),osRelease:xe(),hostname:`[redacted]`,uptime:Te(),freeMem:ve(),totalMem:Ce(),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`,u({encoding:`utf8`})).trim()}catch{}try{let t=P(__dirname,`..`,`..`,`package.json`);I(t)&&(e.okVersion=JSON.parse(R(t,`utf8`)).version)}catch{}return e}const Ie=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function W(e){let t=M(e);return Ie.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function Le(e,t){return Be(e,t).files}const Re=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function ze(e,t=re){let n=P(e,`${t}.ShipIt`);return I(n)?Re.map(e=>P(n,e)).filter(e=>I(e)):[]}function Be(e,t){if(!I(t))return{files:[],excludedByProjectSlug:0};let n=z(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>P(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(W),i=[],a=r.filter(t=>{try{return R(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=>!W(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function Ve(e){let t=P(e,`.ok`,`local`);return I(t)?{files:[`server.lock`,`last-spawn-error.log`,o].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function He(e){let t=P(e,`.ok`,`local`,`logs`);return I(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>P(t,e)).filter(e=>I(e))}:{files:[]}}function Ue(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 G(e){for(let t of e.files)try{Ue({zipfile:e.zipfile,name:`${e.prefix}/${M(t)}`,content:R(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 We(t){let{redact:n,outputPath:r,logger:i}=t,o=t.userLogsDir??P(H(),`.ok`,`logs`),s=t.projectDir?Pe(t.projectDir,i):null;L(N(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=Fe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=Be(s,o),{files:d}=t.projectDir?Ve(t.projectDir):{files:[]},{files:f}=t.projectDir?He(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;G({zipfile:g,files:[...l,...p],prefix:`logs`,redact:n,bundleFiles:h,redactions:m,logger:i}),G({zipfile:g,files:d,prefix:`lockdir`,redact:n,bundleFiles:h,redactions:m,logger:i}),G({zipfile:g,files:f,prefix:`local-logs`,redact:n,bundleFiles:h,redactions:m,logger:i});for(let e of t.extraFiles??[])try{let t=R(e.sourcePath),n=`extra/${e.zipName??M(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&&Ue({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/${M(e)}`)),x=h.filter(e=>b.has(e)),S=s?h.filter(e=>e.startsWith(`logs/`)&&!W(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
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 Ge=e(C(),1),K=e(ne(),1);function Ke(e){return _({absPath:v(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function qe({home:e=H(),env:n=process.env}={}){let i=Ke(e),{override:a,preferenceList:o}=ee(n),{locale:c,source:l}=s({override:a,storedPreference:i,supportedLocales:r,preferenceList:o,autoDetectableLocales:t});return{preference:i,locale:c,source:l,systemLanguages:o}}function Je(e,t){return t.length===0||!e.includes(t)?e:e.split(t).join(`<CONTENT_DIR>`)}function Ye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e,t){if(typeof e==`string`)return Je(e,t.contentDir);if(Array.isArray(e))return e.map(e=>q(e,t));if(!Ye(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=q(i,t);return n}function Xe(e,t){let n=R(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=q(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}V(e,r?`${a.join(`
|
|
@@ -17,4 +17,4 @@ import{o as e}from"./chunk-DTipWd-i.mjs";import{K as t,ft 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 ln(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function un(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 dn(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:p(r),command:r,isDesktop:ln(r)}}function fn(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function Q(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&fn(e)?`ui-orphan`:`stale`}const pn=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function mn(e){switch(e){case`running`:return K.default.green(e);case`desktop`:return K.default.blue(e);case`foreign`:return K.default.cyan(e);case`ui-orphan`:return K.default.magenta(e);case`stale`:return K.default.yellow(e)}}function hn(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function gn(e){return`${hn(e.server.usage)} | ${hn(e.ui?.usage??null)}`}function _n(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function vn(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=>{let t=Q(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,_n(e),gn(e),t,String(n),un(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=mn(Q(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=K.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
19
19
|
`)}async function yn(e={}){let t=e.discover??h,n=e.inspect??Z,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=n(e,`ui`),o=dn(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:Q(e)}));r(JSON.stringify(e,null,2));return}r(vn(e.all?s:s.filter(e=>pn.has(Q(e)))))}function bn(){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 yn({all:t.all===!0||e===`all`,json:t.json===!0})})}function xn(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 Sn(e){let t=e.inspect??(t=>Z(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=xn(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 Cn(e,t=b){let n=await h(),r=null;for(let i of n){let n=Z(i,`server`),a=Z(i,`ui`);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 wn(e){let t=Sn({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Tn(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=Sn({lockDir:f(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 yn({});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=Z(n,`server`),r=Z(n,`ui`);!$(e,b)&&!$(r,b)||(wn(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 Cn(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}wn(t);return}wn(f(F(je(),n)))})}export{je as _,Xt as a,$t as c,Z as d,qt as f,Me as g,Ne as h,an as i,en as l,Wt as m,Tn as n,tn as o,Ut as p,bn as r,Zt as s,Sn as t,Yt as u,Ae as v,Oe as y};
|
|
20
|
-
//# sourceMappingURL=src-
|
|
20
|
+
//# sourceMappingURL=src-B9IqHTFZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-DMi2O7yV.mjs";import"./write-project-skill-CpzPK3Kr.mjs";import"./src-B9IqHTFZ.mjs";import"./acp-harness-probe-z0kwtWNz.mjs";import"./init-CuxgCZK8.mjs";import{n as e}from"./loader-CpDf5eCy.mjs";import"./skill-teardown-sZPAAcyi.mjs";import"./preview-B9-lbB2r.mjs";import"./mcp-migrate-event-B1gJf6bG.mjs";export{e as loadConfig};
|
|
@@ -18,7 +18,7 @@ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{$t as r,At as i,Bt
|
|
|
18
18
|
`)),c=e.shadow?.();if(!c||!e.docName){e.lossRing?.record({event:Vb,docName:e.docName??``,writerId:null,direction:`a`,site:`observer-a-apply`,lostLen:o,digest:s});return}let l=e.getBranch?.()??`main`,u=e.contentRoot??``,d=e.docName;queueMicrotask(()=>{Ix(c,u,{kind:`observer-a-apply-loss`,docName:d,contents:t,label:`Before Observer-A apply content-loss @ ${new Date().toISOString()}`,branch:l,metadata:{lostSubstrings:a}}).then(t=>{Koe(),e.lossRing?.record({event:Vb,docName:d,writerId:null,direction:`a`,site:`observer-a-apply`,lostLen:o,digest:s,checkpointSha:t}),console.warn(JSON.stringify({event:`observer-a-apply-loss-checkpoint-created`,docName:d,sha:t,kind:`observer-a-apply-loss`,timestamp:new Date().toISOString()}))}).catch(t=>{let n=t instanceof Error?t:Error(String(t));VC.warn({docName:d,err:n},`[Server Observer A] Apply-loss checkpoint write failed`),HC.warn({err:n,"doc.name":d,branch:l,kind:`observer-a-apply-loss`},`checkpoint write failed`),e.lossRing?.record({event:Vb,docName:d,writerId:null,direction:`a`,site:`observer-a-apply`,lostLen:o,digest:s})})})},d=(t,n,r)=>{qoe();let i=r.reduce((e,t)=>e+t.length,0),a=e.shadow?.(),o=e.docName;if(!a||!o){e.lossRing?.record({event:Ub,docName:o??``,writerId:null,direction:`b`,site:`derive-timing-exhaustion`,lostLen:i});return}let s=e.getBranch?.()??`main`,c=e.contentRoot??``;queueMicrotask(()=>{Ix(a,c,{kind:`defer-exhaustion-loss`,docName:o,contents:t,label:`Before derive-defer force-resolve @ ${new Date().toISOString()}`,branch:s,metadata:{deferCount:n}}).then(t=>{e.lossRing?.record({event:Ub,docName:o,writerId:null,direction:`b`,site:`derive-timing-exhaustion`,lostLen:i,checkpointSha:t}),console.warn(JSON.stringify({event:`derive-defer-exhaustion-checkpoint-created`,docName:o,sha:t,kind:`defer-exhaustion-loss`,timestamp:new Date().toISOString()}))}).catch(t=>{let n=t instanceof Error?t:Error(String(t));VC.warn({docName:o,err:n},`[Server Observer B] Derive-defer exhaustion checkpoint write failed`),HC.warn({err:n,"doc.name":o,branch:s,kind:`defer-exhaustion-loss`},`checkpoint write failed`),e.lossRing?.record({event:Ub,docName:o,writerId:null,direction:`b`,site:`derive-timing-exhaustion`,lostLen:i})})})},f=t=>{D=!0,cse(),e.onReDeriveBackstop?.(t);let n=r.toString(),i=e.shadow?.(),a=e.docName;if(!i||!a){e.lossRing?.record({event:Hb,docName:a??``,writerId:null,direction:`b`,site:`rederive-backstop`});return}let o=e.getBranch?.()??`main`,s=e.contentRoot??``;queueMicrotask(()=>{Ix(i,s,{kind:`bridge-backstop-trip`,docName:a,contents:n,label:`Before re-derive backstop freeze @ ${new Date().toISOString()}`,branch:o,metadata:{rounds:t}}).then(t=>{e.lossRing?.record({event:Hb,docName:a,writerId:null,direction:`b`,site:`rederive-backstop`,checkpointSha:t}),console.warn(JSON.stringify({event:`bridge-rederive-backstop-checkpoint-created`,docName:a,sha:t,kind:`bridge-backstop-trip`,timestamp:new Date().toISOString()}))}).catch(t=>{let n=t instanceof Error?t:Error(String(t));VC.warn({docName:a,err:n},`[Server Observer B] Re-derive backstop checkpoint write failed`),HC.warn({err:n,"doc.name":a,branch:o,kind:`bridge-backstop-trip`},`checkpoint write failed`),e.lossRing?.record({event:Hb,docName:a,writerId:null,direction:`b`,site:`rederive-backstop`})})})},p=``,m=``,h=!1,g=!1,_=!1,v=0,y=e.deferGuardEnabled!==!1,b=``,x=!1,S=0,C=!1,w=!1,T=e.fixedPointBackstopEnabled!==!1,E=e.preDrainEnabled!==!1,ee=[],te=0,D=!1,ne=!1,O=!1,re=!1,k=()=>{m=r.toString(),h=!1},A=e=>{p=e,k(),h=e!==``,T&&e!==``&&m===e&&(O=!0)},ie=e=>{p=e,m=e,h=!1},ae=e=>{p=e,h=!1},oe=e=>{p=e,m=r.toString(),h=!0},se=()=>So(r.toString()).frontmatter,ce=(e,t)=>{let{slot:n}=Mt(e,So(r.toString()).body);return Vn(e,n+t)},le=e.resolveEmbed&&e.docName?{resolveEmbed:e.resolveEmbed,resolveSize:e.resolveSize,sourcePath:e.docName}:void 0,ue=uC(i,{resolveEmbed:e.resolveEmbed,resolveSize:e.resolveSize,docName:e.docName}),de=``,j=``,fe=!1,pe=(e,t)=>{if(fe&&e===de&&t===j)return!0;let n=_o(e,t,ue);return n&&(de=e,j=t,fe=!0),n},me=(e,t,n,r)=>aw(e,t,n,r)&&!pe(e,t);try{let e=Pb(n,a).toJSON(),t=i.serialize(e),o=ce(se(),t).md;pe(r.toString(),o)?A(o):ie(o),b=o}catch(e){rx(`a`),VC.warn({err:e instanceof Error?e:Error(String(e))},`[Server Observer A] Baseline init failed — starting from empty snapshot`),A(``)}let he,ge=new Map,_e=new Map,M=(t,n)=>{let i=e.docName??`__nodoc__`,a=Date.now(),o=ge.get(i);if(o!==void 0&&a-o.lastMs<5e3)o.suppressed+=1,koe();else{let r=o?.suppressed??0;ge.set(i,{lastMs:a,suppressed:0}),Ooe(),console.warn(JSON.stringify({event:`producer-guard-violation`,docName:e.docName??null,reason:t.reason,construct:n,appliedDegrades:t.appliedDegrades,suppressedSincePrevious:r,timestamp:new Date().toISOString()}))}let s=e.shadow?.();if(!s||!e.docName)return;let c=r.toString();if(_e.get(i)===c)return;_e.set(i,c);let l=e.getBranch?.()??`main`,u=e.contentRoot??``,d=e.docName;queueMicrotask(()=>{Ix(s,u,{kind:`producer-guard-loss`,docName:d,contents:c,label:`Before producer-guard content-loss @ ${new Date().toISOString()}`,branch:l,metadata:{construct:n}}).then(e=>{Doe(),console.warn(JSON.stringify({event:`producer-guard-checkpoint-created`,docName:d,sha:e,kind:`producer-guard-loss`,timestamp:new Date().toISOString()}))}).catch(e=>{_e.get(i)===c&&_e.delete(i);let t=e instanceof Error?e:Error(String(e));VC.warn({err:t},`[Server Observer A] Producer-guard checkpoint write failed`),HC.warn({err:t,"doc.name":d,branch:l,kind:`producer-guard-loss`},`checkpoint write failed`)})})},ve=(t,n)=>{if(n===he||(he=n,!YC(t)))return;let r=ia(t,i.parseWithFallback(n,le));if(!(r.equivalent||r.reason!==`content-loss`)){if(GC())throw new KC({docName:e.docName,reason:r.reason,detail:r.detail});M(r,XC(t))}},ye=()=>{try{let c=Pb(n,a).toJSON(),d=r.toString()===m,f=Date.now()-v>=2e3,g=d&&f,y=i.serialize(c,{skipFreshnessDerive:!g});g&&ve(c,y);let w=ce(se(),y),T=w.md,E=r.toString(),ee=gt(T,E,8);if(ee.length>0&&fw(n,t.clientID,ee)){ie(T),_=!0,C=!0,s(`duplication-guard`),Uoe(),l(T,ee.length),Ts({"observer.a.path":`gated-duplication-rederive`});return}if(g&&(b=T,x=!1,S=0),h&&p===T){me(r.toString(),T)?(ie(T),_=!0,s(`identity-gate`),Ts({"observer.a.path":`gated-fragment-unchanged-rederive`})):Ts({"observer.a.path":`gated-fragment-unchanged`});return}let te=fa(E),D=fa(T);if(te===D&&!Ka(E,T)&&!Er(E,T)){Ts({"observer.a.path":`gated-in-sync`,"observer.a.gate_reason":E===T?`bytes-identical`:`tolerance-equivalent`}),A(T);return}let ne=m,O=E===m,re=O&&h&&m!==p&&te!==fa(p);Ts({"observer.a.path":O?re?`residual-merge`:`path-a`:`path-b`});let k={mergedText:null},ae=performance.now(),oe=O&&re||w.adjusted!==`none`||Er(E,T)?null:$C({currentText:E,lastSyncedXmlMd:m,json:c,mdManager:i,docName:e.docName});oe&&Ts({"observer.a.path":`map-driven-splice`,"observer.a.splice.compute_ms":Math.round(performance.now()-ae)}),t.transact(()=>{if(oe)ew(r,oe);else if(O&&!re)un(r,E,T);else{let t=O?p:ne,n=es(y),i=e=>n.unproject(e,E),a=e.mergeThreeWay??us;try{let e=i(a(n.project(t),n.project(T),n.project(E)));Bt(r,E,e),k.mergedText=e}catch(e){if(!(e instanceof _i)||(o(e,ne),GC()))throw e;let t=i(e.info.result);Bt(r,E,t),k.mergedText=t}}e.__testApplyLossInjector?.(r)},UC),oe&&Voe();let le=r.toString(),ue=fa(le);(oe||O&&!re)&&u(T,D,le,ue),k.mergedText!==null&&!O&&Tce(e.docName)&&(zoe(),console.warn(JSON.stringify({event:`observer-a-path-b-fired`,"doc.name":e.docName??null,xmlFragmentAdvanced:!0,ytextDiverged:!O,mergeBytesChanged:Math.abs(k.mergedText.length-E.length)}))),k.mergedText!==null&&O&&Hoe(),nx(`a`),A(T),me(le,T,D,ue)&&(le===ne&&ie(T),_=!0,s(`post-merge`))}catch(t){if(t instanceof _i||t instanceof KC)throw t;rx(`a`),VC.error({err:t},`[Server Observer A] Failed to sync tree→text`);try{let e=Pb(n,a).toJSON(),t=i.serialize(e),o=ce(se(),t).md;me(r.toString(),o)?(oe(o),_=!0,s(`error-recovery`)):A(o)}catch(n){VC.warn({docName:e.docName??null,originalError:t instanceof Error?t.message:String(t),recoveryError:n instanceof Error?n.message:String(n)},`[Server Observer A] Baseline recovery also failed`),p=``,m=``,h=!1}}},be=()=>{Es(`observer.runASync`,{attributes:{"doc.name":e.docName??``}},ye)},xe=(e,t)=>{if(t.origin!==UC){if(WC(t.origin)){try{let e=se();k(),b=m,x=!1,S=0,Se=e}catch(e){rx(`a`),VC.warn({err:e instanceof Error?e:Error(String(e))},`[Server Observer A] Paired-write baseline refresh failed — falling through to settlement`),g=!0}return}g=!0,x=!0}};if(n.length>0&&r.length===0)try{let e=Pb(n,a).toJSON(),o=i.serialize(e),s=ce(se(),o).md;t.transact(()=>{r.insert(0,s)},UC),A(s)}catch(e){rx(`a`),VC.error({err:e},`[Server Observer A] Failed initial sync`),A(``)}let Se=se(),Ce=()=>{try{let o=r.toString(),{frontmatter:s,body:l}=So(o),{slot:u,body:f}=Mt(s,l);if(!w&&fa(m)===fa(o)&&!Er(m,o)){Se!==s&&(AS(`source-mode`),Se=s),T&&h&&p===o&&(O=!0);return}if(D){Ts({"observer.b.path":`backstop-frozen`});return}if(C)C=!1;else if(y&&x){let t=ce(s,i.serialize(Pb(n,a).toJSON())).md;if(as(t,o,b))if(S>=8)d(t,S,xr(t,o,b)),S=0,Ts({"observer.b.path":`derive-timing-force-resolve`});else{S+=1,g=!0,_=!0,c(xr(t,o,b)),e.onDeriveTimingDefer?.({canonicalWitness:p,rawWitness:m}),re=!0,Ts({"observer.b.path":`derive-timing-defer`});return}}let v=i.parseWithFallback(f,le),E=e.schema.nodeFromJSON(v);t.transact(()=>{Mb(t,n,E,{mapping:new Map,isOMark:new Map})},UC),w=!1,T&&(ne=!0),Se!==s&&(AS(`source-mode`),Se=s),nx(`b`);try{let t=i.serialize(v),n=Cn(s,u+t);dC(r.toString(),n,{site:`observer-b`,docName:e.docName,canonicalizeBody:e=>e===l?u+t:ue(e)}),A(n),b=n,x=!1,S=0}catch(e){if(e instanceof et)throw e;VC.warn({err:e},`[Server Observer B] Post-sync re-serialization failed — using input body as baseline`),A(Cn(s,l))}}catch(e){if(e instanceof et)throw e;rx(`b`),VC.error({err:e},`[Server Observer B] Failed to sync text→tree`);try{let e=Pb(n,a).toJSON(),t=i.serialize(e);ae(ce(se(),t).md)}catch(e){if(e instanceof et)throw e;VC.warn({err:e},`[Server Observer B] Baseline recovery also failed`)}}},we=()=>{Es(`observer.runBSync`,{attributes:{"doc.name":e.docName??``}},Ce)},Te=(e,t)=>{if(t.origin!==UC){if(WC(t.origin)){try{let e=se();k(),Se=e}catch(e){rx(`b`),VC.warn({err:e instanceof Error?e:Error(String(e))},`[Server Observer B] Paired-write baseline refresh failed — falling through to settlement`),_=!0}return}v=Date.now(),_=!0}},Ee=(t,n)=>{Es(`observer.dispatch`,{attributes:{"doc.name":e.docName??``}},t=>{if(!g&&!_){t.setAttribute(`observer.dispatch`,`none`),e.onDispatch?.(`none`);return}if(n.every(e=>e.origin===UC)){g=!1,_=!1,t.setAttribute(`observer.dispatch`,`none`),e.onDispatch?.(`none`);return}ne=!1,O=!1,re=!1;let i=g;g&&(g=!1,e.onDispatch?.(`a`),be());let a=_;if(_&&(_=!1,e.onDispatch?.(`b`),we()),T&&!re){if(O)te=0,ee.length=0,D=!1;else if(ne){let e=Rn(r.toString());ee.includes(e)?(te+=1,te>=8&&!D&&f(te)):te=0,ee.push(e),ee.length>8&&ee.shift()}}t.setAttribute(`observer.dispatch`,i&&a?`a-then-b`:i?`a`:a?`b`:`none`)})};n.observeDeep(xe),r.observe(Te),t.on(`afterAllTransactions`,Ee);let De=LC(()=>g||_),Oe=_ce(t);return tw.set(t,{preDrain(o){if(!E)return{preDrain:!1,reason:`skip-disabled`};if(!x)return{preDrain:!1,reason:`skip-no-pending`};try{let e=Pb(n,a).toJSON(),s=r.toString(),{body:c}=So(s),l=s.length-c.length,{preDrain:u,verdict:d,splice:f}=CC({pendingDirty:!0,body:c,fragmentPmJson:e,witnessMatched:s===m,fmPrefixLen:l,op:o.kind===`agent-undo`?{kind:`agent-undo`,ytext:r,stackItem:o.stackItem}:{kind:`agent-write`,writeKind:o.writeKind},mdManager:i});if(!u)return d;let p=ce(se(),i.serialize(e));if(p.adjusted!==`none`)return{preDrain:!1,reason:`checkpoint-fm-ambiguous`};let h=s.length-c.length;t.transact(()=>{ew(r,{spliceStart:h+f.spliceStart,spliceEnd:h+f.spliceEnd,newSlice:f.newSlice})},UC);let g=p.md;return A(g),b=g,x=!1,S=0,d}catch(t){return rx(`a`),VC.warn({err:t instanceof Error?t:Error(String(t)),docName:e.docName},`[Server pre-drain] Discrimination threw — routing to the checkpoint floor`),{preDrain:!1,reason:`checkpoint-witness-mismatch`}}}}),rw.set(t,()=>b),()=>{De(),Oe(),tw.delete(t),rw.delete(t),t.off(`afterAllTransactions`,Ee),n.unobserveDeep(xe),r.unobserve(Te)}}const mw=P(`agent-sessions`),hw={source:`local`,skipStoreHooks:!1,context:{origin:`agent-write`,paired:!0}};function gw(e){return e.endsWith(`.md`)||e.endsWith(`.mdx`)?e:`${Gx(e)}${Xx(e)}`}async function _w(e,t,n,r){if(vS(e))return;let i=Cw(e.getText(`source`).toString(),t,n);if(i!==void 0)return QS(i.newContent,r)}async function vw(e,t){let{fenced:n,body:r}=bi(e.getText(`source`).toString()),i=xa(n,t);if(!i.ok||i.nextFenced===n)return;let a=n===``&&r!==``&&!r.startsWith(`
|
|
19
19
|
`);return QS(i.nextFenced+(a?`
|
|
20
20
|
`:``)+r)}function yw(e){return e.bridgeLossReporter?{reporter:e.bridgeLossReporter,writerId:e.agentId}:void 0}function bw(e,t,n){let r=nw(e);r&&Cw(e.getText(`source`).toString(),t,n)!==void 0&&r.preDrain({kind:`agent-write`,writeKind:n})}function xw(e,t,n,r,i,a){if(vS(e))throw new bS({file:gw(e.name)});return Es(`agent.applyAgentMarkdownWrite`,{attributes:{"doc.name":e.name,"agent.write_position":n,"agent.markdown.bytes":t.length}},()=>{let o=ww(e,t,n,r,i,a);return o!==void 0&&Ts({"agent.content_divergent":!0,"agent.intended_bytes":o.intendedBytes,"agent.actual_bytes":o.actualBytes,"agent.byte_delta":o.byteDelta,"agent.divergence_type":o.divergenceType}),o})}function Sw(e){return e.getXmlFragment(`default`).toArray().map(e=>e.toString())}function Cw(e,t,n){let{frontmatter:r,body:i}=So(e),{frontmatter:a,body:o}=n===`append`||n===`prepend`?vh(t):So(t);if((n===`append`||n===`prepend`)&&o===``)return;let s,c;switch(n){case`replace`:s=a||r,c=o;break;case`patch`:s=a||r,c=o;break;case`prepend`:s=r,c=i.length>0?`${o.replace(/\n+$/,``)}\n\n${i.replace(/^\n+/,``)}`:o;break;case`append`:s=r,c=i.length>0?`${i.replace(/\n+$/,``)}\n\n${o.replace(/^\n+/,``)}`:o;break}return{existingFm:r,finalFm:s,newContent:Cn(s,c)}}function ww(e,t,n,r,i,a){try{let o=e.getText(`source`).toString(),s=Cw(o,t,n);if(s===void 0)return;let{existingFm:c,finalFm:l,newContent:u}=s,d=a&&Hx(hw.context.origin)?{report:t=>a.reporter(e.name,t,a.writerId,`agent-write-intake`),baselineFullMd:o}:void 0;if(l!==c){let t=Io(hn(l));if(t.map===null)throw new TS({file:gw(e.name),parseError:t.parseError??`unknown YAML parse error`});AS(`mcp-write`)}else if(l===``&&So(u).frontmatter!==``)throw new TS({file:gw(e.name),parseError:"the payload's leading `---` fence pair would land at byte 0, where the composed document re-reads it as the frontmatter region instead of body",refusalClass:`byte-0-promotion`,hint:"Start the payload with a blank line so the fence pair cannot open the document, or use `***` / `___` for the thematic break."});n===`replace`?Bb(e,u,r,i,d):zb(e,u,`agent`,r,i,d);let f=CS(e.getText(`source`).toString(),u,n);return mw.debug({docName:e.name,position:n,markdownBytes:t.length,divergent:f!==void 0},`[agent-write] applied agent markdown write`),f}catch(r){throw r instanceof TS||mw.error({err:r,docName:e.name,position:n,markdownLen:t.length},`[applyAgentMarkdownWrite] failed for '${e.name}'`),r}}function Tw(e,t,n,r){let i=e.dc.document;if(vS(i))throw new bS({file:gw(i.name)});return Es(`agent.applyAgentUndo`,{attributes:{"doc.name":e.dc.document.name,"agent.undo_scope":t}},()=>{let i=Ew(e,t,n,r);return Ts({"agent.undo_effective":i}),i})}function Ew(e,t,n,r){let{dc:i,um:a,undoOrigin:o}=e,s=i.document,c=t===`last`?1:t===`count`?Math.min(Math.max(0,r??0),a.undoStack.length):a.undoStack.length;c===1&&a.undoStack.length>0&&nw(s)?.preDrain({kind:`agent-undo`,stackItem:a.undoStack[a.undoStack.length-1]});let l=!1,u=e.bridgeLossReporter,d=u&&Hx(o.context.origin)?{report:t=>u(e.docName,t,e.agentId),baselineFullMd:s.getText(`source`).toString()}:void 0;return s.transact(()=>{for(let e=0;e<c&&a.undoStack.length>0;e++)a.undo(),l=!0;l&&noe(s,n,d)},o),mw.debug({docName:e.docName,agentId:e.agentId,scope:t,framesToPop:c,undone:l},`[agent-session] applied agent undo`),l}function Dw(e,t,n,r,i){let a={origin:`agent-write`,paired:!0,session_id:e};t!==void 0&&(a.agent_type=t),n!==void 0&&(a.principal=n),r!==void 0&&(a.display_name=r),i!==void 0&&(a.color_seed=i),Object.freeze(a);let o={source:`local`,skipStoreHooks:!1,context:a};return Object.freeze(o),o}function Ow(e,t){let n={origin:`agent-undo`,paired:!0,session_id:e};t!==void 0&&(n.agent_type=t),Object.freeze(n);let r={source:`local`,skipStoreHooks:!1,context:n};return Object.freeze(r),r}const kw=256,Aw=5e3;var jw=class extends Error{limit;constructor(e){super(`Maximum agent session count reached (${e})`),this.name=`AgentSessionCapacityError`,this.limit=e}};let Mw=null;function Nw(){return Mw||=nc().createCounter(`ok.sessions.evictions_total`,{description:`Agent sessions evicted (LRU-idle) under capacity pressure to admit a new session. Sustained growth alongside ok.sessions.active pinned at ok.sessions.limit means the working set exceeds the cap.`,unit:`{sessions}`}),Mw}var Pw=class{sessions=new Map;pendingSessions=new Map;hocuspocus;maxSessions;minEvictableIdleMs;bridgeLossReporter;evictions=0;constructor(e,t={}){this.hocuspocus=e,this.maxSessions=t.maxSessions??256,this.minEvictableIdleMs=t.minEvictableIdleMs??5e3,this.bridgeLossReporter=t.bridgeLossReporter}attachBridgeLossReporter(e){this.bridgeLossReporter=e}get liveSessionCount(){return this.sessions.size}get sessionLimit(){return this.maxSessions}get evictionCount(){return this.evictions}touchSession(e,t){t.lastUsedAt=Date.now(),this.sessions.delete(e),this.sessions.set(e,t)}sessionKey(e,t){return`${e}\0${t}`}*sessionsForConnection(e){let t=`\0${e}`;for(let[e,n]of this.sessions)e.endsWith(t)&&(yield n)}getLiveSession(e,t){let n=this.sessionKey(e,t),r=this.sessions.get(n);return r&&this.touchSession(n,r),r}async getSession(e,t=`claude-1`,n){if(tS(e)||nS(e))throw Error(`Cannot create agent session for reserved doc: ${e}`);let r=this.sessionKey(e,t),i=this.sessions.get(r);if(i)return this.touchSession(r,i),i;let a=this.pendingSessions.get(r);if(a)return mw.debug({docName:e,agentId:t},`[agent-session] joining in-flight session creation`),a;for(;this.sessions.size+this.pendingSessions.size>=this.maxSessions;)if(await this.evictLruIdleSession()===null)throw mw.warn({docName:e,agentId:t,limit:this.maxSessions},`[agent-session] session capacity reached, refusing new session`),new jw(this.maxSessions);let o=this._createSession(e,t,n);this.pendingSessions.set(r,o);try{let e=await o;return this.sessions.set(r,e),e}finally{this.pendingSessions.delete(r)}}async _createSession(e,t,n){let r=n?.clientName,i=t.startsWith(`agent-`)?t.slice(6):t,a=Dw(i,r,n?.principalId,n?.displayName,n?.colorSeed),o=Ow(i,r),s={session_id:i,...r===void 0?{}:{agent_type:r},...n?.clientName===void 0?{}:{client_name:n.clientName},...n?.principalId===void 0?{}:{principalId:n.principalId}},c=await this.hocuspocus.openDirectConnection(e,s);mw.debug({docName:e,agentId:t,sessionId:i,agentType:r},`[agent-session] DirectConnection opened`);let l=new Hie([c.document.getText(`source`),c.document.getMap(`agent-flash`)],{trackedOrigins:new Set([a]),captureTimeout:500,captureTransaction:e=>e.origin!==o,ignoreRemoteMapChanges:!0}),u=({stackItem:e})=>{e.meta.set(`time`,Date.now())};return l.on(`stack-item-added`,u),l.on(`stack-item-updated`,u),mw.info({docName:e,agentId:t,sessionId:i},`[agent-session] Created session for: ${e} / ${t}`),{dc:c,origin:a,undoOrigin:o,um:l,agentId:t,docName:e,lastUsedAt:Date.now(),bridgeLossReporter:this.bridgeLossReporter}}async evictLruIdleSession(){let e=this.sessions.entries().next();if(e.done)return null;let[t,n]=e.value,r=Date.now()-n.lastUsedAt;return r<this.minEvictableIdleMs?null:(this.sessions.delete(t),await this.cleanupSession(t,n,{docName:n.docName,agentId:n.agentId,evicted:!0}),this.evictions++,Coe(),Nw().add(1),mw.info({docName:n.docName,agentId:n.agentId,idleMs:r},`[agent-session] Evicted LRU idle session under capacity pressure`),t)}hasSession(e,t=`claude-1`){return this.sessions.has(this.sessionKey(e,t))}async cleanupSession(e,t,n){mw.debug({docName:t.docName,agentId:t.agentId,...n},`[agent-session] closing session`);try{try{t.um.destroy()}catch(e){mw.error({err:e,...n},`[agent-session] um.destroy() failed`)}try{await t.dc.disconnect()}catch(e){mw.error({err:e,...n},`[agent-session] dc.disconnect() failed`)}}finally{this.sessions.delete(e)}}async closeSession(e,t=`claude-1`){let n=this.sessionKey(e,t),r=this.sessions.get(n);r&&(await this.cleanupSession(n,r,{docName:e,agentId:t}),mw.info({docName:e,agentId:t},`[agent-session] Closed session for: ${e} / ${t}`))}async closeAllForAgent(e){let t=`\0${e}`,n=[...this.pendingSessions.keys()].filter(e=>e.endsWith(t));n.length>0&&await Promise.allSettled(n.map(e=>this.pendingSessions.get(e)));let r=[...this.sessions.keys()].filter(e=>e.endsWith(t));mw.debug({agentId:e,pendingSettled:n.length,closing:r.length},`[agent-session] closing all sessions for agent`);for(let t of r){let n=this.sessions.get(t);n&&await this.cleanupSession(t,n,{agentId:e,key:t})}}async closeAllForDoc(e){let t=`${e}\0`,n=[...this.sessions.keys()].filter(e=>e.startsWith(t));mw.debug({docName:e,closing:n.length},`[agent-session] closing all sessions for doc`);for(let t of n){let n=this.sessions.get(t);n&&await this.cleanupSession(t,n,{docName:e,key:t})}}async closeAll(e){if(e){await this.closeAllForDoc(e);return}let t=[...this.sessions.keys()];mw.debug({closing:t.length},`[agent-session] closing all sessions`);for(let e of t){let t=this.sessions.get(e);t&&await this.cleanupSession(e,t,{key:e})}}};const Fw=`x-ok-connection-id`,Iw=`x-ok-hosted-agent`;function Lw(e,t){let n=Array.from(e??``).map(e=>{let t=e.charCodeAt(0);return t<=31||t===127?` `:e}).join(``).replace(/\s+/g,` `).trim();return n?n.slice(0,128):t}function Rw(e){return e===null?!1:e.startsWith(`text/`)?!0:e===`application/json`||e===`application/xml`||e===`application/x-yaml`||e===`application/yaml`||e===`application/javascript`||e===`application/typescript`||e===`application/toml`||e===`application/x-sh`||e===`application/sql`}function zw(e){let t=e.lastIndexOf(`.`);return t<0?null:{md:`text/markdown`,mdx:`text/markdown`,txt:`text/plain`,log:`text/plain`,csv:`text/csv`,tsv:`text/tab-separated-values`,html:`text/html`,htm:`text/html`,xml:`application/xml`,json:`application/json`,yaml:`application/yaml`,yml:`application/yaml`,toml:`application/toml`,js:`application/javascript`,mjs:`application/javascript`,cjs:`application/javascript`,ts:`application/typescript`,tsx:`application/typescript`,py:`text/x-python`,rs:`text/x-rust`,go:`text/x-go`,java:`text/x-java`,rb:`text/x-ruby`,php:`text/x-php`,sh:`application/x-sh`,css:`text/css`,scss:`text/x-scss`,sql:`application/sql`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,pdf:`application/pdf`,zip:`application/zip`}[e.slice(t+1).toLowerCase()]??null}function Bw(e){return Nu(e).href}async function Vw(e,t,n,r={}){let i=r.readFile??ld,a=r.stat??fd;if(e.kind===`image`)return t?.image===!0?{block:{type:`image`,data:e.data,mimeType:e.mimeType}}:{dropped:!0,reason:`agent does not accept images (${e.name})`};if(e.kind===`blob`){if(t?.embeddedContext!==!0){let t=e.textPayload?e.data:`[binary attachment ${e.name} (${e.mimeType||`application/octet-stream`}) — this agent doesn't accept embedded resources]`;return{block:{type:`text`,text:`\n\n--- Attachment: ${e.name} ---\n${t}\n--- End attachment ---`}}}let n=`attachment:///${encodeURIComponent(e.name||`attachment`)}`;return e.textPayload?{block:{type:`resource`,resource:{uri:n,text:e.data,...e.mimeType===``?{}:{mimeType:e.mimeType}}}}:{block:{type:`resource`,resource:{uri:n,blob:e.data,...e.mimeType===``?{}:{mimeType:e.mimeType}}}}}if(e.kind===`folder`){let t;try{({abs:t}=await n(e.path))}catch(t){return{dropped:!0,reason:Uw(e.path,t)}}return{block:{type:`resource_link`,uri:Bw(t),name:e.name||Cu(e.path)||e.path,mimeType:`inode/directory`}}}let o;try{({abs:o}=await n(e.path))}catch(t){return{dropped:!0,reason:Uw(e.path,t)}}let s=null;try{s=(await a(o)).size}catch(e){return{dropped:!0,reason:`file unavailable: ${Ww(e)}`}}let c=zw(e.path),l=e.name||Cu(e.path)||e.path,u=Bw(o);if(!(t?.embeddedContext===!0&&s<=524288&&Rw(c)))return{block:{type:`resource_link`,uri:u,name:l,...c===null?{}:{mimeType:c},...s===null?{}:{size:s}}};let d;try{d=await i(o,`utf8`)}catch(e){return{dropped:!0,reason:`file read failed: ${Ww(e)}`}}return{block:{type:`resource`,resource:{uri:u,text:d,...c===null?{}:{mimeType:c}}}}}async function Hw(e,t,n,r,i={}){let a=[];for(let e of t??[])(e.kind===`file`||e.kind===`folder`)&&a.push(`[${e.name||e.path}](${e.path})`);let o=[{type:`text`,text:a.length>0?e===``?a.join(` `):`${a.join(` `)}\n\n${e}`:e}],s=[];for(let e of t??[]){let t=await Vw(e,n,r,i);`block`in t?o.push(t.block):s.push({part:e,reason:t.reason})}return{blocks:o,dropped:s}}function Uw(e,t){return`attachment path refused: ${e} (${Ww(t)})`}function Ww(e){return e instanceof Error?e.message:String(e)}const Gw=16e3;function Kw(e){return e.length<=Gw?e:`${e.slice(0,Gw)}\n… [truncated ${e.length-Gw} chars]`}function qw(e){let t=e;if(t.sessionUpdate!==`tool_call`&&t.sessionUpdate!==`tool_call_update`||!Array.isArray(t.content))return e;let n=!1,r=t.content.map(e=>{let t=e;if(t.type===`diff`){let r=typeof t.oldText==`string`?Kw(t.oldText):t.oldText,i=typeof t.newText==`string`?Kw(t.newText):t.newText;return r!==t.oldText||i!==t.newText?(n=!0,{...t,oldText:r,newText:i}):e}if(t.type===`content`){let r=t.content;if(r?.type===`text`&&typeof r.text==`string`){let e=Kw(r.text);if(e!==r.text)return n=!0,{...t,content:{...r,text:e}}}return e}return e});return n?{...e,content:r}:e}const Jw=new Set([`agent_message_chunk`,`agent_thought_chunk`,`user_message_chunk`]),Yw=16e3;function Xw(e){if(typeof e!=`object`||!e)return null;let t=e;return t.type===`text`&&typeof t.text==`string`?t.text:null}function Zw(e){return typeof e.messageId==`string`?e.messageId:`default`}function Qw(e,t){if(e.kind===`terminal_output`&&t.kind===`terminal_output`)return e.terminalId!==t.terminalId||e.chunk.length>=Yw?!1:(e.chunk+=t.chunk,!0);if(e.kind!==`session_update`||t.kind!==`session_update`)return!1;let n=e.update,r=t.update;if(n.sessionUpdate!==r.sessionUpdate||!Jw.has(r.sessionUpdate)||Zw(n)!==Zw(r))return!1;let i=Xw(n.content),a=Xw(r.content);return i===null||a===null||i.length>=Yw?!1:(n.content={type:`text`,text:i+a},!0)}function $w(e,t){let n=Du(e)+z;return`${Du(t)}${z}`.startsWith(n)}function eT(e){let t=e.replace(/[^a-zA-Z0-9._-]/g,`_`);return t===``||t===`.`||t===`..`?`_`:t}function tT(e,t,n,r=12e4){let[i,a]=n?process.platform===`darwin`?[`ditto`,[`-x`,`-k`,e,t]]:process.platform===`win32`?[`tar`,[`-xf`,e,`-C`,t]]:[`unzip`,[`-q`,e,`-d`,t]]:[`tar`,[`-xf`,e,`-C`,t]];return new Promise((t,n)=>{let o=bu(i,a,{stdio:[`ignore`,`ignore`,`pipe`],shell:!1,windowsHide:!0}),s=setTimeout(()=>{o.kill(`SIGKILL`),n(Error(`${i} timed out after ${r}ms extracting ${e}`))},r);s.unref?.();let c=``;o.stderr?.on(`data`,e=>{c=(c+e.toString()).slice(-2e3)}),o.on(`error`,e=>{clearTimeout(s),n(e)}),o.on(`exit`,e=>{clearTimeout(s),e===0?t():n(Error(`${i} exited ${e}: ${c}`))})})}async function nT(e,t,n={}){let r=await(n.fetchImpl??fetch)(e,{signal:n.signal});if(!r.ok||r.body===null)throw Error(`download failed: HTTP ${r.status} for ${e}`);let i=r.headers.get(`content-length`),a=i!==null&&i!==``?Number(i):null,o=hd(`sha256`),s=0,c=Bu(t),l=pd.fromWeb(r.body);return l.on(`data`,e=>{o.update(e),s+=e.length,n.onProgress?.({receivedBytes:s,totalBytes:Number.isFinite(a)?a:null})}),await new Promise((e,t)=>{l.pipe(c).on(`finish`,()=>e()).on(`error`,t),l.on(`error`,t)}),o.digest(`hex`)}async function rT(e,t={}){let n=await(t.fetchImpl??fetch)(e,{signal:t.signal});if(!n.ok)throw Error(`fetch failed: HTTP ${n.status} for ${e}`);return n.text()}function iT(e,t){for(let n of e.split(`
|
|
21
|
-
`)){let e=n.trim();if(e===``)continue;let r=/^([a-fA-F0-9]{64})\s+\*?(.+)$/.exec(e);if(r===null)continue;let[,i,a]=r;if(a.trim().split(/[\\/]/).pop()===t)return i.toLowerCase()}return null}const aT=`__OK_PATH_BEGIN__`,oT=`__OK_PATH_END__`,sT=`printf %s ${aT}; printenv PATH; printf %s ${oT}`;function cT(){return[`-l`,`-i`,`-c`,sT]}function lT(){return[`-i`,`-c`,sT]}const uT=new Set([`bash`,`sh`]);function dT(e){let t=e.lastIndexOf(aT);if(t===-1)return null;let n=t+17,r=e.indexOf(oT,n);if(r===-1)return null;let i=e.slice(n,r).trim();return i===``?null:i}function fT(e,t,n){let r=(e??``).split(n).filter(e=>e!==``),i=new Set(r);for(let e of t.split(n))e===``||i.has(e)||(i.add(e),r.push(e));return r.join(n)}const pT=new Set([`false`,`nologin`,`sync`]),mT=(e,t,n)=>new Promise(r=>{let i;try{i=bu(e,[...t],{stdio:[`ignore`,`pipe`,`ignore`],windowsHide:!0})}catch{r(null);return}let a=``,o=!1,s=e=>{o||(o=!0,clearTimeout(c),r(e))},c=setTimeout(()=>{i.kill(`SIGKILL`),s(null)},n);c.unref?.(),i.stdout?.setEncoding(`utf8`),i.stdout?.on(`data`,e=>{a.length>=524288||(a+=e)}),i.on(`error`,()=>s(null)),i.on(`close`,()=>s(a))});async function hT(e,t,n,r,i){let a=Date.now(),o=await i(t,n,r).catch(()=>null),s=Date.now()-a;if(o===null)return e.log.debug({shell:t,args:n,elapsed:s},`[login-shell-path] probe produced no output`),null;let c=dT(o);return c===null?(e.log.debug({shell:t,args:n,elapsed:s},`[login-shell-path] probe output carried no PATH`),null):c}function gT(e){let t=e.platform??process.platform,n=e.shell??process.env.SHELL,r=e.timeoutMs??5e3,i=e.runProbe??mT,a=e.now??Date.now,o=null,s=0,c=async()=>{if(t===`win32`)return null;if(n===void 0||n===``)return e.log.debug({},`[login-shell-path] no $SHELL; skipping probe`),null;let a=n.slice(n.lastIndexOf(`/`)+1);if(pT.has(a))return e.log.debug({shell:n},`[login-shell-path] login-refusing shell; skipping probe`),null;let o=await hT(e,n,cT(),r,i);if(!uT.has(a))return o;let s=await hT(e,n,lT(),r,i);return o===null?s:s===null?o:fT(o,s,wu)};return()=>{if(o!==null)return o;if(a()<s)return Promise.resolve(null);let e=c().catch(()=>null);return o=e,e.then(e=>{e===null&&(o=null,s=a()+6e4)}),e}}let _T=null;function vT(e){return _T??=gT({log:e}),_T}function yT(){_T=null}var bT=class extends Error{code;constructor(e,t){super(t),this.name=`AgentLaunchError`,this.code=e}};function xT(){return I(nd(),`.ok`,`acp-agents`)}function ST(e){try{return Qu(e).isDirectory()}catch{return!1}}function CT(e){let t={};for(let[e,n]of Object.entries(process.env))n!==void 0&&(t[e]=n);return t[jT(t)]=Qt(VT(t),{platform:process.platform,homeDir:nd(),isDir:ST,delimiter:wu}),{...t,...e}}function wT(e){return e!==void 0&&Object.keys(e).some(e=>e.toLowerCase()===`path`)}function TT(e){return{...e,[oa]:`1`}}async function ET(e,t,n,r=xT()){let i=e.distribution;if(i.npx!==void 0)return{cmd:`npx`,args:[`-y`,i.npx.package,...i.npx.args??[]],env:CT(i.npx.env),kind:`npx`,pathFromOverlay:wT(i.npx.env)};if(i.uvx!==void 0)return{cmd:`uvx`,args:[i.uvx.package,...i.uvx.args??[]],env:CT(i.uvx.env),kind:`uvx`,pathFromOverlay:wT(i.uvx.env)};if(i.binary!==void 0){if(t===null||i.binary[t]===void 0)throw new bT(`unsupported-platform`,`${e.name} has no build for this platform`);let a=i.binary[t],o=await NT(e.id,e.version,a,r,n),s=R(o,a.cmd.replace(/\\/g,`/`));if(!$w(o,s))throw new bT(`install-failed`,`${e.name} manifest cmd escapes its archive`);return{cmd:s,args:[...a.args??[]],env:CT(a.env),kind:`binary`,pathFromOverlay:wT(a.env)}}throw new bT(`no-distribution`,`${e.name} has no supported distribution`)}function DT(e){return{cmd:e.command,args:[...e.args??[]],env:CT(e.env),kind:`custom`,pathFromOverlay:wT(e.env)}}function OT(e,t){let n={...e.env};n[jT(n)]=MT(t.binDir,VT(n));let r=e.pathFromOverlay;return t.kind===`node`?(n.npm_config_cache=t.cacheDir,{cmd:t.npxBin,args:[...e.args],env:n,kind:`npx`,pathFromOverlay:r}):(n.UV_CACHE_DIR=t.cacheDir,{cmd:t.uvxBin,args:[...e.args],env:n,kind:`uvx`,pathFromOverlay:r})}function kT(e,t){return{...e,env:AT(e.env,t)}}function AT(e,t){let n={...e};return n[jT(n)]=fT(VT(n),t,wu),n}function jT(e){for(let t of Object.keys(e))if(t.toLowerCase()===`path`)return t;return`PATH`}function MT(e,t){return t!==void 0&&t!==``?`${e}${wu}${t}`:e}async function NT(e,t,n,r,i){let a=I(r,eT(e),eT(t));try{if((await fd(a)).isDirectory())return a}catch{}i.info({id:e,version:t,archive:n.archive},`[acp-launch] downloading agent binary`);let o=I(ad(),`ok-acp-install-${process.pid}-${Date.now()}`);await Is(o,{recursive:!0});let s=/\.zip$/i.test(new URL(n.archive).pathname),c=I(o,s?`archive.zip`:`archive.tar.gz`);try{let l=await nT(n.archive,c,{signal:AbortSignal.timeout(12e4)});if(n.sha256!==void 0){if(l!==n.sha256.toLowerCase())throw Error(`archive checksum mismatch: expected ${n.sha256}, got ${l}`)}else i.warn({id:e,version:t,archive:n.archive},`[acp-launch] manifest carries no sha256 for the binary archive — installing unverified`);let u=I(o,`extracted`);await Is(u,{recursive:!0}),await tT(c,u,s);let d=R(u,n.cmd.replace(/\\/g,`/`));if(!$w(u,d))throw Error(`manifest cmd escapes the extracted archive`);return await mte(d,493).catch(()=>{}),await Is(I(r,eT(e)),{recursive:!0}),await Rs(a,{recursive:!0,force:!0}),await Qs(u,a),i.info({id:e,version:t,versionDir:a},`[acp-launch] agent binary installed`),a}catch(n){throw new bT(`install-failed`,`installing ${e}@${t} failed: ${n instanceof Error?n.message:String(n)}`)}finally{await Rs(o,{recursive:!0,force:!0}).catch(()=>{})}}async function PT(e){if(!await UT(e.cmd,VT(e.env)))throw new bT(`command-not-found`,FT(e))}function FT(e){switch(e.kind){case`npx`:return`\`${e.cmd}\` was not found. This agent runs through npx, which ships with Node.js — install Node.js (https://nodejs.org) and make sure it is on your PATH.`;case`uvx`:return`\`${e.cmd}\` was not found. This agent runs through uvx, which ships with uv — install uv (https://docs.astral.sh/uv/getting-started/installation/) and make sure it is on your PATH.`;case`binary`:return`the agent binary at ${e.cmd} is missing or not executable.`;case`custom`:return`\`${e.cmd}\` was not found on your PATH. A desktop app launched from the Dock or Finder doesn't inherit your shell's PATH, so an agent installed only in a shell-configured location won't be visible here — use an absolute path to the command, or install it to a standard location.`}}function IT(e,t){let n=e.kind===`uvx`?`That usually means its uv is broken. Reinstall or repair uv and try again.`:"That usually means its Node.js is broken — on macOS a common cause is a Homebrew `node` whose `icu4c` library was upgraded out from under it. Reinstall or repair Node.js and try again.";return`\`${e.cmd}\` is installed but failed to run (${t}). ${n}`}function LT(e,t){return`OK downloaded a fresh copy of ${e.kind===`uvx`?`uv`:`Node.js`} and it still can't run (${t}). Something on this machine is stopping it — antivirus, a security policy, or an unsupported CPU are the usual causes.`}function RT(e,t){return`OK's own copy of ${e.kind===`uvx`?`uv`:`Node.js`} is damaged (${t}) and couldn't be replaced — another agent may still be using it. Close other agent threads and try again.`}function zT(e){return`OK's own copy of ${e.kind===`uvx`?`uv`:`Node.js`} is damaged and can't run this agent. Start the agent again to let OK download a fresh copy.`}function BT(e,t=5e3,n){let r=process.platform===`win32`,i=r?GT(e.cmd,VT(e.env)):e.cmd,a=r&&/\.(cmd|bat)$/i.test(i),{cmd:o,args:s}=a?qT(i,[`--version`]):{cmd:i,args:[`--version`]};return new Promise(i=>{let c;try{c=bu(o,s,{env:e.env,stdio:[`ignore`,`ignore`,`pipe`],shell:!1,detached:!r,windowsHide:!0,windowsVerbatimArguments:a})}catch(e){i(e instanceof Error?e.message:String(e));return}let l=``;c.stderr?.setEncoding(`utf8`),c.stderr?.on(`data`,e=>{l.length<2e3&&(l+=e)});let u=!1,d=e=>{u||(u=!0,clearTimeout(f),i(e))},f=setTimeout(()=>{QT(c,{graceMs:0,forceWaitMs:0}).catch(()=>{}),n?.debug({cmd:e.cmd,kind:e.kind,timeoutMs:t},`[acp-launch] interpreter health probe timed out — proceeding with the launch`),d(null)},t);f.unref?.(),c.on(`error`,e=>d(e.message)),c.on(`exit`,(e,t)=>{if(t===null&&(e===null||e===0)){d(null);return}let n=l.split(`
|
|
21
|
+
`)){let e=n.trim();if(e===``)continue;let r=/^([a-fA-F0-9]{64})\s+\*?(.+)$/.exec(e);if(r===null)continue;let[,i,a]=r;if(a.trim().split(/[\\/]/).pop()===t)return i.toLowerCase()}return null}const aT=`__OK_PATH_BEGIN__`,oT=`__OK_PATH_END__`,sT=`printf %s ${aT}; printenv PATH; printf %s ${oT}`;function cT(){return[`-l`,`-i`,`-c`,sT]}function lT(){return[`-i`,`-c`,sT]}const uT=new Set([`bash`,`sh`]);function dT(e){let t=e.lastIndexOf(aT);if(t===-1)return null;let n=t+17,r=e.indexOf(oT,n);if(r===-1)return null;let i=e.slice(n,r).trim();return i===``?null:i}function fT(e,t,n){let r=(e??``).split(n).filter(e=>e!==``),i=new Set(r);for(let e of t.split(n))e===``||i.has(e)||(i.add(e),r.push(e));return r.join(n)}const pT=new Set([`false`,`nologin`,`sync`]),mT=(e,t,n)=>new Promise(r=>{let i;try{i=bu(e,[...t],{stdio:[`ignore`,`pipe`,`ignore`],windowsHide:!0})}catch{r(null);return}let a=``,o=!1,s=e=>{o||(o=!0,clearTimeout(c),r(e))},c=setTimeout(()=>{i.kill(`SIGKILL`),s(null)},n);c.unref?.(),i.stdout?.setEncoding(`utf8`),i.stdout?.on(`data`,e=>{a.length>=524288||(a+=e)}),i.on(`error`,()=>s(null)),i.on(`close`,()=>s(a))});async function hT(e,t,n,r,i){let a=Date.now(),o=await i(t,n,r).catch(()=>null),s=Date.now()-a;if(o===null)return e.log.debug({shell:t,args:n,elapsed:s},`[login-shell-path] probe produced no output`),null;let c=dT(o);return c===null?(e.log.debug({shell:t,args:n,elapsed:s},`[login-shell-path] probe output carried no PATH`),null):c}function gT(e){let t=e.platform??process.platform,n=e.shell??process.env.SHELL,r=e.timeoutMs??5e3,i=e.runProbe??mT,a=e.now??Date.now,o=null,s=0,c=async()=>{if(t===`win32`)return null;if(n===void 0||n===``)return e.log.debug({},`[login-shell-path] no $SHELL; skipping probe`),null;let a=n.slice(n.lastIndexOf(`/`)+1);if(pT.has(a))return e.log.debug({shell:n},`[login-shell-path] login-refusing shell; skipping probe`),null;let o=await hT(e,n,cT(),r,i);if(!uT.has(a))return o;let s=await hT(e,n,lT(),r,i);return o===null?s:s===null?o:fT(o,s,wu)};return()=>{if(o!==null)return o;if(a()<s)return Promise.resolve(null);let e=c().catch(()=>null);return o=e,e.then(e=>{e===null&&(o=null,s=a()+6e4)}),e}}let _T=null;function vT(e){return _T??=gT({log:e}),_T}function yT(){_T=null}var bT=class extends Error{code;constructor(e,t){super(t),this.name=`AgentLaunchError`,this.code=e}};function xT(){return I(nd(),`.ok`,`acp-agents`)}function ST(e){try{return Qu(e).isDirectory()}catch{return!1}}function CT(e){let t={};for(let[e,n]of Object.entries(process.env))n!==void 0&&e.toLowerCase()!==`npm_config_overrides`&&(t[e]=n);return t[jT(t)]=Qt(VT(t),{platform:process.platform,homeDir:nd(),isDir:ST,delimiter:wu}),{...t,...e}}function wT(e){return e!==void 0&&Object.keys(e).some(e=>e.toLowerCase()===`path`)}function TT(e){return{...e,[oa]:`1`}}async function ET(e,t,n,r=xT()){let i=e.distribution;if(i.npx!==void 0)return{cmd:`npx`,args:[`-y`,i.npx.package,...i.npx.args??[]],env:CT(i.npx.env),kind:`npx`,pathFromOverlay:wT(i.npx.env)};if(i.uvx!==void 0)return{cmd:`uvx`,args:[i.uvx.package,...i.uvx.args??[]],env:CT(i.uvx.env),kind:`uvx`,pathFromOverlay:wT(i.uvx.env)};if(i.binary!==void 0){if(t===null||i.binary[t]===void 0)throw new bT(`unsupported-platform`,`${e.name} has no build for this platform`);let a=i.binary[t],o=await NT(e.id,e.version,a,r,n),s=R(o,a.cmd.replace(/\\/g,`/`));if(!$w(o,s))throw new bT(`install-failed`,`${e.name} manifest cmd escapes its archive`);return{cmd:s,args:[...a.args??[]],env:CT(a.env),kind:`binary`,pathFromOverlay:wT(a.env)}}throw new bT(`no-distribution`,`${e.name} has no supported distribution`)}function DT(e){return{cmd:e.command,args:[...e.args??[]],env:CT(e.env),kind:`custom`,pathFromOverlay:wT(e.env)}}function OT(e,t){let n={...e.env};n[jT(n)]=MT(t.binDir,VT(n));let r=e.pathFromOverlay;return t.kind===`node`?(n.npm_config_cache=t.cacheDir,{cmd:t.npxBin,args:[...e.args],env:n,kind:`npx`,pathFromOverlay:r}):(n.UV_CACHE_DIR=t.cacheDir,{cmd:t.uvxBin,args:[...e.args],env:n,kind:`uvx`,pathFromOverlay:r})}function kT(e,t){return{...e,env:AT(e.env,t)}}function AT(e,t){let n={...e};return n[jT(n)]=fT(VT(n),t,wu),n}function jT(e){for(let t of Object.keys(e))if(t.toLowerCase()===`path`)return t;return`PATH`}function MT(e,t){return t!==void 0&&t!==``?`${e}${wu}${t}`:e}async function NT(e,t,n,r,i){let a=I(r,eT(e),eT(t));try{if((await fd(a)).isDirectory())return a}catch{}i.info({id:e,version:t,archive:n.archive},`[acp-launch] downloading agent binary`);let o=I(ad(),`ok-acp-install-${process.pid}-${Date.now()}`);await Is(o,{recursive:!0});let s=/\.zip$/i.test(new URL(n.archive).pathname),c=I(o,s?`archive.zip`:`archive.tar.gz`);try{let l=await nT(n.archive,c,{signal:AbortSignal.timeout(12e4)});if(n.sha256!==void 0){if(l!==n.sha256.toLowerCase())throw Error(`archive checksum mismatch: expected ${n.sha256}, got ${l}`)}else i.warn({id:e,version:t,archive:n.archive},`[acp-launch] manifest carries no sha256 for the binary archive — installing unverified`);let u=I(o,`extracted`);await Is(u,{recursive:!0}),await tT(c,u,s);let d=R(u,n.cmd.replace(/\\/g,`/`));if(!$w(u,d))throw Error(`manifest cmd escapes the extracted archive`);return await mte(d,493).catch(()=>{}),await Is(I(r,eT(e)),{recursive:!0}),await Rs(a,{recursive:!0,force:!0}),await Qs(u,a),i.info({id:e,version:t,versionDir:a},`[acp-launch] agent binary installed`),a}catch(n){throw new bT(`install-failed`,`installing ${e}@${t} failed: ${n instanceof Error?n.message:String(n)}`)}finally{await Rs(o,{recursive:!0,force:!0}).catch(()=>{})}}async function PT(e){if(!await UT(e.cmd,VT(e.env)))throw new bT(`command-not-found`,FT(e))}function FT(e){switch(e.kind){case`npx`:return`\`${e.cmd}\` was not found. This agent runs through npx, which ships with Node.js — install Node.js (https://nodejs.org) and make sure it is on your PATH.`;case`uvx`:return`\`${e.cmd}\` was not found. This agent runs through uvx, which ships with uv — install uv (https://docs.astral.sh/uv/getting-started/installation/) and make sure it is on your PATH.`;case`binary`:return`the agent binary at ${e.cmd} is missing or not executable.`;case`custom`:return`\`${e.cmd}\` was not found on your PATH. A desktop app launched from the Dock or Finder doesn't inherit your shell's PATH, so an agent installed only in a shell-configured location won't be visible here — use an absolute path to the command, or install it to a standard location.`}}function IT(e,t){let n=e.kind===`uvx`?`That usually means its uv is broken. Reinstall or repair uv and try again.`:"That usually means its Node.js is broken — on macOS a common cause is a Homebrew `node` whose `icu4c` library was upgraded out from under it. Reinstall or repair Node.js and try again.";return`\`${e.cmd}\` is installed but failed to run (${t}). ${n}`}function LT(e,t){return`OK downloaded a fresh copy of ${e.kind===`uvx`?`uv`:`Node.js`} and it still can't run (${t}). Something on this machine is stopping it — antivirus, a security policy, or an unsupported CPU are the usual causes.`}function RT(e,t){return`OK's own copy of ${e.kind===`uvx`?`uv`:`Node.js`} is damaged (${t}) and couldn't be replaced — another agent may still be using it. Close other agent threads and try again.`}function zT(e){return`OK's own copy of ${e.kind===`uvx`?`uv`:`Node.js`} is damaged and can't run this agent. Start the agent again to let OK download a fresh copy.`}function BT(e,t=5e3,n){let r=process.platform===`win32`,i=r?GT(e.cmd,VT(e.env)):e.cmd,a=r&&/\.(cmd|bat)$/i.test(i),{cmd:o,args:s}=a?qT(i,[`--version`]):{cmd:i,args:[`--version`]};return new Promise(i=>{let c;try{c=bu(o,s,{env:e.env,stdio:[`ignore`,`ignore`,`pipe`],shell:!1,detached:!r,windowsHide:!0,windowsVerbatimArguments:a})}catch(e){i(e instanceof Error?e.message:String(e));return}let l=``;c.stderr?.setEncoding(`utf8`),c.stderr?.on(`data`,e=>{l.length<2e3&&(l+=e)});let u=!1,d=e=>{u||(u=!0,clearTimeout(f),i(e))},f=setTimeout(()=>{QT(c,{graceMs:0,forceWaitMs:0}).catch(()=>{}),n?.debug({cmd:e.cmd,kind:e.kind,timeoutMs:t},`[acp-launch] interpreter health probe timed out — proceeding with the launch`),d(null)},t);f.unref?.(),c.on(`error`,e=>d(e.message)),c.on(`exit`,(e,t)=>{if(t===null&&(e===null||e===0)){d(null);return}let n=l.split(`
|
|
22
22
|
`).map(e=>e.trim()).find(e=>e!==``),r=t??`exit code ${e}`;d(n===void 0?r:`${r}: ${n.slice(0,300)}`)})})}function VT(e){for(let[t,n]of Object.entries(e))if(t.toLowerCase()===`path`)return n;return process.env.PATH}function HT(e){let t=process.platform===`win32`;return Eu(e)||e.includes(`/`)||t&&e.includes(`\\`)}async function UT(e,t){let n=process.platform===`win32`;if(HT(e))return WT(e);let r=n?[``,...(process.env.PATHEXT??`.COM;.EXE;.BAT;.CMD`).split(`;`).map(e=>e.trim()).filter(e=>e!==``)]:[``];for(let n of(t??``).split(wu))if(n!==``){for(let t of r)if(await WT(I(n,e+t)))return!0}return!1}async function WT(e){try{return(await fd(e)).isFile()?(process.platform===`win32`||await od(e,Ru.X_OK),!0):!1}catch{return!1}}function GT(e,t){if(Eu(e)||e.includes(`\\`)||e.includes(`/`))return e;let n=(process.env.PATHEXT??`.COM;.EXE;.BAT;.CMD`).split(`;`).map(e=>e.trim()).filter(e=>e!==``);for(let r of(t??``).split(wu))if(r!==``)for(let t of n){let n=I(r,e+t);try{if(Qu(n).isFile())return n}catch{}}return e}function KT(e){return e===``?`""`:/[\s"&()<>^|%]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function qT(e,t){let n=[`"${e}"`,...t.map(KT)].join(` `);return{cmd:process.env.ComSpec??`cmd.exe`,args:[`/d`,`/s`,`/c`,`"${n}"`]}}function JT(e,t){if(!Eu(t))throw Error(`spawnAcpAgent requires an absolute cwd, got: ${t}`);let n=process.platform===`win32`,r=n?GT(e.cmd,VT(e.env)):e.cmd,i=n&&/\.(cmd|bat)$/i.test(r),{cmd:a,args:o}=i?qT(r,e.args):{cmd:r,args:e.args};return bu(a,o,{cwd:t,env:TT(e.env),stdio:[`pipe`,`pipe`,`pipe`],shell:!1,detached:!n,windowsHide:!0,windowsVerbatimArguments:i})}function YT(e){return e.exitCode!==null||e.signalCode!==null}function XT(e,t){return YT(e)?Promise.resolve(!0):new Promise(n=>{let r=()=>{clearTimeout(i),n(!0)},i=setTimeout(()=>{e.removeListener(`exit`,r),n(!1)},t);i.unref?.(),e.once(`exit`,r)})}function ZT(e,t){let n=e.pid;if(!(n===void 0||YT(e))){try{process.kill(-n,t);return}catch{}try{e.kill(t)}catch{}}}async function QT(e,t){let n=t.forceWaitMs??2e3;if(YT(e))return!0;if(process.platform===`win32`){if(e.pid!==void 0)try{bu(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{stdio:`ignore`,shell:!1,windowsHide:!0}).unref()}catch{try{e.kill(`SIGKILL`)}catch{}}return XT(e,Math.max(t.graceMs,n))}return ZT(e,`SIGTERM`),await XT(e,t.graceMs)?!0:(ZT(e,`SIGKILL`),XT(e,n))}const $T=`v24.18.0`,eE=`0.11.28`,tE=`https://nodejs.org/dist`,nE=`https://github.com/astral-sh/uv/releases/download`,rE={node:45,uv:20};function iE(e){return e===`npx`?`node`:`uv`}function aE(e){return e===`node`?{kind:`node`,displayName:`Node.js`,provides:`npx`,version:$T,approxSizeMB:rE.node,sourceHost:`nodejs.org`}:{kind:`uv`,displayName:`uv`,provides:`uvx`,version:eE,approxSizeMB:rE.uv,sourceHost:`github.com/astral-sh`}}function oE(){return I(nd(),`.ok`)}function sE(){return I(oE(),`runtimes`)}function cE(e){return e===`node`?$T:eE}function lE(e){let t=process.platform===`win32`;return e===`node`?t?[`npx.cmd`,`npx.exe`]:[`npx`]:t?[`uvx.exe`]:[`uvx`]}function uE(){let e=id(),t=td(),n=e===`darwin`?`darwin`:e===`linux`?`linux`:e===`win32`?`win`:null,r=t===`arm64`?`arm64`:t===`x64`?`x64`:null;if(n===null||r===null)return null;let i=e===`win32`,a=`node-${$T}-${n}-${r}.${i?`zip`:`tar.gz`}`;return{archiveUrl:`${tE}/${$T}/${a}`,checksumUrl:`${tE}/${$T}/SHASUMS256.txt`,archiveName:a,isZip:i}}function dE(){let e={"darwin-arm64":`aarch64-apple-darwin`,"darwin-x64":`x86_64-apple-darwin`,"linux-arm64":`aarch64-unknown-linux-gnu`,"linux-x64":`x86_64-unknown-linux-gnu`,"win32-x64":`x86_64-pc-windows-msvc`,"win32-arm64":`aarch64-pc-windows-msvc`}[`${id()}-${td()}`];if(e===void 0)return null;let t=id()===`win32`,n=`uv-${e}.${t?`zip`:`tar.gz`}`;return{archiveUrl:`${nE}/${eE}/${n}`,checksumUrl:`${nE}/${eE}/${n}.sha256`,archiveName:n,isZip:t}}function fE(e){return e===`node`?uE():dE()}function pE(e){return fE(e)!==null}async function mE(e){try{let t=await fd(e);return!t.isFile()&&!t.isSymbolicLink()?!1:(process.platform===`win32`||await od(e,sd.X_OK),!0)}catch{return!1}}async function hE(e,t,n){let r;try{r=await ud(e,{withFileTypes:!0})}catch{return null}for(let n of r)if((n.isFile()||n.isSymbolicLink())&&t.includes(n.name))return I(e,n.name);if(n<=0)return null;for(let i of r)if(i.isDirectory()){let r=await hE(I(e,i.name),t,n-1);if(r!==null)return r}return null}function gE(e,t,n){let r=F(t),i=I(n,`cache`,e);return e===`node`?{kind:`node`,binDir:r,npxBin:t,cacheDir:i}:{kind:`uv`,binDir:r,uvxBin:t,cacheDir:i}}async function _E(e,t=sE()){let n=I(t,e,eT(cE(e)));try{if(!(await fd(n)).isDirectory())return null}catch{return null}let r=await hE(n,lE(e),3);return r===null||!await mE(r)?null:gE(e,r,t)}var vE=class extends Error{constructor(e){super(e),this.name=`RuntimeInstallError`}};async function yE(e,t){let n;try{n=await ud(e,{withFileTypes:!0})}catch(e){e.code!==`ENOENT`&&t.warn({err:e},`[managed-runtime] could not read staging dir for cleanup`);return}let r=Date.now()-864e5;for(let i of n){if(!i.isDirectory()||!i.name.startsWith(`.install-`))continue;let n=I(e,i.name);try{if((await fd(n)).mtimeMs>=r)continue;await Rs(n,{recursive:!0,force:!0})}catch(e){if(e.code===`ENOENT`)continue;t.warn({err:e},`[managed-runtime] stale staging cleanup failed`)}}}async function bE(e,t,n=sE()){await yE(I(n,e),t)}async function xE(e,t,n=sE()){let r=I(n,e,eT(cE(e))),i=I(F(r),`.install-damaged-${eT(cE(e))}-${gd()}`);try{await Qs(r,i)}catch(n){return n.code===`ENOENT`?!0:(t.warn({err:n,kind:e,versionDir:r},`[managed-runtime] could not quarantine damaged runtime`),!1)}return t.info({kind:e,versionDir:r},`[managed-runtime] quarantined damaged runtime`),await Rs(i,{recursive:!0,force:!0}).catch(()=>{}),!0}async function SE(e,t,n={}){let r=n.root??sE(),i=I(r,e,eT(cE(e))),a=F(i),o=await _E(e,r);if(o!==null)return await yE(a,t),o;let s=fE(e);if(s===null)throw new vE(`no ${e} build for ${id()}-${td()}`);await Is(a,{recursive:!0}),await yE(a,t);let c=I(a,`.install-${eT(cE(e))}-${process.pid}-${gd()}`);await Is(c,{recursive:!0});let l=I(c,s.archiveName);t.info({kind:e,version:cE(e),url:s.archiveUrl},`[managed-runtime] downloading runtime`);try{let[a,o]=await Promise.all([nT(s.archiveUrl,l,{signal:n.signal,onProgress:n.onProgress,fetchImpl:n.fetchImpl}),rT(s.checksumUrl,{signal:n.signal,fetchImpl:n.fetchImpl})]),u=iT(o,s.archiveName);if(u===null)throw new vE(`no published checksum for ${s.archiveName}`);if(a!==u)throw new vE(`checksum mismatch for ${s.archiveName}: got ${a}, expected ${u}`);let d=I(c,`extracted`);await Is(d,{recursive:!0}),await tT(l,d,s.isZip);let f=await hE(d,lE(e),3);if(f===null||!$w(d,f))throw new vE(`extracted ${e} archive has no usable launcher`);let p=await _E(e,r);if(p!==null)return p;await n.beforeCommit?.();try{return await Os(`${i}.install.lock`,async()=>{let n=await _E(e,r);if(n!==null)return n;await Rs(i,{recursive:!0,force:!0}),await Qs(d,i),t.info({kind:e,version:cE(e),versionDir:i},`[managed-runtime] runtime installed`);let a=await _E(e,r);if(a===null)throw new vE(`installed ${e} runtime not found after extract`);return a},{timeoutMs:n.commitLockTimeoutMs??6e4,onWarn:(n,r)=>{t.warn({...r,kind:e},`[managed-runtime] ${n}`)}})}catch(n){if(n instanceof Hs){let i=await _E(e,r);if(i!==null)return i;t.warn({kind:e,lockPath:n.lockPath,timeoutMs:n.timeoutMs},`[managed-runtime] commit lock timed out with no winner installed`)}throw n}}catch(t){throw t instanceof vE?t:new vE(`installing ${e} ${cE(e)} failed: ${t instanceof Error?t.message:String(t)}`)}finally{await Rs(c,{recursive:!0,force:!0}).catch(()=>{})}}const CE=2e3;function wE(e){let t=0;for(;t<e.length&&(e[t]&192)==128;)t++;return e.subarray(t)}function TE(e,t){let n=Buffer.from(e,`utf8`);return n.length<=t?e:wE(n.subarray(n.length-t)).toString(`utf8`)}function EE(e){if(e.outputBytes<=e.byteLimit)return;let t=wE(Buffer.from(e.output,`utf8`).subarray(e.outputBytes-e.byteLimit));e.output=t.toString(`utf8`),e.outputBytes=t.length,e.truncated=!0}var DE=class{terminals=new Map;emit;defaultCwd;log;loginShellPath;disposed=!1;constructor(e){this.defaultCwd=e.defaultCwd,this.emit=e.emit,this.log=e.log,this.loginShellPath=e.loginShellPath??null}liveCount(){let e=0;for(let t of this.terminals.values())t.exitStatus===null&&e++;return e}create(e){if(this.disposed)throw Error(`thread is closing — no new terminals`);if(this.terminals.size>=64)throw Error(`terminal limit reached (64 per thread) — release finished terminals first`);let t=crypto.randomUUID(),n={};for(let t of e.env??[])n[t.name]=t.value;let r=TT(this.spawnEnv(n)),i=e.cwd==null?this.defaultCwd:Eu(e.cwd)?e.cwd:R(this.defaultCwd,e.cwd),a=process.platform===`win32`,o=a?GT(e.command,VT(r)):e.command,s=a&&/\.(cmd|bat)$/i.test(o),{cmd:c,args:l}=s?qT(o,e.args??[]):{cmd:o,args:e.args??[]},u=bu(c,l,{cwd:i,env:r,stdio:[`ignore`,`pipe`,`pipe`],shell:!1,detached:!a,windowsHide:!0,windowsVerbatimArguments:s}),d=e.outputByteLimit,f={child:u,output:``,outputBytes:0,byteLimit:typeof d==`number`&&d>0?Math.floor(d):1048576,truncated:!1,exitStatus:null,exitWaiters:[],transcriptBytes:0,transcriptPaused:!1,pausedTail:``};this.terminals.set(t,f),this.safeEmit({kind:`terminal_created`,terminalId:t,command:e.command,args:e.args??[],ts:Date.now()});let p=e=>this.ingestChunk(t,f,e);u.stdout?.setEncoding(`utf8`),u.stdout?.on(`data`,p),u.stderr?.setEncoding(`utf8`),u.stderr?.on(`data`,p);let m=!1;return u.on(`spawn`,()=>{m=!0}),u.on(`error`,e=>{if(m){this.log.warn({err:e,terminalId:t},`[acp-terminals] child error after spawn`);return}p(`${e.message}\n`),this.settleExit(t,f,{exitCode:127,signal:null})}),u.on(`close`,(e,n)=>{this.settleExit(t,f,{exitCode:e,signal:n})}),{terminalId:t}}output(e){let t=this.mustGet(e);return EE(t),{output:t.output,truncated:t.truncated,exitStatus:t.exitStatus}}waitForExit(e){let t=this.mustGet(e);return t.exitStatus===null?new Promise(e=>{t.exitWaiters.push(e)}):Promise.resolve(t.exitStatus)}async kill(e){let t=this.mustGet(e);t.exitStatus===null&&await QT(t.child,{graceMs:CE})}async release(e){let t=this.terminals.get(e);t!==void 0&&(t.exitStatus===null&&await QT(t.child,{graceMs:CE}),this.terminals.delete(e))}async disposeAll(){this.disposed=!0;let e=[...this.terminals.keys()];await Promise.allSettled(e.map(e=>this.release(e)))}spawnEnv(e){let t=CT(e);return this.loginShellPath===null||wT(e)?t:AT(t,this.loginShellPath)}mustGet(e){let t=this.terminals.get(e);if(t===void 0)throw Error(`unknown terminal '${e}'`);return t}safeEmit(e){try{this.emit(e)}catch(t){this.log.warn({err:t,kind:e.kind},`[acp-terminals] transcript emit failed`)}}ingestChunk(e,t,n){if(n!==``){if(t.output+=n,t.outputBytes+=Buffer.byteLength(n,`utf8`),t.outputBytes>t.byteLimit*2?EE(t):t.outputBytes>t.byteLimit&&(t.truncated=!0),!t.transcriptPaused){let r=Buffer.byteLength(n,`utf8`);if(t.transcriptBytes+r<=262144){t.transcriptBytes+=r,this.safeEmit({kind:`terminal_output`,terminalId:e,chunk:n,ts:Date.now()});return}t.transcriptPaused=!0}t.pausedTail=TE(t.pausedTail+n,16384)}}settleExit(e,t,n){if(t.exitStatus!==null)return;t.exitStatus=n,EE(t),t.transcriptPaused&&t.pausedTail!==``&&this.safeEmit({kind:`terminal_output`,terminalId:e,chunk:`\n… [output truncated — resuming at the end]\n${t.pausedTail}`,ts:Date.now()}),this.safeEmit({kind:`terminal_exit`,terminalId:e,exitCode:n.exitCode,signal:n.signal,ts:Date.now()});let r=t.exitWaiters;t.exitWaiters=[];for(let t of r)try{t(n)}catch(t){this.log.warn({err:t,terminalId:e},`[acp-terminals] exit waiter threw`)}}};const OE=`threads`;var kE=class{primaryThreadsDir;legacyThreadsDir;cwd;log;writeThreadsDir;homeByThread=new Map;writeQueues=new Map;appendBroken=new Set;constructor(e){this.primaryThreadsDir=I(e.primaryDir,OE),this.legacyThreadsDir=e.legacyDir==null?null:I(e.legacyDir,OE),this.cwd=e.cwd??null,this.log=e.log,this.writeThreadsDir=this.primaryThreadsDir}threadsDirFor(e){return this.homeByThread.get(e)??this.writeThreadsDir}pinHome(e){this.homeByThread.has(e)||this.homeByThread.set(e,this.writeThreadsDir)}enqueue(e,t){let n=this.writeQueues.get(e)??Promise.resolve();this.writeQueues.set(e,n.then(t))}async init(){try{await Is(this.primaryThreadsDir,{recursive:!0})}catch(e){if(this.log.warn({err:e,dir:this.primaryThreadsDir},`[acp-persist] primary threads dir unavailable`),this.legacyThreadsDir!==null){this.writeThreadsDir=this.legacyThreadsDir;try{await Is(this.legacyThreadsDir,{recursive:!0})}catch(e){this.log.error({err:e,dir:this.legacyThreadsDir},`[acp-persist] legacy threads dir also unavailable; threads are memory-only`)}}}}eventsPath(e){return I(this.threadsDirFor(e),`${e}.ndjson`)}metaPath(e){return I(this.threadsDirFor(e),`${e}.meta.json`)}appendEvents(e,t){if(t.length===0||this.appendBroken.has(e))return;this.pinHome(e);let n=`${t.map(e=>JSON.stringify(e)).join(`
|
|
23
23
|
`)}\n`;this.enqueue(e,async()=>{if(!this.appendBroken.has(e))try{await Ys(this.eventsPath(e),n)}catch(t){this.appendBroken.add(e),this.log.error({err:t,threadId:e},`[acp-persist] event append failed; thread continues memory-only`)}})}queueMetaWrite(e,t){this.pinHome(e);let n=`${JSON.stringify(t,null,1)}\n`;this.enqueue(e,async()=>{let t=this.metaPath(e),r=`${t}.tmp`;try{await Ns(r,n),await Qs(r,t)}catch(t){this.log.warn({err:t,threadId:e},`[acp-persist] meta write failed`);try{await Rs(r,{force:!0})}catch{}}})}whenIdle(e){return this.writeQueues.get(e)??Promise.resolve()}async scan(){let e=[],t=new Set,n=this.cwd===null?null:await ME(this.cwd);return await this.scanDir(this.primaryThreadsDir,n,e,t),this.legacyThreadsDir!==null&&this.legacyThreadsDir!==this.primaryThreadsDir&&await this.scanDir(this.legacyThreadsDir,null,e,t),e}async scanDir(e,t,n,r){let i;try{i=await ud(e)}catch(t){t.code!==`ENOENT`&&this.log.warn({err:t,dir:e},`[acp-persist] could not read a threads dir`);return}for(let a of i){if(!a.endsWith(`.meta.json`))continue;let i=I(e,a),o;try{o=JSON.parse(await ld(i,`utf8`))}catch(e){this.log.warn({err:e,path:i},`[acp-persist] skipping unreadable thread meta`);continue}if(o.version!==1||typeof o.info!=`object`||o.info===null||typeof o.info.threadId!=`string`||typeof o.cwd!=`string`||typeof o.agentRef!=`object`||o.agentRef===null){this.log.warn({path:i},`[acp-persist] skipping unreadable thread meta`);continue}let s=o,c=s.info.threadId;r.has(c)||t!==null&&await ME(s.cwd)!==t||(r.add(c),this.homeByThread.has(c)||this.homeByThread.set(c,e),n.push(s))}}async resolveEventLog(e){let t=this.eventsPath(e);if(!B(t))return{count:0,midTurn:!1};let n=0,r=!1;return await this.forEachCompleteLine(t,e=>(n+=1,e.startsWith(`{"kind":"turn_started"`)?r=!0:e.startsWith(`{"kind":"turn_ended"`)&&(r=!1),!0)),{count:n,midTurn:r}}async readEvents(e,t,n,r){let i=this.eventsPath(e);if(t>=n||!B(i))return;let a=0,o=[],s=t,c=()=>{o.length!==0&&(r(s,o),s+=o.length,o=[])};await this.forEachCompleteLine(i,e=>a>=n?!1:(a>=t&&(o.push(jE(e)),o.length>=512&&c()),a+=1,!0)),c()}async delete(e){this.appendBroken.delete(e),this.writeQueues.delete(e);let t=[this.eventsPath(e),this.metaPath(e)],n=await Promise.allSettled(t.map(e=>Rs(e,{force:!0})));this.homeByThread.delete(e);for(let[r,i]of n.entries())i.status===`rejected`&&this.log.warn({err:i.reason,threadId:e,path:t[r]},`[acp-persist] thread file removal failed`)}async forEachCompleteLine(e,t){let n=zu(e,{encoding:`utf8`}),r=null;n.on(`error`,e=>{r=e});let i=Ste({input:n,crlfDelay:1/0}),a=!1,o=null,s=!1;try{for await(let e of i){if(o!==null&&!t(o)){s=!0;break}o=e}s||(a=await AE(e),o!==null&&a&&t(o))}finally{i.close(),n.destroy()}if(r!==null)throw r}};async function AE(e){let{open:t}=await import(`node:fs/promises`),n=await t(e,`r`);try{let{size:e}=await n.stat();if(e===0)return!1;let t=Buffer.alloc(1);return await n.read(t,0,1,e-1),t[0]===10}finally{await n.close()}}function jE(e){try{return JSON.parse(e)}catch{return{kind:`agent_stderr`,line:`[unreadable log entry]`,ts:0}}}async function ME(e){try{return await dd(e)}catch{return R(e)}}const NE=RegExp(`^(?:${`do you mind.i would like you to.i'd like you to.i want you to.i need you to.i would like to.i'd like to.i want to.i need to.we need to.we want to.we should.go ahead and.take a look at.have a look at.look into.look at.help me with.help me to.help me.can you.could you.would you.will you.can we.could we.should we.let's.lets.try to.please.kindly.hello.alright.actually.anyway.also.okay.hey.hi.yo.ok.so.pls.plz.just.maybe`.split(`.`).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})\\b(?:[\\s,:;!.\\-–—]+|$)`,`i`),PE=/^(?:[#>]+\s*|[-*]\s+|\d+[.)]\s+)+/;function FE(e){return(e.trim().split(`
|
|
24
24
|
`)[0]??``).trim()}function IE(e){let t=FE(e);if(t.length<=48)return t;let n=t.slice(0,47),r=n.lastIndexOf(` `);return`${(r>=48/2?n.slice(0,r):n).trimEnd()}…`}function LE(e){let t=FE(e),n=t.replace(PE,``);for(let e=0;e<6;e++){let e=n.replace(NE,``);if(e===n)break;n=e}n=n.trim();let r=n.split(/\s+/).filter(e=>e!==``).length;return!(n!==``&&(r>=2||n.length>=12))||n===t?IE(t):IE(n.charAt(0).toUpperCase()+n.slice(1))}const RE=8,zE=5e3,BE=5e3,VE=2e3;var HE=class extends Error{code;constructor(e,t){super(t),this.name=`ThreadOpError`,this.code=e}},UE=class extends Error{constructor(){super(`authenticate timed out`),this.name=`AuthenticateTimeoutError`}},WE=class extends Error{constructor(){super(`prompt build cancelled before dispatch`),this.name=`PromptCancelledBeforeDispatchError`}};function GE(){return new HE(`not-ready`,`the thread was restarted during the sign-in`)}function KE(e,t){let[n=`open-knowledge`,...r]=e&&e.length>0?e:[`open-knowledge`];return{command:n,args:[...r,`mcp`,`--port`,String(t)]}}var qE=class{opts;threads=new Map;reapTimer;maxThreads;idleReapMs;steerStallMs;authenticateTimeoutMs;unwatchedTurnCancelMs;unwatchedTurnKillMs;persistence;resolveLoginShellPath;healthyInterpreters=new Set;destroyed=!1;initialized=!1;constructor(e){this.opts=e,this.resolveLoginShellPath=e.resolveLoginShellPath??(()=>vT(e.log)()),this.maxThreads=e.maxThreads??8,this.idleReapMs=e.idleReapMs??36e5,this.steerStallMs=e.steerStallMs??1e4,this.authenticateTimeoutMs=e.authenticateTimeoutMs??3e5,this.unwatchedTurnCancelMs=e.unwatchedTurnCancelMs??6e5,this.unwatchedTurnKillMs=e.unwatchedTurnKillMs??12e5,this.persistence=new kE({primaryDir:e.globalDir??e.localDir,legacyDir:e.globalDir===null?null:e.localDir,cwd:e.globalDir===null?null:e.contentDir,log:e.log}),this.reapTimer=setInterval(()=>this.reapIdleThreads(),3e5),this.reapTimer.unref?.()}async init(){if(this.initialized)return;this.initialized=!0,this.resolveLoginShellPath().catch(()=>{}),await this.persistence.init();let e=await this.persistence.scan();for(let t of e){let e=t.info.threadId;this.threads.has(e)||this.threads.set(e,YE(t))}e.length>0&&this.opts.log.info({count:e.length},`[acp-threads] rehydrated archived threads`)}listThreads(){return[...this.threads.values()].map(e=>({...e.info}))}liveThreadCount(){let e=0;for(let t of this.threads.values())t.info.archived!==!0&&(e+=1);return e}getInfo(e){let t=this.threads.get(e);return t===void 0?void 0:{...t.info}}async subscribe(e,t,n){let r=this.mustGet(e);await this.ensureLogResolved(r);let i=Math.max(t,0),a=i;for(;a<r.baseSeq;){let t=r.baseSeq;await this.persistence.whenIdle(e),await this.persistence.readEvents(e,a,t,(t,r)=>{n({op:`events`,threadId:e,fromSeq:t,events:r})}),a=t}this.flushBroadcast(r);let o=Math.max(i,r.baseSeq),s=r.baseSeq+r.events.length;for(let t=o;t<s;t+=512){let i=Math.min(t+512,s);n({op:`events`,threadId:e,fromSeq:t,events:r.events.slice(t-r.baseSeq,i-r.baseSeq)})}return r.subscribers.add(n),r.unwatchedSince=null,r.unwatchedCancelSent=!1,{...r.info}}ensureLogResolved(e){return e.logResolved?Promise.resolve():(e.logResolution??=(async()=>{let t=await this.persistence.resolveEventLog(e.info.threadId);e.baseSeq=t.count,e.midTurnOnDisk=t.midTurn,e.info.lastSeq=t.count-1,e.logResolved=!0})(),e.logResolution)}unsubscribe(e,t){let n=this.threads.get(e);n!==void 0&&(n.subscribers.delete(t),n.subscribers.size===0&&n.unwatchedSince===null&&(n.unwatchedSince=Date.now()))}async createThread(e){if(this.destroyed)throw new HE(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new HE(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);let{info:t,custom:n}=await this.resolveAgentInfo(e.agent);if(this.destroyed)throw new HE(`capacity`,`server is shutting down`);if(this.liveThreadCount()>=this.maxThreads)throw new HE(`capacity`,`maximum of ${this.maxThreads} concurrent agent threads`);let r=crypto.randomUUID(),i=Date.now(),a={info:{threadId:r,agent:t,title:t.name,status:`installing`,createdAt:i,lastActivityAt:i,promptCapabilities:null,modes:null,configOptions:null,availableCommands:null,lastSeq:-1,archived:!1},docName:e.docName,agentRef:{source:e.agent.source,id:e.agent.id},launchSettings:e.settings,cwd:this.opts.contentDir,child:null,conn:null,lastInit:null,sessionId:null,agentSessionId:`acp-${r}`,events:[],baseSeq:0,logResolved:!0,logResolution:null,midTurnOnDisk:!1,resumeInFlight:!1,authInFlight:!1,suppressUpdates:!1,lastSuppressedAt:0,subscribers:new Set,pendingPermissions:new Map,pendingRuntimeConsent:new Map,stderrTail:[],authStderr:null,terminals:null,turnActive:!1,cancelRequested:!1,steerStallTimer:null,unwatchedSince:i,unwatchedCancelSent:!1,pendingBroadcast:[],pendingBroadcastFromSeq:0,flushTimer:null,closed:!1,hadUserMessage:!1,titleHint:e.titleHint,envNotePending:!1};return this.threads.set(r,a),this.emitStatus(a,`installing`),this.startThread(a,e,n).catch(e=>{this.opts.log.error({err:e,threadId:r},`[acp-threads] thread start failed`),this.emitStatus(a,`error`,e instanceof Error?e.message:String(e))}),{...a.info}}async resolveAgentInfo(e){if(e.source===`custom`){let t=(await vf(this.opts.localDir,this.opts.log)).find(t=>t.id===e.id);if(t===void 0)throw new HE(`unknown-agent`,`no custom agent '${e.id}'`);return{info:{id:t.id,name:t.name,source:`custom`},custom:t}}let t;try{t=await this.opts.registry.getAgent(e.id)}catch(e){throw new HE(`install-failed`,`agent registry unavailable: ${e instanceof Error?e.message:String(e)}`)}if(t===void 0)throw new HE(`unknown-agent`,`agent '${e.id}' is not in the registry`);return{info:{id:t.id,name:t.name,iconUrl:t.icon,source:`registry`,version:t.version},custom:null}}async connectAgent(e,t){let n;if(t!==null)n=DT(t);else{let t=await this.opts.registry.getAgent(e.agentRef.id);if(t===void 0)throw new HE(`unknown-agent`,`agent vanished`);n=await ET(t,ff(),this.opts.log)}if(e.closed)return null;let r=await this.ensureLaunchable(e,n);if(r===null||(n=r,e.closed))return null;let i=await this.resolveLoginShellPath().catch(()=>null);if(e.closed)return null;let a=new DE({defaultCwd:e.cwd,emit:t=>this.appendEvent(e,t),log:this.opts.log,loginShellPath:i});this.emitStatus(e,`spawning`);let o=JT(n,e.cwd);if(e.child=o,e.terminals=a,o.stderr?.setEncoding(`utf8`),o.stderr?.on(`data`,t=>{for(let n of t.split(`
|
|
@@ -2014,4 +2014,4 @@ native-divergence-injected
|
|
|
2014
2014
|
`))e&&await t.raw(`update-ref`,`-d`,e)}),b.info({context:e.oldBranch},`[branch-switch] cleaned up detached context ${e.oldBranch}`))}catch(e){b.error({err:e},`[branch-switch] detached cleanup failed`)}ee(!1),await ye.flushDeferredStores(`discard-stale`),t=!0,ke?.emitBranchSwitched(i)}finally{_e.abortBranchSwitch(r),t||(ee(!1),await ye.flushDeferredStores(`discard-stale`))}}if(e.headMoved&&e.newHead&&M.current&&t>0){let t=p??`.`;try{let n=await Nx(M.current,t,e.oldHead,e.newHead,i);Zb(),b.info({oldHead:e.oldHead?.slice(0,8)??`null`,newHead:e.newHead.slice(0,8),sha:n.slice(0,8)},`[history] upstream-import from ${e.oldHead?.slice(0,8)??`null`}..${e.newHead.slice(0,8)} → ${n.slice(0,8)}`)}catch(e){b.error({err:e},`[shadow] upstream-import failed`)}}})}catch(e){b.error({err:e},`[server] HEAD watcher failed to start`),rn.push(`head-watcher`)}function l(e){for(let t of e)try{let e=UM(L(n,I(r,t)));if(e.startsWith(`..`))continue;let i=Gx(e),a=Ce.documents.get(i);if(!a)continue;let o=Bt(i);o===null?b.warn({docName:i,file:t},`[sync] content conflict: serializeDoc returned null; reconciledBase snapshot skipped`):w(i,o);let s=a.getMap(`lifecycle`);s.set(`status`,`conflict`),s.set(`reason`,`sync-merge-conflict`),b.info({docName:i,file:t},`[sync] marked loaded content conflict`)}catch(e){b.warn({err:e,file:t},`[sync] failed to mark loaded content conflict`)}}function d(e){for(let t of e)try{let e=UM(L(n,I(r,t)));if(e.startsWith(`..`))continue;let i=Ce.documents.get(Gx(e));i&&Ht(i)}catch(e){b.warn({err:e,file:t},`[sync] failed to clear resolved content conflict`)}}let f=WMe(h),m=ne();m.mode!==`off`&&b.info({mode:m.mode,source:m.source},`[sync] mode active at boot`);try{$t=new zMe({projectDir:r,contentDir:n,contentFilter:ge,contentRoot:p,mode:m.mode,pullIntervalSeconds:e.pullIntervalSeconds,pushIntervalSeconds:e.pushIntervalSeconds,credentialArgs:f,cc1Broadcaster:ke,detectGh:e.detectGh,tokenStore:e.tokenStore,checkPushPermissionFn:e.checkPushPermissionFn,setBatchInProgress:e=>{ee(e),e||ye.flushDeferredStores(`within-branch`).catch(e=>{b.error({err:e},`[persistence] deferred store drain failed after sync batch`)})},onStateChange:e=>{b.info({state:e},`[sync] state → ${e}`)},onContentConflictsDetected:l,onContentConflictsResolved:d,checkpointBeforeStrandedConversion:async({branch:e,ahead:t})=>{let n=M.current;n&&await Fx(n,p??``,{action:`pull-only-stranded-conversion`,context:{ahead:t}},e)},checkpointBeforeOverlayRestore:async({branch:e,paths:t})=>{let n=M.current;n&&await Fx(n,p??``,{action:`pull-only-overlay-restore`,context:{paths:t}},e)},onAutoDisable:async e=>{b.warn({reason:e},`[sync] auto-disabled — persisting to project-local config`);let t=await ws({cwd:r,scope:`project-local`,patch:{autoSync:{enabled:!1}}});t.ok||b.error({result:t,reason:e,humanError:we(t.error),configPath:Us(`project-local`,r)},`[sync] failed to persist auto-disable — next restart WILL re-enable sync and re-trigger the same failure. Check permissions on the config path.`)}}),await $t.start()}catch(e){b.warn({err:e},`[server] SyncEngine failed to start — sync disabled`),$t=null}qe(`files`),_e.announceReadyViews();let g=TL();g!==void 0&&EL(`readyMs`,g),ae()}return an().then(()=>{Ze=!0,Ve(),ut()},e=>{Qe=!0,$e.abort(),st({status:`failed`,indexCount:0}),_e.close(),We(),He(e)}),{hocuspocus:Ce,durabilityState:x,sessionManager:Te,nativeApi:Ee,localApi:De,cc1Broadcaster:ke,agentFocusBroadcaster:je,agentPresenceBroadcaster:Me,maintenanceCoordinator:ve,contentFilter:ge,basenameIndex:fe,serverInstanceId:le,destroy:nn,ready:Ue,generatedIndexSweepReady:ot,degraded:rn,lockDir:ue,get syncEngine(){return $t},getLinkPreviewsEnabled:A,resolveEmbed:pe,acpRegistry:de,acpPermissions:j}}function f9(e){return e/1048576}function KMe(){let e=process.memoryUsage();return{schemaVersion:1,capturedAt:new Date().toISOString(),snapshot:{rssMb:f9(e.rss),heapTotalMb:f9(e.heapTotal),heapUsedMb:f9(e.heapUsed),externalMb:f9(e.external),arrayBuffersMb:f9(e.arrayBuffers)}}}let p9=null,m9=null,h9=null;const g9=1e6;let _9=null,v9=null;js(()=>{p9=null,m9=null,h9=null,_9?.disable(),_9=null,v9=null});function qMe(){if(p9)return;let e=nc().createObservableGauge(`ok.server.memory.usage_megabytes`,{description:`Server process memory by section. Bounded labels: section ∈ {heap_used, heap_total, rss, external, array_buffers}.`,unit:`MB`});e.addCallback(e=>{let{snapshot:t}=KMe();e.observe(t.heapUsedMb,{section:`heap_used`}),e.observe(t.heapTotalMb,{section:`heap_total`}),e.observe(t.rssMb,{section:`rss`}),e.observe(t.externalMb,{section:`external`}),e.observe(t.arrayBuffersMb,{section:`array_buffers`})}),p9=e}function JMe(){if(!m9){let e=nc().createObservableGauge(`ok.server.event_loop.delay_ms`,{description:`Event-loop delay percentiles over the last export window. Bounded labels: stat ∈ {p50, p99}.`,unit:`ms`});e.addCallback(e=>{if(!_9){_9=xte({resolution:20}),_9.enable();return}e.observe(_9.percentile(50)/g9,{stat:`p50`}),e.observe(_9.percentile(99)/g9,{stat:`p99`}),_9.reset()}),m9=e}if(!h9){let e=nc().createObservableGauge(`ok.server.cpu.utilization`,{description:`Process CPU time as a fraction of wall time since the previous export. Bounded labels: mode ∈ {user, system}.`,unit:`1`});e.addCallback(e=>{let t=process.cpuUsage(),n=process.hrtime.bigint(),r=v9;if(v9={cpu:t,hrtimeNs:n},!r)return;let i=Number(n-r.hrtimeNs)/1e3;i<=0||(e.observe((t.user-r.cpu.user)/i,{mode:`user`}),e.observe((t.system-r.cpu.system)/i,{mode:`system`}))}),h9=e}}const y9=P(`skill-migrate`);function b9(e){return[{host:`agents`,root:Ue},...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({host:e,root:t}))].sort((e,t)=>{let n=oO.indexOf(e.host),r=oO.indexOf(t.host);return(n===-1?oO.length:n)-(r===-1?oO.length:r)||e.host.localeCompare(t.host)})}const YMe=b9(br),XMe=b9(ht);function ZMe(e,t){return B(R(e,Aa(t)))}function QMe(e,t){Ws(F(t),{recursive:!0});try{Ls(e,t)}catch(n){if(!(n instanceof Error)||n.code!==`EXDEV`)throw n;qs(e,t,{recursive:!0}),Js(e,{recursive:!0,force:!0})}}function $Me(e,t,n){let r=AI(e,t,n);switch(r.kind){case`absent`:return{kind:`absent`};case`other`:return{kind:`occupied`,by:`different`};case`symlink`:return r.resolution===`target`?{kind:`store-link`}:{kind:`occupied`,by:`foreign-link`};case`dir`:return r.identity===`different`?{kind:`occupied`,by:`different`}:{kind:`same-copy`}}}function x9(e,t){let n;try{n=H(R(e,`.ok`,`skills`))}catch{n=R(e,`.ok`,`skills`)}return new Set(t.filter(t=>{try{return!H(R(e,t.dir)).startsWith(n+z)}catch{return!0}}).map(e=>e.name))}async function S9(e){let{projectDir:t,skillsRoot:n}=e,r=e.inPlaceNames??new Set,i=e.hostRoots??YMe,a={migrated:[],skipped:[]};if(!B(n))return a;let o;try{o=qu(n)}catch{return a}let s=L(t,n).split(z).join(`/`),c=new Set;for(let[e,n]of Object.entries(mX(t)))for(let t of n)t.path.split(`/`).slice(0,-1).join(`/`)===s&&c.add(e);for(let e of o)try{if(!Ji.test(e)||ZF.has(e))continue;if(r.has(e)){a.skipped.push({name:e,reason:`placement-of-in-place`});continue}if(c.has(e)){a.skipped.push({name:e,reason:`recorded-placement`});continue}let o=R(n,e);if(!B(I(o,`SKILL.md`)))continue;let s=YD(o)?.contentHash;if(s===void 0)continue;let l=H(o),u=i.map(({host:n,root:r})=>{let i=R(t,r);return{host:n,root:r,path:I(i,e),escapes:RI(t,i),state:$Me(I(i,e),l,s)}}).filter(e=>!e.escapes),d=u.find(e=>e.state.kind===`store-link`||e.state.kind===`same-copy`)??u.find(e=>ZMe(t,e.root));if(!d){a.skipped.push({name:e,reason:`no-usable-target`});continue}if(d.state.kind===`occupied`){a.skipped.push({name:e,reason:`target-occupied:${d.root} (${d.state.by})`});continue}d.state.kind===`same-copy`?Js(o,{recursive:!0,force:!0}):(d.state.kind===`store-link`&&Js(d.path,{recursive:!0,force:!0}),QMe(o,d.path));for(let e of u)e===d||e.state.kind!==`store-link`||(Js(e.path,{recursive:!0,force:!0}),qs(d.path,e.path,{recursive:!0}));await wN(t,e),a.migrated.push({name:e,to:`${d.root}/${e}`}),y9.info({skill:e,to:`${d.root}/${e}`},`migrated store skill in place`)}catch(t){a.skipped.push({name:e,reason:`error`}),y9.warn({err:t,skill:e},`store-skill migration skipped one entry after error`)}return a}const C9=P(`skill-reconcile`),eNe=ZF;function w9(){let e=[];for(let t of Tr){let n=br[t];n!==null&&e.push({rel:n,editor:t})}return e.push({rel:Ue,editor:null}),e}function tNe(e,t){let n=L(e,R(t));return Eu(n)?R(t):n}function T9(e){let{frontmatter:t,body:n}=So(e),r={};if(t!==``)try{let e=(0,ck.parse)(hn(t));e&&typeof e==`object`&&!Array.isArray(e)&&(r=e)}catch{}return{fm:r,body:n}}function nNe(e,t){let n=T9(e),r=T9(t);if(n.body!==r.body)return!1;for(let e of Object.keys(n.fm))if(e in r.fm&&JSON.stringify(n.fm[e])!==JSON.stringify(r.fm[e]))return!1;return!0}function E9(e,t){let n=D9(e),r=D9(t);if(n.length!==r.length)return!1;let i=0;for(let a=0;a<n.length;a+=1){if(n[a]!==r[a])return!1;let o=n[a],s=I(e,o),c=I(t,o);if(i+=Qu(s).size+Qu(c).size,i>1048576)return!1;let l=V(s),u=V(c);if(!l.equals(u)&&(o!==`SKILL.md`||!nNe(l.toString(`utf8`),u.toString(`utf8`))))return!1}return!0}function D9(e,t=``){let n=[];for(let r of qu(e,{withFileTypes:!0})){let i=t?`${t}/${r.name}`:r.name;r.isDirectory()?n.push(...D9(I(e,r.name),i)):r.isFile()&&n.push(i)}return n.sort()}function O9(e,t,n){Js(t,{recursive:!0,force:!0}),Ws(e,{recursive:!0}),Bs(tNe(e,n),t,`dir`)}function k9(e,t){try{let n=Ju(e);return R(Eu(n)?n:R(F(e),n))===R(t)}catch{return!1}}function rNe(e,t){try{let n=Ju(e),r=Eu(n)?R(n):R(F(e),n);if(!B(r))return!1;let i=L(R(t),r);return i!==``&&(i.startsWith(`..`)||Eu(i))}catch(t){return C9.warn({linkPath:e,err:t},`isForeignSymlink: could not resolve symlink; treating as reconcile-managed`),!1}}const iNe=[...Tr,`agents`];function aNe(e){for(let t of iNe){let n=`-${t}`;if(e.length>n.length&&e.endsWith(n))return e.slice(0,-n.length)}return null}function oNe(e){let{projectDir:t,skillsRoot:n}=e;if(!B(n))return;let r;try{r=qu(n)}catch{return}let i=w9();for(let e of r){let r=aNe(e);if(r===null)continue;let a=R(n,e),o=R(n,r);if(B(o))try{let n=Vu(a);if(n.isSymbolicLink()||!n.isDirectory()||!B(I(a,`SKILL.md`))||!B(I(o,`SKILL.md`))||!E9(o,a))continue;for(let{rel:n}of i){let r=R(t,n);if(RI(t,r))continue;let i=I(r,e);k9(i,a)&&O9(r,i,o)}Js(a,{recursive:!0,force:!0}),C9.info({base:r,suffixed:e},`collapsed accreted suffix-duplicate skill into its base`)}catch(t){C9.warn({err:t,base:r,suffixed:e},`suffix-dupe collapse skipped one entry after error`)}}}async function sNe(e){let{projectDir:t,skillsRoot:n}=e,r={healed:[],replaced:[],orphansRemoved:[],skipped:[]},i=new Map,a=(e,t)=>{if(t===null)return;let n=i.get(e)??new Set;n.add(t),i.set(e,n)};for(let{rel:e,editor:i}of w9()){let o=R(t,e);if(!B(o)||RI(t,o))continue;let s;try{s=qu(o)}catch(e){C9.warn({hostRoot:o,err:e},`reconcile: skipped unreadable host skills root`);continue}for(let e of s){if(eNe.has(e))continue;let t=I(o,e),s=R(n,e),c=B(s);try{let l=Vu(t);if(l.isSymbolicLink()){if(k9(t,s)&&c)continue;if(rNe(t,n)){r.skipped.push({name:e,editor:i});continue}c?(O9(o,t,s),r.healed.push({name:e,editor:i})):(Js(t,{recursive:!0,force:!0}),r.orphansRemoved.push({name:e,editor:i}));continue}if(!l.isDirectory())continue;if(!Ji.test(e)){C9.warn({skill:e,editor:i},`reconcile: skipping host-dir entry with a non-skill name`);continue}if(c&&E9(t,s)){O9(o,t,s),r.replaced.push({name:e,editor:i}),a(e,i);continue}r.skipped.push({name:e,editor:i})}catch(t){C9.warn({err:t,skill:e,editor:i},`reconcile skipped one skill entry after error`)}}}if(i.size>0){let e=xN(t);for(let[r,a]of i){let i=R(n,r);if(!B(i))continue;let o=e.skills[r],s=Array.from(new Set([...o?.hosts??[],...a]));try{await CN(t,r,{hosts:s,scope:o?.scope??`project`,scripts:o?.scripts??NI(i,r).hasScripts,installedAt:o?.installedAt??new Date().toISOString()})}catch(e){C9.warn({err:e,skill:r},`reconcile marker update failed (non-fatal)`)}}}try{oNe({projectDir:t,skillsRoot:n})}catch(e){C9.warn({err:e},`suffix-dupe collapse pass failed (non-fatal)`)}return r}let A9=null,j9=!1;function M9(e=process.env){return e.OK_BRIDGE_TOLERANCE_TELEMETRY===`1`}function N9(e){if(!M9())return;let t=Bk(e);A9=new dc({currentPath:R(t,`tolerance-telemetry.jsonl`),previousPath:R(t,`tolerance-telemetry.prev.jsonl`),maxBytes:8388608}),ja(e=>{let t={event:`bridge-tolerance-fire`,timestamp:e.timestamp,class:e.className,document:e.documentName??null,codeUnitPosition:e.codeUnitPosition,severity:e.severity};A9?.append(`${JSON.stringify(t)}\n`).catch(e=>{j9||(j9=!0,P(`tolerance-telemetry`).warn({err:e instanceof Error?e:Error(String(e))},`append failed; further failures are silent`))})})}async function P9(){ja(null),await A9?.drain(),A9=null,j9=!1}bs();const cNe=[`server.lock`,`ui.lock`,`state.json`,`principal.json`,`sync-state.json`,`conflicts.json`,`last-spawn-error.log`],lNe=[`cache`,`tmp`];function uNe(e){let t=R(e,he);if(!(()=>{if(!B(t))return!0;try{return qu(t).length===0}catch{return!0}})())return[];let n=[];for(let t of cNe)B(R(e,t))&&n.push(t);for(let t of lNe){let r=R(e,t);try{B(r)&&Qu(r).isDirectory()&&n.push(`${t}/`)}catch{}}return n}function dNe(e){let t=Nd(e);switch(t.kind){case`directory`:return{kind:`main`,gitdir:t.path};case`linked`:return{kind:`linked`,gitdir:t.path};case`malformed-pointer`:return{kind:`linked`,gitdir:null};case`inaccessible`:case`absent`:return{kind:`main`,gitdir:null}}}const F9=Number(process.env.OK_DESTROY_STEP_TIMEOUT_MS)||5e3;async function fNe(e){mhe();let t=e.projectDir??e.contentDir,n=Cve({projectDir:t});if(n){let e=n.telemetry.attributeDenylist,t=[];for(let n of e){t.push(n);for(let e=1;e<=5;e++)t.push(`${`*.`.repeat(e)}${n}`)}sc.configure({pinoConfig:{fileSink:n.logs,redactPaths:t}})}tc({localSink:n?.telemetry}),N9(t),qMe(),JMe();let{kind:r,gitdir:i}=dNe(e.projectDir??e.contentDir),a={"ok.worktree.kind":r};i!==null&&(a[`ok.worktree.gitdir`]=Ks(i));let o=xve(t),s=process.env.OK_STARTUP_TRACEPARENT,c=()=>Ms(`ok.boot`,{attributes:a},async()=>pNe(e)),l=()=>{if(s)try{let e=vs.extract(xs.active(),{traceparent:s});return xs.with(e,c)}catch(e){P(`boot`).warn({err:e},`ok.boot trace-join failed — starting unparented boot`)}return c()},u;try{u=await l()}catch(e){throw o.uninstall(),e}let d=u.destroy;return u.destroy=async()=>{try{await d()}finally{o.uninstall()}},u}async function pNe(e){let t=e.skipAutoInit??!1,n=e.log??P(`boot`),r=e.serverRuntime??{...ba(e.config),allowExternal:!1},i=e.bind!==void 0&&e.bind.length>0?e.bind:[e.host??`127.0.0.1`];if((Oo(r)||!Ya(i))&&!r.allowExternal)throw new EB(`refusing to start: the server would bind a non-loopback address (${(Ya(i)?r.bind:i).join(`, `)}), which exposes this server beyond this machine. Consent with OK_ALLOW_EXTERNAL=1, or server.allowExternal: true in .ok/local/config.yml.`);let a=kB({serverRuntime:r});r.allowExternal&&!r.loopbackOnly&&r.externalUrlSource!==`server`&&(a.bindLiterals.length===0?n.warn({bind:r.bind},`[ingress] server.allowExternal is set on a wildcard bind (0.0.0.0/::) with no server.externalUrl — external requests will be REFUSED (403 host-not-allowed) because no external Host name is admitted. Set server.externalUrl to the public origin clients dial (e.g. behind a reverse proxy or platform edge), or bind a specific address instead of a wildcard.`):n.info({bind:r.bind},`[ingress] server.allowExternal is set with no server.externalUrl — the bind-address literals are admitted as Host names (direct IP access). Set server.externalUrl to admit a hostname.`));let o=process.env.OK_LOCK_KIND===`mcp-spawned`||process.env.OK_LOCK_KIND===`interactive`?process.env.OK_LOCK_KIND:void 0,s=e.lockKind??o??`interactive`,{createServer:c}=await import(`node:http`),{markServerLockDraining:l,releaseServerLock:u,updateServerLockPort:d}=await import(`./server-lock-CXt9yQWS.mjs`),f=!1;if(!t&&e.autoInitFn)try{f=!!await e.autoInitFn()}catch(e){n.warn({err:e},`autoInitFn failed`)}let p=e.projectDir??e.contentDir,m=R(p,`.ok`);if(!B(R(m,`config.yml`)))throw new g8(B(m)?`config`:`okdir`,p);let h=R(m,`.gitignore`);B(h)||P(`boot`).warn({path:h},"Note: .ok/.gitignore is missing — per-machine state files in .ok/ may show up as untracked changes. Run `ok init` to add the recommended ignore entries.");let g=e.gitPreflight??nK;try{e.gitEnabled!==!1&&g()}catch(e){if(e instanceof $G||e instanceof eK){let t=e instanceof eK?e.detected:``,r=e instanceof eK?`too_old`:`not_available`;xK(e),n.warn({event:`git_preflight_fail`,platform:e.platform,reason:r,detectedVersion:t},r===`not_available`?`git binary not found`:`git binary too old`),process.stderr.write(`${e.message}\n`)}throw await ec(),await Promise.race([P9(),new Promise(e=>setTimeout(e,F9))]),e}let _=uNe(m);_.length>0&&P(`boot`).warn({files:_},`Found legacy runtime files at .ok/${_.join(`, `)}. Delete .ok/ and re-init — these files moved to .ok/${he}/.`);let v=d9({contentDir:e.contentDir,projectDir:e.projectDir,ingressPolicy:a,contentRoot:e.contentRoot,port:e.port,host:e.host,quiet:e.quiet??!1,debounce:e.debounce,maxDebounce:e.maxDebounce,gitEnabled:e.gitEnabled,commitDebounceMs:e.commitDebounceMs,wipRef:e.wipRef,enableTestRoutes:e.enableTestRoutes,shadowRepo:e.shadowRepo,destroyTimeoutMs:e.destroyTimeoutMs,localOpCliArgs:e.localOpCliArgs,authStreamHeartbeatMs:e.authStreamHeartbeatMs,onAgentWrite:e.onAgentWrite,lockKind:s,capabilities:e.reactShellDistDir?[`http`,`ws`,`ui`]:[`http`,`ws`],skipStateManifestCheck:e.skipStateManifestCheck,detectGh:e.detectGh,tokenStore:e.tokenStore,embeddingsKeyStore:e.embeddingsKeyStore,singleDocRelPath:e.singleDocRelPath,ephemeral:e.ephemeral}),{hocuspocus:y,destroy:b,ready:x,degraded:S,lockDir:C,sessionManager:T,agentFocusBroadcaster:E,agentPresenceBroadcaster:ee,maintenanceCoordinator:te}=v,D=(()=>{let t=e.host??`localhost`;return t===`0.0.0.0`||t===`::`?`localhost`:t.includes(`:`)&&!t.startsWith(`[`)?`[${t}]`:t})(),ne=e.port??0,O=()=>r.externalUrlSource===`server`&&r.externalUrl!==void 0?r.externalUrl.replace(/\/+$/,``):`http://${D}:${ne}`,re=e.ephemeral?void 0:l8({contentDir:e.contentDir,projectDir:e.projectDir??e.contentDir,config:e.config,getServerUrl:()=>O(),localApi:v.localApi,log:n}),k=c();k.headersTimeout=3e4,k.requestTimeout=6e4;let A=e.serveContentAssets===!1?void 0:zZ({contentFilter:v.contentFilter,contentSirv:zc(e.contentDir,{dev:!0,dotfiles:!1}),inlineExtensions:ge,assetExtensions:w,blocklistExtensions:Ae,ingressPolicy:a}),ie=!1;if(e.reactShellDistDir)try{HX(C,{port:0,worktreeRoot:e.projectDir??e.contentDir}),ie=!0}catch(e){if(e instanceof VX)n.info({event:`ui-lock-yielded-to-live-holder`,pid:process.pid,existingPid:e.existing.pid,existingPort:e.existing.port,lockDir:C},`ui.lock already held by a live process — yielding (advertisement is fulfilled)`);else throw await b().catch(()=>{}),u(C),e}let ae=e.reactShellDistDir?zc(e.reactShellDistDir,{single:!0,gzip:!0,etag:!0,dev:!0}):void 0,oe=e.ephemeral?null:new qE({contentDir:e.contentDir,localDir:C,globalDir:R(nd(),`.ok`),registry:v.acpRegistry,permissions:v.acpPermissions,sessionManager:T,agentPresenceBroadcaster:ee,resolveEmbed:v.resolveEmbed,isExcludedPath:e=>v.contentFilter.isExcluded(e),isIgnoredPath:e=>v.contentFilter.isPathIgnored(e),getLoadedDocText:e=>y.documents.get(e)?.getText(`source`).toString()??null,getServerUrl:()=>O(),getMcpStdioCommand:()=>KE(e.localOpCliArgs,ne),probeHarnessManagedMcpEntry:e.probeHarnessManagedMcpEntry,log:n});oe!==null&&await oe.init();let se=`pending`;x.then(()=>{se=`ready`},()=>{se=`failed`});let ce=m8({httpServer:k,hocuspocus:y,nativeApi:v.nativeApi,mcpHttpHandler:re,ingressPolicy:a,health:{readiness:()=>se,degraded:()=>S},log:n,sessionManager:T,agentFocusBroadcaster:E,agentPresenceBroadcaster:ee,maintenanceCoordinator:te,keepaliveGraceMs:e.keepaliveGraceMs,contentAssetMiddleware:A,reactShellMiddleware:ae,ephemeral:e.ephemeral,acpThreadManager:oe}),le=async()=>{throw Error(`bootServer: destroy() invoked before initialization — boot did not complete`)},ue=null;e.idleShutdownMs!==null&&(ue=$Z({httpServer:k,thresholdMs:e.idleShutdownMs??18e5,log:n,onShutdown:(e.idleShutdownHandler??(e=>async()=>{await e()}))(async()=>{await le()})})),await I9({hocuspocus:y,projectDir:e.projectDir??e.contentDir,log:n});let de=[...new Set(i)],j=de[0],fe=async()=>{if(ie)try{GX(C)}catch(e){n.warn({err:e},`releaseUiLock failed during listen-error cleanup`)}await b().catch(e=>{n.warn({err:e},`destroyHocuspocus failed during listen-error cleanup`)}),u(C)},pe=(e,t,n)=>new Promise((r,i)=>{let a=e=>i(e);e.once(`error`,a),e.listen(t,n,()=>{e.removeListener(`error`,a),r()})});try{await pe(k,e.port??0,j??`127.0.0.1`)}catch(e){throw await fe(),e}let me=k.address(),_e=typeof me==`object`&&me?me.port:e.port??0,M=[];for(let e of de.slice(1)){let t=c();t.headersTimeout=k.headersTimeout,t.requestTimeout=k.requestTimeout;for(let e of k.listeners(`request`))t.on(`request`,e);for(let e of k.listeners(`upgrade`))t.on(`upgrade`,e);try{await pe(t,_e,e)}catch(t){n.error({err:t,failedAddress:e,port:_e,alreadyBound:M.length+1},`[boot] secondary address bind failed — unwinding all listeners`);for(let e of[...M,k])e.closeAllConnections?.(),await new Promise(t=>{e.close(e=>{e&&n.warn({err:e},`[boot] listener close failed during unwind`),t()})});throw await fe(),t}M.push(t)}let ve=TL();ve!==void 0&&EL(`httpListenMs`,ve);let ye=k.address(),be=typeof ye==`object`&&ye?ye.port:e.port??0;ne=be;let xe=`http://${D}:${be}`;d(C,be,xe),ie&&UX(C,be,xe);let Se=!1,Ce=async(e,t)=>{let n;try{await Promise.race([t(),new Promise((t,r)=>{n=setTimeout(()=>{r(Error(`${e} timed out after ${F9}ms`))},F9),n.unref?.()})])}finally{n!==void 0&&clearTimeout(n)}};le=async()=>{if(Se)return;Se=!0,se=`draining`;let e=[],t=async(t,r)=>{try{await Ce(t,r)}catch(r){e.push(r),n.warn({err:r,step:t},`bootServer destroy step failed`)}};try{l(C),ie&&G_e(C)}catch(e){n.warn({err:e,step:`markLocksDraining`},`bootServer destroy step failed`)}try{ue?.detach()}catch(t){e.push(t),n.warn({err:t,step:`idleHandle.detach`},`bootServer destroy step failed`)}if(oe!==null&&await t(`acpThreads.destroy`,()=>oe.destroy()),await t(`secondaryListeners.close`,async()=>{for(let e of M)e.closeAllConnections?.(),await new Promise(t=>{e.close(e=>{e&&n.warn({err:e},`[boot] secondary listener close failed during teardown`),t()})})}),await t(`mount.shutdown`,()=>ce.shutdown()),re!==void 0&&await t(`mcpHttpHandler.close`,()=>re.close()),await t(`mount.wss.close`,()=>new Promise((e,t)=>{ce.wss.close(n=>n?t(n):e())})),await t(`httpServer.closeAllConnections`,async()=>{k.closeAllConnections?.()}),await t(`httpServer.close`,()=>new Promise((e,t)=>{k.close(n=>n&&n.code!==`ERR_SERVER_NOT_RUNNING`?t(n):e())})),await t(`destroyHocuspocus`,()=>b()),ie&&await t(`releaseUiLock`,async()=>GX(C,{deferUnlinkToExit:!0})),await t(`shutdownTelemetry`,()=>ec()),await t(`teardownToleranceTelemetry`,()=>P9()),await t(`flushLogFileSinks`,()=>sc.flushAllFileSinks()),e.length>0)throw AggregateError(e,`bootServer destroy completed with errors`)};try{let t=await S9({projectDir:p,skillsRoot:R(e.contentDir,`.ok`,`skills`),inPlaceNames:x9(e.contentDir,fL(e.contentDir))});t.migrated.length+t.skipped.length>0&&n.info?.({event:`store-skills-migrated-in-place`,migrated:t.migrated,skipped:t.skipped},`Migrated ${t.migrated.length} store skill(s) in place (${t.skipped.length} skipped).`)}catch(e){n.warn?.({err:e,event:`store-skill-migration-failed`},`Store-skill in-place migration failed (non-fatal).`)}try{let e=nd(),t=await S9({projectDir:e,skillsRoot:R(e,`.ok`,`skills`),hostRoots:XMe,inPlaceNames:x9(e,pL(e))});t.migrated.length+t.skipped.length>0&&n.info?.({event:`global-store-skills-migrated-in-place`,migrated:t.migrated,skipped:t.skipped},`Migrated ${t.migrated.length} global store skill(s) in place (${t.skipped.length} skipped).`)}catch(e){n.warn?.({err:e,event:`global-store-skill-migration-failed`},`Global store-skill in-place migration failed (non-fatal).`)}try{let t=await sNe({projectDir:p,skillsRoot:R(e.contentDir,`.ok`,`skills`)}),r=t.healed.length+t.replaced.length+t.orphansRemoved.length;r>0&&n.info?.({event:`installed-skills-reconciled`,healed:t.healed.length,replaced:t.replaced.length,orphansRemoved:t.orphansRemoved.length},`Reconciled ${r} editor skill entr${r===1?`y`:`ies`} to the symlink model.`)}catch(e){n.warn?.({event:`installed-skills-reconcile-failed`,err:e},`Installed-skills reconcile failed (non-fatal).`)}return{httpServer:k,destroy:le,lockDir:C,contentDir:e.contentDir,port:be,ready:x,generatedIndexSweepReady:v.generatedIndexSweepReady,degraded:S,didAutoInit:f,serverInstance:v,runtime:jke(v,{contentDir:e.contentDir,projectDir:p}),acpThreadManager:oe}}async function I9(e){let{hocuspocus:t,projectDir:n,log:r}=e,i,a;try{i=new XZ(n),a=i.list()}catch(e){r.warn({err:e,projectDir:n},`[boot] lifecycle restore: failed to read conflicts.json — skipping`);return}if(a.length===0)return;let o=e=>e.variant===`working-tree`,s=null;try{let e=Pd(n),t=e?I(e,`MERGE_HEAD`):null;if(!t||!B(t)){let e=a.filter(e=>!o(e));for(let t of e)i.removeConflict(t.file);if(a=a.filter(o),e.length>0&&console.warn(JSON.stringify({event:`lifecycle-restore-cleared-stale-conflicts`,reason:`no-merge-head`,count:e.length})),a.length===0)return}else{let e=gc({baseDir:n,timeout:{block:5e3}});s=new Set(await Jb(e,[`diff`,`--name-only`,`--diff-filter=U`]))}}catch(e){r.warn({err:e,projectDir:n},`[boot] lifecycle restore: git unmerged probe failed — restoring all entries`)}if(s!==null){let e=0;for(let t of a)!o(t)&&!s.has(t.file)&&(i.removeConflict(t.file),e++);if(e>0&&console.warn(JSON.stringify({event:`lifecycle-restore-pruned-resolved-entries`,pruned:e,remaining:a.length-e})),a=a.filter(e=>o(e)||s?.has(e.file)),a.length===0)return}for(let e of a){let n=Gx(e.file),i=null,a=!1;try{i=await t.openDirectConnection(n);let e=i.document;if(!e)continue;let r=e.getMap(`lifecycle`);r.set(`status`,`conflict`),r.set(`reason`,`conflict-markers`),a=!0,console.warn(JSON.stringify({event:`lifecycle-restored-from-conflicts-json`,"doc.name":n}))}catch(e){r.warn({err:e,docName:n},`[boot] lifecycle restore: failed to set lifecycle for doc — skipping`)}finally{if(i)try{await i.disconnect()}catch(e){r.warn({err:e,docName:n,restored:a},`[boot] lifecycle restore: disconnect failed after lifecycle write`)}}}}const mNe=Ne;function hNe(e={}){let t=e.home??nd(),n=e.platformName??process.platform,r=e.env??process.env;return n===`darwin`?B(I(t,`Library`,`Application Support`,`Claude`)):n===`win32`?B(I(r.APPDATA??I(t,`AppData`,`Roaming`),`Claude`)):!1}var L9=t(uc(),1);const R9=I(nd(),`.ok`,`logs`),gNe=[`authorization`,`password`,`token`,`apiKey`,`secret`,`*.authorization`,`*.password`,`*.token`,`*.apiKey`,`*.secret`];function _Ne(){let e=process.env.OK_LOG_LEVEL??process.env.LOG_LEVEL;if(e){let t=[`fatal`,`error`,`warn`,`info`,`debug`],n=e.toLowerCase();if(t.includes(n))return n}return process.env.NODE_ENV===`test`?`silent`:`info`}function vNe(e){Hu(e,{recursive:!0})}function z9(){return new Date().toISOString().slice(0,10)}function yNe(e){try{if(Qu(e).size<5242880)return}catch{return}for(let t=2;t>=1;t--){let n=t===1?e:`${e}.${t-1}`,r=`${e}.${t}`;try{Yu(n,r)}catch{}}try{$u(`${e}.3`)}catch{}}function bNe(e){try{let t=Date.now(),n=10080*60*1e3,r=qu(e).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(t=>{try{let n=Qu(I(e,t));return{name:t,mtime:n.mtimeMs,size:n.size}}catch{return null}}).filter(Boolean);for(let i of r)if(t-i.mtime>n)try{$u(I(e,i.name))}catch{}let i=r.filter(e=>t-e.mtime<=n).sort((e,t)=>e.mtime-t.mtime),a=i.reduce((e,t)=>e+t.size,0);for(let t of i){if(a<=47185920)break;try{$u(I(e,t.name)),a-=t.size}catch{}}}catch{}}function xNe(e){vNe(R9);let t=z9(),n=e.filePath??I(R9,`${e.name}.${t}.log`);yNe(n),(e._setTimeout??setTimeout)(()=>bNe(R9),5e3).unref();let r=L9.default.destination({dest:n,append:!0,sync:!0});return(0,L9.default)({level:_Ne(),name:e.name,redact:{paths:gNe,censor:`[REDACTED]`},base:{pid:process.pid,hostname:void 0,runtime:`cli`,project:e.project??`<no-project>`},timestamp:L9.default.stdTimeFunctions.isoTime,...e.additionalOptions},r)}function SNe(e,t=250){return new Promise(n=>{if(!e){n();return}let r=e[L9.default.symbols.streamSym],i=!1,a=()=>{i||(i=!0,n())};if(!r||typeof r.flushSync!=`function`){a();return}let o=()=>{try{r.flushSync?.()}catch{}a()},s=setTimeout(a,t);typeof s.unref==`function`&&s.unref(),typeof r.fd==`number`&&r.fd>=0?(clearTimeout(s),o()):typeof r.once==`function`?r.once(`ready`,()=>{clearTimeout(s),o()}):(clearTimeout(s),o())})}function CNe(e){return I(R9,`${e}.${z9()}.log`)}function wNe(){return R9}function TNe(e){let t=R(e),n=0;for(;n<30;){let e=!1;try{e=B(R(t,`.git`))}catch{e=!1}if(e)return{gitRoot:t,distance:n};let r=F(t);if(r===t)return null;t=r,n+=1}return null}const B9=Sd(vu),V9=P(`project-git`);var H9=class extends Error{stderr;constructor(e,t=``,n){super(e,n),this.name=`ProjectGitInitError`,this.stderr=t}};async function ENe(e,t){try{return await B9(e,[`var`,`GIT_COMMITTER_IDENT`],YM({cwd:t,encoding:`utf-8`})),!0}catch{return!1}}async function DNe(e,t){try{let{stdout:n}=await B9(e,[`for-each-ref`,`--count=1`,`refs/`],YM({cwd:t,encoding:`utf-8`}));return n.trim().length>0}catch(e){return V9.warn({path:t,stderr:U9(e)},`could not list refs — assuming history exists and skipping the initial commit`),!0}}function ONe(e){let t=R(e,`packed-refs`);if(B(t))try{if(V(t,`utf-8`).split(`
|
|
2015
2015
|
`).some(e=>e.trim()!==``&&!e.startsWith(`#`)))return!0}catch{return!0}try{return qu(R(e,`refs/heads`)).length>0}catch{return!1}}function U9(e){let t=typeof e==`object`&&e?e:null,n=t?.stderr;return n==null?String(t?.message??e):Buffer.isBuffer(n)?n.toString(`utf-8`):String(n)}async function W9(e,t){if(await DNe(e,t))return;let n=[`commit`,`--allow-empty`,`--no-verify`,`--no-gpg-sign`,`-m`,`Initial commit`],r=await ENe(e,t),i=r?n:[`-c`,`user.name=Open Knowledge`,`-c`,`user.email=noreply@openknowledge.local`,...n];try{await B9(e,i,YM({cwd:t,encoding:`utf-8`})),r||V9.info({path:t},`created initial commit with fallback identity (git identity unset)`)}catch(e){V9.warn({path:t,stderr:U9(e)},`could not create initial commit`)}}async function kNe(e,t){try{let{stdout:n}=await B9(e,[`rev-parse`,`--is-inside-work-tree`],YM({cwd:t,encoding:`utf-8`}));return n.trim()===`true`}catch{return!1}}async function ANe(e){let t=R(e),n=R(t,`.git`),r=R(n,`HEAD`),i=!1,a=!1;if(B(n)){if(!Qu(n).isDirectory())return{didInit:!1};if(B(r)){if(ONe(n))return{didInit:!1};a=!0}else V9.info({},`detected partial .git/ — running git init to repair`),i=!0}let o;try{o=nK()}catch(e){throw e instanceof $G||e instanceof eK?(xK(e),V9.warn({event:`git_preflight_fail`,platform:e.platform,reason:e instanceof eK?`too_old`:`not_available`,detectedVersion:e instanceof eK?e.detected:``},e instanceof eK?`git binary too old`:`git binary not found`)):V9.warn({event:`git_preflight_unexpected_error`,err:e},`unexpected error during git preflight`),e}let s=o.resolvedPath;if(a)return await W9(s,t),{didInit:!1};if(!i&&await kNe(s,t))return{didInit:!1};let c=``;try{c=(await B9(s,[`init`,`--initial-branch=main`,t],YM({encoding:`utf-8`}))).stderr??``}catch(e){let n=typeof e==`object`&&e&&`stderr`in e?String(e.stderr??``):``;throw new H9(`git init failed at ${t}: ${e instanceof Error?e.message:String(e)}`,n,{cause:e})}if(!B(r))throw new H9(`git init reported success but ${n}/HEAD is missing (partial init detected)`,c);return await W9(s,t),i?(V9.info({path:t},`backfilled missing .git/HEAD`),{didInit:!0,repaired:!0}):(V9.info({path:t,branch:`main`},`initialized .git/`),{didInit:!0})}const G9=P(`project-skill-git`),K9=/^[0-9a-f]{40}$/,jNe=jt.map(e=>e.replace(/\/$/,``));async function MNe(e){let t=Pd(e);if(t===null)return{kind:`skipped`,reason:`no-git`};if(INe(t))return{kind:`skipped`,reason:`operation-in-progress`};let n=_c(e);if((await q9(n)).length===0)return{kind:`nothing-tracked`};try{return await hc(async()=>{let t=await NNe(n);if(t===null)return{kind:`skipped`,reason:`detached-head`};let r=await PNe(n);if(r===null)return{kind:`skipped`,reason:`unborn-head`};let i=await q9(n);if(i.length===0)return{kind:`nothing-tracked`};let a=_c(e,{gitIndexFile:I(ad(),`ok-untrack-idx-${process.pid}-${Date.now()}.idx`)});await a.git.raw([`read-tree`,r]),await a.git.raw([`rm`,`--cached`,`-r`,`--ignore-unmatch`,`--`,...i]);let o=(await a.git.raw([`write-tree`])).trim(),s=await FNe(n,r);if(s!==null&&s===o)return{kind:`nothing-tracked`};let c=await gB(e),l=c?.name??`OpenKnowledge`,u=c?.email??`sync@open-knowledge.local`;yc(a,{GIT_AUTHOR_NAME:l,GIT_AUTHOR_EMAIL:u,GIT_COMMITTER_NAME:l,GIT_COMMITTER_EMAIL:u});let d=`Stop tracking the OpenKnowledge project skill\n\nThe \`${Ct}\` skill is regenerated per machine and version-stamped per app build, so tracking it causes recurring sync conflicts. It is now git-ignored.`,f=(await a.git.raw([`commit-tree`,o,`-p`,r,`-m`,d])).trim();if(!K9.test(f))return G9.warn({raw:f},`commit-tree returned invalid SHA — aborting untrack`),{kind:`failed`,error:`commit-tree returned invalid SHA`};try{await n.git.raw([`update-ref`,`refs/heads/${t}`,f,r])}catch(e){return G9.info({branch:t,err:J9(e)},`update-ref CAS failed — ref moved, retry next open`),{kind:`skipped`,reason:`ref-race`}}try{await n.git.raw([`reset`,`-q`,f,`--`,...i])}catch(e){G9.info({err:J9(e)},`real-index reset after untrack failed (cosmetic)`)}return G9.info({dirs:i,commitSha:f},`untracked project-skill projection`),{kind:`untracked`,dirs:i,commitSha:f}})}catch(e){return{kind:`failed`,error:J9(e)}}}async function q9(e){let t=[];for(let n of jNe){let r=``;try{r=(await e.git.raw([`ls-files`,`--`,n])).trim()}catch{r=``}r.length>0&&t.push(n)}return t}async function NNe(e){try{let t=(await e.git.raw([`rev-parse`,`--abbrev-ref`,`HEAD`])).trim();return t.length===0||t===`HEAD`?null:t}catch{return null}}async function PNe(e){try{let t=(await e.git.raw([`rev-parse`,`--verify`,`HEAD`])).trim();return K9.test(t)?t:null}catch{return null}}async function FNe(e,t){try{let n=(await e.git.raw([`rev-parse`,`${t}^{tree}`])).trim();return K9.test(n)?n:null}catch{return null}}function INe(e){return B(I(e,`MERGE_HEAD`))||B(I(e,`rebase-merge`))||B(I(e,`rebase-apply`))||B(I(e,`CHERRY_PICK_HEAD`))||B(I(e,`REVERT_HEAD`))}function J9(e){return e instanceof Error?e.message:String(e)}async function LNe(e,t){let n;try{n=_u(t).resolve(e)}catch(e){if(e?.code===`MODULE_NOT_FOUND`)return;throw e}for(let t=F(n),r=0;r<32;r+=1){let n=I(t,`package.json`);if(B(n))try{let t=JSON.parse(await ld(n,`utf-8`));if(t.name===e&&typeof t.version==`string`)return t.version}catch{}let r=F(t);if(r===t)return;t=r}}const RNe=[{regex:/\/Users\/[^/]+\//g,replacement:`~/`},{regex:/\/home\/[^/]+\//g,replacement:`~/`},{regex:/C:\\\\Users\\\\[^\\\\]+\\\\/g,replacement:`~\\`},{regex:/C:\\Users\\[^\\]+\\/g,replacement:`~\\`}];function Y9(e){if(e===void 0)return;let t=e;for(let{regex:e,replacement:n}of RNe)t=t.replace(e,n);return t}function X9(e,t=0,n=new WeakSet){if(t>=5)return{name:`SerializedError.CauseDepthExceeded`,message:`cause chain depth > 5; truncated`};if(typeof e==`object`&&e){if(n.has(e))return{name:`SerializedError.CauseCycle`,message:`cyclic cause; truncated`};n.add(e)}if(e instanceof Error)return{name:e.name,message:Y9(e.message)??``,stack:Y9(e.stack),code:e.code,cause:e.cause===void 0?void 0:X9(e.cause,t+1,n)};if(e==null)return{name:`UnknownError`,message:String(e)};if(typeof e==`string`)return{name:`StringError`,message:Y9(e)??e};if(typeof e==`object`){let r=e;return{name:String(r.name??`ObjectError`),message:Y9(String(r.message??``))??``,stack:Y9(r.stack),code:r.code,cause:r.cause===void 0?void 0:X9(r.cause,t+1,n)}}return{name:`UnknownError`,message:String(e)}}var Z9=class extends Error{constructor(e){super(`File not found: ${e}`),this.filePath=e,this.name=`SingleFileNotFoundError`}},Q9=class extends Error{constructor(e){super(`Not a file: ${e}. \`ok <file>\` opens a single markdown file.`),this.filePath=e,this.name=`SingleFileNotAFileError`}},$9=class extends Error{constructor(e){super(`OpenKnowledge edits markdown files (.md / .mdx): ${e}`),this.filePath=e,this.name=`SingleFileNotMarkdownError`}};function zNe(e){if(!Ux(e))throw new $9(e);let t;try{t=H(R(e))}catch(t){throw t.code===`ENOENT`?new Z9(e):t}if(!Qu(t).isFile())throw new Q9(e);let n=F(t),r=eB(n);if(r){let e=r.rootPath;return{mode:`project`,projectRoot:e,docName:Gx(L(BNe(e),t).split(z).join(`/`)),canonicalFilePath:t}}let i=Cu(t);return{mode:`ephemeral`,canonicalFilePath:t,contentDir:n,singleDocRelPath:i,docName:Gx(i)}}function BNe(e){return R(e,Ds({absPath:Us(`project`,e),sideline:!1,warn:()=>{}}).value.content?.dir??`.`)}function VNe(e){let t=Uu(R(ad(),`ok-ephemeral-`)),n=R(t,`.ok`);return Hu(n,{recursive:!0}),ed(R(n,`config.yml`),`# Ephemeral single-file session (\`ok <file>\`). Throwaway — safe to delete.\ncontent:\n dir: ${JSON.stringify(e)}\n`,`utf-8`),ed(R(n,`.gitignore`),`local/
|
|
2016
2016
|
`,`utf-8`),t}export{g2 as $,Nx as $i,WR as $n,jM as $r,IJ as $t,G7 as A,hw as Ai,bB as An,zP as Ar,IZ as At,a7 as B,K as Bi,jz as Bn,Kfe as Br,BJ as Bt,d9 as C,Ld as Ca,dD as Ci,EB as Cn,XF as Cr,VZ as Ct,K7 as D,KE as Di,MB as Dn,QP as Dr,tve as Dt,U7 as E,Dd as Ea,RE as Ei,wB as En,RF as Er,iZ as Et,Fje as F,xw as Fi,cz as Fn,jP as Fr,GX as Ft,p8 as G,rS as Gi,Mz as Gn,sN as Gr,GJ as Gt,h8 as H,lS as Hi,pz as Hn,jfe as Hr,Ohe as Ht,g7 as I,UC as Ii,Pz as In,kP as Ir,UX as It,o8 as J,Rx as Ji,ez as Jn,tN as Jr,JJ as Jt,d8 as K,oS as Ki,dz as Kn,aN as Kr,khe as Kt,h7 as L,WC as Li,hz as Ln,qfe as Lr,Lhe as Lt,N7 as M,Pw as Mi,vB as Mn,Qfe as Mr,VX as Mt,A7 as N,kw as Ni,eB as Nn,AP as Nr,HX as Nt,V7 as O,Fw as Oi,NB as On,LP as Or,nve as Ot,m7 as P,Aw as Pi,$z as Pn,MP as Pr,WX as Pt,d2 as Q,Ex as Qi,JR as Qn,GM as Qr,FJ as Qt,Cje as R,pw as Ri,mz as Rn,OP as Rr,tY as Rt,P9 as S,Rd as Sa,pD as Si,AW as Sn,eI as Sr,qZ as St,B7 as T,Fd as Ta,qE as Ti,LB as Tn,vme as Tr,aZ as Tt,g8 as U,nS as Ui,Nz as Un,iN as Ur,XJ as Ut,n7 as V,gS as Vi,Ez as Vn,tP as Vr,Ahe as Vt,m8 as W,sS as Wi,Zz as Wn,rN as Wr,WJ as Wt,l2 as X,Ax as Xi,qR as Xn,$M as Xr,YJ as Xt,X6 as Y,kx as Yi,KR as Yn,XM as Yr,qJ as Yt,u2 as Z,jx as Zi,YR as Zn,YM as Zr,KJ as Zt,mNe as _,ph as _a,Oj as _i,OW as _n,lI as _r,KZ as _t,zNe as a,Fx as aa,ade as ai,eK as an,Ime as ar,Yxe as at,N9 as b,vf as ba,Vk as bi,kW as bn,oI as br,WZ as bt,MNe as c,bx as ca,Yue as ci,yK as cn,bI as cr,p0 as ct,TNe as d,lx as da,jue as di,iK as dn,vI as dr,pye as dt,wx as ea,AM as ei,TK as en,FR as er,sSe as et,xNe as f,nx as fa,jj as fi,JG as fn,_I as fr,I$ as ft,hNe as g,mh as ga,kj as gi,DW as gn,cI as gr,UZ as gt,wNe as h,fh as ha,Dj as hi,yW as hn,uI as hr,JZ as ht,VNe as i,Lx as ia,cde as ii,$G as in,OI as ir,Jxe as it,z7 as j,jw as ji,yB as jn,IP as jr,cZ as jt,W7 as k,Lw as ki,AB as kn,RP as kr,RZ as kt,H9 as l,px as la,zj as li,tK as ln,xI as lr,U$ as lt,CNe as m,kie as ma,Aj as mi,WG as mn,yI as mr,$Z as mt,Z9 as n,zx as na,$j as ni,bK as nn,dR as nr,n2 as nt,X9 as o,Ix as oa,sde as oi,ZG as on,TI as or,Xxe as ot,SNe as p,Tse as pa,kue as pi,qG as pn,wme as pr,z$ as pt,l8 as q,tS as qi,$R as qn,oN as qr,ZJ as qt,$9 as r,Sx as ra,Xj as ri,xK as rn,kI as rr,Z0 as rt,LNe as s,Bx as sa,ode as si,nK as sn,CI as sr,G0 as st,Q9 as t,Ox as ta,eM as ti,CK as tn,bR as tr,r2 as tt,ANe as u,dx as ua,Kj as ui,cK as un,SI as ur,x$ as ut,fNe as v,_f as va,Bk as vi,CW as vn,sI as vr,HZ as vt,u9 as w,rf as wa,lD as wi,kB as wn,tI as wr,zZ as wt,M9 as x,sf as xa,ek as xi,xW as xn,$F as xr,_ve as xt,I9 as y,cf as ya,zk as yi,MW as yn,iI as yr,GZ as yt,c7 as z,_S as zi,Fz as zn,DP as zr,$J as zt};
|
|
2017
|
-
//# sourceMappingURL=src-
|
|
2017
|
+
//# sourceMappingURL=src-BnJNsU3L.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,Ns as t,Us as n,W as r,ds as i,g as a,hs as o,js as s,ms as c,v as l,yc as u}from"./src-DMi2O7yV.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,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,It as ae,J as oe,Ji as se,Jn as ce,Jr as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lt as ye,M as be,Mi as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pi as Ie,Pn as Le,Pr as Re,Pt as ze,Q as Be,Qi as Ve,Qn as He,Qr as Ue,Qt as We,R as Ge,Ri as Ke,Rn as qe,Rt as Je,S as Ye,Sa as Xe,Si as Ze,Sn as Qe,Sr as $e,St as et,T as tt,Ti as nt,Tn as rt,Tr as it,Tt as at,U as ot,Ui as st,Un as ct,Ur as lt,Ut as ut,V as dt,Vi as ft,Vn as pt,Vr as mt,Vt as ht,W as gt,Wi as _t,Wn as vt,Wr as yt,Wt as bt,X as xt,Xi as St,Xn as Ct,Xr as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yr as kt,Yt as At,Z as jt,Zi as Mt,Zn as Nt,Zr as Pt,Zt as Ft,_ as It,_a as Lt,_i as Rt,_n as zt,_r as Bt,_t as Vt,a as Ht,aa as Ut,ai as Wt,an as Gt,ar as Kt,at as qt,b as Jt,ba as Yt,bi as Xt,bn as Zt,br as Qt,bt as $t,c as en,ca as tn,ci as nn,cn as rn,cr as an,d as on,da as sn,di as cn,dn as ln,dr as un,ea as dn,ei as fn,en as pn,er as mn,et as hn,f as gn,fa as _n,fi as vn,fn as yn,fr as bn,g as xn,ga as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,ha as On,hi as kn,hn as An,hr as jn,ht as Mn,i as Nn,ia as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,la as Xn,li as Zn,ln as Qn,lr as $n,m as er,ma as tr,mi as nr,mn as rr,mr as ir,mt as ar,n as or,na as sr,ni as cr,nn as lr,nr as ur,nt as dr,o as fr,oa as pr,oi as mr,on as hr,or as gr,ot as _r,p as vr,pa as yr,pi as br,pn as xr,pr as Sr,q as Cr,qi as wr,qn as Tr,qr as Er,qt as Dr,r as Or,ra as kr,ri as Ar,rn as jr,rr as Mr,rt as Nr,s as Pr,sa as Fr,si as Ir,sn as Lr,sr as Rr,st as zr,t as Br,ta as Vr,ti as Hr,tn as Ur,tr as Wr,tt as Gr,u as Kr,ua as qr,ui as Jr,un as Yr,ur as Xr,v as Zr,va as Qr,vi as $r,vn as ei,vr as ti,vt as ni,w as ri,wi as ii,wn as ai,wr as oi,wt as si,x as ci,xa as li,xn as ui,xr as di,xt as fi,y as pi,ya as mi,yi as hi,yn as gi,yr as _i,yt as vi,z as yi,zi as bi,zn as xi,zt as Si}from"./src-C6s1YGEs.mjs";import{C as Ci,E as wi,T as Ti,_ as Ei,b as Di,c as Oi,d as ki,g as Ai,i as ji,l as Mi,m as Ni,n as Pi,p as Fi,s as Ii,t as Li,u as Ri,v as zi,w as Bi,x as Vi,y as Hi}from"./fs-traced-xJfl5Rxd.mjs";import{a as Ui,d as Wi,f as Gi,i as Ki,l as qi,n as Ji,r as Yi,t as Xi,u as Zi}from"./logger-DFxEUjvj.mjs";import{C as Qi,S as $i,_ as ea,a as ta,c as na,d as ra,g as ia,h as aa,i as oa,l as sa,m as ca,n as la,o as ua,p as da,r as fa,s as pa,t as ma,u as ha,v as ga,y as _a}from"./server-lock-BHY1C3dW.mjs";export{tr as AGENT_ID_MAX_LEN,On as AGENT_ID_RE,_ as AGENT_WRITE_ORIGIN,li as AcpPermissionStore,Qr as AcpRegistry,nt as AcpThreadManager,D as AgentFocusBroadcaster,Ze as AgentPresenceBroadcaster,Bn as AgentSessionCapacityError,xe as AgentSessionManager,Mn as AutoStartDisabledError,di as BUNDLE_IDS,$e as BUNDLE_SCOPE,k as BUNDLE_SKILL_NAME,Wr as BacklinkIndex,Q as CC1Broadcaster,t as CC1_CONTRACT_VERSION,An as CONFIG_FILENAME,Ot as CONFLICT_MARKER_RE,lt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,It as ConfigSchema,se as DEFAULT_CHECKPOINT_RETENTION,nn as DEFAULT_EMBEDDINGS_DIMENSIONS,w as DEFAULT_PACK_ID,dt as DocumentDurabilityState,Zn as EMBEDDINGS_API_KEY_ENV,O as ExposureConsentError,mi as FEATURED_AGENT_IDS,Dt as FILE_SYSTEM_WRITER,p as FILE_WATCHER_ORIGIN,cr as FileEmbeddingsBackend,lr as GIT_PREFLIGHT_FAIL_SPAN_NAME,St as GIT_UPSTREAM_WRITER,Xe as GitDirAccessError,In as GitNotAvailableError,Gt as GitTooOldError,En as HOCUSPOCUS_AUTH_REJECTION_REASONS,Vt as HocuspocusAuthRejection,ni as HocuspocusAuthTokenSchema,kt as INSTALLED_AGENTS_SCHEMES,s as LINEAGE_EPOCH_KEY,Ge as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ht as LOG_MD_TEMPLATE,at as MANAGED_RENAME_ORIGIN,L as MAX_ACP_THREADS,Ee as MAX_AGENT_SESSIONS,je as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,Ie as MIN_EVICTABLE_IDLE_MS,hr as MIN_GIT_VERSION,Z as MISSING_OK_CONFIG_MESSAGE,E as MalformedGitPointerError,hn as McpLogger,ot as MissingOkConfigError,re as OBSERVER_SYNC_ORIGIN,wn as OK_OKIGNORE_TEMPLATE,c as ORPHAN_MODES,u as PROTOCOL_VERSION,Xi as PinoLogger,na as ProcessLockCollisionError,Yn as ProjectGitInitError,B as ROLLBACK_ORIGIN,zt as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,Mt as SERVICE_WRITER,Tn as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,te as STARTER_FOLDERS,ut as STARTER_FOLDER_FRONTMATTER_FILENAME,bt as STARTER_PACKS,X as STARTER_PACK_IDS,he as STARTER_TEMPLATES,tt as STATE_MANIFEST_FILENAME,ga as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,We as SeedPrerequisiteError,h as SeedRootDirError,ma as ServerLockCollisionError,Br as SingleFileNotAFileError,or as SingleFileNotFoundError,Or as SingleFileNotMarkdownError,I as StateManifestError,mn as TagIndex,oi as USER_GLOBAL_BUNDLE_IDS,we as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Pe as __resetShowAllWalkStatsForTesting,sa as acquireProcessLock,la as acquireServerLock,ke as acquireUiLock,H as applyAgentMarkdownWrite,Tr as applyExternalChange,Si as applySeed,j as assertCompatibleStateManifest,Lr as assertGitAvailable,U as assertNeverDiskEvent,ii as attachAcpThreadSocket,ar as attachIdleShutdown,Zr as bootServer,Mr as buildAndOpenSkill,ei as buildConfigYmlContent,Et as buildExecResult,ai as buildIngressPolicy,M as buildOkMcpStdioCommand,ti as buildSkillZip,Dr as buildStarterFolderFrontmatterYaml,Ve as buildWipTree,it as bundleSkillMdPath,Ar as canonicalProjectKey,ie as classifyEvents,Li as classifyFsPath,Fn as clearAllEmbeddingsKeys,cn as clearContributors,ue as coercePackId,a as colorFromSeed,f as commitUpstreamImport,dn as commitWip,Vr as commitWipFromTree,rn as compareSemver,Ne as composeEffectiveLinterConfig,qn as composeFrontmatterSchemasConfig,Ct as containsConflictMarkers,ve as contentHash,vn as contributorCount,Fe as countShadowObjects,V as countStaleAgentWipRefs,ne as countWipRefs,Jn as createApiExtension,si as createAssetServeMiddleware,K as createCollaborationHost,mt as createContentFilter,ee as createContentFilterAsync,Wt as createEmbeddingsSecretStore,Nn as createEphemeralProjectDir,ce as createExternalChangeHandler,gn as createFileLogger,yi as createLiveDerivedIndexExtension,Cr as createMcpHttpHandler,wt as createOsProbe,Te as createPersistenceExtension,T as createServer,zn as createServerObserverExtension,bi as createStreamingErrorWriter,Ji as createTestLogger,mr as describeStoredEmbeddingsKey,xn as detectClaudeDesktopPresence,Qn as detectGit,Ae as detectProjectShape,Ln as detectUserSkillHosts,Nr as discoverLockDirs,Ce as discoverMarkdownlintConfig,jr as emitPreflightFailureSpan,xt as encodeDocName,jt as encodeFolderRoute,Be as encodeSkillRoute,Kr as ensureProjectGit,gi as ensureProjectSkillGitignore,S as errorResponse,qe as evictStaleTrackerEntries,b as extractHeadings,Rn as extractOkBinaryPath,ur as extractWikiLinksFromMarkdown,Yr as fallbackPaths,on as findEnclosingGitRoot,De as findEnclosingProjectRoot,Oe as findNativeMarkdownlintFile,vr as flushFileLogger,vi as formatAuthRejectionWire,br as formatContributors,nr as formatContributorsFrom,ye as formatPackRationale,sr as gcCheckpointRefs,Gr as getCurrentMcpLogger,rt as getIngressContext,$r as getLocalDir,er as getLogFilePath,Yi as getLogger,Dn as getLogsDir,_a as getMachineId,Hi as getMeter,Xn as getMetrics,Di as getTracer,qr as handleCollabSocketError,yt as handleSpawnCursor,R as hasForwardingHeaders,ge as hasGcLogLatch,l as iconFromClientName,sn as incrementCollabSocketFilteredError,_n as incrementServerObserverFire,Zt as initContent,kr as initShadowRepo,Vi as initTelemetry,Jt as initToleranceTelemetryWriter,zr as installPrettyZodErrors,Ki as installTestLoggers,Kt as installUserSkill,Se as isAllowedApiOrigin,v as isAllowedWorkspaceHostHeader,st as isConfigDoc,$t as isHocuspocusAuthRejectionReason,N as isHostAdmitted,At as isKnownPackId,_t as isLinkIndexExcludedDoc,Vn as isLoopbackAddress,q as isManagedArtifactDoc,Me as isOriginAdmitted,o as isOrphanMode,_e as isPairedWriteOrigin,Y as isPathWithinDir,Kn as isPeerAdmitted,$i as isProcessAlive,Le as isProjectRoot,fe as isReservedForUserTree,xi as isSelfWrite,wr as isSystemDoc,ci as isToleranceTelemetryEnabled,Qi as isValidLockPid,C as lastKnownHash,Pn as listRescueCheckpoints,Tt as listStarterPacks,Yt as loadCustomAgents,be as loadPrincipal,ha as lockBaseUrl,ra as lockFilePath,Ui as loggerFactory,qi as logsCurrentPath,Zi as logsPreviousPath,Ir as makeLazyEmbeddingsKeyStore,fa as markServerLockDraining,gt as mountMcpAndApi,Pi as normalizeFsPath,z as originGitHubHost,ui as packageVersionMajorMinor,fi as parseAuthRejectionWire,ln as parseGitVersion,et as parseHocuspocusAuthToken,de as parseKeepaliveConnectionId,pt as pathToDocName,Je as planSeed,Ht as prepareSingleFileOpen,qt as processCommand,_r as processUsage,Rr as readAllTargets,an as readBundleDecision,Re as readOwnNativeRules,da as readProcessLock,ca as readProcessLockDetailed,x as readProjectHeadState,Hr as readProjectLocalSemanticConfig,oa as readServerLock,$n as readServerPackageVersion,Xr as readSkillInstallStateSnapshot,Wn as readStateManifest,un as readTargetRecordedAt,bn as readTargetVersion,ze as readUiLock,Nt as reconcile,kn as recordContributor,Bt as recordSkillInstallEvent,oe as registerAllTools,$ as registerWrite,aa as releaseProcessLock,ta as releaseServerLock,G as releaseUiLock,ct as removeLastKnownHash,gr as reportSkillInstall,yr as resetMetrics,r as resolveBundleEnabled,_i as resolveBundledSkillDir,hi as resolveContentDir,me as resolveCursorBinaryDefault,Er as resolveCursorSpawnInvocation,y as resolveEffectiveLinterConfig,Jr as resolveEmbeddingsCredential,Xt as resolveLockDir,Hn as resolveNativeConfigForDoc,W as resolveNativeMarkdownlintConfig,Ft as resolvePack,Pr as resolvePackageVersion,jn as resolveSkillInstallReportSettings,d as resolveUiInfo,Cn as restoreContributors,pi as restoreLifecycleFromConflictsJson,m as rewriteMarkdownLinksForDocumentRename,fn as rewriteWikiLinksForDocumentRename,yn as runAuthReposSubprocess,xr as runAuthStatusSubprocess,pn as runCloneSubprocess,rr as runDeviceFlowSubprocess,dr as runWithMcpLogger,Ue as safeContentPath,Un as safeSubdir,Ut as safetyCheckpoint,Gn as sanitizeClientName,pr as saveInMemoryCheckpoint,Fr as saveVersion,A as seedBasenameIndex,fr as serializeError,Ci as setActiveSpanAttributes,Ke as setupServerObservers,tn as shadowGit,Bi as shutdownTelemetry,Wi as spansCurrentPath,Gi as spansPreviousPath,le as spawnDetached,He as splitMarkdownBlocks,vt as startWatcher,ft as streamingProblemEvent,Rt as swapContributors,Ye as teardownToleranceTelemetryWriter,Sn as toBroadcasterKey,ji as tracedAppendFileSync,Ii as tracedLinkSync,Oi as tracedMkdir,Mi as tracedMkdirSync,Ri as tracedRename,ki as tracedRenameSync,Fi as tracedRmSync,Ni as tracedRmdirSync,Ai as tracedUnlinkSync,Ei as tracedWriteFile,zi as tracedWriteFileSync,ri as trustSystemCertificates,en as untrackTrackedProjectSkillProjection,J as updateLastKnownHash,ia as updateProcessLockPort,ua as updateServerLockPort,ae as updateUiLockPort,Lt as validateAgentId,Ur as validateCloneInputs,Qt as validateSkillZip,pa as waitForServerLockDrain,Pt as withHiddenWindowsConsole,Ti as withSpan,wi as withSpanSync,Sr as writeBundleDecision,P as writeMarkdownlintRule,Qe as writeRootGitignoreForNewRepo,g as writeStateManifest,ir as writeTargetVersion,pe as writeTracker};
|
|
1
|
+
import{B as e,Ns as t,Us as n,W as r,ds as i,g as a,hs as o,js as s,ms as c,v as l,yc as u}from"./src-DMi2O7yV.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,Ei as L,En as R,Er as z,Et as B,F as V,Fi as H,Fn as U,Fr as W,Ft as G,G as K,Gi as q,Gn as J,Gr as Y,Gt as X,H as Z,Hi as Q,Hn as $,Hr as ee,Ht as te,I as ne,Ii as re,In as ie,It as ae,J as oe,Ji as se,Jn as ce,Jr as le,Jt as ue,K as de,Ki as fe,Kn as pe,Kr as me,Kt as he,L as ge,Li as _e,Ln as ve,Lt as ye,M as be,Mi as xe,Mn as Se,Mr as Ce,Mt as we,N as Te,Ni as Ee,Nn as De,Nr as Oe,Nt as ke,O as Ae,Oi as je,On as Me,Or as Ne,Ot as Pe,P as Fe,Pi as Ie,Pn as Le,Pr as Re,Pt as ze,Q as Be,Qi as Ve,Qn as He,Qr as Ue,Qt as We,R as Ge,Ri as Ke,Rn as qe,Rt as Je,S as Ye,Sa as Xe,Si as Ze,Sn as Qe,Sr as $e,St as et,T as tt,Ti as nt,Tn as rt,Tr as it,Tt as at,U as ot,Ui as st,Un as ct,Ur as lt,Ut as ut,V as dt,Vi as ft,Vn as pt,Vr as mt,Vt as ht,W as gt,Wi as _t,Wn as vt,Wr as yt,Wt as bt,X as xt,Xi as St,Xn as Ct,Xr as wt,Xt as Tt,Y as Et,Yi as Dt,Yn as Ot,Yr as kt,Yt as At,Z as jt,Zi as Mt,Zn as Nt,Zr as Pt,Zt as Ft,_ as It,_a as Lt,_i as Rt,_n as zt,_r as Bt,_t as Vt,a as Ht,aa as Ut,ai as Wt,an as Gt,ar as Kt,at as qt,b as Jt,ba as Yt,bi as Xt,bn as Zt,br as Qt,bt as $t,c as en,ca as tn,ci as nn,cn as rn,cr as an,d as on,da as sn,di as cn,dn as ln,dr as un,ea as dn,ei as fn,en as pn,er as mn,et as hn,f as gn,fa as _n,fi as vn,fn as yn,fr as bn,g as xn,ga as Sn,gi as Cn,gn as wn,gr as Tn,gt as En,h as Dn,ha as On,hi as kn,hn as An,hr as jn,ht as Mn,i as Nn,ia as Pn,ii as Fn,in as In,ir as Ln,it as Rn,j as zn,ji as Bn,jn as Vn,jr as Hn,jt as Un,k as Wn,ki as Gn,kn as Kn,kr as qn,kt as Jn,l as Yn,la as Xn,li as Zn,ln as Qn,lr as $n,m as er,ma as tr,mi as nr,mn as rr,mr as ir,mt as ar,n as or,na as sr,ni as cr,nn as lr,nr as ur,nt as dr,o as fr,oa as pr,oi as mr,on as hr,or as gr,ot as _r,p as vr,pa as yr,pi as br,pn as xr,pr as Sr,q as Cr,qi as wr,qn as Tr,qr as Er,qt as Dr,r as Or,ra as kr,ri as Ar,rn as jr,rr as Mr,rt as Nr,s as Pr,sa as Fr,si as Ir,sn as Lr,sr as Rr,st as zr,t as Br,ta as Vr,ti as Hr,tn as Ur,tr as Wr,tt as Gr,u as Kr,ua as qr,ui as Jr,un as Yr,ur as Xr,v as Zr,va as Qr,vi as $r,vn as ei,vr as ti,vt as ni,w as ri,wi as ii,wn as ai,wr as oi,wt as si,x as ci,xa as li,xn as ui,xr as di,xt as fi,y as pi,ya as mi,yi as hi,yn as gi,yr as _i,yt as vi,z as yi,zi as bi,zn as xi,zt as Si}from"./src-BnJNsU3L.mjs";import{C as Ci,E as wi,T as Ti,_ as Ei,b as Di,c as Oi,d as ki,g as Ai,i as ji,l as Mi,m as Ni,n as Pi,p as Fi,s as Ii,t as Li,u as Ri,v as zi,w as Bi,x as Vi,y as Hi}from"./fs-traced-xJfl5Rxd.mjs";import{a as Ui,d as Wi,f as Gi,i as Ki,l as qi,n as Ji,r as Yi,t as Xi,u as Zi}from"./logger-DFxEUjvj.mjs";import{C as Qi,S as $i,_ as ea,a as ta,c as na,d as ra,g as ia,h as aa,i as oa,l as sa,m as ca,n as la,o as ua,p as da,r as fa,s as pa,t as ma,u as ha,v as ga,y as _a}from"./server-lock-BHY1C3dW.mjs";export{tr as AGENT_ID_MAX_LEN,On as AGENT_ID_RE,_ as AGENT_WRITE_ORIGIN,li as AcpPermissionStore,Qr as AcpRegistry,nt as AcpThreadManager,D as AgentFocusBroadcaster,Ze as AgentPresenceBroadcaster,Bn as AgentSessionCapacityError,xe as AgentSessionManager,Mn as AutoStartDisabledError,di as BUNDLE_IDS,$e as BUNDLE_SCOPE,k as BUNDLE_SKILL_NAME,Wr as BacklinkIndex,Q as CC1Broadcaster,t as CC1_CONTRACT_VERSION,An as CONFIG_FILENAME,Ot as CONFLICT_MARKER_RE,lt as CURSOR_BUNDLE_PATHS_BY_PLATFORM,It as ConfigSchema,se as DEFAULT_CHECKPOINT_RETENTION,nn as DEFAULT_EMBEDDINGS_DIMENSIONS,w as DEFAULT_PACK_ID,dt as DocumentDurabilityState,Zn as EMBEDDINGS_API_KEY_ENV,O as ExposureConsentError,mi as FEATURED_AGENT_IDS,Dt as FILE_SYSTEM_WRITER,p as FILE_WATCHER_ORIGIN,cr as FileEmbeddingsBackend,lr as GIT_PREFLIGHT_FAIL_SPAN_NAME,St as GIT_UPSTREAM_WRITER,Xe as GitDirAccessError,In as GitNotAvailableError,Gt as GitTooOldError,En as HOCUSPOCUS_AUTH_REJECTION_REASONS,Vt as HocuspocusAuthRejection,ni as HocuspocusAuthTokenSchema,kt as INSTALLED_AGENTS_SCHEMES,s as LINEAGE_EPOCH_KEY,Ge as LIVE_DERIVED_INDEX_DEBOUNCE_MS,ht as LOG_MD_TEMPLATE,at as MANAGED_RENAME_ORIGIN,L as MAX_ACP_THREADS,Ee as MAX_AGENT_SESSIONS,je as MCP_CONNECTION_ID_HEADER,i as MCP_SERVER_NAME,Ie as MIN_EVICTABLE_IDLE_MS,hr as MIN_GIT_VERSION,Z as MISSING_OK_CONFIG_MESSAGE,E as MalformedGitPointerError,hn as McpLogger,ot as MissingOkConfigError,re as OBSERVER_SYNC_ORIGIN,wn as OK_OKIGNORE_TEMPLATE,c as ORPHAN_MODES,u as PROTOCOL_VERSION,Xi as PinoLogger,na as ProcessLockCollisionError,Yn as ProjectGitInitError,B as ROLLBACK_ORIGIN,zt as ROOT_GITIGNORE_TEMPLATE,ea as RUNTIME_VERSION,Mt as SERVICE_WRITER,Tn as SKILL_INSTALL_EVENTS_FILE_REL,e as SKILL_STATE_TARGETS,te as STARTER_FOLDERS,ut as STARTER_FOLDER_FRONTMATTER_FILENAME,bt as STARTER_PACKS,X as STARTER_PACK_IDS,he as STARTER_TEMPLATES,tt as STATE_MANIFEST_FILENAME,ga as STATE_SCHEMA_VERSION,n as SYSTEM_DOC_NAME,We as SeedPrerequisiteError,h as SeedRootDirError,ma as ServerLockCollisionError,Br as SingleFileNotAFileError,or as SingleFileNotFoundError,Or as SingleFileNotMarkdownError,I as StateManifestError,mn as TagIndex,oi as USER_GLOBAL_BUNDLE_IDS,we as UiLockCollisionError,F as __getShowAllWalkStatsForTesting,Pe as __resetShowAllWalkStatsForTesting,sa as acquireProcessLock,la as acquireServerLock,ke as acquireUiLock,H as applyAgentMarkdownWrite,Tr as applyExternalChange,Si as applySeed,j as assertCompatibleStateManifest,Lr as assertGitAvailable,U as assertNeverDiskEvent,ii as attachAcpThreadSocket,ar as attachIdleShutdown,Zr as bootServer,Mr as buildAndOpenSkill,ei as buildConfigYmlContent,Et as buildExecResult,ai as buildIngressPolicy,M as buildOkMcpStdioCommand,ti as buildSkillZip,Dr as buildStarterFolderFrontmatterYaml,Ve as buildWipTree,it as bundleSkillMdPath,Ar as canonicalProjectKey,ie as classifyEvents,Li as classifyFsPath,Fn as clearAllEmbeddingsKeys,cn as clearContributors,ue as coercePackId,a as colorFromSeed,f as commitUpstreamImport,dn as commitWip,Vr as commitWipFromTree,rn as compareSemver,Ne as composeEffectiveLinterConfig,qn as composeFrontmatterSchemasConfig,Ct as containsConflictMarkers,ve as contentHash,vn as contributorCount,Fe as countShadowObjects,V as countStaleAgentWipRefs,ne as countWipRefs,Jn as createApiExtension,si as createAssetServeMiddleware,K as createCollaborationHost,mt as createContentFilter,ee as createContentFilterAsync,Wt as createEmbeddingsSecretStore,Nn as createEphemeralProjectDir,ce as createExternalChangeHandler,gn as createFileLogger,yi as createLiveDerivedIndexExtension,Cr as createMcpHttpHandler,wt as createOsProbe,Te as createPersistenceExtension,T as createServer,zn as createServerObserverExtension,bi as createStreamingErrorWriter,Ji as createTestLogger,mr as describeStoredEmbeddingsKey,xn as detectClaudeDesktopPresence,Qn as detectGit,Ae as detectProjectShape,Ln as detectUserSkillHosts,Nr as discoverLockDirs,Ce as discoverMarkdownlintConfig,jr as emitPreflightFailureSpan,xt as encodeDocName,jt as encodeFolderRoute,Be as encodeSkillRoute,Kr as ensureProjectGit,gi as ensureProjectSkillGitignore,S as errorResponse,qe as evictStaleTrackerEntries,b as extractHeadings,Rn as extractOkBinaryPath,ur as extractWikiLinksFromMarkdown,Yr as fallbackPaths,on as findEnclosingGitRoot,De as findEnclosingProjectRoot,Oe as findNativeMarkdownlintFile,vr as flushFileLogger,vi as formatAuthRejectionWire,br as formatContributors,nr as formatContributorsFrom,ye as formatPackRationale,sr as gcCheckpointRefs,Gr as getCurrentMcpLogger,rt as getIngressContext,$r as getLocalDir,er as getLogFilePath,Yi as getLogger,Dn as getLogsDir,_a as getMachineId,Hi as getMeter,Xn as getMetrics,Di as getTracer,qr as handleCollabSocketError,yt as handleSpawnCursor,R as hasForwardingHeaders,ge as hasGcLogLatch,l as iconFromClientName,sn as incrementCollabSocketFilteredError,_n as incrementServerObserverFire,Zt as initContent,kr as initShadowRepo,Vi as initTelemetry,Jt as initToleranceTelemetryWriter,zr as installPrettyZodErrors,Ki as installTestLoggers,Kt as installUserSkill,Se as isAllowedApiOrigin,v as isAllowedWorkspaceHostHeader,st as isConfigDoc,$t as isHocuspocusAuthRejectionReason,N as isHostAdmitted,At as isKnownPackId,_t as isLinkIndexExcludedDoc,Vn as isLoopbackAddress,q as isManagedArtifactDoc,Me as isOriginAdmitted,o as isOrphanMode,_e as isPairedWriteOrigin,Y as isPathWithinDir,Kn as isPeerAdmitted,$i as isProcessAlive,Le as isProjectRoot,fe as isReservedForUserTree,xi as isSelfWrite,wr as isSystemDoc,ci as isToleranceTelemetryEnabled,Qi as isValidLockPid,C as lastKnownHash,Pn as listRescueCheckpoints,Tt as listStarterPacks,Yt as loadCustomAgents,be as loadPrincipal,ha as lockBaseUrl,ra as lockFilePath,Ui as loggerFactory,qi as logsCurrentPath,Zi as logsPreviousPath,Ir as makeLazyEmbeddingsKeyStore,fa as markServerLockDraining,gt as mountMcpAndApi,Pi as normalizeFsPath,z as originGitHubHost,ui as packageVersionMajorMinor,fi as parseAuthRejectionWire,ln as parseGitVersion,et as parseHocuspocusAuthToken,de as parseKeepaliveConnectionId,pt as pathToDocName,Je as planSeed,Ht as prepareSingleFileOpen,qt as processCommand,_r as processUsage,Rr as readAllTargets,an as readBundleDecision,Re as readOwnNativeRules,da as readProcessLock,ca as readProcessLockDetailed,x as readProjectHeadState,Hr as readProjectLocalSemanticConfig,oa as readServerLock,$n as readServerPackageVersion,Xr as readSkillInstallStateSnapshot,Wn as readStateManifest,un as readTargetRecordedAt,bn as readTargetVersion,ze as readUiLock,Nt as reconcile,kn as recordContributor,Bt as recordSkillInstallEvent,oe as registerAllTools,$ as registerWrite,aa as releaseProcessLock,ta as releaseServerLock,G as releaseUiLock,ct as removeLastKnownHash,gr as reportSkillInstall,yr as resetMetrics,r as resolveBundleEnabled,_i as resolveBundledSkillDir,hi as resolveContentDir,me as resolveCursorBinaryDefault,Er as resolveCursorSpawnInvocation,y as resolveEffectiveLinterConfig,Jr as resolveEmbeddingsCredential,Xt as resolveLockDir,Hn as resolveNativeConfigForDoc,W as resolveNativeMarkdownlintConfig,Ft as resolvePack,Pr as resolvePackageVersion,jn as resolveSkillInstallReportSettings,d as resolveUiInfo,Cn as restoreContributors,pi as restoreLifecycleFromConflictsJson,m as rewriteMarkdownLinksForDocumentRename,fn as rewriteWikiLinksForDocumentRename,yn as runAuthReposSubprocess,xr as runAuthStatusSubprocess,pn as runCloneSubprocess,rr as runDeviceFlowSubprocess,dr as runWithMcpLogger,Ue as safeContentPath,Un as safeSubdir,Ut as safetyCheckpoint,Gn as sanitizeClientName,pr as saveInMemoryCheckpoint,Fr as saveVersion,A as seedBasenameIndex,fr as serializeError,Ci as setActiveSpanAttributes,Ke as setupServerObservers,tn as shadowGit,Bi as shutdownTelemetry,Wi as spansCurrentPath,Gi as spansPreviousPath,le as spawnDetached,He as splitMarkdownBlocks,vt as startWatcher,ft as streamingProblemEvent,Rt as swapContributors,Ye as teardownToleranceTelemetryWriter,Sn as toBroadcasterKey,ji as tracedAppendFileSync,Ii as tracedLinkSync,Oi as tracedMkdir,Mi as tracedMkdirSync,Ri as tracedRename,ki as tracedRenameSync,Fi as tracedRmSync,Ni as tracedRmdirSync,Ai as tracedUnlinkSync,Ei as tracedWriteFile,zi as tracedWriteFileSync,ri as trustSystemCertificates,en as untrackTrackedProjectSkillProjection,J as updateLastKnownHash,ia as updateProcessLockPort,ua as updateServerLockPort,ae as updateUiLockPort,Lt as validateAgentId,Ur as validateCloneInputs,Qt as validateSkillZip,pa as waitForServerLockDrain,Pt as withHiddenWindowsConsole,Ti as withSpan,wi as withSpanSync,Sr as writeBundleDecision,P as writeMarkdownlintRule,Qe as writeRootGitignoreForNewRepo,g as writeStateManifest,ir as writeTargetVersion,pe as writeTracker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{T as e,_ as t,m as n,n as r}from"./start-DA0DLWF1.mjs";export{r as bootStartServer,n as resolveBundledReactShellDir,t as resolveHost,e as startCommand};
|