@inkeep/open-knowledge 0.86.13-beta.8 → 0.86.13-beta.9
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/assets/skills/project/references/linking.md +1 -1
- package/dist/cli.mjs +60 -60
- package/dist/constants-MkX1_7dG.mjs +1 -0
- package/dist/{dist-CUHyT8Po.mjs → dist-B2mNPHPS.mjs} +1 -1
- package/dist/{dist-jVEVXcLW.mjs → dist-v2lkJBLz.mjs} +494 -493
- package/dist/index.mjs +9 -9
- package/dist/{init-kdH152Ks.mjs → init-DcmVBoE-.mjs} +33 -33
- package/dist/init-Udt9RQTb.mjs +1 -0
- package/dist/{launch-json-removal-DfnXNgcq.mjs → launch-json-removal-CHhPsbmP.mjs} +1 -1
- package/dist/{loader-BAPBaCdj.mjs → loader-D8aRCnDL.mjs} +1 -1
- package/dist/loader-MSLOcQCZ.mjs +1 -0
- package/dist/{md-manager-BGnqyqi1-BZjgceH4.mjs → md-manager-BGnqyqi1-C2aCFGjW.mjs} +106 -106
- package/dist/{open-browser-4-JUxTJq.mjs → open-browser-Ccrfb4Zg.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/{preview-S7YFOnEc.mjs → preview-BJ6gs2RH.mjs} +1 -1
- package/dist/preview-CntWf8G9.mjs +1 -0
- package/dist/public/assets/{AccountSection-By8eO4DF.js → AccountSection-DtjsHl4P.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-DXsf7rkL.js → ActivityModeContent-ue0cjhAi.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-C9-ztZw_.js → AddPropertiesButton-Bpz_-y_I.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-6LWBfRF0.js → AgentDiffPane-DieBkA8J.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-CjwmogoS.js → AttachmentsSection-D0ANkE-3.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-DzNQgYlQ.js → CodeMirrorPropInput-Dkw0G_gY.js} +4 -4
- package/dist/public/assets/{ContentRulesSection-BT2fCLNL.js → ContentRulesSection-DrL9S92F.js} +1 -1
- package/dist/public/assets/{DocumentContext-Db80U3dt.js → DocumentContext-BT4R__b_.js} +28 -28
- package/dist/public/assets/{EditorModeToggle-DF54OEB_.js → EditorModeToggle-BrSFayGL.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-BCE8VhOn.js → ExcalidrawDocEditor-Cw7cxWTm.js} +1 -1
- package/dist/public/assets/FeedbackForm-Bqmfw-XS.js +1 -0
- package/dist/public/assets/{GraphPanel-BZ86oMzh.js → GraphPanel-Bq6fUIBW.js} +1 -1
- package/dist/public/assets/{ImageAttachments-DA_IO7l-.js → ImageAttachments-BkNRauWd.js} +1 -1
- package/dist/public/assets/{ImportSkillDialog-iNvdKf3A.js → ImportSkillDialog-Cqcp5gZh.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-DJJDT9tt.js → LinkPreviewsSection-D7bkvkE6.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-Bqtg6Wo1.js → LintConfigEditor-B86O_7x_.js} +1 -1
- package/dist/public/assets/{LintingSection-Cgt0cds5.js → LintingSection-BokrC8-Q.js} +1 -1
- package/dist/public/assets/{ManagedArtifactProperties-Bz4exizS.js → ManagedArtifactProperties-XJly8z5W.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-yyVotSha.js +1 -0
- package/dist/public/assets/{MermaidDocEditor-DN2R0mvw.js → MermaidDocEditor-BYZqgvF7.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-C65GEQs_.js → NetworkAccessSection-CVAEH3yW.js} +1 -1
- package/dist/public/assets/{OkignoreSection-CB1scSj_.js → OkignoreSection-GTDGySNc.js} +1 -1
- package/dist/public/assets/{PageListContext-DhMqc0Dx.js → PageListContext-HSyJOlMQ.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-BwqAwXVj.js → PropertyDisplayRow-DvzKSJ4l.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-CK-eGzTy.js → PublishToGitHubDialog-CncGO5IH.js} +1 -1
- package/dist/public/assets/{ReportBugDialogBody-tgBrnYBX.js → ReportBugDialogBody-C3o-b5FB.js} +1 -1
- package/dist/public/assets/{ReportBugMenuTrigger-CxTQeLcC.js → ReportBugMenuTrigger-BSic8aEj.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-92Y3R-gV.js → SchemaConfigEditor-XhXJlVUd.js} +1 -1
- package/dist/public/assets/{SearchSection-D1TBVHyq.js → SearchSection-C2fJ-AZD.js} +1 -1
- package/dist/public/assets/{SessionsHost-CXSwHd_R.js → SessionsHost-w8sD1wRy.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-BlwAeg8V.js → SettingsDialogBody-CptWw-8n.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-V3V9l5_l.js → ShareReceiveMissDialog-BqbonvaU.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-BIwWYubn.js → SkillToolbarControls-PlEcYJis.js} +1 -1
- package/dist/public/assets/{SourceEditor-BaYDGvRA.js → SourceEditor-CspQKnvE.js} +1 -1
- package/dist/public/assets/{SyncSection-BZtJ8qBB.js → SyncSection-az1Jic0z.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-DWP0pdU-.js → SyncStatusBadge-oD2nm86o.js} +1 -1
- package/dist/public/assets/{TerminalPanel-BfnrGC_7.js → TerminalPanel-C-9jJEyf.js} +1 -1
- package/dist/public/assets/{TerminalSection-hk0zu5zG.js → TerminalSection-Bf1m8ylg.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-lrQ93TuF.js → TerminalWindowApp-B1e5eVxf.js} +1 -1
- package/dist/public/assets/{TextDocEditor-CtVCY0Jr.js → TextDocEditor--crQL7j8.js} +1 -1
- package/dist/public/assets/{ThreadView-CCU9GEGb.js → ThreadView-DuI0ePSb.js} +3 -3
- package/dist/public/assets/{TimelineDiffPane-9rHxONpH.js → TimelineDiffPane-CGC7pH5m.js} +1 -1
- package/dist/public/assets/{client-version-LCIbDwjv.js → client-version-o0-e6Xg8.js} +1 -1
- package/dist/public/assets/{comment-chips-BL9CA_7r.js → comment-chips-BYzSWjE3.js} +3 -3
- package/dist/public/assets/{config-provider-C3qfGKpJ.js → config-provider-BcgiYSim.js} +1 -1
- package/dist/public/assets/{doc-undo-manager-CLUlSazH.js → doc-undo-manager-B-Erku0G.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-CW5EohSW.js → file-tree-adapter-D27t3A4R.js} +1 -1
- package/dist/public/assets/globals-G6Xf2xYI.css +1 -0
- package/dist/public/assets/index-DGrnzC_B.js +2205 -0
- package/dist/public/assets/{lint-plugins-Gc193-uk.js → lint-plugins-yQ5R3Dg-.js} +1 -1
- package/dist/public/assets/navigation-targets-pcYc32Il.js +1 -0
- package/dist/public/assets/{page-list-cache-B9RqU_KB.js → page-list-cache-C-bM1SMu.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-CBSAFtzU.js → pending-receive-nav-store-BV9hiWqU.js} +1 -1
- package/dist/public/assets/{preferred-session-events-ZmfH8TC-.js → preferred-session-events-CnOr_7vC.js} +1 -1
- package/dist/public/assets/progress-CIQy-NPJ.js +10 -0
- package/dist/public/assets/{selection-context-DLM2xYX3.js → selection-context-CP5ebTKT.js} +1 -1
- package/dist/public/assets/{src-B6V0x6iY.js → src-BUcEmKCH.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-OCgrT_rG.js → target-navigation-intent-B9dIW1Bq.js} +1 -1
- package/dist/public/assets/{telemetry-impl-EfUmLz7w.js → telemetry-impl-Bou1hrP6.js} +1 -1
- package/dist/public/assets/{telemetry-startup-B098Rfya.js → telemetry-startup-tSXZexaZ.js} +1 -1
- package/dist/public/assets/typing-burst-detector-adZ2R93j.js +8 -0
- package/dist/public/assets/{uninstall-BhKucRvy.js → uninstall-BNoyrj3Z.js} +1 -1
- package/dist/public/assets/{use-activity-panel-BXxBc9js.js → use-activity-panel-B0NYKsaf.js} +1 -1
- package/dist/public/assets/{use-installed-clis-DoWN-tVr.js → use-installed-clis-BqTMhT_v.js} +2 -2
- package/dist/public/assets/{use-open-skill-D4CHLLCX.js → use-open-skill-B7ZDbwPM.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-CC9zzjLB.js → use-terminal-enabled-MD4VMEe5.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-CYAX4sjQ.js → use-timeline-entry-diff-DBiVVCYO.js} +2 -2
- package/dist/public/index.html +28 -28
- package/dist/public/uninstall.html +3 -3
- package/dist/registry-probes-Bi3J6EAt.mjs +17 -0
- package/dist/{removal-file-path-U4VI8Y6X.mjs → removal-file-path-Ca9-pX6Q.mjs} +1 -1
- package/dist/{repair-launch-json-CVn0L03H.mjs → repair-launch-json-CwPWeO2c.mjs} +1 -1
- package/dist/{repair-mcp-configs-CNMFjBnO.mjs → repair-mcp-configs-DNzXqCJ8.mjs} +1 -1
- package/dist/src-C63FVPx1.mjs +1 -0
- package/dist/src-DgPsVo-K.mjs +16 -0
- package/dist/{start-CloYBm1u.mjs → start-Bd1cuWOs.mjs} +3 -3
- package/dist/start-DqnTaf73.mjs +1 -0
- package/package.json +4 -4
- package/dist/constants-DsqstLHH.mjs +0 -1
- package/dist/init-Cazf_ig6.mjs +0 -1
- package/dist/loader-55F_2Z6p.mjs +0 -1
- package/dist/preview-Cf3plc2s.mjs +0 -1
- package/dist/public/assets/FeedbackForm-BwnVqBbq.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-NyM5UGrR.js +0 -1
- package/dist/public/assets/globals-BddzEyvs.css +0 -1
- package/dist/public/assets/index-DR4V3jNo.js +0 -2205
- package/dist/public/assets/navigation-targets-CcY2FHJZ.js +0 -1
- package/dist/public/assets/progress-CY6HiIpq.js +0 -10
- package/dist/public/assets/typing-burst-detector-CTTymTnu.js +0 -8
- package/dist/registry-probes--fuRXE7y.mjs +0 -17
- package/dist/src-CQO5GchD.mjs +0 -1
- package/dist/src-oPFH8u4O.mjs +0 -16
- package/dist/start-BND4jpTX.mjs +0 -1
- /package/dist/public/assets/{globals-BfTv_Hnc.js → globals-aghZx9Sb.js} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-DPpTSio4.mjs";import"./libesm-CSMdpGMF.mjs";import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import"./chunk-5QMZ5MUS-B37CnsNb.mjs";import"./chunk-A5O5YHGN-2_dxLAd1.mjs";import"./chunk-24IMIIXA-CZ-UxWg_.mjs";import{createRequire as a}from"node:module";import{execFile as o,execFileSync as s,execSync as c,spawnSync as l}from"node:child_process";import{access as u,accessSync as d,closeSync as f,constants as p,cpSync as m,createWriteStream as h,existsSync as g,lstatSync as _,mkdirSync as v,mkdtempSync as y,openSync as b,readFile as x,readFileSync as S,readSync as C,readdirSync as w,readlinkSync as T,realpathSync as E,renameSync as D,rmSync as O,rmdirSync as ee,statSync as te,unlinkSync as ne,writeFileSync as re}from"node:fs";import ie,{basename as ae,dirname as k,extname as oe,isAbsolute as A,join as j,normalize as se,posix as ce,relative as M,resolve as N,sep as le,win32 as ue}from"node:path";import de from"node:process";import{fileURLToPath as fe,fileURLToPath as P}from"node:url";import{EOL as pe,arch as me,availableParallelism as he,freemem as ge,homedir as _e,hostname as ve,platform as ye,release as be,tmpdir as xe,totalmem as Se,type as Ce,uptime as we}from"node:os";import{
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-DPpTSio4.mjs";import"./libesm-CSMdpGMF.mjs";import"./chunk-B74TABJS-DAm9lxFL.mjs";import"./chunk-R6VWJ2ZL-Cu1kOJ3f.mjs";import"./chunk-CWQS3NFK-Dma10iZG.mjs";import"./chunk-DXB73IDG-MLBj3lvC.mjs";import"./chunk-5QMZ5MUS-B37CnsNb.mjs";import"./chunk-A5O5YHGN-2_dxLAd1.mjs";import"./chunk-24IMIIXA-CZ-UxWg_.mjs";import{createRequire as a}from"node:module";import{execFile as o,execFileSync as s,execSync as c,spawnSync as l}from"node:child_process";import{access as u,accessSync as d,closeSync as f,constants as p,cpSync as m,createWriteStream as h,existsSync as g,lstatSync as _,mkdirSync as v,mkdtempSync as y,openSync as b,readFile as x,readFileSync as S,readSync as C,readdirSync as w,readlinkSync as T,realpathSync as E,renameSync as D,rmSync as O,rmdirSync as ee,statSync as te,unlinkSync as ne,writeFileSync as re}from"node:fs";import ie,{basename as ae,dirname as k,extname as oe,isAbsolute as A,join as j,normalize as se,posix as ce,relative as M,resolve as N,sep as le,win32 as ue}from"node:path";import de from"node:process";import{fileURLToPath as fe,fileURLToPath as P}from"node:url";import{EOL as pe,arch as me,availableParallelism as he,freemem as ge,homedir as _e,hostname as ve,platform as ye,release as be,tmpdir as xe,totalmem as Se,type as Ce,uptime as we}from"node:os";import{createHash as Te,randomUUID as Ee}from"node:crypto";import{mkdir as De,readFile as Oe,readdir as ke,realpath as Ae,rename as je,stat as Me,writeFile as Ne}from"node:fs/promises";import{isDeepStrictEqual as Pe,promisify as Fe}from"node:util";import{Readable as Ie,Writable as Le}from"node:stream";import Re from"crypto";import"node:events";import"node:worker_threads";import"yjs";import{Readable as ze}from"stream";import{spawn as Be}from"child_process";import{setTimeout as Ve}from"node:timers/promises";import{AsyncLocalStorage as He}from"node:async_hooks";import"node:stream/promises";import{Http2ServerRequest as Ue}from"node:http2";const We=[`/opt/homebrew/bin/gh`,`/usr/local/bin/gh`,`/opt/local/bin/gh`,`/snap/bin/gh`,`/usr/bin/gh`],Ge={encoding:`utf-8`,stdio:[`ignore`,`pipe`,`pipe`],timeout:5e3,windowsHide:!0};function Ke(e,t={}){let{login:n}=t,r=t._exec??s,i=qe(t._fileExists??g),a=e?[`--hostname`,e]:[];if(n){let e=Je(r,i,[`auth`,`token`,...a,`--user`,n]);if(e)return{available:!0,token:e,resolvedLogin:n,fallback:!1}}let o=Je(r,i,[`auth`,`token`,...a]);return o?n?{available:!0,token:o,fallback:!0}:{available:!0,token:o}:{available:!1}}function qe(e){return[`gh`,...We.filter(e)]}function Je(e,t,n){for(let r of t)try{let t=e(r,n,Ge).toString().trim();if(t.length>0)return t}catch{}}function Ye(e,t={}){let n=t._exec??s,r=qe(t._fileExists??g),i=[`auth`,`status`,...e?[`--hostname`,e]:[]],a=Je(n,r,[...i,`--json`,`hosts`]);if(a!==void 0){let t=Ze(a,e);if(t)return t}let o=Je(n,r,i);if(o!==void 0){let e=nt(o);if(e.length>0)return e}}function Xe(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Ze(e,t){let n;try{n=JSON.parse(e)}catch{return}let r=Xe(Xe(n)?.hosts);if(!r||t!==void 0&&r[t]===void 0)return;let i=t===void 0?Object.values(r):[r[t]],a=[];for(let e of i){if(!Array.isArray(e))return;for(let t of e){let e=Xe(t);if(!e)continue;let n=e.login;typeof n==`string`&&n.length!==0&&a.push({login:n,active:e.active===!0})}}return a}const Qe=/Logged in to \S+ account (\S+) \(/,$e=/(?:Failed to log in to|Timeout trying to log in to) \S+/,et=/^\s*-\s*Active account:\s*true\s*$/,tt=/\u001b\[[0-9;]*m/g;function nt(e){let t=[],n;for(let r of e.split(`
|
|
2
2
|
`)){let e=r.replace(tt,``),i=Qe.exec(e)?.[1];if(i){n={login:i,active:!1},t.push(n);continue}if($e.test(e)){n=void 0;continue}n&&et.test(e)&&(n.active=!0)}return t}const rt={stable:{appId:`com.inkeep.open-knowledge`,productName:`OpenKnowledge`,packageName:`@inkeep/open-knowledge-desktop`,linuxExecutableName:`openknowledge`,protocolScheme:`openknowledge`,linuxPackageNames:{deb:`openknowledge`,rpm:`openknowledge`},retiredLinuxPackageNames:{deb:[],rpm:[`OpenKnowledge`]},cliCommandNames:[`ok`,`open-knowledge`],mcpServerName:`open-knowledge`,mcpChainTag:``,npmDistTag:`latest`,userHomeDirName:`.ok`,keyringService:`open-knowledge`},beta:{appId:`com.inkeep.open-knowledge.beta`,productName:`OpenKnowledge Beta`,packageName:`openknowledge-beta-desktop`,linuxExecutableName:`openknowledge-beta`,protocolScheme:`openknowledge-beta`,linuxPackageNames:{deb:`openknowledge-beta`,rpm:`openknowledge-beta`},retiredLinuxPackageNames:{deb:[`openknowledge-beta-desktop`],rpm:[`openknowledge-beta-desktop`]},cliCommandNames:[`ok-beta`,`open-knowledge-beta`],mcpServerName:`open-knowledge-beta`,mcpChainTag:`-beta`,npmDistTag:`beta`,userHomeDirName:`.ok-beta`,keyringService:`open-knowledge-beta`},dev:{appId:`com.inkeep.open-knowledge.dev`,productName:`OpenKnowledge Dev`,packageName:`openknowledge-dev-desktop`,linuxExecutableName:`openknowledge-dev`,protocolScheme:`openknowledge-dev`,linuxPackageNames:{deb:`openknowledge-dev`,rpm:`openknowledge-dev`},retiredLinuxPackageNames:{deb:[],rpm:[]},cliCommandNames:[`ok-dev`,`open-knowledge-dev`],mcpServerName:`open-knowledge-dev`,mcpChainTag:`-dev`,npmDistTag:`latest`,userHomeDirName:`.ok-dev`,keyringService:`open-knowledge-dev`}},it=[`stable`,`beta`];function at(e){return`${e.productName}.exe`}const ot=rt.stable.productName,st=`OK_CHANNEL`;function ct(e){return Object.hasOwn(rt,e)}function lt(e){return e.OK_CHANNEL?.trim().toLowerCase()||void 0}function ut(e=globalThis.process?.env??{}){return lt(e)===`dev`}function eee(e){return e===`stable`?`${ot} (Stable)`:ct(e)?rt[e].productName:`${ot} (${e})`}function tee(e){return(e.split(/[\\/]/).pop()??``).replace(/\.exe$/i,``)}function dt(e=globalThis.process?.env??{},t=globalThis.process?.execPath??``){let n=lt(e);if(n){if(ct(n))return n;throw Error(`Unsupported ${st}=${JSON.stringify(n)}. Expected ${Object.keys(rt).join(` or `)}.`)}let r=tee(t);for(let e of it){if(e===`stable`)continue;let t=rt[e];if(r===t.linuxExecutableName||r===t.productName||r.startsWith(`${t.productName} `))return e}return`stable`}function ft(){return rt[dt()]}function pt(){return ft().mcpServerName}function mt(){return ft().cliCommandNames[0]}const ht=`node <checkout>/packages/cli/dist/cli.mjs`;function nee(e,...t){return[`~`,e.userHomeDirName,...t].join(`/`)}const gt=[`claude`,`claude-desktop`,`cursor`,`codex`,`copilot`,`opencode`,`openclaw`,`pi`,`antigravity`,`lm-studio`,`hermes`],ree={claude:`Claude`,"claude-desktop":`Claude Desktop`,cursor:`Cursor`,codex:`Codex`,copilot:`GitHub Copilot`,opencode:`OpenCode`,openclaw:`OpenClaw`,pi:`Pi`,antigravity:`Antigravity`,"lm-studio":`LM Studio`,hermes:`Hermes`},_t={claude:`.claude/skills`,"claude-desktop":null,cursor:`.cursor/skills`,codex:`.codex/skills`,copilot:`.github/skills`,opencode:`.opencode/skills`,openclaw:null,pi:`.pi/skills`,antigravity:null,"lm-studio":null,hermes:null},vt={claude:`.claude/skills`,"claude-desktop":null,cursor:`.cursor/skills`,codex:`.codex/skills`,copilot:`.copilot/skills`,opencode:`.opencode/skills`,openclaw:null,pi:`.pi/agent/skills`,antigravity:`.gemini/skills`,"lm-studio":`.lmstudio/skills`,hermes:null},yt=[{editorId:`lm-studio`,dotDir:`.lmstudio`,scope:`project`},{editorId:`openclaw`,dotDir:`.openclaw`,scope:`global`}],bt=gt.filter(e=>_t[e]!==null),iee=gt.filter(e=>vt[e]!==null),xt=`open-knowledge`;gt.flatMap(e=>{let t=_t[e];return t===null?[]:[`${t}/${xt}/`]});const aee=bt.filter(e=>e!==`pi`&&e!==`copilot`).map(e=>({hostDir:(_t[e]??``).split(`/`)[0],editorId:e})),St=gt.flatMap(e=>{let t=vt[e];if(t===null)return[];let n=t.split(`/`)[0];return n===void 0?[]:[{hostDir:n,skillsRoot:t,editorId:e}]}),Ct={claude:`claude-code`,"claude-desktop":`claude-code`,cursor:`cursor`,codex:`codex`,copilot:`github-copilot-cli`,opencode:`opencode`,openclaw:`openclaw`,pi:`pi`,antigravity:`antigravity`,"lm-studio":`lm-studio`,hermes:`hermes`};function wt(e){return`.pi/extensions/${e.mcpServerName}.ts`}function Tt(e){return`ok${e.mcpChainTag}`}wt(rt.stable);const oee=[`copilot`],see=[`delete`,`move`,`share_link`,`install`,`import`],cee=[`claude`,`codex`,`opencode`,`cursor`,`copilot`,`pi`,`antigravity`,`openclaw`,`hermes`];var Et;const Dt=Object.freeze({status:`aborted`});function F(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Ot=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},kt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Et=globalThis).__zod_globalConfig??(Et.__zod_globalConfig={});const At=globalThis.__zod_globalConfig;function jt(e){return e&&Object.assign(At,e),At}function Mt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Nt(e,t){return typeof t==`bigint`?t.toString():t}function Pt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ft(e){return e==null}function It(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function lee(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const Lt=Symbol(`evaluating`);function Rt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Lt)return r===void 0&&(r=Lt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function zt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Bt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Vt(e){return JSON.stringify(e)}function uee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Ht=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ut(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const dee=Pt(()=>{if(At.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Wt(e){if(Ut(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Ut(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Gt(e){return Wt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const fee=new Set([`string`,`number`,`symbol`]);function Kt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function qt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Jt(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Yt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Xt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Zt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return qt(e,Bt(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return zt(this,`shape`,e),e},checks:[]}))}function Qt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return qt(e,Bt(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return zt(this,`shape`,r),r},checks:[]}))}function pee(e,t){if(!Wt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return zt(this,`shape`,n),n}}))}function mee(e,t){if(!Wt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return qt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return zt(this,`shape`,n),n}}))}function hee(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return qt(e,Bt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return zt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function gee(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return qt(t,Bt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return zt(this,`shape`,i),i},checks:[]}))}function _ee(e,t,n){return qt(t,Bt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return zt(this,`shape`,i),i}}))}function $t(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function vee(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function en(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function tn(e){return typeof e==`string`?e:e?.message}function nn(e,t,n){let r=e.message?e.message:tn(e.inst?._zod.def?.error?.(e))??tn(t?.error?.(e))??tn(n.customError?.(e))??tn(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function rn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function an(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const on=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Nt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sn=F(`$ZodError`,on),cn=F(`$ZodError`,on,{Parent:Error});function yee(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function bee(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}const ln=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Ot;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>nn(e,a,jt())));throw Ht(t,i?.callee),t}return o.value},un=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>nn(e,a,jt())));throw Ht(t,i?.callee),t}return o.value},dn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ot;return a.issues.length?{success:!1,error:new(e??sn)(a.issues.map(e=>nn(e,i,jt())))}:{success:!0,data:a.value}},xee=dn(cn),fn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>nn(e,i,jt())))}:{success:!0,data:a.value}},See=fn(cn),Cee=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ln(e)(t,n,i)},wee=e=>(t,n,r)=>ln(e)(t,n,r),Tee=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return un(e)(t,n,i)},Eee=e=>async(t,n,r)=>un(e)(t,n,r),Dee=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return dn(e)(t,n,i)},Oee=e=>(t,n,r)=>dn(e)(t,n,r),kee=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return fn(e)(t,n,i)},Aee=e=>async(t,n,r)=>fn(e)(t,n,r),jee=/^[cC][0-9a-z]{6,}$/,Mee=/^[0-9a-z]+$/,Nee=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pee=/^[0-9a-vA-V]{20}$/,Fee=/^[A-Za-z0-9]{27}$/,pn=/^[a-zA-Z0-9_-]{21}$/,mn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,gn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,_n=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function vn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,xn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wn=/^[A-Za-z0-9_-]*$/,Tn=/^https?$/,En=/^\+[1-9]\d{6,14}$/,Dn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,On=RegExp(`^${Dn}$`);function kn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Iee(e){return RegExp(`^${kn(e)}$`)}function Lee(e){let t=kn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Dn}T(?:${r})$`)}const Ree=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},zee=/^-?\d+$/,An=/^-?\d+(?:\.\d+)?$/,Bee=/^(?:true|false)$/i,Vee=/^null$/i,Hee=/^[^A-Z]*$/,Uee=/^[^a-z]*$/,jn=F(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Mn={number:`number`,bigint:`bigint`,object:`date`},Nn=F(`$ZodCheckLessThan`,(e,t)=>{jn.init(e,t);let n=Mn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pn=F(`$ZodCheckGreaterThan`,(e,t)=>{jn.init(e,t);let n=Mn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wee=F(`$ZodCheckMultipleOf`,(e,t)=>{jn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):lee(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gee=F(`$ZodCheckNumberFormat`,(e,t)=>{jn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Xt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=zee)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Kee=F(`$ZodCheckMaxLength`,(e,t)=>{var n;jn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=rn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qee=F(`$ZodCheckMinLength`,(e,t)=>{var n;jn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=rn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jee=F(`$ZodCheckLengthEquals`,(e,t)=>{var n;jn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ft(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=rn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Fn=F(`$ZodCheckStringFormat`,(e,t)=>{var n,r;jn.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Yee=F(`$ZodCheckRegex`,(e,t)=>{Fn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Xee=F(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Hee,Fn.init(e,t)}),Zee=F(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Uee,Fn.init(e,t)}),Qee=F(`$ZodCheckIncludes`,(e,t)=>{jn.init(e,t);let n=Kt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$ee=F(`$ZodCheckStartsWith`,(e,t)=>{jn.init(e,t);let n=RegExp(`^${Kt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ete=F(`$ZodCheckEndsWith`,(e,t)=>{jn.init(e,t);let n=RegExp(`.*${Kt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),tte=F(`$ZodCheckOverwrite`,(e,t)=>{jn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var nte=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}};const rte={major:4,minor:4,patch:3},In=F(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=rte;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=$t(e),i;for(let a of t){if(a._zod.def.when){if(vee(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Ot;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=$t(e,t))});else{if(e.issues.length===t)continue;r||=$t(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if($t(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Ot;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Ot;return o.then(e=>t(e,r,a))}return t(o,r,a)}}Rt(e,`~standard`,()=>({validate:t=>{try{let n=xee(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return See(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Ln=F(`$ZodString`,(e,t)=>{In.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ree(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Rn=F(`$ZodStringFormat`,(e,t)=>{Fn.init(e,t),Ln.init(e,t)}),ite=F(`$ZodGUID`,(e,t)=>{t.pattern??=hn,Rn.init(e,t)}),ate=F(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=gn(e)}else t.pattern??=gn();Rn.init(e,t)}),ote=F(`$ZodEmail`,(e,t)=>{t.pattern??=_n,Rn.init(e,t)}),ste=F(`$ZodURL`,(e,t)=>{Rn.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Tn.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),cte=F(`$ZodEmoji`,(e,t)=>{t.pattern??=vn(),Rn.init(e,t)}),lte=F(`$ZodNanoID`,(e,t)=>{t.pattern??=pn,Rn.init(e,t)}),ute=F(`$ZodCUID`,(e,t)=>{t.pattern??=jee,Rn.init(e,t)}),dte=F(`$ZodCUID2`,(e,t)=>{t.pattern??=Mee,Rn.init(e,t)}),fte=F(`$ZodULID`,(e,t)=>{t.pattern??=Nee,Rn.init(e,t)}),pte=F(`$ZodXID`,(e,t)=>{t.pattern??=Pee,Rn.init(e,t)}),mte=F(`$ZodKSUID`,(e,t)=>{t.pattern??=Fee,Rn.init(e,t)}),hte=F(`$ZodISODateTime`,(e,t)=>{t.pattern??=Lee(t),Rn.init(e,t)}),gte=F(`$ZodISODate`,(e,t)=>{t.pattern??=On,Rn.init(e,t)}),_te=F(`$ZodISOTime`,(e,t)=>{t.pattern??=Iee(t),Rn.init(e,t)}),vte=F(`$ZodISODuration`,(e,t)=>{t.pattern??=mn,Rn.init(e,t)}),yte=F(`$ZodIPv4`,(e,t)=>{t.pattern??=yn,Rn.init(e,t),e._zod.bag.format=`ipv4`}),bte=F(`$ZodIPv6`,(e,t)=>{t.pattern??=bn,Rn.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),xte=F(`$ZodCIDRv4`,(e,t)=>{t.pattern??=xn,Rn.init(e,t)}),Ste=F(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Sn,Rn.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function zn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Cte=F(`$ZodBase64`,(e,t)=>{t.pattern??=Cn,Rn.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{zn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function wte(e){if(!wn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return zn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Tte=F(`$ZodBase64URL`,(e,t)=>{t.pattern??=wn,Rn.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{wte(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ete=F(`$ZodE164`,(e,t)=>{t.pattern??=En,Rn.init(e,t)});function Dte(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Ote=F(`$ZodJWT`,(e,t)=>{Rn.init(e,t),e._zod.check=n=>{Dte(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Bn=F(`$ZodNumber`,(e,t)=>{In.init(e,t),e._zod.pattern=e._zod.bag.pattern??An,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),kte=F(`$ZodNumberFormat`,(e,t)=>{Gee.init(e,t),Bn.init(e,t)}),Ate=F(`$ZodBoolean`,(e,t)=>{In.init(e,t),e._zod.pattern=Bee,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),jte=F(`$ZodNull`,(e,t)=>{In.init(e,t),e._zod.pattern=Vee,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Mte=F(`$ZodUnknown`,(e,t)=>{In.init(e,t),e._zod.parse=e=>e}),Nte=F(`$ZodNever`,(e,t)=>{In.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Vn(e,t,n){e.issues.length&&t.issues.push(...en(n,e.issues)),t.value[n]=e.value}const Pte=F(`$ZodArray`,(e,t)=>{In.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Vn(t,n,e))):Vn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Hn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...en(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Un(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Yt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Wn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Hn(e,n,i,t,u,d))):Hn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const Fte=F(`$ZodObject`,(e,t)=>{if(In.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Pt(()=>Un(t));Rt(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Ut,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Hn(n,t,e,s,r,i))):Hn(a,t,e,s,r,i)}return i?Wn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ite=F(`$ZodObjectJIT`,(e,t)=>{Fte.init(e,t);let n=e._zod.parse,r=Pt(()=>Un(t)),i=e=>{let t=new nte([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Vt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Vt(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
@@ -426,7 +426,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content:
|
|
|
426
426
|
`)},mdxJsxFlowElement(e,t,n,r){let i=e,a=i.data?.sourceRaw;if(typeof a==`string`)return a;let o=i.data?.htmlBoundary;if(o&&typeof o.opener==`string`&&typeof o.closer==`string`){let e=n.containerFlow({type:`root`,children:i.children??[]},r);return`${o.opener}\n\n${e}\n\n${o.closer}`}let s=i.name??``,c=bq(i.attributes??[]);if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let l={...i,attributes:(i.attributes??[]).map(v_e),children:(i.children??[]).map(g_e)};return m_e(l,t,n,r)},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=Dq(n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),r,`==`),o+=i.move(`==`),a(),o},underline(e,t,n,r){let i=e.data?.sourceForm===`ins`?`<ins>`:`<u>`,a=e.data?.sourceForm===`ins`?`</ins>`:`</u>`,o=n.createTracker(r),s=n.enter(`underline`),c=o.move(i);return c+=n.containerPhrasing(e,{before:c,after:a,...o.current()}),c+=o.move(a),s(),c},comment(e,t,n,r){let i=e.data?.sourceForm,a=i===`html`?`<!-- `:`%%`,o=i===`html`?` -->`:`%%`,s=n.createTracker(r),c=n.enter(`comment`),l=s.move(a);return l+=n.containerPhrasing(e,{before:l,after:o,...s.current()}),l+=s.move(o),c(),l},commentBlock(e,t,n,r){let i=n.createTracker(r),a=n.enter(`commentBlock`),o=e.children??[],s=e.data?.sourceForm,c=e.data?.sourceLayout,l=o.length===1&&o[0]?.type===`paragraph`;if(s===`html`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`<!-- `,after:` -->`,...i.current()});return a(),`<!-- ${t} -->`}if(c===`inline`&&l){let e=o[0],t=n.containerPhrasing(e,{before:`%% `,after:` %%`,...i.current()});return a(),`%% ${t} %%`}let u=n.containerFlow(e,i.current());return a(),`%%\n\n${u}\n\n%%`},mdxJsxTextElement(e){let t=e.data?.sourceRaw;if(typeof t==`string`)return t;let n=e.name??``,r=bq(e.attributes??[]),i=(e.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return i?r?`<${n} ${r}>${i}</${n}>`:`<${n}>${i}</${n}>`:r?`<${n} ${r} />`:`<${n}/>`},rawMdxFallback(e){return e.value??``},blockquote(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.containerFlow(e,a.current());i();let s=e.data?.sourceMarkerSpacings,c=0;return n.indentLines(o,(e,t,n)=>{if(n)return`>`;let r=c++,i=s?.[r];return i===`lazy`&&r>0&&!h_e.test(e)?e:i===`none`||i===0?`>${e}`:typeof i==`number`&&i>=2&&!e.startsWith(` `)?`>${` `.repeat(i)}${e}`:`> ${e}`})}};function bq(e){let t=[];for(let n of e){if(n.type===`mdxJsxExpressionAttribute`){t.push(`{${n.value}}`);continue}let e=n.name;if(n.value===null||n.value===void 0){t.push(e);continue}if(typeof n.value==`string`){n.value.includes(`"`)?t.push(`${e}={${xq(n.value)}}`):t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function xq(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function v_e(e){return e.type===`mdxJsxAttribute`&&typeof e.value==`string`&&e.value.includes(`"`)?{type:`mdxJsxAttribute`,name:e.name,value:{type:`mdxJsxAttributeValueExpression`,value:xq(e.value)}}:e}function Sq(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function Cq(e,t,n,r=!1){let i=String(n.url??``),a=i.startsWith(`<`)&&i.endsWith(`>`);if(n.data?.sourceUrlForm===`angle-bracketed`&&!a||r){let n=e.enter(`destinationLiteral`),r=t.move(y_e(i,e.stack.includes(`tableCell`)));return n(),r}let o=e.enter(`destinationRaw`),s=t.move(b_e(i));return o(),s}function y_e(e,t=!1){let n=`<`;for(let r=0;r<e.length;r++){let i=e[r];wH(i)||t&&i===`|`?n+=`\\${i}`:n+=i===`
|
|
427
427
|
`?`
`:i===`\r`?`
`:i===`\\`?TH(e[r+1])?`\\\\`:`\\`:i}return`${n}>`}function b_e(e){if(!e)return``;let t=0,n=!0;for(let r of e)r===`(`?t++:r===`)`&&(t--,t<0&&(n=!1));return t!==0&&(n=!1),n?e:e.replace(/[\\()]/g,`\\$&`)}function x_e(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>S_e(t)?e:`\\${e}`)}function S_e(e){if(e.charCodeAt(0)!==35)return!1;let t=e[1]===`x`||e[1]===`X`?Number.parseInt(e.slice(2),16):Number.parseInt(e.slice(1),10);return t===9||t===10||t===11||t===12||t===13||t===32||t===160}const C_e=/&#(?:x[0-9A-Fa-f]+|X[0-9A-Fa-f]+|[0-9]+);/g;function w_e(e){return e.replace(C_e,e=>rc(e)?``+e.slice(1):e)}function T_e(e){return/[\r\n][\t ]*$/.test(e)}function wq(e,t,n,r=!1){let{matched:i}=MU(t,{escapeAware:!1});if(i.length===0)return Tq(e,t,n,r);let a=``,o=0,s=i=>{i>o&&(a+=Tq(e,t.slice(o,i),{...n,before:n.before+a,after:t.slice(i,i+1)||n.after},r)),o=i};for(let e of i)s(e.start),!T_e(n.before+a)&&(a+=t.slice(e.start,e.end),o=e.end);return s(t.length),a}function Tq(e,t,n,r=!1){let i=e.unsafe;e.unsafe=i.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character===`!`&&e.after===`\\[`&&e.inConstruct===`phrasing`||e.character===`@`&&e.before===`[+\\-.\\w]`||r&&e.character===`:`&&e.before===`[ps]`&&e.after===`\\/`||e.character===`{`&&Array.isArray(e.inConstruct)&&e.inConstruct.includes(`phrasing`)||e.character==="`"||(e.character===`*`||e.character===`_`||e.character===`~`)&&e.inConstruct===`phrasing`||e.character===`=`&&e.atBreak===!0||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`||e.character===` `&&e.inConstruct===`phrasing`&&e.after===`[\\r\\n]`)),e.unsafe=e.unsafe.map(e=>{if(e.character!==`)`||e.atBreak!==!0||e.before!==`\\d+`||e.after!==void 0)return e;let t={...e,after:`(?:[ \r
|
|
428
428
|
]|$)`};return delete t._compiled,t});let a;try{a=e.safe(w_e(t),n)}finally{e.unsafe=i}return a=a.replaceAll(``,`\\&`),x_e(O_e(a,n))}function Eq(e){if(Number.isNaN(e))return`ws`;let t=Vf(e);return t===1?`ws`:t===2?`punct`:`other`}function E_e(e,t,n){let r=Eq(t),i=Eq(n),a=i!==`ws`&&(i===`other`||r!==`other`),o=r!==`ws`&&(r===`other`||i!==`other`);return e===`_`?a&&(!o||r===`punct`)||o&&(!a||i===`punct`):a||o}function D_e(e,t,n){let r=t;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r<e.length)return e[r]===`
|
|
429
|
-
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function O_e(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&D_e(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=E_e(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function Dq(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);Oq(i.charCodeAt(i.length-1),s,r)&&(o=kq(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return Oq(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+kq(c)),o}function Oq(e,t,n){return!(Vf(t)!==1||n===`_`&&Vf(e)===void 0)}function kq(e){return`&#x${e.toString(16).toUpperCase()};`}function k_e(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!j_e(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function A_e(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=Dq(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function j_e(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}const Aq=[{mode:`protecting`,protect:LH,reservations:FH},{mode:`protecting`,protect:FU,reservations:HH},{mode:`protecting`,protect:jH,reservations:DH},{mode:`serializer-only`,reservations:[{to:``}]}];new Set(Aq.flatMap(({reservations:e})=>e.map(({to:e})=>e)));function M_e(e,t){switch(t.mode){case`protecting`:return t.protect(e);case`serializer-only`:return e}}function jq(e){return Aq.reduce(M_e,e)}function Mq(e){return e.data?.sourceRaw}function N_e(e){return e.type===`text`?e.value===``:e.type===`mdxJsxTextElement`&&Mq(e)===``}function Nq(e){return e.type===`paragraph`&&(e.children??[]).every(N_e)}function Pq(e){let t=e.children??[],n=t[0]?.children?.length??0,r=0;for(let e=1;e<t.length;e++)r=Math.max(r,t[e]?.children?.length??0);let i=e.align??[];return Math.max(n,r,i.length)}function P_e(e){switch(e.type){case`table`:return Pq(e)===0;case`code`:return e.data?.sourceStyle===`indented`&&/^\n*$/.test(e.value??``);case`thematicBreak`:return Mq(e)===``;case`html`:return(e.value??``)===``;case`mdxJsxFlowElement`:return Mq(e)===void 0&&e.data?.htmlBoundary===void 0&&(e.children??[]).length===0&&!e.name;case`list`:return(e.children??[]).length===0;default:return!1}}function F_e(e){let t=[];for(let n of e.children){if(n.type===`table`&&Pq(n)===0){console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:(n.children??[]).length}));continue}P_e(n)||(n.type===`paragraph`&&n.children.length>0&&Nq(n)&&(n.children=[]),t.push(n))}e.children=t}function I_e(e,t){let n=e,r=t;return n.type===`heading`&&n.data?.sourceContiguousNext===!0&&r.type===`paragraph`}const L_e=(e,t)=>{if(Nq(e)||I_e(e,t))return 0;let n=e.position,r=t.position;if(!n||!r)return;let i=r.start.line-n.end.line-1;return i>=1?i:void 0},Fq=/(?<!\\)\$(?=\S)([^$\n]*?[^\s$])\$(?!\d)/g;function R_e(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;Wf(e,`text`,(e,t,r)=>{if(r===void 0||t==null)return;let i=e.value;if(i.indexOf(`$`)===-1)return;let a=mP(e);Fq.lastIndex=0;let o=[],s;for(;(s=Fq.exec(i))!==null;){let e=s.index,t=e+s[0].length;if(vP(a,e,1)||vP(a,t-1,1)){Fq.lastIndex=e+1;continue}o.push(s)}if(o.length===0)return;let c=[],l=0;for(let t of o){let r=t.index,i=r+t[0].length;r>l&&c.push(_P(n,e,l,r));let a={type:`inlineMath`,value:t[1]},o=xP(n,e,r,i);o&&(a.position=o),c.push(a),l=i}return l<i.length&&c.push(_P(n,e,l,i.length)),r.children.splice(t,1,...c),[yf,t+c.length]})}}const z_e=new Set([`strong`,`emphasis`,`delete`,`link`,`mark`,`comment`]);function B_e(e){if(e?.type!==`break`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}function V_e(e){e.data??={},e.data.sourceRaw=`<br />`,e.data.sourceStyle=`html`}function Iq(e){if(e?.type!==`text`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}const Lq=/[ \t]+$/,Rq=/^[ \t]*$/;function H_e(e){return e.some(e=>!(Iq(e)&&Rq.test(e.value)))}function zq(e,t=!1){for(;e.length>0;){let n=e[e.length-1];if(B_e(n)){V_e(n);break}if(n&&z_e.has(n.type)&&`children`in n){let t=n.children;if(zq(t,!0),t.length===0){e.pop();continue}}if(!t&&Iq(n)&&Lq.test(n.value)){let t=n.value.replace(Lq,``);if(t.length>0){n.value=t;continue}if(H_e(e.slice(0,-1))){e.pop();continue}if(e.every(e=>Iq(e)&&Rq.test(e.value))){let t=e[0];t.value=t.value.charAt(0),e.splice(1)}}break}}const U_e=new Set([`paragraph`,`heading`,`tableCell`]);function W_e(e){let t=e=>{if(U_e.has(e.type)&&`children`in e&&zq(e.children),`children`in e)for(let n of e.children)t(n)};t(e)}const Bq={handlers:{tag:e=>`#${e.value}`},unsafe:[{character:`#`,inConstruct:[`phrasing`],before:`\\s`,after:`[A-Za-z]|[^\\x00-\\x7F]`}]};function G_e(){let e=this.data();e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===Bq)||e.toMarkdownExtensions.push(Bq)}const K_e=new Set([`u`,`ins`]);function q_e(){return e=>{Wf(e,`mdxJsxTextElement`,(e,t,n)=>{if(n===void 0||t==null||e.name===null||!K_e.has(e.name)||(e.attributes??[]).length>0)return;let r={type:`underline`,children:e.children??[],data:{sourceForm:e.name===`ins`?`ins`:`u`}};return e.position&&(r.position=e.position),n.children.splice(t,1,r),t+1})}}function J_e(e){return e.children.some(e=>{let t=e.type;return t!==`yaml`&&t!==`toml`})?e:{...e,children:[...e.children,{type:`paragraph`,children:[]}]}}const Y_e=[{name:`remark-parse`,plugin:w_},{name:`escape-provenance`,plugin:AK},{name:`remark-mdx-agnostic`,plugin:UU},{name:`remark-gfm`,plugin:Uh},{name:`remark-math`,plugin:qW,options:{singleDollarTextMath:!1}},{name:`remark-wiki-link`,plugin:fW},{name:`remark-github-alerts`,plugin:UW,options:xG},{name:`callout-transformer`,plugin:bG},{name:`restore-from-mdx`,plugin:LU},{name:`void-br-promoter`,plugin:qU},{name:`restore-entity-refs`,plugin:PH},{name:`restore-backslash-escapes`,plugin:RH},{name:`details-accordion-promoter`,plugin:aK},{name:`div-align-promoter`,plugin:mK},{name:`image-promoter`,plugin:RK},{name:`indented-code-promoter`,plugin:WK},{name:`math-promoter`,plugin:eq},{name:`single-dollar-math-promoter`,plugin:R_e},{name:`highlight-promoter`,plugin:LK},{name:`underline-promoter`,plugin:q_e},{name:`mermaid-promoter`,plugin:n_e},{name:`comment-promoter`,plugin:wG},{name:`merged-post-parse-walker`,plugin:e_e},{name:`empty-task-item-unmint`,plugin:xK},{name:`link-reference-destination`,plugin:QK},{name:`non-rendering-context-demote`,plugin:d_e},{name:`ensure-non-empty-doc`,plugin:()=>J_e}];function X_e(e){let t=ug();for(let e of Y_e)t=`options`in e&&e.options!==void 0?t.use(e.plugin,e.options):t.use(e.plugin);return t=t.use(FW,{schema:e.schema,handlers:e.handlers}),t.freeze(),t}function Z_e(e){let t=ug().use(zg,[`yaml`]).use(Uh,{tablePipeAlign:!1}).use(qW,{singleDollarTextMath:!1}).use(UU).use(fW).use(G_e).use(aB,{bullet:`-`,fences:!0,rule:`-`,join:[L_e],...e.toMarkdownHandlers?{handlers:e.toMarkdownHandlers}:{}});return t.freeze(),t}function Vq(e){return e.charCodeAt(0)===65279?{source:e.slice(1),hadBom:!0}:{source:e,hadBom:!1}}const Hq=/^\n+$/,Uq=/^\n{2,}$/;function Wq(e,t,n){let r,i,a=e.children;if(a.length>0){let e=a[0]?.position?.start?.offset;if(typeof e==`number`&&e>0){let n=t.slice(0,e);Hq.test(n)&&(r=n)}let n=a[a.length-1]?.position?.end?.offset;if(typeof n==`number`&&n<=t.length){let e=t.slice(n);Uq.test(e)&&(i=e)}}if(!n&&r===void 0&&i===void 0)return;let o={...n?{bom:!0}:{},...r===void 0?{}:{leading:r},...i===void 0?{}:{trailing:i}};return e.data??={},e.data.sourceDocBoundary=o,o}function Q_e(e){if(typeof e!=`object`||!e)return;let t=e,n={};return t.bom===!0&&(n.bom=!0),typeof t.leading==`string`&&Hq.test(t.leading)&&(n.leading=t.leading),typeof t.trailing==`string`&&Uq.test(t.trailing)&&(n.trailing=t.trailing),n.bom||n.leading||n.trailing?n:void 0}function $_e(e,t){let{source:n,hadBom:r}=Vq(e),i=JG(n),a=new ng(jq(i)),o=t.parse(a);a.value=i;let s=t.runSync(o,a);JK(s,i);let c=Wq(s,i,r),l=c?ws(s,c):void 0,u=t.stringify(s);return l?u.type.create({...u.attrs,sourceDocBoundary:l},u.content,u.marks):u}function eve(e,t){return Gq(e,t,!1)}function tve(e,t){return Gq(e,t,!0)}function Gq(e,t,n){let{source:r,hadBom:i}=Vq(e),a=JG(r),o=new ng(jq(a)),s=t.parse(o);o.value=a;let c=t.runSync(s,o);n&&JK(c,a);let l=Wq(c,a,i);return n&&l&&ws(c,l),c}function nve(e,t,n){let r=LW(e,{schema:n.schema,nodeHandlers:n.pmNodeHandlers,markHandlers:n.pmMarkHandlers});Kq(r),yK(r),W_e(r),F_e(r);let i=Q_e(e.attrs?.sourceDocBoundary),a=String(t.stringify(r));return i?.leading&&(a=i.leading+a),i?.trailing&&(a=a.replace(/\n+$/,``)+i.trailing),i?.bom&&(a=`\uFEFF${a}`),a}function Kq(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)Kq(t);for(let t=0;t+1<e.children.length;){let n=e.children[t],r=e.children[t+1],i=n?.data,a=r?.data,o=lP(i)?i.escapedChars:null,s=lP(a)?a.escapedChars:null;if(n?.type!==`text`||r?.type!==`text`||typeof n.data?.sourceRaw==`string`||typeof r.data?.sourceRaw==`string`||o===null&&s===null){t+=1;continue}let c=n.value.length;n.value+=r.value,n.data??={},n.data.escapedChars=[...o??[],...(s??[]).map(e=>({...e,offset:e.offset+c}))],r.data?.entityRefSpans?.length&&(n.data.entityRefSpans=[...n.data.entityRefSpans??[],...r.data.entityRefSpans.map(e=>({...e,offset:e.offset+c}))]),e.children.splice(t+1,1)}}}var rve=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=yO(e.extensions),this.handlers=cve(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?Qs({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=lve(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=X_e({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=Z_e({toMarkdownHandlers:__e})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return $_e(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?eve(e,this.parseProcessor):{type:`root`,children:[]}}parseToEditorMdast(e){return e.trim()?tve(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?XW(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return nve(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const qq=eV();function Jq(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else r[e]=i?.type===`boolean`?t.value===`true`:t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function ive(e){let t=!1;return e.descendants(e=>t?!1:e.type.name===`jsxInline`?(e.attrs.sourceDirty&&(t=!0),!1):e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function ave(e,t){return e.attrs.sourceDirty||ive(e)?!0:t?t.isDiverged(e.toJSON()):!1}function ove(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0||t.every(e=>e.type===`text`&&e.value===``)}function Yq(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function Xq(e,t){if(e.length===0)return Yq({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return Yq({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[Xq(n.children,t)]}}return Yq({type:`inlineCode`,value:Zq(e)},t)}function Zq(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=Zq(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const sve=Oc;function cve(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=MW(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=MW(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=yW(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r,sourceUrlForm:e.data?.sourceUrlForm??null})},i.imageReference=n.imageReference?e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i)return r.sourceLiteral?e.text(n,[r.sourceLiteral.create({sourceRaw:i})]):e.text(n);let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n);let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&oc(t.raw)!==null&&rc(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length);if(i){if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=oc(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i))}u=t.offset+t.length}}if(u<n.length){let t=n.slice(u);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=NW(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=NW(r.highlight)),r.underline&&(i.underline=NW(r.underline,e=>({sourceForm:e.data?.sourceForm===`ins`?`ins`:`u`}))),r.comment&&(i.comment=NW(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=MW(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=NW(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=NW(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=MW(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceUnclosedFence:t.data?.sourceUnclosedFence??!1,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=MW(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=MW(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.data?.resolvedUrl??``,title:n.data?.resolvedTitle??null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker,s=!!o.spec.attrs?.sourceUrlForm;i.definition=i=>{let c={title:i.title??null};return n&&(c.identifier=i.identifier??``),c.label=i.label??i.identifier??``,e?c.url=i.url??``:t&&(c.href=i.url??``),r&&(c.sourceLayout=i.data?.sourceLayout??null),a&&(c.sourceTitleMarker=i.data?.sourceTitleMarker??null),s&&(c.sourceUrlForm=i.data?.sourceUrlForm??null),o.createAndFill(c)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=qq.getOrWildcard(o),c=Jq(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=yW(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}let i=t.name??``,o=i?qq.get(i):void 0;if(o&&n.jsxInline){let e=Jq(t.attributes,o.props),a=r(t.data)??``,s=(t.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return s&&(e.children=s),n.jsxInline.createAndFill({componentName:i,attributes:t.attributes,sourceRaw:a,sourceDirty:!1,props:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=i.data?.sourceTarget??null,u=i.data?.sourceAnchor??null,d=i.data?.sourceAlias??null,f=sk(o),{resolveEmbed:p,sourcePath:m}=t.current,h=p&&m?p(o,m)??null:null,g=h?`/${h}`:o,_=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(_&&sve.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,alt:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&kc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&jc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&Mc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&m?e(o,m)??null:null,i=r===null?null:bW(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,target:o,anchor:c,alias:s,size:i,sourceTarget:l,sourceAnchor:u,sourceAlias:d}})}let v=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:g,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d});return e.text(v,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=MW(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function lve(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=RW(`paragraph`)),i.blockquote&&(n.blockquote=RW(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),i.heading&&(n.heading=RW(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0||void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceUnclosedFence:e.attrs.sourceUnclosedFence===!0||void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=RW(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&ove(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=RW(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:HP(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>{let t={type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title};return e.attrs.sourceUrlForm===`angle-bracketed`&&(t.data={sourceUrlForm:`angle-bracketed`}),t}),i.imageReference&&(n.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!ave(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:qq.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:qq,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),i.rawMdxFallback&&(n.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.componentName||``;if(t&&e.attrs.sourceDirty)return CB(t,e,qq.get(t)?.props);let n=e.attrs.attributes,r=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:t||null,attributes:Array.isArray(n)?n:[],children:[],data:{sourceRaw:String(r)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),a.emphasis&&(r.emphasis=zW(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=zW(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return Xq(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0||void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=zW(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=zW(`mark`)),a.underline&&(r.underline=zW(`underline`,e=>({data:{sourceForm:e.attrs.sourceForm===`ins`?`ins`:`u`}}))),a.comment&&(r.comment=zW(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=RW(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=RW(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,o=typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,s=typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null,c=i||(r?`${t}#${r}`:t),l=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return l!==c&&l.trim().length>0&&!l.includes(`]]`)&&(i=l,c=l),{type:`wikiLinkEmbed`,value:c,data:{target:t,anchor:r,alias:i,sourceTarget:a,sourceAnchor:o,sourceAlias:s},children:[{type:`text`,value:c}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),a.sourceLiteral&&(r.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return tk(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const uve=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]);new Map(QB.flatMap(e=>e.surface===`compat`&&uve.has(e.rendersAs)?[[e.name,e]]:[])),Np(`<>`);var Qq={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100};Qq.SINGLE_TILDE,Qq.COMPARISON_OPERATORS,Qq.HTML_TAGS,Qq.SETEXT_HEADINGS,Qq.LINKS,Qq.BOLD_ITALIC,Qq.BOLD,Qq.ITALIC_DOUBLE_UNDERSCORE,Qq.ITALIC_SINGLE_ASTERISK,Qq.ITALIC_SINGLE_UNDERSCORE,Qq.INLINE_CODE,Qq.STRIKETHROUGH,Qq.KATEX,Qq.INLINE_KATEX,ug().use(w_).use(Uh);const $q=U(bt),dve=U(iee),fve=V({alwaysOn:L().int().nonnegative(),onTrigger:L().int().nonnegative(),onDemand:L().int().nonnegative()}).strict();V({intents:B(V({satisfierId:I().min(1),desired:U([`present`,`absent`])}).loose()),...Ud,summary:Wd}).loose();const pve=V({satisfierId:I(),agentId:I(),piece:I(),scope:I(),kind:I(),pathId:I().optional(),desired:U([`present`,`absent`]),action:U(va),errorId:I().optional()}).loose(),mve=V({kind:I(),satisfierIds:B(I()),agentIds:B(I()),pathId:I().optional(),blockedReason:I().optional()}).loose(),hve=V({state:I(),strictness:B(U(ga)).optional()}).loose(),gve=V({probes:V({env:U([`desktop`,`local-web`,`remote-web`]),satisfiers:H(I(),hve)}).loose(),detection:V({detected:B(I()),probed:R()}).loose()}).loose();V({actions:B(pve),conflicts:B(mve),withheld:B(I()),snapshot:gve}).loose(),V({entries:B(V({level:U([`info`,`warn`,`error`]),message:I().max(8192),event:I().optional(),fields:H(I(),z()).optional(),ts:L().optional(),sourceId:I().optional(),lineNumber:L().optional()}).loose()).max(100),droppedSinceLastFlush:L().int().min(0).optional()}).loose(),V({accepted:L().int().min(0)}).loose();const _ve=V({exact:I().min(1),prefix:I(),suffix:I(),start:L().int().nonnegative(),end:L().int().nonnegative()}),vve=B($i([I(),L().int().nonnegative()])),yve=ea(`kind`,[V({kind:W(`body`)}),V({kind:W(`property`),key:I().min(1),path:vve.default([])})]).default({kind:`body`}),bve=U([`anchored`,`orphaned`,`resolved`]),eJ=V({threadId:I().min(1),docName:I().min(1),target:yve,anchor:_ve.nullable(),state:bve,queued:R(),latestComment:I(),createdBy:I().min(1),createdAt:L(),updatedAt:L().optional()}),tJ=V({docName:I(),instruction:I(),property:I().nullable(),passage:V({exact:I(),prefix:I(),suffix:I()}).nullable(),anchorLost:R(),passageRepeats:R()}).loose(),nJ=V({threadId:I(),ok:W(!0)}),rJ=V({threadId:I(),ok:W(!1),error:W(`not-found`)});V({threads:B(eJ)}).loose(),V({meta:eJ,orphaned:R()}).loose(),V({threadId:I()}).loose(),V({meta:eJ,payload:tJ}).loose(),V({results:B($i([nJ.extend({meta:eJ,payload:tJ}),rJ]))}).loose(),V({results:B($i([nJ.extend({meta:eJ}),rJ]))}).loose();const xve=V({status:I().min(1),reason:I()}).loose();V({docName:I().min(1),content:I(),lifecycle:xve.nullable()}).loose(),V({documents:B(V({kind:U([`document`,`asset`,`folder`,`file`]).default(`document`),docName:I().min(1).optional(),docExt:I().min(1).default(`.md`),size:L().int().nonnegative(),modified:I().min(1),isSymlink:R().default(!1),canonicalDocName:I().nullable().default(null),targetPath:I().nullable().default(null),path:I().min(1).optional(),assetExt:I().min(1).optional(),mediaKind:U([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`,`excalidraw`]).nullable().optional(),referencedBy:B(I().min(1)).optional(),hasChildren:R().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:R().optional()}).loose();const Sve=V({source:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose();V({docName:I().min(1),backlinks:B(Sve)}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose();const Cve=ea(`kind`,[V({kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose(),V({kind:W(`external`),url:I().min(1),title:I(),snippet:I().nullable()}).loose()]),wve=V({role:I().min(1),sourceForm:I().min(1),targetKind:I().min(1),href:I(),resolvedTarget:I().nullable(),status:I().min(1),reason:I().nullable(),resolutionMethod:I().min(1),fallbackTarget:I().nullable().default(null),range:V({start:L().int().nonnegative(),end:L().int().nonnegative()}),line:L().int().nonnegative(),column:L().int().nonnegative(),definition:V({label:I(),line:L().int().nonnegative()}).nullable().default(null)}).loose();V({docName:I().min(1),forwardLinks:B(Cve),localTargets:B(wve).optional()}).loose();const Tve=ea(`kind`,[V({id:I().min(1),kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),label:I(),cluster:I().nullable(),category:I().nullable(),tags:B(I()).nullable(),managed:R().optional()}).loose(),V({id:I().min(1),kind:W(`external`),url:I().min(1),label:I()}).loose()]),Eve=V({source:I().min(1),target:I().min(1)}).loose();V({nodes:B(Tve),links:B(Eve)}).loose();const Dve=V({ts:L().int().min(0),url:I(),method:I(),ua:I().optional(),origin:I().optional(),referer:I().optional(),host:I().optional(),remote:I().optional(),secChUa:I().optional(),secChUaMobile:I().optional(),secChUaPlatform:I().optional(),secFetchSite:I().optional(),secFetchDest:I().optional(),secFetchMode:I().optional(),secFetchUser:I().optional()}).loose(),Ove=V({app:$i([W(`cursor`),W(`codex`),W(`claude`),qi()]),signals_fired:B(I())}).loose();V({entries:B(Dve),count:L().int().min(0),detection:Ove}).loose();const iJ=V({path:I().min(1),code:U([`M`,`A`,`D`,`R`,`C`,`U`,`T`,`?`,`!`,` `]),origPath:I().min(1).optional(),syncScoped:R(),open:ea(`kind`,[V({kind:W(`doc`),docName:I().min(1)}),V({kind:W(`asset`),path:I().min(1)})]).optional()}).loose();V({branch:I().nullable(),detached:R(),upstream:I().nullable(),staged:B(iJ),notStaged:B(iJ),untracked:B(iJ),incoming:B(iJ),truncated:R(),readable:R().default(!0)}).loose();const kve=U([`AWAITING_CHECKS`,`LOCKED`,`MERGEABLE`,`QUEUED`,`UNMERGEABLE`]),Ave=U([`BEHIND`,`BLOCKED`,`CLEAN`,`DIRTY`,`DRAFT`,`HAS_HOOKS`,`UNKNOWN`,`UNSTABLE`]),jve=U([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),Mve=U([`ERROR`,`EXPECTED`,`FAILURE`,`PENDING`,`SUCCESS`]),Nve=V({mergeQueue:V({position:L().int().nonnegative(),state:kve.nullable().catch(null)}).nullable().catch(null),autoMerge:R(),mergeState:Ave.nullable().catch(null),reviewDecision:jve.nullable().catch(null),checks:Mve.nullable().catch(null)}).loose(),Pve=V({kind:U([`pull`,`issue`]),repo:I().min(1),number:L().int().positive(),title:I(),author:I().nullable(),createdAt:I(),lifecycle:U([`open`,`draft`,`merged`,`closed`,`completed`,`not-planned`]),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional(),status:Nve.optional()}).loose();V({url:I()}).loose(),ea(`ok`,[V({ok:W(!0),preview:Pve}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({writers:B(V({id:I().min(1),name:I().optional(),email:I().optional()}).loose()).optional(),summary:Wd,...Ud}).loose(),V({checkpointRef:I().min(1)}).loose();const Fve=V({v:L().int().optional(),id:I().min(1),name:I().min(1),colorSeed:I().optional(),docs:B(I()),summaries:B(I()).optional()}).loose();V({entries:B(V({sha:I().min(1),timestamp:I().min(1),author:I(),authorEmail:I(),type:U([`checkpoint`,`wip`,`upstream`,`park`]),message:I(),contributors:B(Fve),checkpoint:z().nullable(),parentSha:I().nullable().optional()}).loose()),total:L().int().nonnegative().optional(),truncated:R().optional(),hasMore:R().optional()}).loose(),V({sha:I().regex(/^[0-9a-f]{40}$/i),content:I(),timestamp:I(),author:I()}).loose(),V({contentDir:I().min(1),pathSeparator:U([`/`,`\\`]),symlinkResolved:R()}).loose(),B(ea(`source`,[V({docName:I().min(1),timestamp:I().min(1),size:L().int().nonnegative(),source:W(`flat`)}).loose(),V({docName:I().min(1),timestamp:I().min(1),source:W(`timeline`),sha:I().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."});const Ive=V({domain:I().min(1),title:I().optional(),description:I().optional(),siteName:I().optional(),faviconDataUri:I().optional()}).loose();V({url:I()}).loose(),ea(`ok`,[V({ok:W(!0),metadata:Ive}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({orphans:B(V({docName:I().min(1),title:I()}).loose())}).loose(),V({hubs:B(V({docName:I().min(1),title:I(),count:L().int().nonnegative()}).loose())}).loose();const Lve=V({source:I().min(1),title:I(),snippet:I().nullable()}).loose();V({deadLinks:B(V({target:I().min(1),sources:B(Lve)}).loose())}).loose(),V({target:V({docName:I().min(1),title:I(),aliases:B(I())}).loose(),mentions:B(V({source:I().min(1),excerpt:I(),offset:L().int().nonnegative()}).loose()),truncated:R()}).loose(),V({projectPath:I().min(1)}).loose();const Rve=U([`not-a-git-worktree`,`init-failed`]);ea(`ok`,[V({ok:W(!0),projectPath:I().min(1)}).loose(),V({ok:W(!1),reason:Rve,message:I().min(1)}).loose()]),V({host:I().min(1).optional()}).loose(),V({host:I().min(1).optional(),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({host:I().refine(hc,{message:`Host must be a hostname with an optional :port, with no scheme or path`}),username:I().min(1),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({key:I().min(1)}).loose(),V({keyPresent:R()}).loose();const zve=U([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]);ea(`ok`,[V({ok:W(!0),endpoint:I().min(1),model:I().min(1),dimensions:L().int().positive()}).loose(),V({ok:W(!1),endpoint:I().min(1),model:I().min(1),reason:zve,status:L().int().optional()}).loose()]),V({name:I().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:I().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),V({authenticated:R()}).loose(),V({channel:U([`login`,`gh-login`]).default(`login`)}).loose(),V({}).loose();const Bve=V({stackIndex:L().int().min(0),ts:L().int().min(0),additions:L().int().min(0),deletions:L().int().min(0)}).loose(),Vve=V({docName:I().min(1),additionsTotal:L().int().min(0),deletionsTotal:L().int().min(0),lastTs:L().int().min(0),bursts:B(Bve)}).loose(),Hve=V({displayName:I().min(1),color:I().min(1),icon:I().optional(),connectionId:I().min(1)}).loose();V({sessionAlive:R(),agent:Hve.nullable(),files:B(Vve)}).loose(),V({diff:I(),before:I(),after:I(),properties:kP,generatedAt:L().int().min(0)}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose();const Uve=V({displayName:I().min(1),icon:I(),color:I().min(1),currentDoc:I().nullable(),mode:U([`idle`,`writing`]),ts:L().int().min(0)}).loose();V({presence:H(I().min(1),Uve)}).loose();const Wve=V({sessionId:I().min(1),agentType:I().min(1),ts:L().int().min(0),insertedChars:L().int().min(0),deletedChars:L().int().min(0)}).loose();V({effects:B(V({"doc.name":I().min(1),entries:B(Wve)}).loose())}).loose(),V({decisions:B(V({ts:L().int().min(0),decision:I().min(1),kind:I().min(1),"doc.name":I().min(1),pathRole:I().min(1)}).loose())}).loose(),H(I().min(1),R()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`}),V({path:I().min(1,`path must be non-empty`)}).loose(),V({}).loose();const Gve=V({fromDocName:I().min(1),toDocName:I().min(1)}).loose(),Kve=V({fromPath:I().min(1),toPath:I().min(1)}).loose();V({}).loose(),V({path:I().min(1),...Ud,summary:Wd}).loose(),V({docName:I().min(1)}).loose(),V({path:I().min(1),...Ud,summary:Wd}).loose(),V({path:I().min(1)}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),...Ud,summary:Wd}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),duplicatedDocNames:B(I().min(1))}).loose(),V({pages:B(V({docName:I().min(1),title:I(),docExt:I().min(1),size:L().int().nonnegative(),modified:I().min(1),icon:I().min(1).max(2048).optional()}).loose())}).loose();const qve=V({level:L().int().min(1).max(6),text:I(),slug:I()}).loose();V({docName:I().min(1),headings:B(qve)}).loose();const Jve=V({docName:I().min(1),rewrites:L().int().nonnegative()}).loose();V({kind:U([`file`,`folder`,`asset`]),fromPath:I().min(1),toPath:I().min(1),...Ud,summary:Wd}).loose(),V({renamed:B(Gve),renamedAssets:B(Kve),rewrittenDocs:B(Jve).optional(),summary:Kd.optional()}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...Ud}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...Ud,summary:Wd}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({docName:I().min(1),commitSha:I().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Wd,...Ud}).loose(),V({restoredFrom:I().min(1),timestamp:I().min(1),summary:Kd.optional(),warnings:Zd.optional()}).loose();const Yve=/^#[0-9a-fA-F]{6}$/,Xve=V(Object.fromEntries(el.map(e=>[e,I().regex(Yve,`must be a #rrggbb hex color`)]))),aJ=I().min(1).refine(al,{message:`must contain a non-whitespace character`}),oJ=V({name:aJ,author:aJ.optional(),variant:U([`dark`,`light`]),palette:Xve}).loose();V({name:I().min(1),scheme:oJ,stem:I().min(1).optional(),extension:U([`.yaml`,`.yml`]).optional()}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),V({id:I().min(1),scheme:oJ}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),ea(`existed`,[V({existed:W(!1)}).loose(),V({existed:W(!0),filename:I().min(1),scheme:oJ}).loose()]),V({themes:B(ea(`ok`,[V({ok:W(!0),id:I().min(1),filename:I().min(1),scheme:oJ}),V({ok:W(!1),filename:I().min(1),id:I().min(1).optional(),code:I().min(1),conflictingFilenames:B(I().min(1)).min(2).optional()})])),truncated:R()}).loose();function Zve(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==``&&e!==`.`)}function Qve(e){let t=Zve(e).at(-1);return t!==void 0&&Dd.some(e=>t.toLowerCase().endsWith(e))}V({tags:B(V({name:I().min(1),count:L().int().nonnegative(),isLeaf:R()}).loose())}).loose();const $ve=V({docName:I().min(1),title:I(),matchingTags:B(I().min(1)),snippet:I().nullable()}).loose();V({name:I().min(1),docs:B($ve)}).loose(),V({folder:z(),frontmatter_local:H(I(),z()).nullable(),warnings:B(I()).optional().meta({description:"Non-fatal degradations of this response, one per entry; the field each affects is absent, null, or incomplete — the aligned `warningCodes` entry names which field and how."}),warningCodes:B(U([`symlink-refused`,`malformed-yaml`,`unverifiable`,`templates-symlink-refused`,`templates-unverifiable`])).optional().meta({description:"Machine-readable codes aligned 1:1 with `warnings`; switch on these, never on the English. `symlink-refused` / `malformed-yaml` / `unverifiable`: this folder's own `.ok/frontmatter.yml` (a symlink, malformed YAML, or an lstat failure) — `frontmatter_local` is null. `templates-symlink-refused` / `templates-unverifiable`: the `.ok/templates` directory on this folder, or a `.ok` or `.ok/templates` directory on an ancestor it inherits from — a symlink (wherever it points, dangling included), or a non-ENOTDIR `lstat` failure — `folder.templates_available` omits that directory's templates and may still list others. A non-directory `.ok` / `.ok/templates` (ENOTDIR) is treated as empty and yields no `templates-*` code. This folder's own symlinked `.ok` is a 400, never a warning."})}).loose(),V({path:I(),frontmatter:H(I(),z()).optional()}).loose(),V({applied:z()}).loose();const sJ=H(I(),z()).meta({description:`Free-form frontmatter map embedded in template payloads.`});V({template:V({name:I().min(1),folder:I(),scope:U([`local`,`inherited`]),path:I().min(1),frontmatter:sJ,body:I()}).strict()}).strict(),V({templates:B(V({name:I().min(1),title:I().optional(),description:I().optional(),path:I().min(1),source_folder:I()}).strict()),truncated:R()}).strict(),V({folder:I(),name:I(),body:Bd.optional(),frontmatter:sJ.optional(),...Ud,summary:Wd}).strict(),V({path:I().min(1),created:R(),warnings:B(I())}).strict(),V({sourcePath:I().min(1),targetFolder:I(),name:I().optional(),title:I().optional(),deleteSource:R().optional(),...Ud,summary:Wd}).strict(),V({path:I().min(1),created:R(),warnings:B(I())}).strict(),V({existed:R(),path:I().min(1)}).strict(),V({fromFolder:I(),fromName:I(),toFolder:I(),toName:I(),body:Bd.optional(),frontmatter:sJ.optional(),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),committed:R()}).strict();const cJ=U(Ed),eye=/^[a-z0-9-]+$/,lJ=V({name:I(),description:I(),metadata:V({pack:I()}).strict().optional()}).strict();V({skill:V({name:I().min(1),scope:cJ,path:I().min(1),frontmatter:lJ,body:I(),files:B(V({path:I().min(1),text:I().nullable()})).optional(),managed:R().optional()}).strict()}).strict();const tye=V({source:I().min(1),publisher:I().optional(),skill:I().optional(),marketplaceUrl:I().optional(),importedAt:I().min(1),autoUpdate:R().optional()}).strict(),nye=V({name:I().min(1),description:I().optional(),scope:cJ,path:I().min(1),canonicalPath:I().min(1).optional(),filePaths:B(I()).optional(),absolutePath:I().min(1).optional(),installed:R(),hosts:B(I()),hostQualifier:I().optional().meta({description:"Set on a GLOBAL entry that shares its name with a distinct-content bundle in another host dir AND is not the by-name default: the host id whose root holds THIS bundle. Doc-name builders append it (`__skill__/global/<name>@<host>`) so each same-named bundle keeps its own tab and its own write-back path; the default bundle keeps the stable unqualified name."}),driftPaths:B(I()).optional().meta({description:`Recorded locations whose on-disk form (copy vs symlink) no longer matches what OK last wrote there — evidence another tool rewrote the path.`}),hostAliases:H(I(),I()).optional().meta({description:`Host skills roots that are symlink ALIASES of another location (host id → base-relative target root). An aliased folder is a derived view — no menu row, never a write target; the host's icon rides the target root's row.`}),conflictHosts:B(I()).optional().meta({description:`Hosts whose dir holds a DIFFERENT same-name skill (fork/conflict) — occupied, not this skill.`}),symlinkedHosts:B(I()).optional(),installableEditors:B(I()).optional(),hubOffered:R().optional().meta({description:"Whether the vendor-neutral `.agents/skills` hub is a live destination at this scope on THIS machine — server-computed via the same predicate that filters the Folders surface, so the install menu and Settings cannot disagree. True when the project already uses the hub OR a host that reads it is installed (`HUB_READER_EDITORS`)."}),linkMode:R().optional(),customPlacements:B(V({path:I(),mode:U([`copy`,`link`])}).strict()).optional(),plugin:V({name:I().min(1),marketplace:I().min(1),provider:I().min(1),url:I().optional()}).strict().optional(),managed:R().optional(),origin:tye.optional(),pack:I().optional(),modified:R().optional(),revertable:R().optional(),ignored:R().optional(),size:fve.optional()}).strict();V({name:I().min(1),scope:cJ,apply:R().optional()}).strict(),V({line:I().min(1),gitignorePath:I().min(1),applied:R(),alreadyTracked:R().optional()}).strict(),V({skills:B(nye),truncated:R()}).strict(),V({scope:cJ.default(`project`),name:I().meta({description:`Managed skill name to create or update.`}),body:Bd.optional(),frontmatter:lJ,...Ud,summary:Wd}).strict();const uJ=[`skill-name-vendor-word`,`skill-body-too-long`],dJ=B(U(uJ)).meta({description:"Machine-readable codes aligned 1:1 with `warnings` (`warnings[i]` is the display text for `warningCodes[i]`)."});V({path:I().min(1),created:R(),warnings:B(I()),warningCodes:dJ}).strict(),V({scope:cJ.default(`project`),name:I(),dryRun:R().optional(),setAutoUpdate:R().optional(),...Ud,summary:Wd}).strict(),V({name:I().min(1),updated:R(),source:I().min(1),localBody:I().optional(),upstreamBody:I().optional(),gitTracked:R().optional(),warnings:B(I()),warningCodes:dJ}).strict(),V({scope:cJ.default(`project`),name:I(),...Ud,summary:Wd}).strict(),V({name:I().min(1),baselineRef:I().min(1),restoredFiles:B(I()),warnings:B(I())}).strict();const fJ=`This member also carries the one bookkeeping failure that does not undo the operation: the content change landed, but a state file this server keeps beside it refused to be rewritten because it could not be read, so the install or import records still describe the old state until an operator repairs that file. Absent when there is nothing to report; a server that predates this member omits it, so treat its absence as no warning rather than as an error.`;V({existed:R(),path:I().min(1),warnings:B(I()).optional().meta({description:`Present when this delete removed a directory a retention record ties to a recovery copy an earlier failed move kept, whose source was never verified unchanged — either because this server verified the deleted directory against the copy that record describes, or because it could not read the directory and so could not confirm either way. Each entry says which of the two it is; neither claims more than the check established. ${fJ}`})}).strict(),V({scope:cJ.default(`project`),fromName:I(),toName:I(),body:Bd.optional(),frontmatter:lJ.optional(),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),committed:R(),warnings:B(I()).optional().meta({description:`Present when the rename itself completed but something beside it did not. ${fJ}`})}).strict(),V({name:I(),toName:I().optional().meta({description:"Name for the skill at the destination scope; defaults to `name`. The SKILL.md `name` frontmatter is rewritten to match."}),fromScope:cJ,toScope:cJ,...Ud,summary:Wd}).strict(),V({scope:cJ,path:I().optional(),droppedLocations:B(I()).default([]).meta({description:"Locations the skill occupied at the source that were removed and not re-created at the destination: the `agents` hub and custom roots, which projection does not cover. Entries are install location ids, so they can be passed straight back as an install `add` list with `scope` set to the destination scope; custom roots resolve against that scope's base."}),warnings:B(I()).optional().meta({description:`Present when the move itself completed but something beside it did not. ${fJ}`})}).strict().meta({description:"Scope-move result. Rename paths deliberately do not emit authoring warnings, consistent with same-scope rename and duplicate. Content-authoring and import responses carry those warnings and their codes. The Skills Studio client parses `droppedLocations` off the wire but deliberately does not render it yet; how a human is told what was removed is an open product decision."}),V({scope:cJ,name:I(),toName:I(),...Ud,summary:Wd}).strict(),V({name:I().min(1)}).strict(),V({name:I(),home:I().min(1)}).strict(),V({docName:I().min(1)}).strict();const pJ=U([`reference`,`script`,`file`]);V({scope:cJ.default(`project`),name:I(),path:I().min(1),content:I(),...Ud,summary:Wd}).strict().superRefine((e,t)=>{Qve(e.path)&&zd(e.content,t,[`content`])}),V({path:I().min(1),created:R(),kind:pJ,content:R()}).strict(),V({scope:cJ.default(`project`),name:I(),from:I().min(1),to:I().min(1),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),fromDocName:I().optional(),toDocName:I().optional()}).strict(),V({path:I().min(1),kind:pJ,text:I()}).strict(),V({path:I().min(1),existed:R(),kind:pJ}).strict();const mJ=$i([dve,W(`agents`)]),hJ=I().min(1).refine(e=>!e.startsWith(`/`)&&!e.startsWith(`~`)&&!/^[A-Za-z]:/.test(e),{error:`a custom root is base-relative (e.g. ".tim/skills"), not absolute or ~-prefixed`}).refine(e=>e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),{error:`a custom root may not contain "..", "." or empty path segments`}).refine(e=>e.includes(`/`),{error:`a custom root is a path (e.g. ".tim/skills") — bare editor names are host ids`}),gJ=$i([mJ,hJ]);V({scope:cJ.default(`project`),name:I(),targets:B(mJ).optional().meta({description:'SET-EXACT install targets (editor ids, plus "agents" for the .agents hub — in-place skills only): the COMPLETE resulting host set. Omit to use project-configured editors; pass [] to uninstall everywhere. Stateless callers should prefer `add`/`remove`.'}),add:B(gJ).optional().meta({description:`Locations to ADD the skill to (everything else untouched). Editor ids fan out a managed copy/symlink; a custom root path (".tim/skills") places the bundle there.`}),remove:B(gJ).optional().meta({description:"Locations to REMOVE the skill from (lossless only — a hand-edited fork is refused, never deleted). The source cannot be removed; move it first with `source`."}),mode:U([`copy`,`link`]).optional().meta({description:`"link": one real folder (the source); every other location becomes a symlink to it. "copy": independent real folders, refreshed from the source until hand-edited (a hand-edit forks that copy). Converts existing locations losslessly. Omit to follow the form the skill already uses.`}),source:gJ.optional().meta({description:`Move the skill's REAL folder to this location (the old source becomes a symlink to it — never a removal). Sticky across rescans.`}),linkMode:R().optional(),setSource:I().min(1).optional(),place:V({dir:I().min(1).meta({description:`Project-relative directory the bundle dir is created under (e.g. ".windsurf/skills").`}),mode:U([`copy`,`link`])}).strict().optional(),convert:V({target:gJ.meta({description:`The installed location to convert — an editor id, "agents", or a recorded custom placement path.`}),mode:U([`copy`,`link`]).meta({description:`"link": replace this location with a symlink to the source. "copy": replace it with an independent real folder.`})}).strict().optional(),unplace:V({path:I().min(1).meta({description:`The recorded placement bundle path (e.g. ".windsurf/skills/my-skill").`})}).strict().optional(),...Ud,summary:Wd,fork:V({editor:I().min(1),action:U([`align`,`make-source`,`rename`]),toName:I().optional()}).strict().optional()}).strict().refine(e=>e.targets===void 0||e.add===void 0&&e.remove===void 0,{error:"`targets` is set-exact; `add`/`remove` are additive — use one style per call"}).refine(e=>e.fork===void 0||e.targets===void 0&&e.add===void 0&&e.remove===void 0&&e.source===void 0&&e.setSource===void 0,{error:"`fork` is its own operation — run it in a separate call"}).refine(e=>e.fork?.action!==`rename`||e.fork.toName!==void 0,{error:"`fork.rename` requires `toName`"}).refine(e=>e.source===void 0||e.add===void 0&&e.remove===void 0,{error:"a `source` move is its own operation — run it in a separate call from `add`/`remove`"}).refine(e=>[e.targets!==void 0||e.add!==void 0||e.remove!==void 0,e.place!==void 0,e.unplace!==void 0,e.convert!==void 0,e.source!==void 0||e.setSource!==void 0,e.fork!==void 0].filter(Boolean).length<=1,{error:"one operation per call — membership (`targets`/`add`/`remove`), `place`, `unplace`, `convert`, `source`, and `fork` are mutually exclusive"});const _J=[`no-targets`,`scripts-present`,`name-conflict`,`no-description`,`skill-fork-name-unpatched`,`place-path-invalid`,`place-fork-refused`,`links-not-permitted`];V({name:I().min(1).meta({description:`Managed skill name installed or uninstalled.`}),hosts:B(I()).meta({description:`Editor ids the skill is projected into after the operation; [] is expected after uninstall.`}),scripts:R().meta({description:`True when the skill ships executable scripts, projected but never run.`}),warnings:B(I()).meta({description:`Non-fatal install/uninstall warnings from target projection.`}),warningCodes:B(U(_J)).meta({description:"Machine-readable warning codes aligned with `warnings`."}),placedAt:I().optional(),sourceMovedTo:I().optional()}).strict(),V({scope:cJ.default(`project`),name:I().meta({description:`Managed skill name to uninstall without deleting source.`})}).strict(),V({name:I().min(1).meta({description:`Managed skill name requested for uninstall.`}),uninstalled:R().meta({description:`True when an install marker existed and was removed; false for an idempotent no-op.`})}).strict(),V({targets:B($q),configured:R(),folders:B(V({scope:cJ,host:I(),root:I(),state:U([`own`,`linked`,`linked-parent`,`absent`]),target:I().optional(),drift:W(!0).optional(),expected:I().optional()}).strict()).optional()}).strict();const vJ=V({action:W(`link`),scope:cJ,root:I().min(1).meta({description:`The folder to link (e.g. ".codex/skills").`}),target:I().min(1).meta({description:`The root it merges into (e.g. ".agents/skills"). Required.`})}),yJ=V({action:W(`unlink`),scope:cJ,root:I().min(1).meta({description:`The linked folder to materialize back.`}),exclude:B(I().min(1)).optional().meta({description:`Skill names to LEAVE OUT when materializing — the folder keeps every other skill it currently sees (as per-skill links) and stops auto-following the target root.`})}).strict(),bJ=V({action:W(`add-root`),scope:cJ,root:hJ.meta({description:`New custom skills root to declare (base-relative, e.g. ".team/skills").`})}).strict(),rye=ea(`action`,[vJ.extend({preview:R().optional().meta({description:`Return the merge plan only (moves, drops, removes, conflicts, strays) — nothing is written.`})}).strict(),yJ,bJ]);ea(`action`,[vJ.strict(),yJ,bJ]),V({folderAction:rye}).strict();const iye=V({moves:B(I()),drops:B(I()),removes:B(I()),replaces:B(I()),conflicts:B(I()),strays:B(I())}).strict();V({targets:B($q),reprojected:B(V({name:I(),hosts:B(I())}).strict()),bundleHosts:B(I()),removedFrom:B(I()),folder:V({moved:B(I()),dropped:B(I()),linked:B(I())}).strict().optional(),preview:iye.optional()}).strict(),V({scope:cJ.default(`project`),name:I(),version:I().regex(/^[0-9a-f]{40}$/i),...Ud,summary:Wd}).strict(),V({name:I().min(1),version:I(),restoredFiles:B(I()),warnings:B(I())}).strict(),V({query:I().optional(),intent:U([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:U([`navigation`,`relevance`]).optional(),scopes:B(U([`page`,`folder`,`content`,`file`])).optional(),scope:I().optional(),limit:L().int().nonnegative().optional(),semantic:R().optional(),source:U([`omnibar`,`mcp`,`http`]).optional()}).loose();const aye=V({kind:U([`page`,`folder`,`content`,`file`]),path:I().min(1),title:I(),score:L(),signals:H(I(),z()),snippet:I().optional()}).loose(),oye=U([`applied`,`no_match`,`warming`,`incapable`,`provider_error`,`restart_required`,`query_too_short`]),xJ=U([`warm`,`corpus`,`query`,`dimensions`,`configured_dimensions`]),SJ=V({capable:R(),applied:R(),outcome:oye,providerErrorReason:xJ.nullable().optional().catch(null),coverage:V({embedded:L().int().nonnegative(),total:L().int().nonnegative()})}).loose();V({enabled:R(),keyPresent:R(),keyNotRequired:R(),keySource:U([`project`,`file`,`env`]).nullable(),keyHint:I().nullable(),ready:R(),capable:R(),providerError:R().optional(),providerErrorReason:xJ.nullable().optional().catch(null),embedded:L().int().nonnegative(),total:L().int().nonnegative()}).loose(),V({query:I(),intent:U([`autocomplete`,`full_text`,`omnibar`]),results:B(aye),elapsedMs:L().nonnegative(),semantic:SJ.optional(),truncated:R().optional(),ready:R().optional()}).loose();const sye=V({version:I().min(1),recordedAt:I().min(1)}).loose();V({currentVersion:I().min(1),targets:H(I(),sye.nullable())}).loose(),V({scope:cJ.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL (https://www.skills.sh/<owner>/<repo>/<skill>, or https://www.skills.sh/site/<hostname>/<skill> for a website catalog), GitHub owner/repo[/subpath], git URL, or local/file path.`}),skill:I().min(1).optional().meta({description:`Specific skill name to import from a multi-skill source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection (the caller installs explicitly afterwards). Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (the Explore tab), so the install is reported to skills.sh and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...Ud,summary:Wd}).strict(),V({scope:cJ.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL, GitHub owner/repo[/subpath], git URL, or local/file path.`}),skills:B(I().min(1)).min(1).max(100).meta({description:`Skill names to import from the source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection. Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (a marketplace plugin bundle), so the import is reported to skills.sh as one batched install event and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...Ud,summary:Wd}).strict(),V({results:B(V({requested:I(),status:U([`imported`,`already-imported`,`not-found`,`failed`]),name:I().optional(),collisionRenamedFrom:I().optional(),warnings:B(I()),warningCodes:dJ,error:I().optional()}).loose()),imported:L(),alreadyImported:L(),failed:L()}).loose(),V({scope:cJ.default(`project`),names:B(I().min(1)).min(1).max(100).meta({description:`Managed skill names to refresh from their recorded upstreams.`}),...Ud,summary:Wd}).strict(),V({results:B(V({requested:I(),status:U([`updated`,`up-to-date`,`not-found`,`failed`]),source:I().optional(),warnings:B(I()),warningCodes:dJ,error:I().optional()}).loose()),updated:L(),upToDate:L(),failed:L()}).loose();const cye=V({source:I(),ref:I().optional(),contentHash:I(),publisher:I().optional()}).loose();V({name:I().min(1).meta({description:`Managed skill name created or matched.`}),path:I().min(1).meta({description:`Store-relative path to the imported skill source.`}),created:R().meta({description:`True when this request created new source files.`}),alreadyImported:R().meta({description:`True when identical content was already present and no files changed.`}),collisionRenamedFrom:I().optional().meta({description:`Original source name when collision handling renamed the import.`}),provenance:cye,warnings:B(I()).meta({description:`Non-fatal import warnings, such as skipped unsupported files.`}),warningCodes:dJ}).loose();const lye=U([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`comments`,`lint-config`,`local-targets`]);V({v:W(1),ch:W(`server-info`),seq:L(),serverInstanceId:I().min(1),currentBranch:I().min(1).optional()}).loose(),V({v:W(1),ch:W(`branch-switched`),seq:L(),branch:I().min(1)}).loose(),V({v:W(1),ch:lye,seq:L()}).loose(),V({v:W(1),ch:W(`disk-ack`),seq:L(),docName:I().min(1),sv:I().min(1)}).loose(),V({v:W(1),ch:W(`config-validation-rejected`),seq:L(),docName:I().min(1),error:Qie}).loose(),V({v:W(1),ch:W(`config-ignore-nested-error`),seq:L(),path:I().min(1),error:I().min(1)}).loose(),(()=>{let e=globalThis.Intl.Segmenter;return e?new e(`en`,{granularity:`word`}):null})();const uye=Zi({name:I(),description:I(),files:Zi({skillMd:I(),scripts:B(I()),references:B(I())})}),dye=Zi({pluginProvider:I().optional(),plugin:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional(),version:I().optional(),gitCommitSha:I().optional(),scope:I().optional(),projectPath:I().optional()}),fye=Zi({commands:R(),hooks:R(),mcp:R()}),pye=Zi({...uye.shape,sourceHarness:I(),sourceHarnesses:B(I()),home:I(),provenance:dye,inert:fye,outsideProject:R().optional()}),mye=Zi({schema:W(1),name:I(),version:I(),description:I().optional(),author:Zi({name:I()}).optional(),skills:B(I()),hostCompatibility:B(I()).optional(),capabilities:Zi({scripts:I(),network:I(),inert:B(I())}).optional(),provenance:Zi({source:I(),ref:I(),contentHash:I()}).optional()});V({skills:B(pye),packs:B(mye)}).loose(),V({results:B(V({id:I().min(1),name:I().min(1),source:I().min(1),description:I(),installs:L().int().nonnegative().nullable(),publisher:I().nullable()}).loose()),backend:U([`skills.sh`,`github-fallback`]),degraded:R()}).loose(),V({title:I(),description:I(),image:I().nullable(),skillsUrl:I().nullable(),sourceKind:U([`github`,`site`]),sourceUrl:I()}).loose(),V({skills:B(V({name:I(),description:I().nullable()}).loose())}).loose(),V({kind:U([`local`,`import`,`none`]),scope:U(Ed).optional(),name:I().optional(),dir:I().optional(),source:I().optional(),ref:I().optional(),via:U([`source`,`publisher`]).optional()}).loose();const hye=V({relPath:I(),content:I().nullable()}).loose(),gye=V({provider:I(),plugin:I(),version:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional()}).loose(),_ye=V({provider:I(),plugin:I(),version:I().optional(),description:I().optional(),repositoryUrl:I().optional(),bundledSkills:B(I()),capabilities:V({commands:R(),hooks:R(),mcp:R(),agents:R()}),setupSupported:R()}).loose();V({name:I(),description:I().nullable(),skillMd:I(),files:B(hye),plugin:gye.optional(),pluginBundle:_ye.optional()}).loose();const vye=[`auth-error`,`detached-head`,`dirty-tree`,`diverged-local-commits`,`external-changes-pending`,`git-index-locked`,`git-operation-in-progress`,`no-commits-yet`,`no-push-permission`,`non-content-merge-failure`,`protected-branch`,`unsafe-incoming-symlinks`],CJ=e=>e*8+4;CJ(92),CJ(40),Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));const wJ={fileSystem:`File System`,gitUpstream:`Git (upstream)`,service:`OpenKnowledge (service)`,generator:`OpenKnowledge (generated)`},TJ=`state/bug-reports`,yye=Zi({at:I(),transport:I(),outcome:I(),reference:I().optional(),error:I().optional(),errorCode:I().optional()}),bye=Zi({reason:I(),at:I(),errorCode:I().optional()});Zi({version:L().int().catch(1),id:I(),createdAt:I(),bundleLevel:I(),zipBytes:L().int().nonnegative().catch(0),zipDeleted:R().optional(),state:I(),systemWide:R().optional(),projectSlug:I().nullable().optional(),reference:I().optional(),lastError:bye.optional(),attempts:B(yye).optional(),note:I().optional()}),Zi({version:L().int().catch(1),id:I().optional(),sentAt:I().optional(),reference:I().optional()});const xye=new Map([[`PORT`,[`server`,`port`]],[`OK_BIND`,[`server`,`bind`]],[`OK_EXTERNAL_URL`,[`server`,`externalUrl`]],[`OK_ALLOW_EXTERNAL`,[`server`,`allowExternal`]],[`OK_OPEN_BROWSER`,[`server`,`openBrowser`]],[`OK_IDLE_SHUTDOWN`,[`server`,`idleShutdown`]]]);function Sye(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toUpperCase()}function Cye(e){return`OK_${(e[0]===`server`?e.slice(1):e).map(Sye).join(`_`)}`}function wye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tye(e){let{value:t,file:n,source:r,doc:i}=e,a=[],o=(e,t)=>{if(t.length>0){let e=Wl(Ul,t);if(e!==void 0){if(e.scope===`project-local`){let e=Cye(t),o;i!=null&&r!=null&&n!=null&&(o=Zu({file:n,source:r,doc:i,path:t})),a.push({path:[...t],...xye.has(e)?{envVar:e}:{},...o===void 0?{}:{source:o}})}return}}if(wye(e))for(let[n,r]of Object.entries(e))o(r,[...t,n])};return o(t,[]),a}const EJ=`(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)`;RegExp(`^127\\.${EJ}\\.${EJ}\\.${EJ}$`);function DJ(e,t){return e===`unix-chain`?`# ok-mcp${t}-v`:`# ok-mcp${t}-win-v`}function OJ(e){return e.replace(/\/+/g,`/`).replace(/\/+$/,``)}function Eye(e){return rt[e].userHomeDirName}function Dye(e,t){return e===`stable`?`${OJ(t)}/Library/Application Support/OpenKnowledge/path-install.json`:`${OJ(t)}/${Eye(e)}/path-install.json`}const Oye=[`.ok`,cd,`installed-skills.json`],kye=U(Ed),Aye=Zi({hosts:B(I()),scope:kye,scripts:R(),installedAt:ki(),projection:U([`symlink`,`copy`]).optional(),contentHash:I().optional()}),jye=Zi({schema:W(1),skills:H(I(),Aye).default({})});function Mye(e){let t;try{t=JSON.parse(e)}catch{return null}let n=jye.safeParse(t);return n.success?n.data:null}function kJ(e){if(e===``)throw Error(`toPathspec: empty path. ":(literal)" is an empty pattern that matches every tracked path; pass "." if you meant the repo root.`);return`:(literal)${e}`}function Nye(e){if(e.length===0)throw Error(`pathspecArgs: empty path list. A bare "--" removes the pathspec restriction rather than selecting nothing.`);return[`--`,...e.map(e=>kJ(e))]}const AJ=[{tagName:`Mirror`,attrName:`src`,resolution:`bare-doc-name`},{tagName:`Excalidraw`,attrName:`src`,resolution:`doc-relative`}];for(let e of AJ){let t=QB.find(t=>t.name===e.tagName);if(!t)throw Error(`JSX_SRC_REF_TAGS: no built-in component descriptor named '${e.tagName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the tagName to match a descriptor in builtInComponents.`);if(!t.props.some(t=>t.name===e.attrName))throw Error(`JSX_SRC_REF_TAGS: component '${e.tagName}' declares no prop named '${e.attrName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the attrName to match one of the descriptor's props.`)}gH(),PV(),FV();function Pye(){return QB.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function Fye(){return Pye().filter(e=>{let t=Iye(e);return t!==`fence`&&t!==`html`})}function Iye(e){return e.name===`MermaidFence`?`fence`:e.name===`HtmlAlignBlock`?`html`:e.hasChildren?`jsx-block`:`jsx-void`}const jJ=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),MJ=globalThis;MJ[jJ]===void 0&&(MJ[jJ]=sr());const NJ=MJ[jJ],PJ=Zi({version:I().regex(/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(NJ,{description:`Recorded skill version for this target.`}),recordedAt:ki().register(NJ,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:U([`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`]).register(NJ,{description:`Install-source surface that recorded this entry.`}).optional()}),Lye=Zi({enabled:R().register(NJ,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:ki().register(NJ,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})});Zi({schema:W(1).register(NJ,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zi({"claude-cowork":PJ.optional(),"cli-hosts":PJ.optional()}).register(NJ,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:H(I(),Lye).register(NJ,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional(),installsReported:B(I()).register(NJ,{description:"Skill installs already reported to skills.sh from this machine, as `<owner/repo>#<skill>`. Append-only; presence suppresses a re-report."}).optional()});function Rye(e,t,n,r){return e.success?{code:`UNKNOWN`,message:`unexpected success in error path`}:{code:`SCHEMA_INVALID`,issues:e.error.issues.map(e=>{let i=e.path.map(e=>typeof e==`symbol`?String(e):e),a=Zu({file:r,source:n,doc:t,path:i});return{path:i,message:e.message,issueCode:e.code,...a===void 0?{}:{source:a}}})}}function FJ(e,t,n){let r=`${e}.invalid-${t.replace(/[:.]/g,`-`)}`;try{return D(e,r),r}catch(t){n(`[config] Could not sideline invalid config file ${e} → ${r}: ${t instanceof Error?t.message:String(t)}. File left in place; using schema defaults.`);return}}function IJ(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Reflect.get(n,e)}return n}function zye(e){let t=[],n=[[`maxBatchSize`,1,Ll],[`maxBatchChars`,1,Rl],[`docTimeoutMs`,1,zl]];for(let[r,i,a]of n){let n=[`search`,`semantic`,r],o=IJ(e.rawConfig,n),s=e.config.search.semantic[r];if(o===void 0||o===s)continue;let c=`Expected an integer between ${i} and ${a}; using default ${s}.`,l=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});t.push({path:n,message:c,...l===void 0?{}:{source:{file:l.file,line:l.line,column:l.column}}})}return t.length>0?[{code:`VALUE_FALLBACK`,issues:t}]:[]}function Bye(e){let t=IJ(e.rawConfig,[`git`,`hosts`]);if(t===void 0)return[];let n=gie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`git`,`hosts`,...t.path.map(String)],r=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:`${t.message}; ignoring this git-host declaration.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function Vye(e){let t=IJ(e.rawConfig,[`autolinks`]);if(t===void 0)return[];let n=_ie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`autolinks`,...t.path.map(String)],r=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:t.path.length===0?`${t.message}; ignoring autolinks.`:`${t.message}; ignoring this autolink entry.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function LJ(e){let{absPath:t,sideline:n=!0,timestamp:r=new Date().toISOString()}=e,i=e.warn??(e=>console.warn(e)),a=Ul.parse({});if(!g(t))return{valid:!0,value:a,source:void 0,diagnostics:[]};let o;try{o=S(t,`utf-8`)}catch(e){let n=e instanceof Error?e.message:String(e);i(`[config] Could not read ${t}: ${n}. Using schema defaults.`);let r={code:`UNREADABLE`,detail:n};return{valid:!1,value:a,error:r,diagnostics:[{...r}]}}let s=(0,xs.parseDocument)(o);if(s.errors.length>0){let e=s.errors.map(e=>e.message).join(`; `);i(`[config] ${t} contains invalid YAML (${e}). Using schema defaults.`+(n?``:` Pass-through mode: file left in place.`));let o=n?FJ(t,r,i):void 0,c={code:`YAML_PARSE`,detail:e};return{valid:!1,value:a,error:c,diagnostics:[{...c}],...o===void 0?{}:{sidelinedTo:o}}}let c=s.toJSON()??{},l=nd({value:c,file:t,source:o,doc:s}),u=l.length>0?id(c):c,d=[...Bye({rawConfig:u,doc:s,source:o,absPath:t}),...Vye({rawConfig:u,doc:s,source:o,absPath:t})];for(let e of d)for(let n of e.issues)i(`[config] ${t} ${n.path.join(`.`)}: ${n.message}`);let f=Ul.safeParse(u);if(!f.success){let e=Rye(f,s,o,t),c=Ul.shape.git.safeParse(IJ(u,[`git`])).data??a.git,p=Object.keys(c.hosts).length>0?`Using schema defaults while preserving valid git-host declarations.`:`Using schema defaults.`;i(`[config] ${t} fails schema validation (${f.error.issues.length} issue(s)). ${p}`+(n?``:` Pass-through mode: file left in place.`));let m=n?FJ(t,r,i):void 0,h=[...l,...d,...Cd(e)&&e.code===`SCHEMA_INVALID`?[{...e}]:[]];return{valid:!1,value:{...a,git:c},error:e,diagnostics:h,...m===void 0?{}:{sidelinedTo:m}}}let p=[...l,...d,...zye({rawConfig:u,config:f.data,doc:s,source:o,absPath:t})];return{valid:!0,value:f.data,source:t,diagnostics:p}}function RJ(e=_e()){return j(e,ft().userHomeDirName)}const zJ=`.tmp.`,BJ=[8,4,4,4,12];function Hye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const Uye=BJ.map(e=>`[0-9a-f]`.repeat(e)).join(`-`),Wye=BJ.map(e=>`[0-9a-f]{${e}}`).join(`-`),Gye=`*${zJ}${Uye}`;RegExp(`${Hye(zJ)}${Wye}$`);function Kye(e){return`${e}${zJ}${Ne()}`}function qye(e){try{let t=k(e),n=`${ae(e)}${zJ}`,r=Date.now()-3e4;for(let e of w(t)){if(!e.startsWith(n))continue;let i=j(t,e);try{te(i).mtimeMs<r&&ne(i)}catch{}}}catch{}}function VJ(e,t,n={}){qye(e);let r=Kye(e);try{re(r,t,{encoding:`utf-8`,mode:n.mode??420}),D(r,e)}catch(e){try{ne(r)}catch{}throw e}}var HJ=class extends Error{code=`LOCK_TIMEOUT`;lockPath;timeoutMs;constructor(e,t){super(`Could not acquire file lock at ${e} within ${t}ms`),this.name=`FileLockTimeoutError`,this.lockPath=e,this.timeoutMs=t}};async function Jye(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new HJ(e,r);s=!1;let c;try{c=b(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=te(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ne(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new HJ(e,r);await Gie(i);continue}try{return await t()}finally{try{f(c)}catch{}try{ne(e)}catch{}}}}function Yye(e){let t=Date.now()+e;for(;Date.now()<t;);}function UJ(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new HJ(e,r);s=!1;let c;try{c=b(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=te(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ne(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new HJ(e,r);Yye(i);continue}try{return t()}finally{try{f(c)}catch{}try{ne(e)}catch{}}}}const WJ=`config.yml`;function GJ(e,t,n){if(e===`user`)return N(RJ(n??_e()),`global.yml`);let r=A(t)?t:N(t);return e===`project-local`?N(r,`.ok`,cd,WJ):N(r,`.ok`,WJ)}const Xye=[`LC_ALL`,`LC_MESSAGES`,`LANG`];function KJ(e){let t=e.trim().split(`@`)[0].split(`.`)[0];return t===``||t===`C`||t===`POSIX`?null:jP(t.replaceAll(`_`,`-`))}function Zye(e){for(let t of Xye){let n=e[t]?.trim();if(n!==void 0&&n!==``)return KJ(n)}return null}function Qye(e){let t=e.OK_LANG?.trim();if(t!==void 0&&t!==``)return jP(t)??void 0}function $ye(e=process.env){let t=Qye(e),n=Zye(e);if(n===null)return{override:t,preferenceList:[]};let r=[],i=e.LANGUAGE;if(i!==void 0)for(let e of i.split(`:`)){let t=KJ(e);t!==null&&r.push(t)}return{override:t,preferenceList:[...r,n]}}function qJ(){return pd(ud)}function JJ(){return ft().keyringService}function YJ(e){try{e()}catch{}}var ebe=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(JJ(),e).getPassword()}catch(t){return YJ(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return YJ(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return YJ(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(JJ(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(JJ(),e).deletePassword()}catch{}}},XJ=class{backend=`file`;authFile;constructor(e){this.authFile=e??j(RJ(),`auth.yml`)}read(){if(!g(this.authFile))return{};try{let e=S(this.authFile,`utf-8`);return(0,xs.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);g(t)||v(t,{recursive:!0,mode:448}),VJ(this.authFile,(0,xs.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},tbe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${qJ()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function ZJ(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(JJ(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
429
|
+
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function O_e(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&D_e(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=E_e(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function Dq(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=t.before??``,a=t.after??``,o=e,s=o.charCodeAt(0);Oq(i.charCodeAt(i.length-1),s,r)&&(o=kq(s)+o.slice(1));let c=o.charCodeAt(o.length-1);return Oq(a.charCodeAt(0),c,r)&&(o=o.slice(0,-1)+kq(c)),o}function Oq(e,t,n){return!(Vf(t)!==1||n===`_`&&Vf(e)===void 0)}function kq(e){return`&#x${e.toString(16).toUpperCase()};`}function k_e(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!j_e(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function A_e(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=Dq(n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),r,i),s+=a.move(i),o(),s}function j_e(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}const Aq=[{mode:`protecting`,protect:LH,reservations:FH},{mode:`protecting`,protect:FU,reservations:HH},{mode:`protecting`,protect:jH,reservations:DH},{mode:`serializer-only`,reservations:[{to:``}]}];new Set(Aq.flatMap(({reservations:e})=>e.map(({to:e})=>e)));function M_e(e,t){switch(t.mode){case`protecting`:return t.protect(e);case`serializer-only`:return e}}function jq(e){return Aq.reduce(M_e,e)}function Mq(e){return e.data?.sourceRaw}function N_e(e){return e.type===`text`?e.value===``:e.type===`mdxJsxTextElement`&&Mq(e)===``}function Nq(e){return e.type===`paragraph`&&(e.children??[]).every(N_e)}function Pq(e){let t=e.children??[],n=t[0]?.children?.length??0,r=0;for(let e=1;e<t.length;e++)r=Math.max(r,t[e]?.children?.length??0);let i=e.align??[];return Math.max(n,r,i.length)}function P_e(e){switch(e.type){case`table`:return Pq(e)===0;case`code`:return e.data?.sourceStyle===`indented`&&/^\n*$/.test(e.value??``);case`thematicBreak`:return Mq(e)===``;case`html`:return(e.value??``)===``;case`mdxJsxFlowElement`:return Mq(e)===void 0&&e.data?.htmlBoundary===void 0&&(e.children??[]).length===0&&!e.name;case`list`:return(e.children??[]).length===0;default:return!1}}function F_e(e){let t=[];for(let n of e.children){if(n.type===`table`&&Pq(n)===0){console.warn(JSON.stringify({event:`table-serialize-dropped-empty`,rows:(n.children??[]).length}));continue}P_e(n)||(n.type===`paragraph`&&n.children.length>0&&Nq(n)&&(n.children=[]),t.push(n))}e.children=t}function I_e(e,t){let n=e,r=t;return n.type===`heading`&&n.data?.sourceContiguousNext===!0&&r.type===`paragraph`}const L_e=(e,t)=>{if(Nq(e)||I_e(e,t))return 0;let n=e.position,r=t.position;if(!n||!r)return;let i=r.start.line-n.end.line-1;return i>=1?i:void 0},Fq=/(?<!\\)\$(?=\S)([^$\n]*?[^\s$])\$(?!\d)/g;function R_e(){return(e,t)=>{let n=typeof t.value==`string`?t.value:``;Wf(e,`text`,(e,t,r)=>{if(r===void 0||t==null)return;let i=e.value;if(i.indexOf(`$`)===-1)return;let a=mP(e);Fq.lastIndex=0;let o=[],s;for(;(s=Fq.exec(i))!==null;){let e=s.index,t=e+s[0].length;if(vP(a,e,1)||vP(a,t-1,1)){Fq.lastIndex=e+1;continue}o.push(s)}if(o.length===0)return;let c=[],l=0;for(let t of o){let r=t.index,i=r+t[0].length;r>l&&c.push(_P(n,e,l,r));let a={type:`inlineMath`,value:t[1]},o=xP(n,e,r,i);o&&(a.position=o),c.push(a),l=i}return l<i.length&&c.push(_P(n,e,l,i.length)),r.children.splice(t,1,...c),[yf,t+c.length]})}}const z_e=new Set([`strong`,`emphasis`,`delete`,`link`,`mark`,`comment`]);function B_e(e){if(e?.type!==`break`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}function V_e(e){e.data??={},e.data.sourceRaw=`<br />`,e.data.sourceStyle=`html`}function Iq(e){if(e?.type!==`text`)return!1;let t=e.data?.sourceRaw;return typeof t!=`string`||t.length===0}const Lq=/[ \t]+$/,Rq=/^[ \t]*$/;function H_e(e){return e.some(e=>!(Iq(e)&&Rq.test(e.value)))}function zq(e,t=!1){for(;e.length>0;){let n=e[e.length-1];if(B_e(n)){V_e(n);break}if(n&&z_e.has(n.type)&&`children`in n){let t=n.children;if(zq(t,!0),t.length===0){e.pop();continue}}if(!t&&Iq(n)&&Lq.test(n.value)){let t=n.value.replace(Lq,``);if(t.length>0){n.value=t;continue}if(H_e(e.slice(0,-1))){e.pop();continue}if(e.every(e=>Iq(e)&&Rq.test(e.value))){let t=e[0];t.value=t.value.charAt(0),e.splice(1)}}break}}const U_e=new Set([`paragraph`,`heading`,`tableCell`]);function W_e(e){let t=e=>{if(U_e.has(e.type)&&`children`in e&&zq(e.children),`children`in e)for(let n of e.children)t(n)};t(e)}const Bq={handlers:{tag:e=>`#${e.value}`},unsafe:[{character:`#`,inConstruct:[`phrasing`],before:`\\s`,after:`[A-Za-z]|[^\\x00-\\x7F]`}]};function G_e(){let e=this.data();e.toMarkdownExtensions||=[],e.toMarkdownExtensions.some(e=>e===Bq)||e.toMarkdownExtensions.push(Bq)}const K_e=new Set([`u`,`ins`]);function q_e(){return e=>{Wf(e,`mdxJsxTextElement`,(e,t,n)=>{if(n===void 0||t==null||e.name===null||!K_e.has(e.name)||(e.attributes??[]).length>0)return;let r={type:`underline`,children:e.children??[],data:{sourceForm:e.name===`ins`?`ins`:`u`}};return e.position&&(r.position=e.position),n.children.splice(t,1,r),t+1})}}function J_e(e){return e.children.some(e=>{let t=e.type;return t!==`yaml`&&t!==`toml`})?e:{...e,children:[...e.children,{type:`paragraph`,children:[]}]}}const Y_e=[{name:`remark-parse`,plugin:w_},{name:`escape-provenance`,plugin:AK},{name:`remark-mdx-agnostic`,plugin:UU},{name:`remark-gfm`,plugin:Uh},{name:`remark-math`,plugin:qW,options:{singleDollarTextMath:!1}},{name:`remark-wiki-link`,plugin:fW},{name:`remark-github-alerts`,plugin:UW,options:xG},{name:`callout-transformer`,plugin:bG},{name:`restore-from-mdx`,plugin:LU},{name:`void-br-promoter`,plugin:qU},{name:`restore-entity-refs`,plugin:PH},{name:`restore-backslash-escapes`,plugin:RH},{name:`details-accordion-promoter`,plugin:aK},{name:`div-align-promoter`,plugin:mK},{name:`image-promoter`,plugin:RK},{name:`indented-code-promoter`,plugin:WK},{name:`math-promoter`,plugin:eq},{name:`single-dollar-math-promoter`,plugin:R_e},{name:`highlight-promoter`,plugin:LK},{name:`underline-promoter`,plugin:q_e},{name:`mermaid-promoter`,plugin:n_e},{name:`comment-promoter`,plugin:wG},{name:`merged-post-parse-walker`,plugin:e_e},{name:`empty-task-item-unmint`,plugin:xK},{name:`link-reference-destination`,plugin:QK},{name:`non-rendering-context-demote`,plugin:d_e},{name:`ensure-non-empty-doc`,plugin:()=>J_e}];function X_e(e){let t=ug();for(let e of Y_e)t=`options`in e&&e.options!==void 0?t.use(e.plugin,e.options):t.use(e.plugin);return t=t.use(FW,{schema:e.schema,handlers:e.handlers}),t.freeze(),t}function Z_e(e){let t=ug().use(zg,[`yaml`]).use(Uh,{tablePipeAlign:!1}).use(qW,{singleDollarTextMath:!1}).use(UU).use(fW).use(G_e).use(aB,{bullet:`-`,fences:!0,rule:`-`,join:[L_e],...e.toMarkdownHandlers?{handlers:e.toMarkdownHandlers}:{}});return t.freeze(),t}function Vq(e){return e.charCodeAt(0)===65279?{source:e.slice(1),hadBom:!0}:{source:e,hadBom:!1}}const Hq=/^\n+$/,Uq=/^\n{2,}$/;function Wq(e,t,n){let r,i,a=e.children;if(a.length>0){let e=a[0]?.position?.start?.offset;if(typeof e==`number`&&e>0){let n=t.slice(0,e);Hq.test(n)&&(r=n)}let n=a[a.length-1]?.position?.end?.offset;if(typeof n==`number`&&n<=t.length){let e=t.slice(n);Uq.test(e)&&(i=e)}}if(!n&&r===void 0&&i===void 0)return;let o={...n?{bom:!0}:{},...r===void 0?{}:{leading:r},...i===void 0?{}:{trailing:i}};return e.data??={},e.data.sourceDocBoundary=o,o}function Q_e(e){if(typeof e!=`object`||!e)return;let t=e,n={};return t.bom===!0&&(n.bom=!0),typeof t.leading==`string`&&Hq.test(t.leading)&&(n.leading=t.leading),typeof t.trailing==`string`&&Uq.test(t.trailing)&&(n.trailing=t.trailing),n.bom||n.leading||n.trailing?n:void 0}function $_e(e,t){let{source:n,hadBom:r}=Vq(e),i=JG(n),a=new ng(jq(i)),o=t.parse(a);a.value=i;let s=t.runSync(o,a);JK(s,i);let c=Wq(s,i,r),l=c?ws(s,c):void 0,u=t.stringify(s);return l?u.type.create({...u.attrs,sourceDocBoundary:l},u.content,u.marks):u}function eve(e,t){return Gq(e,t,!1)}function tve(e,t){return Gq(e,t,!0)}function Gq(e,t,n){let{source:r,hadBom:i}=Vq(e),a=JG(r),o=new ng(jq(a)),s=t.parse(o);o.value=a;let c=t.runSync(s,o);n&&JK(c,a);let l=Wq(c,a,i);return n&&l&&ws(c,l),c}function nve(e,t,n){let r=LW(e,{schema:n.schema,nodeHandlers:n.pmNodeHandlers,markHandlers:n.pmMarkHandlers});Kq(r),yK(r),W_e(r),F_e(r);let i=Q_e(e.attrs?.sourceDocBoundary),a=String(t.stringify(r));return i?.leading&&(a=i.leading+a),i?.trailing&&(a=a.replace(/\n+$/,``)+i.trailing),i?.bom&&(a=`\uFEFF${a}`),a}function Kq(e){if(!(!(`children`in e)||!Array.isArray(e.children))){for(let t of e.children)Kq(t);for(let t=0;t+1<e.children.length;){let n=e.children[t],r=e.children[t+1],i=n?.data,a=r?.data,o=lP(i)?i.escapedChars:null,s=lP(a)?a.escapedChars:null;if(n?.type!==`text`||r?.type!==`text`||typeof n.data?.sourceRaw==`string`||typeof r.data?.sourceRaw==`string`||o===null&&s===null){t+=1;continue}let c=n.value.length;n.value+=r.value,n.data??={},n.data.escapedChars=[...o??[],...(s??[]).map(e=>({...e,offset:e.offset+c}))],r.data?.entityRefSpans?.length&&(n.data.entityRefSpans=[...n.data.entityRefSpans??[],...r.data.entityRefSpans.map(e=>({...e,offset:e.offset+c}))]),e.children.splice(t+1,1)}}}var rve=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};freshnessHolder={checker:void 0};constructor(e){this.schema=yO(e.extensions),this.handlers=cve(this.schema,this.parseCtx),this.freshnessHolder.checker=e.deriveStructuralFreshness?Qs({parse:e=>this.parseWithFallback(e)}):void 0;let{nodeHandlers:t,markHandlers:n}=lve(this.schema,this.freshnessHolder);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=X_e({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=Z_e({toMarkdownHandlers:__e})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return $_e(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?eve(e,this.parseProcessor):{type:`root`,children:[]}}parseToEditorMdast(e){return e.trim()?tve(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?XW(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e,t){let n;try{n=this.schema.nodeFromJSON(e)}catch(t){let n=`MarkdownManager.serialize() failed: schema rejected JSONContent (type=${e.type}, childCount=${e.content?.length??0})`;throw Error(n,{cause:t})}let r=this.freshnessHolder.checker;t?.skipFreshnessDerive&&(this.freshnessHolder.checker=void 0);try{return nve(n,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}finally{this.freshnessHolder.checker=r}}};const qq=eV();function Jq(e,t){let n=new Map;for(let e of t)n.set(e.name,e);let r={};for(let t of e){if(t.type===`mdxJsxExpressionAttribute`)continue;let e=t.name,i=n.get(e);if(t.value===null||t.value===void 0){r[e]=!0;continue}if(typeof t.value==`string`){if(i?.type===`number`){let n=Number(t.value);r[e]=Number.isNaN(n)?t.value:n}else r[e]=i?.type===`boolean`?t.value===`true`:t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function ive(e){let t=!1;return e.descendants(e=>t?!1:e.type.name===`jsxInline`?(e.attrs.sourceDirty&&(t=!0),!1):e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function ave(e,t){return e.attrs.sourceDirty||ive(e)?!0:t?t.isDiverged(e.toJSON()):!1}function ove(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0||t.every(e=>e.type===`text`&&e.value===``)}function Yq(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function Xq(e,t){if(e.length===0)return Yq({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return Yq({type:`inlineCode`,value:e.map(e=>e.value).join(``)},t);if(e.length===1&&`children`in e[0]){let n=e[0];return{...n,children:[Xq(n.children,t)]}}return Yq({type:`inlineCode`,value:Zq(e)},t)}function Zq(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=Zq(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const sve=Oc;function cve(e,t){let n=e.nodes,r=e.marks,i={};n.paragraph&&(i.paragraph=(e,t,r)=>{let i=r.all(e).flat(),a=i.some(e=>e?.isBlock&&!e?.isInline),o=i.some(e=>e?.isInline||e?.isText||e?.isTextblock);if(a&&!o)return i.length===1?i[0]:i;if(a&&o){let e=i.filter(e=>!e?.isBlock||e?.isInline),t=i.filter(e=>e?.isBlock&&!e?.isInline),r=[],a=n.paragraph.createAndFill(null,e.length>0?e:null);return a&&r.push(a),r.push(...t),r.length===1?r[0]:r}return n.paragraph.createAndFill(null,i.length>0?i:null)}),n.blockquote&&(i.blockquote=MW(n.blockquote,e=>({sourceMarkerSpacings:e.data?.sourceMarkerSpacings??null}))),n.tableCell&&(i.tableCell=(e=>(t,r,i)=>{let a=i.all(t).flat();if(a.length>0&&n.paragraph){let t=n.paragraph.create(null,a);return e.createAndFill(null,[t])}return e.createAndFill(null,null)})(n.tableCell)),n.tableRow&&(i.tableRow=MW(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=yW(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r,sourceUrlForm:e.data?.sourceUrlForm??null})},i.imageReference=n.imageReference?e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):e=>n.image.createAndFill({src:``,alt:e.alt??null,title:null})),r.escapeMark&&(i.text=t=>{let n=t.value??``,i=typeof t.data?.sourceRaw==`string`?t.data.sourceRaw:null;if(!n&&!i)return null;if(i)return r.sourceLiteral?e.text(n,[r.sourceLiteral.create({sourceRaw:i})]):e.text(n);let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n);let s=[...(a??[]).map(e=>({kind:`escape`,offset:e.offset,length:1})),...(o??[]).map(e=>({kind:`entity`,offset:e.offset,length:e.length,raw:e.raw}))];s.sort((e,t)=>e.offset-t.offset);let c=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&oc(t.raw)!==null&&rc(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length);if(i){if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=oc(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i))}u=t.offset+t.length}}if(u<n.length){let t=n.slice(u);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=NW(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=NW(r.highlight)),r.underline&&(i.underline=NW(r.underline,e=>({sourceForm:e.data?.sourceForm===`ins`?`ins`:`u`}))),r.comment&&(i.comment=NW(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=MW(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=NW(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=NW(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=MW(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceUnclosedFence:t.data?.sourceUnclosedFence??!1,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`,sourceRaw:e.data?.sourceRaw??null})),n.list&&(i.list=MW(n.list,e=>({ordered:!!e.ordered,start:e.start??1,spread:!!e.spread,bulletMarker:e.data?.bulletMarker??null,listMarkerDelimiter:e.data?.listMarkerDelimiter??null}))),n.listItem&&(i.listItem=MW(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.data?.resolvedUrl??``,title:n.data?.resolvedTitle??null,linkStyle:n.referenceType??`shortcut`,refLabel:n.label??n.identifier??null});return o.map(e=>e.mark(s.addToSet(e.marks)))}}n.htmlBlock&&(i.html=e=>n.htmlBlock.createAndFill({content:e.value??``}));let o=n.linkDefinition??n.linkRefDef;if(o){let e=!!o.spec.attrs?.url,t=!!o.spec.attrs?.href,n=!!o.spec.attrs?.identifier,r=!!o.spec.attrs?.sourceLayout,a=!!o.spec.attrs?.sourceTitleMarker,s=!!o.spec.attrs?.sourceUrlForm;i.definition=i=>{let c={title:i.title??null};return n&&(c.identifier=i.identifier??``),c.label=i.label??i.identifier??``,e?c.url=i.url??``:t&&(c.href=i.url??``),r&&(c.sourceLayout=i.data?.sourceLayout??null),a&&(c.sourceTitleMarker=i.data?.sourceTitleMarker??null),s&&(c.sourceUrlForm=i.data?.sourceUrlForm??null),o.createAndFill(c)}}if(n.jsxComponent){let r=e=>{if(e&&typeof e==`object`&&`sourceRaw`in e){let t=e.sourceRaw;if(typeof t==`string`)return t}};i.mdxJsxFlowElement=(e,i,a)=>{let o=e.name??``,s=qq.getOrWildcard(o),c=Jq(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=yW(e,t.current.sourcePath);n!==e&&(c.src=n,c.sourceUrl=e)}let l=a.all(e).flat();return n.jsxComponent.createAndFill({componentName:o,kind:`element`,attributes:e.attributes,sourceRaw:r(e.data)??``,sourceDirty:!1,props:c},l.length?l:void 0)};let a=(e,t)=>{let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n&&typeof n.value==`string`?n.value:null};i.mdxJsxTextElement=t=>{if(t.name===`InlineMath`&&n.mathInline){let e=a(t,`formula`)??``,r=a(t,`id`);return n.mathInline.create({formula:e,id:r??null})}if(t.name===`Tag`&&n.tag){let e=a(t,`value`)??``;return n.tag.create({value:e})}let i=t.name??``,o=i?qq.get(i):void 0;if(o&&n.jsxInline){let e=Jq(t.attributes,o.props),a=r(t.data)??``,s=(t.children??[]).map(e=>e&&typeof e==`object`&&`value`in e?String(e.value??``):``).join(``);return s&&(e.children=s),n.jsxInline.createAndFill({componentName:i,attributes:t.attributes,sourceRaw:a,sourceDirty:!1,props:e})}if(n.jsxInline){let i=r(t.data)??``;return n.jsxInline.createAndFill({},i?[e.text(i)]:null)}return n.jsxComponent.createAndFill({sourceRaw:r(t.data)??``})},i.mdxFlowExpression=e=>{let t=r(e.data)??`{${e.value??``}}`;return n.jsxComponent.createAndFill({kind:`expression`,sourceRaw:t,sourceDirty:!1})},i.mdxTextExpression=t=>{let n=r(t.data)??`{${t.value??``}}`;return e.text(n)}}return n.wikiLink&&(i.wikiLink=e=>n.wikiLink.createAndFill({target:e.data?.target??``,alias:e.data?.alias??null,anchor:e.data?.anchor??null,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=i.data?.sourceTarget??null,u=i.data?.sourceAnchor??null,d=i.data?.sourceAlias??null,f=sk(o),{resolveEmbed:p,sourcePath:m}=t.current,h=p&&m?p(o,m)??null:null,g=h?`/${h}`:o,_=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(_&&sve.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,alt:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&kc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&jc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,title:s??o,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d}});if(_&&Mc.has(f)&&n.jsxComponent&&qq.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&m?e(o,m)??null:null,i=r===null?null:bW(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:g,target:o,anchor:c,alias:s,size:i,sourceTarget:l,sourceAnchor:u,sourceAlias:d}})}let v=s||(c?`${o}#${c}`:o);if(r.link){let t=r.link.create({href:g,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s,sourceTarget:l,sourceAnchor:u,sourceAlias:d});return e.text(v,[t])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=MW(n.footnoteDefinition,e=>{let t=e;return{identifier:t.identifier,label:t.label??t.identifier}}):i.footnoteDefinition||=t=>{console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteDefinition`,reason:`FootnoteDefinition extension missing — recovering [^id]: marker`}));let r=`[^${t.label??t.identifier}]: `;return n.paragraph?n.paragraph.create(null,e.text(r)):null},i.rawMdxFallbackMdast=t=>{if(!n.rawMdxFallback)return null;let r=t.position?{start:t.position.start?.offset??0,end:t.position.end?.offset??0}:{start:0,end:0};return console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.originalType,reason:`Unhandled mdast: ${t.originalType}`,unresolvedPosition:t.unresolvedPosition??!1})),n.rawMdxFallback.createAndFill({reason:`Unhandled mdast: ${t.originalType}`,originalSpan:r},t.value?[e.text(t.value)]:null)},i}function lve(e,t){let n={},r={},i=e.nodes,a=e.marks;i.paragraph&&(n.paragraph=RW(`paragraph`)),i.blockquote&&(n.blockquote=RW(`blockquote`,e=>{let t=e.attrs.sourceMarkerSpacings,n={};return Array.isArray(t)&&t.length>0&&(n.sourceMarkerSpacings=t),Object.keys(n).length>0?{data:n}:{}})),i.heading&&(n.heading=RW(`heading`,e=>({depth:e.attrs.level,data:{sourceStyle:e.attrs.headingStyle,sourceTrailingHashes:e.attrs.sourceTrailingHashes??void 0,sourceUnderlineLength:e.attrs.sourceUnderlineLength??void 0,sourceContiguousNext:e.attrs.sourceContiguousNext===!0||void 0,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??void 0}}))),i.codeBlock&&(n.codeBlock=e=>{let t=e.attrs.sourceStyle===`indented`?`indented`:`fenced`;return{type:`code`,lang:t===`indented`?null:e.attrs.language??null,meta:t===`indented`?null:e.attrs.meta??null,value:e.textContent??``,data:{sourceFenceChar:e.attrs.fenceDelimiter,sourceFenceLength:e.attrs.fenceLength,sourceStyle:t,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceUnclosedFence:e.attrs.sourceUnclosedFence===!0||void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),i.thematicBreak&&(n.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),i.hardBreak&&(n.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle,...typeof e.attrs.sourceRaw==`string`&&e.attrs.sourceRaw.length>0?{sourceRaw:e.attrs.sourceRaw}:{}}})),i.list&&(n.list=RW(`list`,e=>({ordered:e.attrs.ordered??!1,start:e.attrs.ordered?e.attrs.start??1:null,spread:e.attrs.spread??!1,data:{bulletMarker:e.attrs.bulletMarker,listMarkerDelimiter:e.attrs.listMarkerDelimiter}}))),i.listItem&&(n.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&ove(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),i.table&&(n.table=(e,t,n)=>{let r=n.all(e),i=[],a=e.firstChild;a&&a.forEach(e=>{let t=e.attrs.align;i.push(t===`left`||t===`right`||t===`center`?t:null)});let o=r.filter(e=>e.type===`tableRow`),s=e.attrs.sourceDashCounts,c={};Array.isArray(s)&&s.length>0&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),i.tableRow&&(n.tableRow=RW(`tableRow`));let o=(e,t)=>{let n={type:`tableCell`,children:HP(t)},r=e.attrs.sourcePadding;return typeof r==`object`&&r&&typeof r.left==`number`&&typeof r.right==`number`&&(n.data={sourcePadding:r}),n};if(i.tableCell&&(n.tableCell=(e,t,n)=>o(e,n.all(e))),i.tableHeader&&(n.tableHeader=(e,t,n)=>o(e,n.all(e))),i.image&&(n.image=e=>{let t={type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title};return e.attrs.sourceUrlForm===`angle-bracketed`&&(t.data={sourceUrlForm:`angle-bracketed`}),t}),i.imageReference&&(n.imageReference=e=>{let t=e.attrs.label??``,n=e.attrs.identifier??t;return{type:`imageReference`,alt:e.attrs.alt??``,identifier:n,label:t||n,referenceType:e.attrs.referenceType??`shortcut`}}),i.htmlBlock&&(n.htmlBlock=e=>({type:`html`,value:e.attrs.content})),i.linkDefinition??i.linkRefDef){let e=i.linkDefinition?`linkDefinition`:`linkRefDef`;n[e]=e=>{let t={},n=e.attrs.sourceLayout;(n===`multiline`||n===`inline`)&&(t.sourceLayout=n);let r=e.attrs.sourceTitleMarker;(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let i={type:`definition`,identifier:e.attrs.identifier??e.attrs.label??``,label:e.attrs.label??e.attrs.identifier??``,url:e.attrs.url??e.attrs.href??``,title:e.attrs.title};return Object.keys(t).length>0&&(i.data=t),i}}if(i.jsxComponent&&(n.jsxComponent=(e,n,r)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let i=e.attrs.componentName||null,a=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!ave(e,t.checker)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:i,attributes:a,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:qq.getOrWildcard(i??`*`).serialize(e,{all:e=>r.all(e),registry:qq,serializeChildren:()=>{throw Error(`SerializeContext.serializeChildren is not available in the PM→mdast handler. Compat descriptors that need markdown-byte body rendering must emit a marker mdast node and let the to-markdown handler render the body via state.containerFlow.`)}})}),i.rawMdxFallback&&(n.rawMdxFallback=e=>{let t=e.textContent??``,n=typeof e.attrs.reason==`string`?e.attrs.reason:``,r=e.attrs.originalSpan;return{type:`rawMdxFallback`,value:t,data:{reason:n,originalSpan:r&&typeof r==`object`&&`start`in r&&`end`in r?{start:Number(r.start)||0,end:Number(r.end)||0}:{start:0,end:0}}}}),i.jsxInline&&(n.jsxInline=e=>{let t=e.attrs.componentName||``;if(t&&e.attrs.sourceDirty)return CB(t,e,qq.get(t)?.props);let n=e.attrs.attributes,r=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:t||null,attributes:Array.isArray(n)?n:[],children:[],data:{sourceRaw:String(r)}}}),i.mathInline&&(n.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),i.wikiLink&&(n.wikiLink=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLink`,value:i,data:{target:t,anchor:n,alias:r,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),i.tag&&(n.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),i.wikiLinkEmbed&&(n.wikiLinkEmbed=e=>{let t=e.attrs.target??``,n=e.attrs.anchor??null,r=e.attrs.alias??null,i=r||(n?`${t}#${n}`:t);return{type:`wikiLinkEmbed`,value:i,data:{target:t,anchor:n,alias:r},children:[{type:`text`,value:i}]}}),a.emphasis&&(r.emphasis=zW(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.strong&&(r.strong=zW(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),a.code&&(r.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return Xq(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0||void 0})}),a.strike??a.delete){let e=a.strike?`strike`:`delete`;r[e]=zW(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return a.highlight&&(r.highlight=zW(`mark`)),a.underline&&(r.underline=zW(`underline`,e=>({data:{sourceForm:e.attrs.sourceForm===`ins`?`ins`:`u`}}))),a.comment&&(r.comment=zW(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),i.commentBlock&&(n.commentBlock=RW(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),i.footnoteReference&&(n.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),i.footnoteDefinition&&(n.footnoteDefinition=RW(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),a.link&&(r.link=(e,t,n)=>{if(e.attrs.sourceForm===`wikiembed`){let t=typeof e.attrs.target==`string`&&e.attrs.target.length>0?e.attrs.target:e.attrs.href??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,o=typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,s=typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null,c=i||(r?`${t}#${r}`:t),l=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return l!==c&&l.trim().length>0&&!l.includes(`]]`)&&(i=l,c=l),{type:`wikiLinkEmbed`,value:c,data:{target:t,anchor:r,alias:i,sourceTarget:a,sourceAnchor:o,sourceAlias:s},children:[{type:`text`,value:c}]}}let r=e.attrs.linkStyle;if(r===`autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`autolink`}};if(r===`gfm-autolink`)return{type:`link`,url:e.attrs.href??``,title:null,children:n,data:{sourceStyle:`gfm-autolink`}};if(r===`inline`||!r){let t={};e.attrs.sourceUrlForm===`angle-bracketed`&&(t.sourceUrlForm=`angle-bracketed`);let r=e.attrs.sourceTitleMarker;return(r===`single`||r===`double`||r===`paren`)&&(t.sourceTitleMarker=r),{type:`link`,url:e.attrs.href??``,title:e.attrs.title??null,children:n,...Object.keys(t).length>0?{data:t}:{}}}return{type:`linkReference`,identifier:(e.attrs.refLabel??``).toLowerCase(),label:e.attrs.refLabel,referenceType:r,children:n}}),a.escapeMark&&(r.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data??={},t.data.escapedChars??=[];for(let e=0;e<t.value.length;e++)t.data.escapedChars.push({offset:e,char:t.value[e]})}return n.length===1?n[0]:n}),a.sourceLiteral&&(r.sourceLiteral=(e,t,n)=>{let r=typeof e.attrs.sourceRaw==`string`?e.attrs.sourceRaw:``;if(n.length===1&&n[0]?.type===`text`){let e=n[0],t=r||e.value;return tk(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:n,markHandlers:r}}const uve=new Set([`img`,`video`,`audio`,`mark`,`u`,`ins`]);new Map(QB.flatMap(e=>e.surface===`compat`&&uve.has(e.rendersAs)?[[e.name,e]]:[])),Np(`<>`);var Qq={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100};Qq.SINGLE_TILDE,Qq.COMPARISON_OPERATORS,Qq.HTML_TAGS,Qq.SETEXT_HEADINGS,Qq.LINKS,Qq.BOLD_ITALIC,Qq.BOLD,Qq.ITALIC_DOUBLE_UNDERSCORE,Qq.ITALIC_SINGLE_ASTERISK,Qq.ITALIC_SINGLE_UNDERSCORE,Qq.INLINE_CODE,Qq.STRIKETHROUGH,Qq.KATEX,Qq.INLINE_KATEX,ug().use(w_).use(Uh);const $q=U(bt),dve=U(iee),fve=V({alwaysOn:L().int().nonnegative(),onTrigger:L().int().nonnegative(),onDemand:L().int().nonnegative()}).strict();V({intents:B(V({satisfierId:I().min(1),desired:U([`present`,`absent`])}).loose()),...Ud,summary:Wd}).loose();const pve=V({satisfierId:I(),agentId:I(),piece:I(),scope:I(),kind:I(),pathId:I().optional(),desired:U([`present`,`absent`]),action:U(va),errorId:I().optional()}).loose(),mve=V({kind:I(),satisfierIds:B(I()),agentIds:B(I()),pathId:I().optional(),blockedReason:I().optional()}).loose(),hve=V({state:I(),strictness:B(U(ga)).optional()}).loose(),gve=V({probes:V({env:U([`desktop`,`local-web`,`remote-web`]),satisfiers:H(I(),hve)}).loose(),detection:V({detected:B(I()),probed:R()}).loose()}).loose();V({actions:B(pve),conflicts:B(mve),withheld:B(I()),snapshot:gve}).loose(),V({entries:B(V({level:U([`info`,`warn`,`error`]),message:I().max(8192),event:I().optional(),fields:H(I(),z()).optional(),ts:L().optional(),sourceId:I().optional(),lineNumber:L().optional()}).loose()).max(100),droppedSinceLastFlush:L().int().min(0).optional()}).loose(),V({accepted:L().int().min(0)}).loose();const _ve=V({exact:I().min(1),prefix:I(),suffix:I(),start:L().int().nonnegative(),end:L().int().nonnegative()}),vve=B($i([I(),L().int().nonnegative()])),yve=ea(`kind`,[V({kind:W(`body`)}),V({kind:W(`property`),key:I().min(1),path:vve.default([])})]).default({kind:`body`}),bve=U([`anchored`,`orphaned`,`resolved`]),eJ=V({threadId:I().min(1),docName:I().min(1),target:yve,anchor:_ve.nullable(),state:bve,queued:R(),latestComment:I(),createdBy:I().min(1),createdAt:L(),updatedAt:L().optional()}),tJ=V({docName:I(),instruction:I(),property:I().nullable(),passage:V({exact:I(),prefix:I(),suffix:I()}).nullable(),anchorLost:R(),passageRepeats:R()}).loose(),nJ=V({threadId:I(),ok:W(!0)}),rJ=V({threadId:I(),ok:W(!1),error:W(`not-found`)});V({threads:B(eJ)}).loose(),V({meta:eJ,orphaned:R()}).loose(),V({threadId:I()}).loose(),V({meta:eJ,payload:tJ}).loose(),V({results:B($i([nJ.extend({meta:eJ,payload:tJ}),rJ]))}).loose(),V({results:B($i([nJ.extend({meta:eJ}),rJ]))}).loose();const xve=V({status:I().min(1),reason:I()}).loose();V({docName:I().min(1),content:I(),lifecycle:xve.nullable()}).loose(),V({documents:B(V({kind:U([`document`,`asset`,`folder`,`file`]).default(`document`),docName:I().min(1).optional(),docExt:I().min(1).default(`.md`),size:L().int().nonnegative(),modified:I().min(1),isSymlink:R().default(!1),canonicalDocName:I().nullable().default(null),targetPath:I().nullable().default(null),path:I().min(1).optional(),assetExt:I().min(1).optional(),mediaKind:U([`image`,`video`,`audio`,`pdf`,`text`,`mermaid`,`excalidraw`]).nullable().optional(),referencedBy:B(I().min(1)).optional(),hasChildren:R().optional()}).loose().refine(e=>e.kind===`document`?e.docName!==void 0&&e.path===void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.kind===`folder`?e.docName===void 0&&e.path!==void 0&&e.assetExt===void 0&&e.mediaKind===void 0&&e.referencedBy===void 0:e.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:R().optional()}).loose();const Sve=V({source:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose();V({docName:I().min(1),backlinks:B(Sve)}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose(),V({counts:H(I().min(1),L().int().nonnegative())}).loose();const Cve=ea(`kind`,[V({kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),title:I(),snippet:I().nullable()}).loose(),V({kind:W(`external`),url:I().min(1),title:I(),snippet:I().nullable()}).loose()]),wve=V({role:I().min(1),sourceForm:I().min(1),targetKind:I().min(1),href:I(),resolvedTarget:I().nullable(),status:I().min(1),reason:I().nullable(),resolutionMethod:I().min(1),fallbackTarget:I().nullable().default(null),range:V({start:L().int().nonnegative(),end:L().int().nonnegative()}),line:L().int().nonnegative(),column:L().int().nonnegative(),definition:V({label:I(),line:L().int().nonnegative()}).nullable().default(null)}).loose();V({docName:I().min(1),forwardLinks:B(Cve),localTargets:B(wve).optional()}).loose();const Tve=ea(`kind`,[V({id:I().min(1),kind:W(`doc`),docName:I().min(1),anchor:I().nullable(),label:I(),cluster:I().nullable(),category:I().nullable(),tags:B(I()).nullable(),managed:R().optional()}).loose(),V({id:I().min(1),kind:W(`external`),url:I().min(1),label:I()}).loose()]),Eve=V({source:I().min(1),target:I().min(1)}).loose();V({nodes:B(Tve),links:B(Eve)}).loose();const Dve=V({ts:L().int().min(0),url:I(),method:I(),ua:I().optional(),origin:I().optional(),referer:I().optional(),host:I().optional(),remote:I().optional(),secChUa:I().optional(),secChUaMobile:I().optional(),secChUaPlatform:I().optional(),secFetchSite:I().optional(),secFetchDest:I().optional(),secFetchMode:I().optional(),secFetchUser:I().optional()}).loose(),Ove=V({app:$i([W(`cursor`),W(`codex`),W(`claude`),qi()]),signals_fired:B(I())}).loose();V({entries:B(Dve),count:L().int().min(0),detection:Ove}).loose();const iJ=V({path:I().min(1),code:U([`M`,`A`,`D`,`R`,`C`,`U`,`T`,`?`,`!`,` `]),origPath:I().min(1).optional(),syncScoped:R(),open:ea(`kind`,[V({kind:W(`doc`),docName:I().min(1)}),V({kind:W(`asset`),path:I().min(1)})]).optional()}).loose();V({branch:I().nullable(),detached:R(),upstream:I().nullable(),staged:B(iJ),notStaged:B(iJ),untracked:B(iJ),incoming:B(iJ),truncated:R(),readable:R().default(!0)}).loose();const kve=U([`AWAITING_CHECKS`,`LOCKED`,`MERGEABLE`,`QUEUED`,`UNMERGEABLE`]),Ave=U([`BEHIND`,`BLOCKED`,`CLEAN`,`DIRTY`,`DRAFT`,`HAS_HOOKS`,`UNKNOWN`,`UNSTABLE`]),jve=U([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]),Mve=U([`ERROR`,`EXPECTED`,`FAILURE`,`PENDING`,`SUCCESS`]),Nve=V({mergeQueue:V({position:L().int().nonnegative(),state:kve.nullable().catch(null)}).nullable().catch(null),autoMerge:R(),mergeState:Ave.nullable().catch(null),reviewDecision:jve.nullable().catch(null),checks:Mve.nullable().catch(null)}).loose(),Pve=V({kind:U([`pull`,`issue`]),repo:I().min(1),number:L().int().positive(),title:I(),author:I().nullable(),createdAt:I(),lifecycle:U([`open`,`draft`,`merged`,`closed`,`completed`,`not-planned`]),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional(),status:Nve.optional()}).loose();V({url:I()}).loose(),ea(`ok`,[V({ok:W(!0),preview:Pve}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({writers:B(V({id:I().min(1),name:I().optional(),email:I().optional()}).loose()).optional(),summary:Wd,...Ud}).loose(),V({checkpointRef:I().min(1)}).loose();const Fve=V({v:L().int().optional(),id:I().min(1),name:I().min(1),colorSeed:I().optional(),docs:B(I()),summaries:B(I()).optional()}).loose();V({entries:B(V({sha:I().min(1),timestamp:I().min(1),author:I(),authorEmail:I(),type:U([`checkpoint`,`wip`,`upstream`,`park`]),message:I(),contributors:B(Fve),checkpoint:z().nullable(),parentSha:I().nullable().optional()}).loose()),total:L().int().nonnegative().optional(),truncated:R().optional(),hasMore:R().optional()}).loose(),V({sha:I().regex(/^[0-9a-f]{40}$/i),content:I(),timestamp:I(),author:I()}).loose(),V({contentDir:I().min(1),pathSeparator:U([`/`,`\\`]),symlinkResolved:R()}).loose(),B(ea(`source`,[V({docName:I().min(1),timestamp:I().min(1),size:L().int().nonnegative(),source:W(`flat`)}).loose(),V({docName:I().min(1),timestamp:I().min(1),source:W(`timeline`),sha:I().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."});const Ive=V({domain:I().min(1),title:I().optional(),description:I().optional(),siteName:I().optional(),faviconDataUri:I().optional()}).loose();V({url:I()}).loose(),ea(`ok`,[V({ok:W(!0),metadata:Ive}).loose(),V({ok:W(!1),reason:I()}).loose()]),V({orphans:B(V({docName:I().min(1),title:I()}).loose())}).loose(),V({hubs:B(V({docName:I().min(1),title:I(),count:L().int().nonnegative()}).loose())}).loose();const Lve=V({source:I().min(1),title:I(),snippet:I().nullable()}).loose();V({deadLinks:B(V({target:I().min(1),sources:B(Lve)}).loose())}).loose(),V({target:V({docName:I().min(1),title:I(),aliases:B(I())}).loose(),mentions:B(V({source:I().min(1),excerpt:I(),offset:L().int().nonnegative()}).loose()),truncated:R()}).loose(),V({projectPath:I().min(1)}).loose();const Rve=U([`not-a-git-worktree`,`init-failed`]);ea(`ok`,[V({ok:W(!0),projectPath:I().min(1)}).loose(),V({ok:W(!1),reason:Rve,message:I().min(1)}).loose()]),V({host:I().min(1).optional()}).loose(),V({host:I().min(1).optional(),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({host:I().refine(hc,{message:`Host must be a hostname with an optional :port, with no scheme or path`}),username:I().min(1),token:I().min(1)}).loose(),V({host:I(),login:I()}).loose(),V({key:I().min(1)}).loose(),V({keyPresent:R()}).loose();const zve=U([`no_key`,`invalid_endpoint`,`rate_limit`,`timeout`,`http_error`,`network`,`dims_mismatch`,`malformed_response`]);ea(`ok`,[V({ok:W(!0),endpoint:I().min(1),model:I().min(1),dimensions:L().int().positive()}).loose(),V({ok:W(!1),endpoint:I().min(1),model:I().min(1),reason:zve,status:L().int().optional()}).loose()]),V({name:I().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:I().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),V({authenticated:R()}).loose(),V({channel:U([`login`,`gh-login`]).default(`login`)}).loose(),V({}).loose();const Bve=V({stackIndex:L().int().min(0),ts:L().int().min(0),additions:L().int().min(0),deletions:L().int().min(0)}).loose(),Vve=V({docName:I().min(1),additionsTotal:L().int().min(0),deletionsTotal:L().int().min(0),lastTs:L().int().min(0),bursts:B(Bve)}).loose(),Hve=V({displayName:I().min(1),color:I().min(1),icon:I().optional(),connectionId:I().min(1)}).loose();V({sessionAlive:R(),agent:Hve.nullable(),files:B(Vve)}).loose(),V({diff:I(),before:I(),after:I(),properties:kP,generatedAt:L().int().min(0)}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose(),V({}).loose();const Uve=V({displayName:I().min(1),icon:I(),color:I().min(1),currentDoc:I().nullable(),mode:U([`idle`,`writing`]),ts:L().int().min(0)}).loose();V({presence:H(I().min(1),Uve)}).loose();const Wve=V({sessionId:I().min(1),agentType:I().min(1),ts:L().int().min(0),insertedChars:L().int().min(0),deletedChars:L().int().min(0)}).loose();V({effects:B(V({"doc.name":I().min(1),entries:B(Wve)}).loose())}).loose(),V({decisions:B(V({ts:L().int().min(0),decision:I().min(1),kind:I().min(1),"doc.name":I().min(1),pathRole:I().min(1)}).loose())}).loose(),H(I().min(1),R()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`}),V({path:I().min(1,`path must be non-empty`)}).loose(),V({}).loose();const Gve=V({fromDocName:I().min(1),toDocName:I().min(1)}).loose(),Kve=V({fromPath:I().min(1),toPath:I().min(1)}).loose();V({}).loose(),V({path:I().min(1),...Ud,summary:Wd}).loose(),V({docName:I().min(1)}).loose(),V({path:I().min(1),...Ud,summary:Wd}).loose(),V({path:I().min(1)}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),...Ud,summary:Wd}).loose(),V({kind:U([`file`,`folder`]),path:I().min(1),duplicatedDocNames:B(I().min(1))}).loose(),V({pages:B(V({docName:I().min(1),title:I(),docExt:I().min(1),size:L().int().nonnegative(),modified:I().min(1),icon:I().min(1).max(2048).optional()}).loose())}).loose();const qve=V({level:L().int().min(1).max(6),text:I(),slug:I()}).loose();V({docName:I().min(1),headings:B(qve)}).loose();const Jve=V({docName:I().min(1),rewrites:L().int().nonnegative()}).loose();V({kind:U([`file`,`folder`,`asset`]),fromPath:I().min(1),toPath:I().min(1),...Ud,summary:Wd}).loose(),V({renamed:B(Gve),renamedAssets:B(Kve),rewrittenDocs:B(Jve).optional(),summary:Kd.optional()}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...Ud}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({kind:U([`file`,`folder`,`asset`]),path:I().min(1),...Ud,summary:Wd}).loose(),V({deletedDocNames:B(I().min(1))}).loose(),V({docName:I().min(1),commitSha:I().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:Wd,...Ud}).loose(),V({restoredFrom:I().min(1),timestamp:I().min(1),summary:Kd.optional(),warnings:Zd.optional()}).loose();const Yve=/^#[0-9a-fA-F]{6}$/,Xve=V(Object.fromEntries(el.map(e=>[e,I().regex(Yve,`must be a #rrggbb hex color`)]))),aJ=I().min(1).refine(al,{message:`must contain a non-whitespace character`}),oJ=V({name:aJ,author:aJ.optional(),variant:U([`dark`,`light`]),palette:Xve}).loose();V({name:I().min(1),scheme:oJ,stem:I().min(1).optional(),extension:U([`.yaml`,`.yml`]).optional()}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),V({id:I().min(1),scheme:oJ}).loose(),V({id:I().min(1),filename:I().min(1)}).loose(),ea(`existed`,[V({existed:W(!1)}).loose(),V({existed:W(!0),filename:I().min(1),scheme:oJ}).loose()]),V({themes:B(ea(`ok`,[V({ok:W(!0),id:I().min(1),filename:I().min(1),scheme:oJ}),V({ok:W(!1),filename:I().min(1),id:I().min(1).optional(),code:I().min(1),conflictingFilenames:B(I().min(1)).min(2).optional()})])),truncated:R()}).loose();function Zve(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==``&&e!==`.`)}function Qve(e){let t=Zve(e).at(-1);return t!==void 0&&Dd.some(e=>t.toLowerCase().endsWith(e))}V({tags:B(V({name:I().min(1),count:L().int().nonnegative(),isLeaf:R()}).loose())}).loose();const $ve=V({docName:I().min(1),title:I(),matchingTags:B(I().min(1)),snippet:I().nullable()}).loose();V({name:I().min(1),docs:B($ve)}).loose(),V({folder:z(),frontmatter_local:H(I(),z()).nullable(),warnings:B(I()).optional().meta({description:"Non-fatal degradations of this response, one per entry; the field each affects is absent, null, or incomplete — the aligned `warningCodes` entry names which field and how."}),warningCodes:B(U([`symlink-refused`,`malformed-yaml`,`unverifiable`,`templates-symlink-refused`,`templates-unverifiable`])).optional().meta({description:"Machine-readable codes aligned 1:1 with `warnings`; switch on these, never on the English. `symlink-refused` / `malformed-yaml` / `unverifiable`: this folder's own `.ok/frontmatter.yml` (a symlink, malformed YAML, or an lstat failure) — `frontmatter_local` is null. `templates-symlink-refused` / `templates-unverifiable`: the `.ok/templates` directory on this folder, or a `.ok` or `.ok/templates` directory on an ancestor it inherits from — a symlink (wherever it points, dangling included), or a non-ENOTDIR `lstat` failure — `folder.templates_available` omits that directory's templates and may still list others. A non-directory `.ok` / `.ok/templates` (ENOTDIR) is treated as empty and yields no `templates-*` code. This folder's own symlinked `.ok` is a 400, never a warning."})}).loose(),V({path:I(),frontmatter:H(I(),z()).optional()}).loose(),V({applied:z()}).loose();const sJ=H(I(),z()).meta({description:`Free-form frontmatter map embedded in template payloads.`});V({template:V({name:I().min(1),folder:I(),scope:U([`local`,`inherited`]),path:I().min(1),frontmatter:sJ,body:I()}).strict()}).strict(),V({templates:B(V({name:I().min(1),title:I().optional(),description:I().optional(),path:I().min(1),source_folder:I()}).strict()),truncated:R()}).strict(),V({folder:I(),name:I(),body:Bd.optional(),frontmatter:sJ.optional(),...Ud,summary:Wd}).strict(),V({path:I().min(1),created:R(),warnings:B(I())}).strict(),V({sourcePath:I().min(1),targetFolder:I(),name:I().optional(),title:I().optional(),deleteSource:R().optional(),...Ud,summary:Wd}).strict(),V({path:I().min(1),created:R(),warnings:B(I())}).strict(),V({existed:R(),path:I().min(1)}).strict(),V({fromFolder:I(),fromName:I(),toFolder:I(),toName:I(),body:Bd.optional(),frontmatter:sJ.optional(),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),committed:R()}).strict();const cJ=U(Ed),eye=/^[a-z0-9-]+$/,lJ=V({name:I(),description:I(),metadata:V({pack:I()}).strict().optional()}).strict();V({skill:V({name:I().min(1),scope:cJ,path:I().min(1),frontmatter:lJ,body:I(),files:B(V({path:I().min(1),text:I().nullable()})).optional(),managed:R().optional()}).strict()}).strict();const tye=V({source:I().min(1),publisher:I().optional(),skill:I().optional(),marketplaceUrl:I().optional(),importedAt:I().min(1),autoUpdate:R().optional()}).strict(),nye=V({name:I().min(1),description:I().optional(),scope:cJ,path:I().min(1),canonicalPath:I().min(1).optional(),filePaths:B(I()).optional(),absolutePath:I().min(1).optional(),installed:R(),hosts:B(I()),hostQualifier:I().optional().meta({description:"Set on a GLOBAL entry that shares its name with a distinct-content bundle in another host dir AND is not the by-name default: the host id whose root holds THIS bundle. Doc-name builders append it (`__skill__/global/<name>@<host>`) so each same-named bundle keeps its own tab and its own write-back path; the default bundle keeps the stable unqualified name."}),driftPaths:B(I()).optional().meta({description:`Recorded locations whose on-disk form (copy vs symlink) no longer matches what OK last wrote there — evidence another tool rewrote the path.`}),hostAliases:H(I(),I()).optional().meta({description:`Host skills roots that are symlink ALIASES of another location (host id → base-relative target root). An aliased folder is a derived view — no menu row, never a write target; the host's icon rides the target root's row.`}),conflictHosts:B(I()).optional().meta({description:`Hosts whose dir holds a DIFFERENT same-name skill (fork/conflict) — occupied, not this skill.`}),symlinkedHosts:B(I()).optional(),installableEditors:B(I()).optional(),hubOffered:R().optional().meta({description:"Whether the vendor-neutral `.agents/skills` hub is a live destination at this scope on THIS machine — server-computed via the same predicate that filters the Folders surface, so the install menu and Settings cannot disagree. True when the project already uses the hub OR a host that reads it is installed (`HUB_READER_EDITORS`)."}),linkMode:R().optional(),customPlacements:B(V({path:I(),mode:U([`copy`,`link`])}).strict()).optional(),plugin:V({name:I().min(1),marketplace:I().min(1),provider:I().min(1),url:I().optional()}).strict().optional(),managed:R().optional(),origin:tye.optional(),pack:I().optional(),modified:R().optional(),revertable:R().optional(),ignored:R().optional(),size:fve.optional()}).strict();V({name:I().min(1),scope:cJ,apply:R().optional()}).strict(),V({line:I().min(1),gitignorePath:I().min(1),applied:R(),alreadyTracked:R().optional()}).strict(),V({skills:B(nye),truncated:R()}).strict(),V({scope:cJ.default(`project`),name:I().meta({description:`Managed skill name to create or update.`}),body:Bd.optional(),frontmatter:lJ,...Ud,summary:Wd}).strict();const uJ=[`skill-name-vendor-word`,`skill-body-too-long`],dJ=B(U(uJ)).meta({description:"Machine-readable codes aligned 1:1 with `warnings` (`warnings[i]` is the display text for `warningCodes[i]`)."});V({path:I().min(1),created:R(),warnings:B(I()),warningCodes:dJ}).strict(),V({scope:cJ.default(`project`),name:I(),dryRun:R().optional(),setAutoUpdate:R().optional(),...Ud,summary:Wd}).strict(),V({name:I().min(1),updated:R(),source:I().min(1),localBody:I().optional(),upstreamBody:I().optional(),gitTracked:R().optional(),warnings:B(I()),warningCodes:dJ}).strict(),V({scope:cJ.default(`project`),name:I(),...Ud,summary:Wd}).strict(),V({name:I().min(1),baselineRef:I().min(1),restoredFiles:B(I()),warnings:B(I())}).strict();const fJ=`This member also carries the one bookkeeping failure that does not undo the operation: the content change landed, but a state file this server keeps beside it refused to be rewritten because it could not be read, so the install or import records still describe the old state until an operator repairs that file. Absent when there is nothing to report; a server that predates this member omits it, so treat its absence as no warning rather than as an error.`;V({existed:R(),path:I().min(1),warnings:B(I()).optional().meta({description:`Present when this delete removed a directory a retention record ties to a recovery copy an earlier failed move kept, whose source was never verified unchanged — either because this server verified the deleted directory against the copy that record describes, or because it could not read the directory and so could not confirm either way. Each entry says which of the two it is; neither claims more than the check established. ${fJ}`})}).strict(),V({scope:cJ.default(`project`),fromName:I(),toName:I(),body:Bd.optional(),frontmatter:lJ.optional(),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),committed:R(),warnings:B(I()).optional().meta({description:`Present when the rename itself completed but something beside it did not. ${fJ}`})}).strict(),V({name:I(),toName:I().optional().meta({description:"Name for the skill at the destination scope; defaults to `name`. The SKILL.md `name` frontmatter is rewritten to match."}),fromScope:cJ,toScope:cJ,...Ud,summary:Wd}).strict(),V({scope:cJ,path:I().optional(),droppedLocations:B(I()).default([]).meta({description:"Locations the skill occupied at the source that were removed and not re-created at the destination: the `agents` hub and custom roots, which projection does not cover. Entries are install location ids, so they can be passed straight back as an install `add` list with `scope` set to the destination scope; custom roots resolve against that scope's base."}),warnings:B(I()).optional().meta({description:`Present when the move itself completed but something beside it did not. ${fJ}`})}).strict().meta({description:"Scope-move result. Rename paths deliberately do not emit authoring warnings, consistent with same-scope rename and duplicate. Content-authoring and import responses carry those warnings and their codes. The Skills Studio client parses `droppedLocations` off the wire but deliberately does not render it yet; how a human is told what was removed is an open product decision."}),V({scope:cJ,name:I(),toName:I(),...Ud,summary:Wd}).strict(),V({name:I().min(1)}).strict(),V({name:I(),home:I().min(1)}).strict(),V({docName:I().min(1)}).strict();const pJ=U([`reference`,`script`,`file`]);V({scope:cJ.default(`project`),name:I(),path:I().min(1),content:I(),...Ud,summary:Wd}).strict().superRefine((e,t)=>{Qve(e.path)&&zd(e.content,t,[`content`])}),V({path:I().min(1),created:R(),kind:pJ,content:R()}).strict(),V({scope:cJ.default(`project`),name:I(),from:I().min(1),to:I().min(1),...Ud,summary:Wd}).strict(),V({from:I().min(1),to:I().min(1),fromDocName:I().optional(),toDocName:I().optional()}).strict(),V({path:I().min(1),kind:pJ,text:I()}).strict(),V({path:I().min(1),existed:R(),kind:pJ}).strict();const mJ=$i([dve,W(`agents`)]),hJ=I().min(1).refine(e=>!e.startsWith(`/`)&&!e.startsWith(`~`)&&!/^[A-Za-z]:/.test(e),{error:`a custom root is base-relative (e.g. ".tim/skills"), not absolute or ~-prefixed`}).refine(e=>e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),{error:`a custom root may not contain "..", "." or empty path segments`}).refine(e=>e.includes(`/`),{error:`a custom root is a path (e.g. ".tim/skills") — bare editor names are host ids`}),gJ=$i([mJ,hJ]);V({scope:cJ.default(`project`),name:I(),targets:B(mJ).optional().meta({description:'SET-EXACT install targets (editor ids, plus "agents" for the .agents hub — in-place skills only): the COMPLETE resulting host set. Omit to use project-configured editors; pass [] to uninstall everywhere. Stateless callers should prefer `add`/`remove`.'}),add:B(gJ).optional().meta({description:`Locations to ADD the skill to (everything else untouched). Editor ids fan out a managed copy/symlink; a custom root path (".tim/skills") places the bundle there.`}),remove:B(gJ).optional().meta({description:"Locations to REMOVE the skill from (lossless only — a hand-edited fork is refused, never deleted). The source cannot be removed; move it first with `source`."}),mode:U([`copy`,`link`]).optional().meta({description:`"link": one real folder (the source); every other location becomes a symlink to it. "copy": independent real folders, refreshed from the source until hand-edited (a hand-edit forks that copy). Converts existing locations losslessly. Omit to follow the form the skill already uses.`}),source:gJ.optional().meta({description:`Move the skill's REAL folder to this location (the old source becomes a symlink to it — never a removal). Sticky across rescans.`}),linkMode:R().optional(),setSource:I().min(1).optional(),place:V({dir:I().min(1).meta({description:`Project-relative directory the bundle dir is created under (e.g. ".windsurf/skills").`}),mode:U([`copy`,`link`])}).strict().optional(),convert:V({target:gJ.meta({description:`The installed location to convert — an editor id, "agents", or a recorded custom placement path.`}),mode:U([`copy`,`link`]).meta({description:`"link": replace this location with a symlink to the source. "copy": replace it with an independent real folder.`})}).strict().optional(),unplace:V({path:I().min(1).meta({description:`The recorded placement bundle path (e.g. ".windsurf/skills/my-skill").`})}).strict().optional(),...Ud,summary:Wd,fork:V({editor:I().min(1),action:U([`align`,`make-source`,`rename`]),toName:I().optional()}).strict().optional()}).strict().refine(e=>e.targets===void 0||e.add===void 0&&e.remove===void 0,{error:"`targets` is set-exact; `add`/`remove` are additive — use one style per call"}).refine(e=>e.fork===void 0||e.targets===void 0&&e.add===void 0&&e.remove===void 0&&e.source===void 0&&e.setSource===void 0,{error:"`fork` is its own operation — run it in a separate call"}).refine(e=>e.fork?.action!==`rename`||e.fork.toName!==void 0,{error:"`fork.rename` requires `toName`"}).refine(e=>e.source===void 0||e.add===void 0&&e.remove===void 0,{error:"a `source` move is its own operation — run it in a separate call from `add`/`remove`"}).refine(e=>[e.targets!==void 0||e.add!==void 0||e.remove!==void 0,e.place!==void 0,e.unplace!==void 0,e.convert!==void 0,e.source!==void 0||e.setSource!==void 0,e.fork!==void 0].filter(Boolean).length<=1,{error:"one operation per call — membership (`targets`/`add`/`remove`), `place`, `unplace`, `convert`, `source`, and `fork` are mutually exclusive"});const _J=[`no-targets`,`scripts-present`,`name-conflict`,`no-description`,`skill-fork-name-unpatched`,`place-path-invalid`,`place-fork-refused`,`links-not-permitted`];V({name:I().min(1).meta({description:`Managed skill name installed or uninstalled.`}),hosts:B(I()).meta({description:`Editor ids the skill is projected into after the operation; [] is expected after uninstall.`}),scripts:R().meta({description:`True when the skill ships executable scripts, projected but never run.`}),warnings:B(I()).meta({description:`Non-fatal install/uninstall warnings from target projection.`}),warningCodes:B(U(_J)).meta({description:"Machine-readable warning codes aligned with `warnings`."}),placedAt:I().optional(),sourceMovedTo:I().optional()}).strict(),V({scope:cJ.default(`project`),name:I().meta({description:`Managed skill name to uninstall without deleting source.`})}).strict(),V({name:I().min(1).meta({description:`Managed skill name requested for uninstall.`}),uninstalled:R().meta({description:`True when an install marker existed and was removed; false for an idempotent no-op.`})}).strict(),V({targets:B($q),configured:R(),folders:B(V({scope:cJ,host:I(),root:I(),state:U([`own`,`linked`,`linked-parent`,`absent`]),target:I().optional(),drift:W(!0).optional(),expected:I().optional()}).strict()).optional()}).strict();const vJ=V({action:W(`link`),scope:cJ,root:I().min(1).meta({description:`The folder to link (e.g. ".codex/skills").`}),target:I().min(1).meta({description:`The root it merges into (e.g. ".agents/skills"). Required.`})}),yJ=V({action:W(`unlink`),scope:cJ,root:I().min(1).meta({description:`The linked folder to materialize back.`}),exclude:B(I().min(1)).optional().meta({description:`Skill names to LEAVE OUT when materializing — the folder keeps every other skill it currently sees (as per-skill links) and stops auto-following the target root.`})}).strict(),bJ=V({action:W(`add-root`),scope:cJ,root:hJ.meta({description:`New custom skills root to declare (base-relative, e.g. ".team/skills").`})}).strict(),rye=ea(`action`,[vJ.extend({preview:R().optional().meta({description:`Return the merge plan only (moves, drops, removes, conflicts, strays) — nothing is written.`})}).strict(),yJ,bJ]);ea(`action`,[vJ.strict(),yJ,bJ]),V({folderAction:rye}).strict();const iye=V({moves:B(I()),drops:B(I()),removes:B(I()),replaces:B(I()),conflicts:B(I()),strays:B(I())}).strict();V({targets:B($q),reprojected:B(V({name:I(),hosts:B(I())}).strict()),bundleHosts:B(I()),removedFrom:B(I()),folder:V({moved:B(I()),dropped:B(I()),linked:B(I())}).strict().optional(),preview:iye.optional()}).strict(),V({scope:cJ.default(`project`),name:I(),version:I().regex(/^[0-9a-f]{40}$/i),...Ud,summary:Wd}).strict(),V({name:I().min(1),version:I(),restoredFiles:B(I()),warnings:B(I())}).strict(),V({query:I().optional(),intent:U([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:U([`navigation`,`relevance`]).optional(),scopes:B(U([`page`,`folder`,`content`,`file`])).optional(),scope:I().optional(),limit:L().int().nonnegative().optional(),semantic:R().optional(),source:U([`omnibar`,`mcp`,`http`]).optional()}).loose();const aye=V({kind:U([`page`,`folder`,`content`,`file`]),path:I().min(1),title:I(),score:L(),signals:H(I(),z()),snippet:I().optional()}).loose(),oye=U([`applied`,`no_match`,`warming`,`incapable`,`provider_error`,`restart_required`,`query_too_short`]),xJ=U([`warm`,`corpus`,`query`,`dimensions`,`configured_dimensions`]),SJ=V({capable:R(),applied:R(),outcome:oye,providerErrorReason:xJ.nullable().optional().catch(null),coverage:V({embedded:L().int().nonnegative(),total:L().int().nonnegative()})}).loose();V({enabled:R(),keyPresent:R(),keyNotRequired:R(),keySource:U([`project`,`file`,`env`]).nullable(),keyHint:I().nullable(),ready:R(),capable:R(),providerError:R().optional(),providerErrorReason:xJ.nullable().optional().catch(null),embedded:L().int().nonnegative(),total:L().int().nonnegative()}).loose(),V({query:I(),intent:U([`autocomplete`,`full_text`,`omnibar`]),results:B(aye),elapsedMs:L().nonnegative(),semantic:SJ.optional(),truncated:R().optional(),ready:R().optional()}).loose();const sye=V({version:I().min(1),recordedAt:I().min(1)}).loose();V({currentVersion:I().min(1),targets:H(I(),sye.nullable())}).loose(),V({scope:cJ.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL (https://www.skills.sh/<owner>/<repo>/<skill>, or https://www.skills.sh/site/<hostname>/<skill> for a website catalog), GitHub owner/repo[/subpath], git URL, or local/file path.`}),skill:I().min(1).optional().meta({description:`Specific skill name to import from a multi-skill source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection (the caller installs explicitly afterwards). Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (the Explore tab), so the install is reported to skills.sh and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...Ud,summary:Wd}).strict(),V({scope:cJ.default(`project`),source:I().min(1).meta({description:`External skill source: full skills.sh skill-page URL, GitHub owner/repo[/subpath], git URL, or local/file path.`}),skills:B(I().min(1)).min(1).max(100).meta({description:`Skill names to import from the source.`}),install:R().optional().meta({description:`Pass false to import WITHOUT the default-editor auto-projection. Default true.`}),marketplace:R().optional().meta({description:"The source came from a skills.sh listing the user chose (a marketplace plugin bundle), so the import is reported to skills.sh as one batched install event and counts toward that listing. Off by default: a hand-typed repo must not be announced to skills.sh. Honors the `telemetry.skillInstallReports.enabled` setting and DO_NOT_TRACK."}),...Ud,summary:Wd}).strict(),V({results:B(V({requested:I(),status:U([`imported`,`already-imported`,`not-found`,`failed`]),name:I().optional(),collisionRenamedFrom:I().optional(),warnings:B(I()),warningCodes:dJ,error:I().optional()}).loose()),imported:L(),alreadyImported:L(),failed:L()}).loose(),V({scope:cJ.default(`project`),names:B(I().min(1)).min(1).max(100).meta({description:`Managed skill names to refresh from their recorded upstreams.`}),...Ud,summary:Wd}).strict(),V({results:B(V({requested:I(),status:U([`updated`,`up-to-date`,`not-found`,`failed`]),source:I().optional(),warnings:B(I()),warningCodes:dJ,error:I().optional()}).loose()),updated:L(),upToDate:L(),failed:L()}).loose();const cye=V({source:I(),ref:I().optional(),contentHash:I(),publisher:I().optional()}).loose();V({name:I().min(1).meta({description:`Managed skill name created or matched.`}),path:I().min(1).meta({description:`Store-relative path to the imported skill source.`}),created:R().meta({description:`True when this request created new source files.`}),alreadyImported:R().meta({description:`True when identical content was already present and no files changed.`}),collisionRenamedFrom:I().optional().meta({description:`Original source name when collision handling renamed the import.`}),provenance:cye,warnings:B(I()).meta({description:`Non-fatal import warnings, such as skipped unsupported files.`}),warningCodes:dJ}).loose();const lye=U([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`,`comments`,`lint-config`,`local-targets`]);V({v:W(1),ch:W(`server-info`),seq:L(),serverInstanceId:I().min(1),currentBranch:I().min(1).optional()}).loose(),V({v:W(1),ch:W(`branch-switched`),seq:L(),branch:I().min(1)}).loose(),V({v:W(1),ch:lye,seq:L()}).loose(),V({v:W(1),ch:W(`disk-ack`),seq:L(),docName:I().min(1),sv:I().min(1)}).loose(),V({v:W(1),ch:W(`config-validation-rejected`),seq:L(),docName:I().min(1),error:Qie}).loose(),V({v:W(1),ch:W(`config-ignore-nested-error`),seq:L(),path:I().min(1),error:I().min(1)}).loose(),(()=>{let e=globalThis.Intl.Segmenter;return e?new e(`en`,{granularity:`word`}):null})();const uye=Zi({name:I(),description:I(),files:Zi({skillMd:I(),scripts:B(I()),references:B(I())})}),dye=Zi({pluginProvider:I().optional(),plugin:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional(),version:I().optional(),gitCommitSha:I().optional(),scope:I().optional(),projectPath:I().optional()}),fye=Zi({commands:R(),hooks:R(),mcp:R()}),pye=Zi({...uye.shape,sourceHarness:I(),sourceHarnesses:B(I()),home:I(),provenance:dye,inert:fye,outsideProject:R().optional()}),mye=Zi({schema:W(1),name:I(),version:I(),description:I().optional(),author:Zi({name:I()}).optional(),skills:B(I()),hostCompatibility:B(I()).optional(),capabilities:Zi({scripts:I(),network:I(),inert:B(I())}).optional(),provenance:Zi({source:I(),ref:I(),contentHash:I()}).optional()});V({skills:B(pye),packs:B(mye)}).loose(),V({results:B(V({id:I().min(1),name:I().min(1),source:I().min(1),description:I(),installs:L().int().nonnegative().nullable(),publisher:I().nullable()}).loose()),backend:U([`skills.sh`,`github-fallback`]),degraded:R()}).loose(),V({title:I(),description:I(),image:I().nullable(),skillsUrl:I().nullable(),sourceKind:U([`github`,`site`]),sourceUrl:I()}).loose(),V({skills:B(V({name:I(),description:I().nullable()}).loose())}).loose(),V({kind:U([`local`,`import`,`none`]),scope:U(Ed).optional(),name:I().optional(),dir:I().optional(),source:I().optional(),ref:I().optional(),via:U([`source`,`publisher`]).optional()}).loose();const hye=V({relPath:I(),content:I().nullable()}).loose(),gye=V({provider:I(),plugin:I(),version:I().optional(),marketplace:I().optional(),repositoryUrl:I().optional()}).loose(),_ye=V({provider:I(),plugin:I(),version:I().optional(),description:I().optional(),repositoryUrl:I().optional(),bundledSkills:B(I()),capabilities:V({commands:R(),hooks:R(),mcp:R(),agents:R()}),setupSupported:R()}).loose();V({name:I(),description:I().nullable(),skillMd:I(),files:B(hye),plugin:gye.optional(),pluginBundle:_ye.optional()}).loose();const vye=[`auth-error`,`detached-head`,`dirty-tree`,`diverged-local-commits`,`external-changes-pending`,`git-index-locked`,`git-operation-in-progress`,`no-commits-yet`,`no-push-permission`,`non-content-merge-failure`,`protected-branch`,`unsafe-incoming-symlinks`],CJ=e=>e*8+4;CJ(92),CJ(40),Array.from({length:256},(e,t)=>(t+256).toString(16).slice(1));const wJ={fileSystem:`File System`,gitUpstream:`Git (upstream)`,service:`OpenKnowledge (service)`,generator:`OpenKnowledge (generated)`},TJ=`state/bug-reports`,yye=Zi({at:I(),transport:I(),outcome:I(),reference:I().optional(),error:I().optional(),errorCode:I().optional()}),bye=Zi({reason:I(),at:I(),errorCode:I().optional()});Zi({version:L().int().catch(1),id:I(),createdAt:I(),bundleLevel:I(),zipBytes:L().int().nonnegative().catch(0),zipDeleted:R().optional(),state:I(),systemWide:R().optional(),projectSlug:I().nullable().optional(),reference:I().optional(),lastError:bye.optional(),attempts:B(yye).optional(),note:I().optional()}),Zi({version:L().int().catch(1),id:I().optional(),sentAt:I().optional(),reference:I().optional()});const xye=new Map([[`PORT`,[`server`,`port`]],[`OK_BIND`,[`server`,`bind`]],[`OK_EXTERNAL_URL`,[`server`,`externalUrl`]],[`OK_ALLOW_EXTERNAL`,[`server`,`allowExternal`]],[`OK_OPEN_BROWSER`,[`server`,`openBrowser`]],[`OK_IDLE_SHUTDOWN`,[`server`,`idleShutdown`]]]);function Sye(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).toUpperCase()}function Cye(e){return`OK_${(e[0]===`server`?e.slice(1):e).map(Sye).join(`_`)}`}function wye(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tye(e){let{value:t,file:n,source:r,doc:i}=e,a=[],o=(e,t)=>{if(t.length>0){let e=Wl(Ul,t);if(e!==void 0){if(e.scope===`project-local`){let e=Cye(t),o;i!=null&&r!=null&&n!=null&&(o=Zu({file:n,source:r,doc:i,path:t})),a.push({path:[...t],...xye.has(e)?{envVar:e}:{},...o===void 0?{}:{source:o}})}return}}if(wye(e))for(let[n,r]of Object.entries(e))o(r,[...t,n])};return o(t,[]),a}const EJ=`(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)`;RegExp(`^127\\.${EJ}\\.${EJ}\\.${EJ}$`);function DJ(e,t){return e===`unix-chain`?`# ok-mcp${t}-v`:`# ok-mcp${t}-win-v`}function OJ(e){return e.replace(/\/+/g,`/`).replace(/\/+$/,``)}function Eye(e){return rt[e].userHomeDirName}function Dye(e,t){return e===`stable`?`${OJ(t)}/Library/Application Support/OpenKnowledge/path-install.json`:`${OJ(t)}/${Eye(e)}/path-install.json`}const Oye=[`.ok`,cd,`installed-skills.json`],kye=U(Ed),Aye=Zi({hosts:B(I()),scope:kye,scripts:R(),installedAt:ki(),projection:U([`symlink`,`copy`]).optional(),contentHash:I().optional()}),jye=Zi({schema:W(1),skills:H(I(),Aye).default({})});function Mye(e){let t;try{t=JSON.parse(e)}catch{return null}let n=jye.safeParse(t);return n.success?n.data:null}function kJ(e){if(e===``)throw Error(`toPathspec: empty path. ":(literal)" is an empty pattern that matches every tracked path; pass "." if you meant the repo root.`);return`:(literal)${e}`}function Nye(e){if(e.length===0)throw Error(`pathspecArgs: empty path list. A bare "--" removes the pathspec restriction rather than selecting nothing.`);return[`--`,...e.map(e=>kJ(e))]}const AJ=[{tagName:`Mirror`,attrName:`src`,resolution:`bare-doc-name`},{tagName:`Excalidraw`,attrName:`src`,resolution:`doc-relative`}];for(let e of AJ){let t=QB.find(t=>t.name===e.tagName);if(!t)throw Error(`JSX_SRC_REF_TAGS: no built-in component descriptor named '${e.tagName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the tagName to match a descriptor in builtInComponents.`);if(!t.props.some(t=>t.name===e.attrName))throw Error(`JSX_SRC_REF_TAGS: component '${e.tagName}' declares no prop named '${e.attrName}' — the rename-rewrite and backlink passes for this entry would silently never match. Fix the attrName to match one of the descriptor's props.`)}gH(),PV(),FV();function Pye(){return QB.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function Fye(){return Pye().filter(e=>{let t=Iye(e);return t!==`fence`&&t!==`html`})}function Iye(e){return e.name===`MermaidFence`?`fence`:e.name===`HtmlAlignBlock`?`html`:e.hasChildren?`jsx-block`:`jsx-void`}const jJ=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),MJ=globalThis;MJ[jJ]===void 0&&(MJ[jJ]=sr());const NJ=MJ[jJ],PJ=Zi({version:I().regex(/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(NJ,{description:`Recorded skill version for this target.`}),recordedAt:ki().register(NJ,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:U([`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`]).register(NJ,{description:`Install-source surface that recorded this entry.`}).optional()}),Lye=Zi({enabled:R().register(NJ,{description:`Whether this user-global skill bundle is opted in.`}),decidedAt:ki().register(NJ,{description:`ISO 8601 timestamp of the opt-in / opt-out decision.`})});Zi({schema:W(1).register(NJ,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Zi({"claude-cowork":PJ.optional(),"cli-hosts":PJ.optional()}).register(NJ,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({}),bundles:H(I(),Lye).register(NJ,{description:`Per-bundle opt-in decisions keyed by install name. Absent key = no recorded decision.`}).optional(),installsReported:B(I()).register(NJ,{description:"Skill installs already reported to skills.sh from this machine, as `<owner/repo>#<skill>`. Append-only; presence suppresses a re-report."}).optional()});function Rye(e,t,n,r){return e.success?{code:`UNKNOWN`,message:`unexpected success in error path`}:{code:`SCHEMA_INVALID`,issues:e.error.issues.map(e=>{let i=e.path.map(e=>typeof e==`symbol`?String(e):e),a=Zu({file:r,source:n,doc:t,path:i});return{path:i,message:e.message,issueCode:e.code,...a===void 0?{}:{source:a}}})}}function FJ(e,t,n){let r=`${e}.invalid-${t.replace(/[:.]/g,`-`)}`;try{return D(e,r),r}catch(t){n(`[config] Could not sideline invalid config file ${e} → ${r}: ${t instanceof Error?t.message:String(t)}. File left in place; using schema defaults.`);return}}function IJ(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Reflect.get(n,e)}return n}function zye(e){let t=[],n=[[`maxBatchSize`,1,Ll],[`maxBatchChars`,1,Rl],[`docTimeoutMs`,1,zl]];for(let[r,i,a]of n){let n=[`search`,`semantic`,r],o=IJ(e.rawConfig,n),s=e.config.search.semantic[r];if(o===void 0||o===s)continue;let c=`Expected an integer between ${i} and ${a}; using default ${s}.`,l=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});t.push({path:n,message:c,...l===void 0?{}:{source:{file:l.file,line:l.line,column:l.column}}})}return t.length>0?[{code:`VALUE_FALLBACK`,issues:t}]:[]}function Bye(e){let t=IJ(e.rawConfig,[`git`,`hosts`]);if(t===void 0)return[];let n=gie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`git`,`hosts`,...t.path.map(String)],r=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:`${t.message}; ignoring this git-host declaration.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function Vye(e){let t=IJ(e.rawConfig,[`autolinks`]);if(t===void 0)return[];let n=_ie.safeParse(t);return n.success?[]:[{code:`VALUE_FALLBACK`,issues:n.error.issues.map(t=>{let n=[`autolinks`,...t.path.map(String)],r=Zu({file:e.absPath,source:e.source,doc:e.doc,path:n});return{path:n,message:t.path.length===0?`${t.message}; ignoring autolinks.`:`${t.message}; ignoring this autolink entry.`,...r===void 0?{}:{source:{file:r.file,line:r.line,column:r.column}}}})}]}function LJ(e){let{absPath:t,sideline:n=!0,timestamp:r=new Date().toISOString()}=e,i=e.warn??(e=>console.warn(e)),a=Ul.parse({});if(!g(t))return{valid:!0,value:a,source:void 0,diagnostics:[]};let o;try{o=S(t,`utf-8`)}catch(e){let n=e instanceof Error?e.message:String(e);i(`[config] Could not read ${t}: ${n}. Using schema defaults.`);let r={code:`UNREADABLE`,detail:n};return{valid:!1,value:a,error:r,diagnostics:[{...r}]}}let s=(0,xs.parseDocument)(o);if(s.errors.length>0){let e=s.errors.map(e=>e.message).join(`; `);i(`[config] ${t} contains invalid YAML (${e}). Using schema defaults.`+(n?``:` Pass-through mode: file left in place.`));let o=n?FJ(t,r,i):void 0,c={code:`YAML_PARSE`,detail:e};return{valid:!1,value:a,error:c,diagnostics:[{...c}],...o===void 0?{}:{sidelinedTo:o}}}let c=s.toJSON()??{},l=nd({value:c,file:t,source:o,doc:s}),u=l.length>0?id(c):c,d=[...Bye({rawConfig:u,doc:s,source:o,absPath:t}),...Vye({rawConfig:u,doc:s,source:o,absPath:t})];for(let e of d)for(let n of e.issues)i(`[config] ${t} ${n.path.join(`.`)}: ${n.message}`);let f=Ul.safeParse(u);if(!f.success){let e=Rye(f,s,o,t),c=Ul.shape.git.safeParse(IJ(u,[`git`])).data??a.git,p=Object.keys(c.hosts).length>0?`Using schema defaults while preserving valid git-host declarations.`:`Using schema defaults.`;i(`[config] ${t} fails schema validation (${f.error.issues.length} issue(s)). ${p}`+(n?``:` Pass-through mode: file left in place.`));let m=n?FJ(t,r,i):void 0,h=[...l,...d,...Cd(e)&&e.code===`SCHEMA_INVALID`?[{...e}]:[]];return{valid:!1,value:{...a,git:c},error:e,diagnostics:h,...m===void 0?{}:{sidelinedTo:m}}}let p=[...l,...d,...zye({rawConfig:u,config:f.data,doc:s,source:o,absPath:t})];return{valid:!0,value:f.data,source:t,diagnostics:p}}function RJ(e=_e()){return j(e,ft().userHomeDirName)}const zJ=`.tmp.`,BJ=[8,4,4,4,12];function Hye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const Uye=BJ.map(e=>`[0-9a-f]`.repeat(e)).join(`-`),Wye=BJ.map(e=>`[0-9a-f]{${e}}`).join(`-`),Gye=`*${zJ}${Uye}`;RegExp(`${Hye(zJ)}${Wye}$`);function Kye(e){return`${e}${zJ}${Ee()}`}function qye(e){try{let t=k(e),n=`${ae(e)}${zJ}`,r=Date.now()-3e4;for(let e of w(t)){if(!e.startsWith(n))continue;let i=j(t,e);try{te(i).mtimeMs<r&&ne(i)}catch{}}}catch{}}function VJ(e,t,n={}){qye(e);let r=Kye(e);try{re(r,t,{encoding:`utf-8`,mode:n.mode??420}),D(r,e)}catch(e){try{ne(r)}catch{}throw e}}var HJ=class extends Error{code=`LOCK_TIMEOUT`;lockPath;timeoutMs;constructor(e,t){super(`Could not acquire file lock at ${e} within ${t}ms`),this.name=`FileLockTimeoutError`,this.lockPath=e,this.timeoutMs=t}};async function Jye(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new HJ(e,r);s=!1;let c;try{c=b(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=te(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ne(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new HJ(e,r);await Gie(i);continue}try{return await t()}finally{try{f(c)}catch{}try{ne(e)}catch{}}}}function Yye(e){let t=Date.now()+e;for(;Date.now()<t;);}function UJ(e,t,n={}){let r=n.timeoutMs??5e3,i=n.retryIntervalMs??25,a=r*2,o=Date.now()+r,s=!0;for(;;){if(!s&&Date.now()>=o)throw new HJ(e,r);s=!1;let c;try{c=b(e,`wx`,384)}catch(t){if(t.code!==`EEXIST`)throw t;let s;try{let t=te(e);s=Date.now()-t.mtimeMs}catch{continue}let c=!1;if(s>a){n.onWarn?.(`cleared stale file lock`,{lockPath:e,ageMs:s,staleThresholdMs:a});try{ne(e),c=!0}catch{}}if(c)continue;if(Date.now()>=o)throw new HJ(e,r);Yye(i);continue}try{return t()}finally{try{f(c)}catch{}try{ne(e)}catch{}}}}const WJ=`config.yml`;function GJ(e,t,n){if(e===`user`)return N(RJ(n??_e()),`global.yml`);let r=A(t)?t:N(t);return e===`project-local`?N(r,`.ok`,cd,WJ):N(r,`.ok`,WJ)}const Xye=[`LC_ALL`,`LC_MESSAGES`,`LANG`];function KJ(e){let t=e.trim().split(`@`)[0].split(`.`)[0];return t===``||t===`C`||t===`POSIX`?null:jP(t.replaceAll(`_`,`-`))}function Zye(e){for(let t of Xye){let n=e[t]?.trim();if(n!==void 0&&n!==``)return KJ(n)}return null}function Qye(e){let t=e.OK_LANG?.trim();if(t!==void 0&&t!==``)return jP(t)??void 0}function $ye(e=process.env){let t=Qye(e),n=Zye(e);if(n===null)return{override:t,preferenceList:[]};let r=[],i=e.LANGUAGE;if(i!==void 0)for(let e of i.split(`:`)){let t=KJ(e);t!==null&&r.push(t)}return{override:t,preferenceList:[...r,n]}}function qJ(){return pd(ud)}function JJ(){return ft().keyringService}function YJ(e){try{e()}catch{}}var ebe=class{backend=`keyring`;onKeychainRead;constructor(e){this.onKeychainRead=e}async get(e){let{Entry:t}=await import(`@napi-rs/keyring`),n;try{n=new t(JJ(),e).getPassword()}catch(t){return YJ(()=>this.onKeychainRead?.({kind:`read-error`,host:e,error:t instanceof Error?t.name:`unknown`})),null}if(n==null)return YJ(()=>this.onKeychainRead?.({kind:`absent`,host:e})),null;try{return JSON.parse(n)}catch{return YJ(()=>this.onKeychainRead?.({kind:`corrupt-entry`,host:e,error:`corrupt-entry`})),null}}async set(e,t,n,r){let{Entry:i}=await import(`@napi-rs/keyring`),a=new i(JJ(),e),o={login:t,token:n,...r};a.setPassword(JSON.stringify(o))}async clear(e){let{Entry:t}=await import(`@napi-rs/keyring`);try{new t(JJ(),e).deletePassword()}catch{}}},XJ=class{backend=`file`;authFile;constructor(e){this.authFile=e??j(RJ(),`auth.yml`)}read(){if(!g(this.authFile))return{};try{let e=S(this.authFile,`utf-8`);return(0,xs.parse)(e)??{}}catch(e){let t=e instanceof Error?e.message:`unknown error`;return process.stderr.write(`[auth] Failed to parse ${this.authFile}: ${t}. Starting with empty credentials.\n`),{}}}write(e){let t=k(this.authFile);g(t)||v(t,{recursive:!0,mode:448}),VJ(this.authFile,(0,xs.stringify)(e),{mode:384})}async get(e){return this.read()[e]??null}async set(e,t,n,r){let i=this.read();i[e]={login:t,token:n,...r},this.write(i)}async clear(e){let t=this.read();delete t[e],this.write(t)}},tbe=class{backend=`keyring`;keychain;file;constructor(e,t){this.keychain=e,this.file=t}async get(e){let t=await this.keychain.get(e);if(t!=null)return t;let n=await this.file.get(e);if(n==null)return null;try{await this.keychain.set(e,n.login,n.token,{gitProtocol:n.gitProtocol,name:n.name,email:n.email}),await this.file.clear(e),process.stderr.write(`[auth] migrated ${e} credential from ${qJ()} to the OS keychain\n`)}catch{}return n}set(e,t,n,r){return this.keychain.set(e,t,n,r)}async clear(e){await this.keychain.clear(e),await this.file.get(e)!=null&&await this.file.clear(e)}};async function ZJ(e,t){try{let{Entry:n}=await import(`@napi-rs/keyring`);return new n(JJ(),`__probe__`),process.stderr.write(`[auth] token storage: OS keychain
|
|
430
430
|
`),YJ(()=>t?.onBackendSelected?.({backend:`keyring`})),new tbe(new ebe(t?.onKeychainRead),new XJ(e))}catch(n){let r=n instanceof Error?`${n.name}: ${n.message}`:String(n);return process.stderr.write(`[auth] token storage: file (${qJ()}) — OS keychain unavailable: ${r}\n`),YJ(()=>t?.onBackendSelected?.({backend:`file`,reason:r})),new XJ(e)}}function nbe(e){let t=null;return function(){if(t)return t;let n=2e3;return t=(async()=>{let t=null,r=new Promise(r=>{t=setTimeout(()=>{process.stderr.write(`[auth] token storage: keyring init exceeded ${n}ms; falling back to file (${qJ()})\n`),r(new XJ(e))},n)});try{return await Promise.race([ZJ(e),r])}catch{return new XJ(e)}finally{t!==null&&clearTimeout(t)}})(),t}}function rbe(e){let t=nbe(e);return{async get(e){let n=await(await t()).get(e);return n===null?null:{token:n.token,login:n.login}}}}
|
|
431
431
|
/*!
|
|
432
432
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
@@ -719,7 +719,7 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
719
719
|
`}){let r=e.split(/\r?\n/);for(let e=1;e<r.length;e+=1)r[e]=t+r[e];return r.join(n)}})),Oxe=nX(((e,t)=>{t.exports=s;let{LEVEL_NAMES:n}=SX(),r=wX(),i=PX(),a=NX(),o=CX();function s(e){let t=e.crlf?`\r
|
|
720
720
|
`:`
|
|
721
721
|
`,{customPrettifiers:s,errorLikeObjectKeys:c,hideObject:l,levelFirst:u,levelKey:d,levelLabel:f,messageFormat:p,messageKey:m,minimumLevel:h,singleLine:g,timestampKey:_,translateTime:v}=e,y=e.errorProps.split(`,`),b=typeof e.useOnlyCustomProps==`boolean`?e.useOnlyCustomProps:e.useOnlyCustomProps===`true`,x=i(e.customLevels),S=a(e.customLevels),C=o(b,x,S),w;if(e.customColors){if(typeof e.customColors==`string`)w=e.customColors.split(`,`).reduce((t,r)=>{let[i,a]=r.split(`:`),o=(b?e.customLevels:S[i]!==void 0)?S[i]:n[i],s=o===void 0?i:o;return t.push([s,a]),t},[]);else if(typeof e.customColors==`object`)w=Object.keys(e.customColors).reduce((t,r)=>{let[i,a]=[r,e.customColors[r]],o=(b?e.customLevels:S[i]!==void 0)?S[i]:n[i],s=o===void 0?i:o;return t.push([s,a]),t},[]);else throw Error(`options.customColors must be of type string or object.`)}let T={customLevels:x,customLevelNames:S};b===!0&&!e.customLevels&&(T.customLevels=void 0,T.customLevelNames=void 0);let E=e.include===void 0?void 0:new Set(e.include.split(`,`)),D=!E&&e.ignore?new Set(e.ignore.split(`,`)):void 0,O=r(e.colorize,w,b),ee=e.colorizeObjects?O:r(!1,[],!1);return{EOL:t,IDENT:` `,colorizer:O,customColors:w,customLevelNames:S,customLevels:x,customPrettifiers:s,customProperties:T,errorLikeObjectKeys:c,errorProps:y,getLevelLabelData:C,hideObject:l,ignoreKeys:D,includeKeys:E,levelFirst:u,levelKey:d,levelLabel:f,messageFormat:p,messageKey:m,minimumLevel:h,objectColorizer:ee,singleLine:g,timestampKey:_,translateTime:v,useOnlyCustomProps:b}}})),kxe=nX(((e,t)=>{t.exports=s,s.default=s,s.stable=d,s.stableStringify=d;var n=`[...]`,r=`[Circular]`,i=[],a=[];function o(){return{depthLimit:2**53-1,edgesLimit:2**53-1}}function s(e,t,n,r){r===void 0&&(r=o()),l(e,``,0,[],void 0,0,r);var s;try{s=a.length===0?JSON.stringify(e,t,n):JSON.stringify(e,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var c=i.pop();c.length===4?Object.defineProperty(c[0],c[1],c[3]):c[0][c[1]]=c[2]}}return s}function c(e,t,n,r){var o=Object.getOwnPropertyDescriptor(r,n);o.get===void 0?(r[n]=e,i.push([r,n,t])):o.configurable?(Object.defineProperty(r,n,{value:e}),i.push([r,n,t,o])):a.push([t,n,e])}function l(e,t,i,a,o,s,u){s+=1;var d;if(typeof e==`object`&&e){for(d=0;d<a.length;d++)if(a[d]===e){c(r,e,t,o);return}if(u.depthLimit!==void 0&&s>u.depthLimit){c(n,e,t,o);return}if(u.edgesLimit!==void 0&&i+1>u.edgesLimit){c(n,e,t,o);return}if(a.push(e),Array.isArray(e))for(d=0;d<e.length;d++)l(e[d],d,d,a,e,s,u);else{var f=Object.keys(e);for(d=0;d<f.length;d++){var p=f[d];l(e[p],p,d,a,e,s,u)}}a.pop()}}function u(e,t){return e<t?-1:+(e>t)}function d(e,t,n,r){r===void 0&&(r=o());var s=f(e,``,0,[],void 0,0,r)||e,c;try{c=a.length===0?JSON.stringify(s,t,n):JSON.stringify(s,p(t),n)}catch{return JSON.stringify(`[unable to serialize, circular reference is too complex to analyze]`)}finally{for(;i.length!==0;){var l=i.pop();l.length===4?Object.defineProperty(l[0],l[1],l[3]):l[0][l[1]]=l[2]}}return c}function f(e,t,a,o,s,l,d){l+=1;var p;if(typeof e==`object`&&e){for(p=0;p<o.length;p++)if(o[p]===e){c(r,e,t,s);return}try{if(typeof e.toJSON==`function`)return}catch{return}if(d.depthLimit!==void 0&&l>d.depthLimit){c(n,e,t,s);return}if(d.edgesLimit!==void 0&&a+1>d.edgesLimit){c(n,e,t,s);return}if(o.push(e),Array.isArray(e))for(p=0;p<e.length;p++)f(e[p],p,p,o,e,l,d);else{var m={},h=Object.keys(e).sort(u);for(p=0;p<h.length;p++){var g=h[p];f(e[g],g,p,o,e,l,d),m[g]=e[g]}if(s!==void 0)i.push([s,t,e]),s[t]=m;else return m}o.pop()}}function p(e){return e=e===void 0?function(e,t){return t}:e,function(t,n){if(a.length>0)for(var r=0;r<a.length;r++){var i=a[r];if(i[1]===t&&i[0]===n){n=i[2],a.splice(r,1);break}}return e.call(this,t,n)}}})),RX=nX(((e,t)=>{t.exports=r;let n=LX();function r({keyName:e,lines:t,eol:r,ident:i}){let a=``,o=`${i}${e}: ${n({input:t,ident:i,eol:r})}${r}`.split(r);for(let e=0;e<o.length;e+=1){e!==0&&(a+=r);let t=o[e];if(/^\s*"stack"/.test(t)){let e=/^(\s*"stack":)\s*(".*"),?$/.exec(t);if(e&&e.length===3){let n=/^\s*/.exec(t)[0].length+4,i=` `.repeat(n),o=e[2];a+=e[1]+r+i+JSON.parse(o).replace(/\n/g,r+i)}else a+=t}else a+=t}return a}})),zX=nX(((e,t)=>{t.exports=o;let{LOGGER_KEYS:n}=SX(),r=kxe(),i=LX(),a=RX();function o({log:e,excludeLoggerKeys:t=!0,skipKeys:o=[],context:s}){let{EOL:c,IDENT:l,customPrettifiers:u,errorLikeObjectKeys:d,objectColorizer:f,singleLine:p,colorizer:m}=s,h=[].concat(o);t===!0&&Array.prototype.push.apply(h,n);let g=``,{plain:_,errors:v}=Object.entries(e).reduce(({plain:t,errors:n},[r,i])=>{if(h.includes(r)===!1){let a=typeof u[r]==`function`?u[r](i,r,e,{colors:m.colors}):i;d.includes(r)?n[r]=a:t[r]=a}return{plain:t,errors:n}},{plain:{},errors:{}});return p?(Object.keys(_).length>0&&(g+=f.greyMessage(r(_))),g+=c,g=g.replace(/\\\\/gi,`\\`)):Object.entries(_).forEach(([e,t])=>{let n=typeof u[e]==`function`?t:r(t,null,2);if(n===void 0)return;n=n.replace(/\\\\/gi,`\\`);let a=i({input:n,ident:l,eol:c});g+=`${l}${f.property(e)}:${a.startsWith(c)?``:` `}${a}${c}`}),Object.entries(v).forEach(([e,t])=>{let n=typeof u[e]==`function`?t:r(t,null,2);n!==void 0&&(g+=a({keyName:e,lines:n,eol:c,ident:l}))}),g}})),BX=nX(((e,t)=>{t.exports=o;let{LOGGER_KEYS:n}=SX(),r=IX(),i=LX(),a=zX();function o({log:e,context:t}){let{EOL:o,IDENT:s,errorProps:c,messageKey:l}=t,u=e.stack,d=`${s}${i({input:u,ident:s,eol:o})}${o}`;if(c.length>0){let i=n.concat(l,`type`,`stack`),u;u=c[0]===`*`?Object.keys(e).filter(e=>i.includes(e)===!1):c.filter(e=>i.includes(e)===!1);for(let n=0;n<u.length;n+=1){let i=u[n];if(i in e){if(r(e[i])){let n=a({log:e[i],excludeLoggerKeys:!1,context:{...t,IDENT:s+s}});d=`${d}${s}${i}: {${o}${n}${s}}${o}`;continue}d=`${d}${s}${i}: ${e[i]}${o}`}}}return d}})),VX=nX(((e,t)=>{t.exports=r;let n=kX();function r({log:e,context:t}){let{colorizer:r,customLevels:i,customLevelNames:a,levelKey:o,getLevelLabelData:s}=t,c=t.customPrettifiers?.level,l=n(e,o);if(l===void 0)return;let u=r(l,{customLevels:i,customLevelNames:a});if(c){let[t]=s(l);return c(l,o,e,{label:t,labelColorized:u,colors:r.colors})}return u}})),HX=nX(((e,t)=>{t.exports=a;let{LEVELS:n}=SX(),r=kX(),i=FX();function a({log:e,context:t}){let{colorizer:a,customLevels:o,levelKey:s,levelLabel:c,messageFormat:l,messageKey:u,useOnlyCustomProps:d}=t;if(l&&typeof l==`string`){let t=i(l,e),u=String(t).replace(/{([^{}]+)}/g,function(t,i){let a;if(i===c&&(a=r(e,s))!==void 0)return(d?o===void 0:o[a]===void 0)?n[a]:o[a];let l=r(e,i);return l===void 0?``:l});return a.message(u)}if(l&&typeof l==`function`){let t=l(e,u,c,{colors:a.colors});return a.message(t)}if(u in e&&(typeof e[u]==`string`||typeof e[u]==`number`||typeof e[u]==`boolean`))return a.message(e[u])}})),UX=nX(((e,t)=>{t.exports=n;function n({log:e,context:t}){let{customPrettifiers:n,colorizer:r}=t,i=``;if(e.name||e.pid||e.hostname){if(i+=`(`,e.name&&(i+=n.name?n.name(e.name,`name`,e,{colors:r.colors}):e.name),e.pid){let t=n.pid?n.pid(e.pid,`pid`,e,{colors:r.colors}):e.pid;e.name&&e.pid?i+=`/`+t:i+=t}if(e.hostname){let t=n.hostname?n.hostname(e.hostname,`hostname`,e,{colors:r.colors}):e.hostname;i+=`${i===`(`?`on`:` on`} ${t}`}i+=`)`}if(e.caller){let t=n.caller?n.caller(e.caller,`caller`,e,{colors:r.colors}):e.caller;i+=`${i===``?``:` `}<${t}>`}if(i!==``)return i}})),WX=nX(((e,t)=>{t.exports=r;let n=MX();function r({log:e,context:t}){let{timestampKey:r,translateTime:i}=t,a=t.customPrettifiers?.time,o=null;if(r in e?o=e[r]:`timestamp`in e&&(o=e.timestamp),o===null)return;let s=i?n(o,i):o;return a?a(s):`[${s}]`}})),Axe=nX(((e,t)=>{t.exports={buildSafeSonicBoom:Txe(),createDate:DX(),deleteLogProperty:AX(),filterLog:jX(),formatTime:MX(),getPropertyValue:kX(),handleCustomLevelsNamesOpts:NX(),handleCustomLevelsOpts:PX(),interpretConditionals:FX(),isObject:IX(),isValidDate:EX(),joinLinesWithIndentation:LX(),noop:TX(),parseFactoryOptions:Oxe(),prettifyErrorLog:BX(),prettifyError:RX(),prettifyLevel:VX(),prettifyMessage:HX(),prettifyMetadata:UX(),prettifyObject:zX(),prettifyTime:WX(),splitPropertyKey:OX(),getLevelLabelData:CX()}})),jxe=nX(((e,t)=>{let n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),Mxe=nX(((e,t)=>{t.exports=h;let n=jxe(),r=IX(),i=BX(),a=VX(),o=HX(),s=UX(),c=zX(),l=WX(),u=jX(),{LEVELS:d,LEVEL_KEY:f,LEVEL_NAMES:p}=SX(),m=e=>{try{return{value:n.parse(e,{protoAction:`remove`})}}catch(e){return{err:e}}};function h(e){let t;if(r(e))t=e;else{let n=m(e);if(n.err||!r(n.value))return e+this.EOL;t=n.value}if(this.minimumLevel){let e;e=this.useOnlyCustomProps?this.customLevels:this.customLevelNames[this.minimumLevel]!==void 0;let n;if(n=e?this.customLevelNames[this.minimumLevel]:p[this.minimumLevel],n||=typeof this.minimumLevel==`string`?p[this.minimumLevel]:p[d[this.minimumLevel].toLowerCase()],t[this.levelKey===void 0?f:this.levelKey]<n)return}let n=o({log:t,context:this.context});(this.ignoreKeys||this.includeKeys)&&(t=u({log:t,context:this.context}));let h=a({log:t,context:{...this.context,...this.context.customProperties}}),g=s({log:t,context:this.context}),_=l({log:t,context:this.context}),v=``;if(this.levelFirst&&h&&(v=`${h}`),_&&v===``?v=`${_}`:_&&(v=`${v} ${_}`),!this.levelFirst&&h&&(v=v.length>0?`${v} ${h}`:h),g&&(v=v.length>0?`${v} ${g}:`:g),v.endsWith(`:`)===!1&&v!==``&&(v+=`:`),n!==void 0&&(v=v.length>0?`${v} ${n}`:n),v.length>0&&!this.singleLine&&(v+=this.EOL),t.type===`Error`&&typeof t.stack==`string`){let e=i({log:t,context:this.context});this.singleLine&&(v+=this.EOL),v+=e}else if(this.hideObject===!1){let e=[this.messageKey,this.levelKey,this.timestampKey].map(e=>e.replaceAll(/\\/g,``)).filter(e=>typeof t[e]==`string`||typeof t[e]==`number`||typeof t[e]==`boolean`),n=c({log:t,skipKeys:e,context:this.context});this.singleLine&&!/^\s$/.test(n)&&(v+=` `),v+=n}return v}})),Nxe=nX(((e,t)=>{let{isColorSupported:n}=bX(),r=Sxe(),{Transform:i}=iX(`node:stream`),a=wxe(),o=wX(),{ERROR_LIKE_KEYS:s,LEVEL_KEY:c,LEVEL_LABEL:l,MESSAGE_KEY:u,TIMESTAMP_KEY:d}=SX(),{buildSafeSonicBoom:f,parseFactoryOptions:p}=Axe(),m=Mxe(),h={colorize:n,colorizeObjects:!0,crlf:!1,customColors:null,customLevels:null,customPrettifiers:{},errorLikeObjectKeys:s,errorProps:``,hideObject:!1,ignore:`hostname`,include:void 0,levelFirst:!1,levelKey:c,levelLabel:l,messageFormat:null,messageKey:u,minimumLevel:void 0,outputStream:process.stdout,singleLine:!1,timestampKey:d,translateTime:!0,useOnlyCustomProps:!0};function g(e){let t=p(Object.assign({},h,e));return m.bind({...t,context:t})}function _(e={}){let t=g(e),n;return a(function(a){a.on(`message`,function n(r){!r||r.code!==`PINO_CONFIG`||(Object.assign(e,{messageKey:r.config.messageKey,errorLikeObjectKeys:Array.from(new Set([...e.errorLikeObjectKeys||s,r.config.errorKey])),customLevels:r.config.levels.values}),t=g(e),a.off(`message`,n))});let o=new i({objectMode:!0,autoDestroy:!0,transform(e,n,r){r(null,t(e))}});return n=typeof e.destination==`object`&&typeof e.destination.write==`function`?e.destination:f({dest:e.destination||1,append:e.append,mkdir:e.mkdir,sync:e.sync}),a.on(`unknown`,function(e){n.write(e+`
|
|
722
|
-
`)}),r(a,o,n),o},{parse:`lines`,close(e,t){n.on(`close`,()=>{t(e)})}})}t.exports=_,t.exports.build=_,t.exports.PinoPretty=_,t.exports.prettyFactory=g,t.exports.colorizerFactory=o,t.exports.isColorSupported=n,t.exports.default=_})),GX=rX(yX(),1),Pxe=rX(Nxe(),1);const KX=new Map;function Fxe(e){let t=KX.get(e);return t||(t={chain:Promise.resolve(),parentDirEnsured:!1},KX.set(e,t)),t}var Ixe=class{#e;#t;#n;#r;constructor(e){this.#e=e.currentPath,this.#t=e.previousPath,this.#n=e.maxBytes,this.#r=Fxe(e.currentPath)}append(e){let t=this.#r.chain.catch(()=>void 0).then(()=>this.#i(e));return this.#r.chain=t,t}async drain(){await this.#r.chain.catch(()=>void 0)}async#i(e){this.#r.parentDirEnsured||(await Te(k(this.#e),{recursive:!0}),this.#r.parentDirEnsured=!0),await je(this.#e,e,{flag:`a`});let t;try{t=te(this.#e).size}catch{this.#r.parentDirEnsured=!1;return}if(t>this.#n)try{await ke(this.#e,this.#t)}catch(e){if(e?.code!==`ENOENT`)throw e}}};const qX=[`.ok`,`local`,`logs`];function Lxe(e){return j(e,...qX,`server-current.jsonl`)}function Rxe(e){return j(e,...qX,`server-prev.jsonl`)}var JX=class extends Le{#e;#t=0;#n=0;constructor(e){super({decodeStrings:!1}),this.#e=new Ixe({currentPath:Lxe(e.projectDir),previousPath:Rxe(e.projectDir),maxBytes:e.maxBytes})}_write(e,t,n){this.#e.append(e).then(()=>n(),e=>{this.#r(e),n()})}#r(e){let t=Date.now();if(t-this.#t<5e3){this.#n++;return}this.#i(e instanceof Error?e.message:String(e),t)}#i(e,t){let n=this.#n;this.#n=0,this.#t=t,console.error(JSON.stringify({event:`pino-file-sink-write-dropped`,error:e,suppressed:n}))}async drain(){await this.#e.drain(),this.#n>0&&this.#i(`flushed at drain`,Date.now())}};function zxe(){let e=Ju.getSpan(Gu.active());if(!e)return{};let t=e.spanContext();return{trace_id:t.traceId,span_id:t.spanId,trace_flags:t.traceFlags}}function Bxe(){return process.env.NO_COLOR&&process.env.NO_COLOR!==``?!1:process.stdout.isTTY??!1}const YX=new Set([`fatal`,`error`,`warn`,`info`,`debug`,`trace`,`silent`]);function XX(e){return e===`silent`?1/0:GX.default.levels.values[e]??GX.default.levels.values.info}function ZX(e,t){return XX(e)<=XX(t)?e:t}var Vxe=class{name;transportConfigs=[];fileSinkOpts;redactPaths;activeFileSink;pinoInstance;options;constructor(e,t={}){this.name=e,this.options={name:this.name,level:process.env.LOG_LEVEL||(process.env.NODE_ENV===`test`?`silent`:`info`),serializers:{err:GX.default.stdSerializers.err,error:GX.default.stdSerializers.err},mixin:zxe,...t.options},t.transportConfigs&&(this.transportConfigs=t.transportConfigs),t.fileSink&&(this.fileSinkOpts=t.fileSink),t.redactPaths&&t.redactPaths.length>0&&(this.redactPaths=t.redactPaths,this.options={...this.options,redact:{paths:[...t.redactPaths],censor:`[REDACTED]`}}),this.pinoInstance=this.buildInstance()}resolveStreamLevels(){let e=this.options.level??`info`,t=process.env.OK_FILE_LEVEL?.toLowerCase(),n=t&&YX.has(t)?t:e===`silent`?`silent`:ZX(e,`debug`),r=process.env.OK_CONSOLE_LEVEL?.toLowerCase(),i=r&&YX.has(r)?r:e;return{fileLevel:n,consoleLevel:i,instanceLevel:ZX(n,i)}}buildInstance(){this.activeFileSink=void 0;let{fileLevel:e,consoleLevel:t,instanceLevel:n}=this.resolveStreamLevels();if(this.transportConfigs.length>0)return(0,GX.default)(this.options,GX.default.transport({targets:this.transportConfigs}));let r;try{r=(0,Pxe.default)({colorize:Bxe(),translateTime:`HH:MM:ss`,ignore:`pid,hostname`})}catch(r){if(console.warn(`[PinoLogger] pino-pretty failed, falling back to JSON:`,r),this.fileSinkOpts){let t=new JX(this.fileSinkOpts);return this.activeFileSink=t,(0,GX.default)({...this.options,level:n},GX.default.multistream([{stream:t,level:e}]))}return(0,GX.default)({...this.options,level:t})}if(this.fileSinkOpts){let i=new JX(this.fileSinkOpts);return this.activeFileSink=i,(0,GX.default)({...this.options,level:n},GX.default.multistream([{stream:r,level:t},{stream:i,level:e}]))}return(0,GX.default)({...this.options,level:t},r)}recreateInstance(){typeof this.pinoInstance.flush==`function`&&this.pinoInstance.flush(),this.pinoInstance=this.buildInstance()}addTransport(e){this.transportConfigs.push(e),this.recreateInstance()}removeTransport(e){e>=0&&e<this.transportConfigs.length&&(this.transportConfigs.splice(e,1),this.recreateInstance())}getTransports(){return[...this.transportConfigs]}updateOptions(e){this.options={...this.options,...e},this.recreateInstance()}reconfigure(e){e.options&&(this.options={...this.options,...e.options}),e.transportConfigs&&(this.transportConfigs=e.transportConfigs),e.fileSink&&(this.fileSinkOpts=e.fileSink),e.redactPaths&&e.redactPaths.length>0&&(this.redactPaths=e.redactPaths,this.options={...this.options,redact:{paths:[...e.redactPaths],censor:`[REDACTED]`}}),this.recreateInstance()}getPinoInstance(){return this.pinoInstance}async flushFileSink(){this.activeFileSink&&await this.activeFileSink.drain()}error(e,t){this.pinoInstance.error(e,t)}warn(e,t){this.pinoInstance.warn(e,t)}info(e,t){this.pinoInstance.info(e,t)}debug(e,t){this.pinoInstance.debug(e,t)}};const Hxe=new class{config={};loggers=new Map;configure(e){if(this.config=e,e.pinoConfig&&!e.defaultLogger&&!e.loggerFactory){for(let t of this.loggers.values())t.reconfigure(e.pinoConfig);return}this.loggers.clear()}getLogger(e){let t=this.loggers.get(e);if(t)return t;let n;return n=this.config.loggerFactory?this.config.loggerFactory(e):this.config.defaultLogger?this.config.defaultLogger:new Vxe(e,this.config.pinoConfig),this.loggers.set(e,n),n}reset(){this.config={},this.loggers.clear()}async flushAllFileSinks(){let e=[];for(let t of this.loggers.values())e.push(t.flushFileSink());await Promise.all(e)}};function QX(e){return Hxe.getLogger(e)}new rve({extensions:sP,deriveStructuralFreshness:!0}),yO(sP);var $X=class{kind;projectRoot;projectSubPath;gitPath;gitDir;cachedCommonDir;constructor(e,t,n,r,i){this.kind=e,this.projectRoot=t,this.projectSubPath=n,this.gitPath=r,this.gitDir=i}readCommonDir(){if(this.cachedCommonDir!==void 0)return{kind:`resolved`,path:this.cachedCommonDir};let e=this.gitDir;try{let t=S(j(this.gitDir,`commondir`),`utf-8`).trim();t.length>0&&(e=A(t)?t:N(this.gitDir,t))}catch(e){if(!tZ(e))return{kind:`unreadable`,cause:e}}return this.cachedCommonDir=e,{kind:`resolved`,path:e}}readHead(){let e;try{e=S(j(this.gitDir,`HEAD`),`utf-8`).trim()}catch(e){return tZ(e)?{kind:`absent`}:{kind:`unreadable`,cause:e}}let t=/^ref:[ \t]*(refs\/heads\/(.+))$/.exec(e);return t?.[2]?{kind:`branch`,branch:t[2],ref:t[1]}:rZ(e)?{kind:`detached`,oid:e}:{kind:`malformed`,raw:e}}readRemoteUrl(e){let t=this.readCommonDir();if(t.kind===`unreadable`)return t;let n;try{n=S(j(t.path,`config`),`utf-8`)}catch(e){return tZ(e)?{kind:`absent`,reason:`config-missing`}:{kind:`unreadable`,cause:e}}let r=Gxe(n,e);return r===null?{kind:`absent`,reason:`remote-missing`}:{kind:`configured`,url:r}}readRef(e){if(!nZ(e))return{kind:`invalid`};let t=this.readCommonDir();if(t.kind===`unreadable`)return t;let n=N(t.path,e),r=M(t.path,n);if(r.startsWith(`..`)||A(r))return{kind:`invalid`};try{let e=S(n,`utf-8`).trim(),t=Jxe(e);return t===null?{kind:`malformed`,raw:e}:{kind:`present`,storage:`loose`,value:t}}catch(e){if(!tZ(e))return{kind:`unreadable`,cause:e}}let i;try{i=S(j(t.path,`packed-refs`),`utf-8`)}catch(e){return tZ(e)?{kind:`absent`}:{kind:`unreadable`,cause:e}}for(let t of i.split(/\r?\n/)){let n=t.trim();if(n.length===0||n.startsWith(`#`)||n.startsWith(`^`))continue;let r=n.split(/\s+/);if(r.length===2&&r[1]===e)return rZ(r[0])?{kind:`present`,storage:`packed`,value:{kind:`oid`,oid:r[0]}}:{kind:`malformed`,raw:n}}return{kind:`absent`}}};function Uxe(e){return eZ(N(e),``)}function Wxe(e){let t=N(e),n=N(_e());if(t===n)return{kind:`absent`};let r=eZ(t,``);if(r.kind!==`absent`)return r;let i=t;for(let e=0;e<64;e++){if(i===n)return{kind:`absent`};let e=k(i);if(e===i||e===n)return{kind:`absent`};let r=eZ(e,M(e,t));if(r.kind!==`absent`)return r;i=e}return{kind:`absent`}}function eZ(e,t){let n=j(e,`.git`),r;try{r=te(n)}catch(e){return tZ(e)?{kind:`absent`}:{kind:`inaccessible`,gitPath:n,cause:e}}if(r.isDirectory())return{kind:`repository`,repository:new $X(`directory`,e,t,n,n)};if(!r.isFile())return{kind:`absent`};let i;try{i=S(n,`utf-8`).trim()}catch(e){return{kind:`malformed-pointer`,gitPath:n,target:``,cause:e}}let a=/^gitdir:[ \t]*(.+)$/.exec(i);if(!a)return{kind:`malformed-pointer`,gitPath:n,target:``};let o=a[1].trim(),s=A(o)?o:N(e,o);try{if(!te(s).isDirectory())return{kind:`malformed-pointer`,gitPath:n,target:s}}catch(e){return{kind:`malformed-pointer`,gitPath:n,target:s,cause:e}}return{kind:`repository`,repository:new $X(`linked`,e,t,n,s)}}function Gxe(e,t){let n=!1;for(let r of e.split(/\r?\n/)){let e=Kxe(r);if(e.length===0)continue;if(e.startsWith(`[`)){n=/^\[\s*remote\s+["'](.+)["']\s*\]$/.exec(e)?.[1]===t;continue}if(!n)continue;let i=/^url\s*=\s*(.*)$/.exec(e);if(!i)continue;let a=qxe(i[1]);if(a.length>0)return a}return null}function Kxe(e){let t=e.search(/[;#]/);return(t===-1?e:e.slice(0,t)).trim()}function qxe(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function tZ(e){let t=e?.code;return t===`ENOENT`||t===`ENOTDIR`}function nZ(e){return e.startsWith(`refs/`)&&!e.includes(`\0`)&&!e.includes(`\\`)&&!e.includes(`..`)&&!e.includes(`//`)&&!e.endsWith(`/`)}function Jxe(e){if(e.length===0)return null;let t=/^ref:[ \t]*(refs\/.+)$/.exec(e);return t?nZ(t[1])?{kind:`symbolic`,target:t[1]}:null:rZ(e)?{kind:`oid`,oid:e}:null}function rZ(e){return/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(e)}new Set(sae);const Yxe=Object.values(rt).map(e=>e.mcpServerName.slice(oae.length)).filter(e=>e!==``);RegExp(`^open[-_ ]?knowledge(?:${Yxe.join(`|`)})?$`),new Set(Object.values(rt).map(Tt));const iZ={initialize:`initialize`,authenticate:`authenticate`,providers_list:`providers/list`,providers_set:`providers/set`,providers_disable:`providers/disable`,session_new:`session/new`,session_load:`session/load`,session_set_mode:`session/set_mode`,session_set_config_option:`session/set_config_option`,session_prompt:`session/prompt`,session_cancel:`session/cancel`,mcp_message:`mcp/message`,session_list:`session/list`,session_delete:`session/delete`,session_fork:`session/fork`,session_resume:`session/resume`,session_close:`session/close`,logout:`logout`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,nes_accept:`nes/accept`,nes_reject:`nes/reject`,nes_close:`nes/close`,document_did_open:`document/didOpen`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_save:`document/didSave`,document_did_focus:`document/didFocus`},aZ={session_request_permission:`session/request_permission`,session_update:`session/update`,fs_write_text_file:`fs/write_text_file`,fs_read_text_file:`fs/read_text_file`,terminal_create:`terminal/create`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`,terminal_kill:`terminal/kill`,mcp_connect:`mcp/connect`,mcp_message:`mcp/message`,mcp_disconnect:`mcp/disconnect`,elicitation_create:`elicitation/create`,elicitation_complete:`elicitation/complete`},Xxe={cancel_request:`$/cancel_request`},oZ=Symbol(`skippedItem`);function $(e,t){return e.catch(t)}function sZ(e,t){let n=e.catch(t);return z().transform((e,t)=>e===void 0?(t.addIssue({code:`custom`,message:`Required value is missing`}),Dt):n.parse(e))}function cZ(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return;let n=e[t];return typeof n==`string`?n:void 0}function lZ(e,t,n){return e.superRefine((e,r)=>{let i=cZ(e,t);i!==void 0&&n.includes(i)&&r.addIssue({code:`custom`,path:[t],message:`${t} ${JSON.stringify(i)} is reserved by a known variant, but the value does not match that variant's schema`})})}function uZ(e,t,n){return z().transform((r,i)=>{let a=e.safeParse(r);if(!a.success){for(let e of a.error.issues)i.addIssue({...e,input:r});return Dt}let o=a.data,s=cZ(r,t);if(s!==void 0&&!n.includes(s)){let e=r;for(let[t,n]of Object.entries(e))t!==`__proto__`&&(Object.hasOwn(o,t)||(o[t]=n))}return o})}function dZ(e){return B(e.catch(oZ)).transform(e=>e.filter(e=>e!==oZ))}const fZ=$i([L(),I()]).nullable(),pZ=I(),mZ=V({sessionId:pZ,path:I(),content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),hZ=V({sessionId:pZ,path:I(),line:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),limit:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gZ=I(),_Z=$i([W(`read`),W(`edit`),W(`delete`),W(`move`),W(`search`),W(`execute`),W(`think`),W(`fetch`),W(`switch_mode`),W(`other`)]),vZ=$i([W(`pending`),W(`in_progress`),W(`completed`),W(`failed`)]),yZ=V({audience:$(dZ($i([W(`assistant`),W(`user`)])).nullish(),()=>void 0),lastModified:$(I().nullish(),()=>void 0),priority:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),Zxe=V({annotations:$(yZ.nullish(),()=>void 0),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),Qxe=V({annotations:$(yZ.nullish(),()=>void 0),data:I(),mimeType:I(),uri:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),$xe=V({annotations:$(yZ.nullish(),()=>void 0),data:I(),mimeType:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),eSe=V({annotations:$(yZ.nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),mimeType:$(I().nullish(),()=>void 0),name:I(),size:$(L().nullish(),()=>void 0),title:$(I().nullish(),()=>void 0),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),tSe=$i([V({mimeType:$(I().nullish(),()=>void 0),text:I(),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),V({blob:I(),mimeType:$(I().nullish(),()=>void 0),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)})]),nSe=V({annotations:$(yZ.nullish(),()=>void 0),resource:tSe,_meta:$(H(I(),z()).nullish(),()=>void 0)}),bZ=$i([Zxe.and(V({type:W(`text`)})),Qxe.and(V({type:W(`image`)})),$xe.and(V({type:W(`audio`)})),eSe.and(V({type:W(`resource_link`)})),nSe.and(V({type:W(`resource`)}))]),rSe=V({content:bZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),iSe=V({path:I(),oldText:$(I().nullish(),()=>void 0),newText:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xZ=I(),aSe=V({terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),SZ=$i([rSe.and(V({type:W(`content`)})),iSe.and(V({type:W(`diff`)})),aSe.and(V({type:W(`terminal`)}))]),CZ=V({path:I(),line:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),wZ=V({toolCallId:gZ,kind:$(_Z.nullish(),()=>void 0),status:$(vZ.nullish(),()=>void 0),title:$(I().nullish(),()=>void 0),content:$(dZ(SZ).nullish(),()=>void 0),locations:$(dZ(CZ).nullish(),()=>void 0),rawInput:$(z().optional(),()=>void 0),rawOutput:$(z().optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TZ=I(),oSe=$i([W(`allow_once`),W(`allow_always`),W(`reject_once`),W(`reject_always`)]),EZ=V({sessionId:pZ,toolCall:wZ,options:B(V({optionId:TZ,name:I(),kind:oSe,_meta:$(H(I(),z()).nullish(),()=>void 0)})),_meta:$(H(I(),z()).nullish(),()=>void 0)}),DZ=V({name:I(),value:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OZ=V({sessionId:pZ,command:I(),args:$(dZ(I()).optional(),()=>[]),env:$(dZ(DZ).optional(),()=>[]),cwd:$(I().nullish(),()=>void 0),outputByteLimit:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),kZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),AZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),jZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),MZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NZ=V({sessionId:pZ,toolCallId:$(gZ.nullish(),()=>void 0)}),PZ=V({requestId:fZ}),sSe=W(`object`),cSe=$i([W(`email`),W(`uri`),W(`date`),W(`date-time`)]),FZ=V({const:I(),title:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),IZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minLength:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),maxLength:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),pattern:I().nullish(),format:cSe.nullish(),default:$(I().nullish(),()=>void 0),enum:B(I()).nullish(),oneOf:B(FZ).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),LZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minimum:L().nullish(),maximum:L().nullish(),default:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),RZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minimum:L().nullish(),maximum:L().nullish(),default:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),default:$(R().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),BZ=V({enum:B(I()),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lSe=V({anyOf:B(FZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),uSe=uZ($i([BZ.and(V({type:W(`string`)})),lZ(V({type:I()}),`type`,[`string`]),lSe]),`type`,[`string`]),VZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minItems:L().nullish(),maxItems:L().nullish(),items:uSe,default:$(dZ(I()).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),dSe=uZ($i([IZ.and(V({type:W(`string`)})),LZ.and(V({type:W(`number`)})),RZ.and(V({type:W(`integer`)})),zZ.and(V({type:W(`boolean`)})),VZ.and(V({type:W(`array`)})),lZ(V({type:I()}),`type`,[`array`,`boolean`,`integer`,`number`,`string`])]),`type`,[`array`,`boolean`,`integer`,`number`,`string`]),fSe=V({type:$(sSe.optional().default(`object`),()=>`object`),title:$(I().nullish(),()=>void 0),properties:H(I(),dSe).optional().default({}),required:B(I()).nullish(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),HZ=ta($i([NZ,PZ]),V({requestedSchema:fSe})),UZ=I(),WZ=ta($i([NZ,PZ]),V({elicitationId:UZ,url:Wi()})),GZ=uZ(ta($i([HZ.and(V({mode:W(`form`)})),WZ.and(V({mode:W(`url`)})),lZ(ta($i([NZ,PZ]),V({mode:I()})),`mode`,[`form`,`url`])]),V({message:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)})),`mode`,[`form`,`url`]),KZ=I(),pSe=V({serverId:KZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),qZ=I(),JZ=V({connectionId:qZ,method:I(),params:H(I(),z()).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),mSe=V({connectionId:qZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),YZ=z();V({id:fZ,method:I(),params:$i([mZ,hZ,EZ,OZ,kZ,AZ,jZ,MZ,GZ,pSe,JZ,mSe,YZ]).nullish()});const XZ=Ki().gte(0).lte(65535),hSe=V({image:$(R().optional().default(!1),()=>!1),audio:$(R().optional().default(!1),()=>!1),embeddedContext:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gSe=V({http:$(R().optional().default(!1),()=>!1),sse:$(R().optional().default(!1),()=>!1),acp:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Se=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),vSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ySe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),bSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),xSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),SSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),CSe=V({list:$(_Se.nullish(),()=>void 0),delete:$(vSe.nullish(),()=>void 0),additionalDirectories:$(ySe.nullish(),()=>void 0),fork:$(bSe.nullish(),()=>void 0),resume:$(xSe.nullish(),()=>void 0),close:$(SSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),wSe=V({logout:$(V({_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ESe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),DSe=V({syncKind:$i([W(`full`),W(`incremental`)]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),kSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ASe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),jSe=V({document:$(V({didOpen:$(ESe.nullish(),()=>void 0),didChange:$(DSe.nullish(),()=>void 0),didClose:$(OSe.nullish(),()=>void 0),didSave:$(kSe.nullish(),()=>void 0),didFocus:$(ASe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),NSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),PSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ISe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),LSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),RSe=V({recentFiles:$(MSe.nullish(),()=>void 0),relatedSnippets:$(NSe.nullish(),()=>void 0),editHistory:$(PSe.nullish(),()=>void 0),userActions:$(FSe.nullish(),()=>void 0),openFiles:$(ISe.nullish(),()=>void 0),diagnostics:$(LSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zSe=V({events:$(jSe.nullish(),()=>void 0),context:$(RSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZZ=$i([W(`utf-16`),W(`utf-32`),W(`utf-8`)]),BSe=V({loadSession:$(R().optional().default(!1),()=>!1),promptCapabilities:$(hSe.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:$(gSe.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:$(CSe.optional().default({}),()=>({})),auth:$(wSe.optional().default({}),()=>({})),providers:$(TSe.nullish(),()=>void 0),nes:$(zSe.nullish(),()=>void 0),positionEncoding:$(ZZ.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),QZ=I(),VSe=V({name:I(),label:$(I().nullish(),()=>void 0),secret:$(R().optional().default(!0),()=>!0),optional:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),HSe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),vars:sZ(dZ(VSe),()=>[]),link:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),USe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),args:$(dZ(I()).optional(),()=>[]),env:$(H(I(),I()).optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),WSe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),GSe=$i([HSe.and(V({type:W(`env_var`)})),USe.and(V({type:W(`terminal`)})),WSe]),$Z=V({name:I(),title:$(I().nullish(),()=>void 0),version:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),KSe=V({protocolVersion:XZ,agentCapabilities:$(BSe.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:$(dZ(GSe).optional().default([]),()=>[]),agentInfo:$($Z.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),qSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),eQ=I(),tQ=$i([W(`anthropic`),W(`openai`),W(`azure`),W(`vertex`),W(`bedrock`),I()]),JSe=V({apiType:tQ,baseUrl:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),YSe=V({providers:B(V({providerId:eQ,supported:sZ(dZ(tQ),()=>[]),required:R(),current:JSe.nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)})),_meta:$(H(I(),z()).nullish(),()=>void 0)}),XSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),QSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),nQ=I(),rQ=V({currentModeId:nQ,availableModes:sZ(dZ(V({id:nQ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iQ=I(),$Se=$i([W(`mode`),W(`model`),W(`model_config`),W(`thought_level`),I()]),aQ=I(),oQ=V({value:aQ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),eCe=V({group:I(),name:I(),options:sZ(dZ(oQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),tCe=V({currentValue:aQ,options:$i([B(oQ),B(eCe)])}),nCe=V({currentValue:R()}),sQ=ta($i([tCe.and(V({type:W(`select`)})),nCe.and(V({type:W(`boolean`)}))]),V({id:iQ,name:I(),description:$(I().nullish(),()=>void 0),category:$($Se.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),rCe=V({sessionId:pZ,modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iCe=V({modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),aCe=V({sessions:sZ(dZ(V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),title:$(I().nullish(),()=>void 0),updatedAt:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),nextCursor:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),oCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),sCe=V({sessionId:pZ,modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),cCe=V({modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),uCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dCe=V({configOptions:sZ(dZ(sQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),fCe=V({stopReason:$i([W(`end_turn`),W(`max_tokens`),W(`max_turn_requests`),W(`refusal`),W(`cancelled`)]),usage:$(V({totalTokens:L(),inputTokens:L(),outputTokens:L(),thoughtTokens:$(L().nullish(),()=>void 0),cachedReadTokens:$(L().nullish(),()=>void 0),cachedWriteTokens:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),pCe=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),cQ=I(),lQ=V({line:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),character:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),_meta:$(H(I(),z()).nullish(),()=>void 0)}),uQ=V({start:lQ,end:lQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),mCe=V({range:uQ,newText:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),hCe=V({id:cQ,uri:I(),edits:B(mCe),cursorPosition:$(lQ.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gCe=V({id:cQ,uri:I(),position:lQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Ce=V({id:cQ,uri:I(),position:lQ,newName:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),vCe=V({id:cQ,uri:I(),search:I(),replace:I(),isRegex:R().nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),yCe=V({suggestions:B($i([hCe.and(V({kind:W(`edit`)})),gCe.and(V({kind:W(`jump`)})),_Ce.and(V({kind:W(`rename`)})),vCe.and(V({kind:W(`searchAndReplace`)}))])),_meta:$(H(I(),z()).nullish(),()=>void 0)}),bCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dQ=z(),fQ=z(),pQ=V({code:$i([W(-32700),W(-32600),W(-32601),W(-32602),W(-32603),W(-32800),W(-32e3),W(-32002),Ki().min(-2147483648,{error:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{error:`Invalid value: Expected int32 to be <= 2147483647`})]),message:I(),data:$(z().optional(),()=>void 0)});$i([V({id:fZ,result:$i([KSe,qSe,YSe,XSe,ZSe,QSe,rCe,iCe,aCe,oCe,sCe,cCe,lCe,uCe,dCe,fCe,pCe,yCe,bCe,dQ,fQ])}),V({id:fZ,error:pQ})]);const mQ=V({content:bZ,messageId:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xCe=V({toolCallId:gZ,title:I(),kind:$(_Z.optional(),()=>void 0),status:$(vZ.optional(),()=>void 0),content:$(dZ(SZ).optional(),()=>[]),locations:$(dZ(CZ).optional(),()=>[]),rawInput:$(z().optional(),()=>void 0),rawOutput:$(z().optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),SCe=$i([W(`high`),W(`medium`),W(`low`)]),CCe=$i([W(`pending`),W(`in_progress`),W(`completed`)]),hQ=V({content:I(),priority:SCe,status:CCe,_meta:$(H(I(),z()).nullish(),()=>void 0)}),wCe=V({entries:sZ(dZ(hQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gQ=I(),TCe=V({planId:gQ,entries:sZ(dZ(hQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ECe=V({planId:gQ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),DCe=V({planId:gQ,content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OCe=V({plan:$i([TCe.and(V({type:W(`items`)})),ECe.and(V({type:W(`file`)})),DCe.and(V({type:W(`markdown`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),kCe=V({planId:gQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),ACe=V({hint:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),jCe=V({availableCommands:sZ(dZ(V({name:I(),description:I(),input:$(ACe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MCe=V({currentModeId:nQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NCe=V({configOptions:sZ(dZ(sQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),PCe=V({title:$(I().nullish(),()=>void 0),updatedAt:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FCe=V({amount:L(),currency:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ICe=V({used:L(),size:L(),cost:$(FCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Q=V({sessionId:pZ,update:$i([mQ.and(V({sessionUpdate:W(`user_message_chunk`)})),mQ.and(V({sessionUpdate:W(`agent_message_chunk`)})),mQ.and(V({sessionUpdate:W(`agent_thought_chunk`)})),xCe.and(V({sessionUpdate:W(`tool_call`)})),wZ.and(V({sessionUpdate:W(`tool_call_update`)})),wCe.and(V({sessionUpdate:W(`plan`)})),OCe.and(V({sessionUpdate:W(`plan_update`)})),kCe.and(V({sessionUpdate:W(`plan_removed`)})),jCe.and(V({sessionUpdate:W(`available_commands_update`)})),MCe.and(V({sessionUpdate:W(`current_mode_update`)})),NCe.and(V({sessionUpdate:W(`config_option_update`)})),PCe.and(V({sessionUpdate:W(`session_info_update`)})),ICe.and(V({sessionUpdate:W(`usage_update`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),vQ=V({elicitationId:UZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),yQ=V({connectionId:qZ,method:I(),params:$(H(I(),z()).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),bQ=z();V({method:I(),params:$i([_Q,vQ,yQ,bQ]).nullish()});const LCe=V({readTextFile:$(R().optional().default(!1),()=>!1),writeTextFile:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),RCe=V({configOptions:$(V({boolean:$(V({_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),BCe=V({terminal:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),VCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),HCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),UCe=V({form:$(VCe.nullish(),()=>void 0),url:$(HCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),WCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),GCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),KCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),qCe=V({jump:$(WCe.nullish(),()=>void 0),rename:$(GCe.nullish(),()=>void 0),searchAndReplace:$(KCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xQ=V({protocolVersion:XZ,clientCapabilities:$(V({fs:$(LCe.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:$(R().optional().default(!1),()=>!1),session:$(RCe.nullish(),()=>void 0),plan:$(zCe.nullish(),()=>void 0),auth:$(BCe.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:$(UCe.nullish(),()=>void 0),nes:$(qCe.nullish(),()=>void 0),positionEncodings:$(dZ(ZZ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}).optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:$($Z.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),SQ=V({methodId:QZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),CQ=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),wQ=V({providerId:eQ,apiType:tQ,baseUrl:I(),headers:H(I(),I()).optional(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TQ=V({providerId:eQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),EQ=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),DQ=V({name:I(),value:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),JCe=V({name:I(),url:I(),headers:B(DQ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),YCe=V({name:I(),url:I(),headers:B(DQ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),XCe=V({name:I(),serverId:KZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZCe=V({name:I(),command:I(),args:B(I()),env:B(DZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OQ=$i([JCe.and(V({type:W(`http`)})),YCe.and(V({type:W(`sse`)})),XCe.and(V({type:W(`acp`)})),ZCe]),kQ=V({cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:sZ(dZ(OQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),AQ=V({mcpServers:sZ(dZ(OQ),()=>[]),cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),jQ=V({cwd:I().nullish(),cursor:I().nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NQ=V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:$(dZ(OQ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),PQ=V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:$(dZ(OQ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),IQ=V({sessionId:pZ,modeId:nQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),LQ=ta($i([V({value:R(),type:W(`boolean`)}),V({value:aQ})]),V({sessionId:pZ,configId:iQ,_meta:$(H(I(),z()).nullish(),()=>void 0)})),RQ=V({sessionId:pZ,prompt:B(bZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),QCe=V({uri:I(),name:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),$Ce=V({name:I(),owner:I(),remoteUrl:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zQ=V({workspaceUri:$(I().nullish(),()=>void 0),workspaceFolders:B(QCe).nullish(),repository:$($Ce.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ewe=$i([W(`automatic`),W(`diagnostic`),W(`manual`)]),twe=V({uri:I(),languageId:I(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),nwe=V({startLine:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),endLine:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),rwe=V({uri:I(),excerpts:B(nwe),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iwe=V({uri:I(),diff:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),awe=V({action:I(),uri:I(),position:lQ,timestampMs:L(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),owe=V({uri:I(),languageId:I(),visibleRange:$(uQ.nullish(),()=>void 0),lastFocusedMs:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),swe=$i([W(`error`),W(`warning`),W(`information`),W(`hint`)]),cwe=V({uri:I(),range:uQ,severity:swe,message:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lwe=V({recentFiles:B(twe).nullish(),relatedSnippets:B(rwe).nullish(),editHistory:B(iwe).nullish(),userActions:B(awe).nullish(),openFiles:B(owe).nullish(),diagnostics:B(cwe).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),BQ=V({sessionId:pZ,uri:I(),version:L(),position:lQ,selection:uQ.nullish(),triggerKind:ewe,context:lwe.nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),VQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)});V({id:fZ,method:I(),params:$i([xQ,SQ,CQ,wQ,TQ,EQ,kQ,AQ,jQ,MQ,NQ,PQ,FQ,IQ,LQ,RQ,zQ,BQ,VQ,JZ,YZ]).nullish()});const uwe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dwe=V({content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),fwe=V({optionId:TZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),pwe=V({outcome:$i([V({outcome:W(`cancelled`)}),fwe.and(V({outcome:W(`selected`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),mwe=V({terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),hwe=V({exitCode:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),signal:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gwe=V({output:I(),truncated:R(),exitStatus:$(hwe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_we=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),vwe=V({exitCode:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),signal:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ywe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),bwe=$i([I(),L(),L(),R(),B(I())]),HQ=V({content:H(I(),bwe).nullish()});$i([V({id:fZ,result:$i([uwe,dwe,pwe,mwe,gwe,_we,vwe,ywe,uZ(ta($i([HQ.and(V({action:W(`accept`)})),V({action:W(`decline`)}),V({action:W(`cancel`)}),lZ(V({action:I()}),`action`,[`accept`,`cancel`,`decline`])]),V({_meta:$(H(I(),z()).nullish(),()=>void 0)})),`action`,[`accept`,`cancel`,`decline`]),V({connectionId:qZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),fQ,dQ])}),V({id:fZ,error:pQ})]);const UQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),WQ=V({sessionId:pZ,uri:I(),languageId:I(),version:L(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xwe=V({range:uQ.nullish(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),GQ=V({sessionId:pZ,uri:I(),version:L(),contentChanges:sZ(dZ(xwe),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),KQ=V({sessionId:pZ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),qQ=V({sessionId:pZ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),JQ=V({sessionId:pZ,uri:I(),version:L(),position:lQ,visibleRange:uQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),YQ=V({sessionId:pZ,id:cQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),XQ=V({sessionId:pZ,id:cQ,reason:$($i([W(`rejected`),W(`ignored`),W(`replaced`),W(`cancelled`)]).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)});V({method:I(),params:$i([UQ,WQ,GQ,KQ,qQ,JQ,YQ,XQ,yQ,bQ]).nullish()}),V({requestId:fZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),HZ.and(V({mode:W(`form`)})).and(V({message:I()})),WZ.and(V({mode:W(`url`)})).and(V({message:I()})),$i([NZ,PZ]).and(V({message:I()})),IZ.and(V({type:W(`string`)})),LZ.and(V({type:W(`number`)})),RZ.and(V({type:W(`integer`)})),zZ.and(V({type:W(`boolean`)})),VZ.and(V({type:W(`array`)})),BZ.and(V({type:W(`string`)})),HQ.and(V({action:W(`accept`)})),V({action:W(`decline`)}),V({action:W(`cancel`)});function ZQ(e){return e??{}}iZ.initialize,iZ.authenticate,iZ.logout,iZ.providers_list,iZ.providers_set,iZ.providers_disable,iZ.session_new,iZ.session_load,iZ.session_list,iZ.session_delete,iZ.session_fork,iZ.session_resume,iZ.session_close,iZ.session_set_mode,iZ.session_set_config_option,iZ.session_prompt,iZ.session_cancel,iZ.nes_start,iZ.nes_suggest,iZ.nes_accept,iZ.nes_reject,iZ.nes_close,iZ.document_did_open,iZ.document_did_change,iZ.document_did_close,iZ.document_did_save,iZ.document_did_focus,aZ.session_request_permission,aZ.session_update,aZ.fs_write_text_file,aZ.fs_read_text_file,aZ.terminal_create,aZ.terminal_output,aZ.terminal_release,aZ.terminal_wait_for_exit,aZ.terminal_kill,aZ.elicitation_create,aZ.elicitation_complete,Xxe.cancel_request;function QQ(e,t,n){return{method:e,params:t,mapResponse:n}}function $Q(e,t){return{method:e,params:t}}function e$(e){let t={};for(let n of Object.values(e))t[n.method]=n;return t}const Swe={initialize:QQ(iZ.initialize,xQ),newSession:QQ(iZ.session_new,kQ),loadSession:QQ(iZ.session_load,AQ,ZQ),unstable_forkSession:QQ(iZ.session_fork,NQ),listSessions:QQ(iZ.session_list,jQ),deleteSession:QQ(iZ.session_delete,MQ,ZQ),resumeSession:QQ(iZ.session_resume,PQ),closeSession:QQ(iZ.session_close,FQ,ZQ),setSessionMode:QQ(iZ.session_set_mode,IQ,ZQ),setSessionConfigOption:QQ(iZ.session_set_config_option,LQ),authenticate:QQ(iZ.authenticate,SQ,ZQ),unstable_listProviders:QQ(iZ.providers_list,CQ),unstable_setProvider:QQ(iZ.providers_set,wQ,ZQ),unstable_disableProvider:QQ(iZ.providers_disable,TQ,ZQ),logout:QQ(iZ.logout,EQ,ZQ),prompt:QQ(iZ.session_prompt,RQ),unstable_startNes:QQ(iZ.nes_start,zQ),unstable_suggestNes:QQ(iZ.nes_suggest,BQ),unstable_closeNes:QQ(iZ.nes_close,VQ,ZQ)},Cwe={cancel:$Q(iZ.session_cancel,UQ),unstable_didOpenDocument:$Q(iZ.document_did_open,WQ),unstable_didChangeDocument:$Q(iZ.document_did_change,GQ),unstable_didCloseDocument:$Q(iZ.document_did_close,KQ),unstable_didSaveDocument:$Q(iZ.document_did_save,qQ),unstable_didFocusDocument:$Q(iZ.document_did_focus,JQ),unstable_acceptNes:$Q(iZ.nes_accept,YQ),unstable_rejectNes:$Q(iZ.nes_reject,XQ)},wwe={requestPermission:QQ(aZ.session_request_permission,EZ),writeTextFile:QQ(aZ.fs_write_text_file,mZ,ZQ),readTextFile:QQ(aZ.fs_read_text_file,hZ),createTerminal:QQ(aZ.terminal_create,OZ),terminalOutput:QQ(aZ.terminal_output,kZ),releaseTerminal:QQ(aZ.terminal_release,AZ,ZQ),waitForTerminalExit:QQ(aZ.terminal_wait_for_exit,jZ),killTerminal:QQ(aZ.terminal_kill,MZ,ZQ),unstable_createElicitation:QQ(aZ.elicitation_create,GZ)},Twe={sessionUpdate:$Q(aZ.session_update,_Q),unstable_completeElicitation:$Q(aZ.elicitation_complete,vQ)};e$(Swe),e$(Cwe),e$(wwe),e$(Twe),iZ.initialize,iZ.authenticate,iZ.providers_list,iZ.providers_set,iZ.providers_disable,iZ.session_new,iZ.session_load,iZ.session_set_mode,iZ.session_set_config_option,iZ.session_prompt,iZ.session_list,iZ.session_delete,iZ.session_fork,iZ.session_resume,iZ.session_close,iZ.logout,iZ.nes_start,iZ.nes_suggest,iZ.nes_close,iZ.session_cancel,iZ.nes_accept,iZ.nes_reject,iZ.document_did_open,iZ.document_did_change,iZ.document_did_close,iZ.document_did_save,iZ.document_did_focus,aZ.session_request_permission,aZ.fs_write_text_file,aZ.fs_read_text_file,aZ.terminal_create,aZ.terminal_output,aZ.terminal_release,aZ.terminal_wait_for_exit,aZ.terminal_kill,aZ.elicitation_create,aZ.session_update,aZ.elicitation_complete;var Ewe=i(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),t$=i(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=Ewe(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Dwe=i(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=t$()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Owe=i(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),kwe=i(((e,n)=>{let r=t(`os`),i=t(`tty`),a=Owe(),{env:o}=process,s;a(`no-color`)||a(`no-colors`)||a(`color=false`)||a(`color=never`)?s=0:(a(`color`)||a(`colors`)||a(`color=true`)||a(`color=always`))&&(s=1),`FORCE_COLOR`in o&&(s=o.FORCE_COLOR===`true`?1:o.FORCE_COLOR===`false`?0:o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function c(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(s===0)return 0;if(a(`color=16m`)||a(`color=full`)||a(`color=truecolor`))return 3;if(a(`color=256`))return 2;if(e&&!t&&s===void 0)return 0;let n=s||0;if(o.TERM===`dumb`)return n;if(process.platform===`win32`){let e=r.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in o)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in o)||o.CI_NAME===`codeship`?1:n;if(`TEAMCITY_VERSION`in o)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION);if(o.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in o){let e=parseInt((o.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(o.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||`COLORTERM`in o?1:n}function u(e){return c(l(e,e&&e.isTTY))}n.exports={supportsColor:u,stdout:c(l(!0,i.isatty(1))),stderr:c(l(!0,i.isatty(2)))}})),Awe=i(((e,n)=>{let r=t(`tty`),i=t(`util`);e.init=d,e.log=c,e.formatArgs=o,e.save=l,e.load=u,e.useColors=a,e.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=kwe();t&&(t.stderr||t).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function a(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(e){let{namespace:t,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${t} \u001B[0m`;e[0]=a+e[0].split(`
|
|
722
|
+
`)}),r(a,o,n),o},{parse:`lines`,close(e,t){n.on(`close`,()=>{t(e)})}})}t.exports=_,t.exports.build=_,t.exports.PinoPretty=_,t.exports.prettyFactory=g,t.exports.colorizerFactory=o,t.exports.isColorSupported=n,t.exports.default=_})),GX=rX(yX(),1),Pxe=rX(Nxe(),1);const KX=new Map;function Fxe(e){let t=KX.get(e);return t||(t={chain:Promise.resolve(),parentDirEnsured:!1},KX.set(e,t)),t}var Ixe=class{#e;#t;#n;#r;constructor(e){this.#e=e.currentPath,this.#t=e.previousPath,this.#n=e.maxBytes,this.#r=Fxe(e.currentPath)}append(e){let t=this.#r.chain.catch(()=>void 0).then(()=>this.#i(e));return this.#r.chain=t,t}async drain(){await this.#r.chain.catch(()=>void 0)}async#i(e){this.#r.parentDirEnsured||(await De(k(this.#e),{recursive:!0}),this.#r.parentDirEnsured=!0),await Ne(this.#e,e,{flag:`a`});let t;try{t=te(this.#e).size}catch{this.#r.parentDirEnsured=!1;return}if(t>this.#n)try{await je(this.#e,this.#t)}catch(e){if(e?.code!==`ENOENT`)throw e}}};const qX=[`.ok`,`local`,`logs`];function Lxe(e){return j(e,...qX,`server-current.jsonl`)}function Rxe(e){return j(e,...qX,`server-prev.jsonl`)}var JX=class extends Le{#e;#t=0;#n=0;constructor(e){super({decodeStrings:!1}),this.#e=new Ixe({currentPath:Lxe(e.projectDir),previousPath:Rxe(e.projectDir),maxBytes:e.maxBytes})}_write(e,t,n){this.#e.append(e).then(()=>n(),e=>{this.#r(e),n()})}#r(e){let t=Date.now();if(t-this.#t<5e3){this.#n++;return}this.#i(e instanceof Error?e.message:String(e),t)}#i(e,t){let n=this.#n;this.#n=0,this.#t=t,console.error(JSON.stringify({event:`pino-file-sink-write-dropped`,error:e,suppressed:n}))}async drain(){await this.#e.drain(),this.#n>0&&this.#i(`flushed at drain`,Date.now())}};function zxe(){let e=Ju.getSpan(Gu.active());if(!e)return{};let t=e.spanContext();return{trace_id:t.traceId,span_id:t.spanId,trace_flags:t.traceFlags}}function Bxe(){return process.env.NO_COLOR&&process.env.NO_COLOR!==``?!1:process.stdout.isTTY??!1}const YX=new Set([`fatal`,`error`,`warn`,`info`,`debug`,`trace`,`silent`]);function XX(e){return e===`silent`?1/0:GX.default.levels.values[e]??GX.default.levels.values.info}function ZX(e,t){return XX(e)<=XX(t)?e:t}var Vxe=class{name;transportConfigs=[];fileSinkOpts;redactPaths;activeFileSink;pinoInstance;options;constructor(e,t={}){this.name=e,this.options={name:this.name,level:process.env.LOG_LEVEL||(process.env.NODE_ENV===`test`?`silent`:`info`),serializers:{err:GX.default.stdSerializers.err,error:GX.default.stdSerializers.err},mixin:zxe,...t.options},t.transportConfigs&&(this.transportConfigs=t.transportConfigs),t.fileSink&&(this.fileSinkOpts=t.fileSink),t.redactPaths&&t.redactPaths.length>0&&(this.redactPaths=t.redactPaths,this.options={...this.options,redact:{paths:[...t.redactPaths],censor:`[REDACTED]`}}),this.pinoInstance=this.buildInstance()}resolveStreamLevels(){let e=this.options.level??`info`,t=process.env.OK_FILE_LEVEL?.toLowerCase(),n=t&&YX.has(t)?t:e===`silent`?`silent`:ZX(e,`debug`),r=process.env.OK_CONSOLE_LEVEL?.toLowerCase(),i=r&&YX.has(r)?r:e;return{fileLevel:n,consoleLevel:i,instanceLevel:ZX(n,i)}}buildInstance(){this.activeFileSink=void 0;let{fileLevel:e,consoleLevel:t,instanceLevel:n}=this.resolveStreamLevels();if(this.transportConfigs.length>0)return(0,GX.default)(this.options,GX.default.transport({targets:this.transportConfigs}));let r;try{r=(0,Pxe.default)({colorize:Bxe(),translateTime:`HH:MM:ss`,ignore:`pid,hostname`})}catch(r){if(console.warn(`[PinoLogger] pino-pretty failed, falling back to JSON:`,r),this.fileSinkOpts){let t=new JX(this.fileSinkOpts);return this.activeFileSink=t,(0,GX.default)({...this.options,level:n},GX.default.multistream([{stream:t,level:e}]))}return(0,GX.default)({...this.options,level:t})}if(this.fileSinkOpts){let i=new JX(this.fileSinkOpts);return this.activeFileSink=i,(0,GX.default)({...this.options,level:n},GX.default.multistream([{stream:r,level:t},{stream:i,level:e}]))}return(0,GX.default)({...this.options,level:t},r)}recreateInstance(){typeof this.pinoInstance.flush==`function`&&this.pinoInstance.flush(),this.pinoInstance=this.buildInstance()}addTransport(e){this.transportConfigs.push(e),this.recreateInstance()}removeTransport(e){e>=0&&e<this.transportConfigs.length&&(this.transportConfigs.splice(e,1),this.recreateInstance())}getTransports(){return[...this.transportConfigs]}updateOptions(e){this.options={...this.options,...e},this.recreateInstance()}reconfigure(e){e.options&&(this.options={...this.options,...e.options}),e.transportConfigs&&(this.transportConfigs=e.transportConfigs),e.fileSink&&(this.fileSinkOpts=e.fileSink),e.redactPaths&&e.redactPaths.length>0&&(this.redactPaths=e.redactPaths,this.options={...this.options,redact:{paths:[...e.redactPaths],censor:`[REDACTED]`}}),this.recreateInstance()}getPinoInstance(){return this.pinoInstance}async flushFileSink(){this.activeFileSink&&await this.activeFileSink.drain()}error(e,t){this.pinoInstance.error(e,t)}warn(e,t){this.pinoInstance.warn(e,t)}info(e,t){this.pinoInstance.info(e,t)}debug(e,t){this.pinoInstance.debug(e,t)}};const Hxe=new class{config={};loggers=new Map;configure(e){if(this.config=e,e.pinoConfig&&!e.defaultLogger&&!e.loggerFactory){for(let t of this.loggers.values())t.reconfigure(e.pinoConfig);return}this.loggers.clear()}getLogger(e){let t=this.loggers.get(e);if(t)return t;let n;return n=this.config.loggerFactory?this.config.loggerFactory(e):this.config.defaultLogger?this.config.defaultLogger:new Vxe(e,this.config.pinoConfig),this.loggers.set(e,n),n}reset(){this.config={},this.loggers.clear()}async flushAllFileSinks(){let e=[];for(let t of this.loggers.values())e.push(t.flushFileSink());await Promise.all(e)}};function QX(e){return Hxe.getLogger(e)}new rve({extensions:sP,deriveStructuralFreshness:!0}),yO(sP);var $X=class{kind;projectRoot;projectSubPath;gitPath;gitDir;cachedCommonDir;constructor(e,t,n,r,i){this.kind=e,this.projectRoot=t,this.projectSubPath=n,this.gitPath=r,this.gitDir=i}readCommonDir(){if(this.cachedCommonDir!==void 0)return{kind:`resolved`,path:this.cachedCommonDir};let e=this.gitDir;try{let t=S(j(this.gitDir,`commondir`),`utf-8`).trim();t.length>0&&(e=A(t)?t:N(this.gitDir,t))}catch(e){if(!tZ(e))return{kind:`unreadable`,cause:e}}return this.cachedCommonDir=e,{kind:`resolved`,path:e}}readHead(){let e;try{e=S(j(this.gitDir,`HEAD`),`utf-8`).trim()}catch(e){return tZ(e)?{kind:`absent`}:{kind:`unreadable`,cause:e}}let t=/^ref:[ \t]*(refs\/heads\/(.+))$/.exec(e);return t?.[2]?{kind:`branch`,branch:t[2],ref:t[1]}:rZ(e)?{kind:`detached`,oid:e}:{kind:`malformed`,raw:e}}readRemoteUrl(e){let t=this.readCommonDir();if(t.kind===`unreadable`)return t;let n;try{n=S(j(t.path,`config`),`utf-8`)}catch(e){return tZ(e)?{kind:`absent`,reason:`config-missing`}:{kind:`unreadable`,cause:e}}let r=Gxe(n,e);return r===null?{kind:`absent`,reason:`remote-missing`}:{kind:`configured`,url:r}}readRef(e){if(!nZ(e))return{kind:`invalid`};let t=this.readCommonDir();if(t.kind===`unreadable`)return t;let n=N(t.path,e),r=M(t.path,n);if(r.startsWith(`..`)||A(r))return{kind:`invalid`};try{let e=S(n,`utf-8`).trim(),t=Jxe(e);return t===null?{kind:`malformed`,raw:e}:{kind:`present`,storage:`loose`,value:t}}catch(e){if(!tZ(e))return{kind:`unreadable`,cause:e}}let i;try{i=S(j(t.path,`packed-refs`),`utf-8`)}catch(e){return tZ(e)?{kind:`absent`}:{kind:`unreadable`,cause:e}}for(let t of i.split(/\r?\n/)){let n=t.trim();if(n.length===0||n.startsWith(`#`)||n.startsWith(`^`))continue;let r=n.split(/\s+/);if(r.length===2&&r[1]===e)return rZ(r[0])?{kind:`present`,storage:`packed`,value:{kind:`oid`,oid:r[0]}}:{kind:`malformed`,raw:n}}return{kind:`absent`}}};function Uxe(e){return eZ(N(e),``)}function Wxe(e){let t=N(e),n=N(_e());if(t===n)return{kind:`absent`};let r=eZ(t,``);if(r.kind!==`absent`)return r;let i=t;for(let e=0;e<64;e++){if(i===n)return{kind:`absent`};let e=k(i);if(e===i||e===n)return{kind:`absent`};let r=eZ(e,M(e,t));if(r.kind!==`absent`)return r;i=e}return{kind:`absent`}}function eZ(e,t){let n=j(e,`.git`),r;try{r=te(n)}catch(e){return tZ(e)?{kind:`absent`}:{kind:`inaccessible`,gitPath:n,cause:e}}if(r.isDirectory())return{kind:`repository`,repository:new $X(`directory`,e,t,n,n)};if(!r.isFile())return{kind:`absent`};let i;try{i=S(n,`utf-8`).trim()}catch(e){return{kind:`malformed-pointer`,gitPath:n,target:``,cause:e}}let a=/^gitdir:[ \t]*(.+)$/.exec(i);if(!a)return{kind:`malformed-pointer`,gitPath:n,target:``};let o=a[1].trim(),s=A(o)?o:N(e,o);try{if(!te(s).isDirectory())return{kind:`malformed-pointer`,gitPath:n,target:s}}catch(e){return{kind:`malformed-pointer`,gitPath:n,target:s,cause:e}}return{kind:`repository`,repository:new $X(`linked`,e,t,n,s)}}function Gxe(e,t){let n=!1;for(let r of e.split(/\r?\n/)){let e=Kxe(r);if(e.length===0)continue;if(e.startsWith(`[`)){n=/^\[\s*remote\s+["'](.+)["']\s*\]$/.exec(e)?.[1]===t;continue}if(!n)continue;let i=/^url\s*=\s*(.*)$/.exec(e);if(!i)continue;let a=qxe(i[1]);if(a.length>0)return a}return null}function Kxe(e){let t=e.search(/[;#]/);return(t===-1?e:e.slice(0,t)).trim()}function qxe(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function tZ(e){let t=e?.code;return t===`ENOENT`||t===`ENOTDIR`}function nZ(e){return e.startsWith(`refs/`)&&!e.includes(`\0`)&&!e.includes(`\\`)&&!e.includes(`..`)&&!e.includes(`//`)&&!e.endsWith(`/`)}function Jxe(e){if(e.length===0)return null;let t=/^ref:[ \t]*(refs\/.+)$/.exec(e);return t?nZ(t[1])?{kind:`symbolic`,target:t[1]}:null:rZ(e)?{kind:`oid`,oid:e}:null}function rZ(e){return/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(e)}process.platform===`darwin`||process.platform,new Set(sae);const Yxe=Object.values(rt).map(e=>e.mcpServerName.slice(oae.length)).filter(e=>e!==``);RegExp(`^open[-_ ]?knowledge(?:${Yxe.join(`|`)})?$`),new Set(Object.values(rt).map(Tt));const iZ={initialize:`initialize`,authenticate:`authenticate`,providers_list:`providers/list`,providers_set:`providers/set`,providers_disable:`providers/disable`,session_new:`session/new`,session_load:`session/load`,session_set_mode:`session/set_mode`,session_set_config_option:`session/set_config_option`,session_prompt:`session/prompt`,session_cancel:`session/cancel`,mcp_message:`mcp/message`,session_list:`session/list`,session_delete:`session/delete`,session_fork:`session/fork`,session_resume:`session/resume`,session_close:`session/close`,logout:`logout`,nes_start:`nes/start`,nes_suggest:`nes/suggest`,nes_accept:`nes/accept`,nes_reject:`nes/reject`,nes_close:`nes/close`,document_did_open:`document/didOpen`,document_did_change:`document/didChange`,document_did_close:`document/didClose`,document_did_save:`document/didSave`,document_did_focus:`document/didFocus`},aZ={session_request_permission:`session/request_permission`,session_update:`session/update`,fs_write_text_file:`fs/write_text_file`,fs_read_text_file:`fs/read_text_file`,terminal_create:`terminal/create`,terminal_output:`terminal/output`,terminal_release:`terminal/release`,terminal_wait_for_exit:`terminal/wait_for_exit`,terminal_kill:`terminal/kill`,mcp_connect:`mcp/connect`,mcp_message:`mcp/message`,mcp_disconnect:`mcp/disconnect`,elicitation_create:`elicitation/create`,elicitation_complete:`elicitation/complete`},Xxe={cancel_request:`$/cancel_request`},oZ=Symbol(`skippedItem`);function $(e,t){return e.catch(t)}function sZ(e,t){let n=e.catch(t);return z().transform((e,t)=>e===void 0?(t.addIssue({code:`custom`,message:`Required value is missing`}),Dt):n.parse(e))}function cZ(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return;let n=e[t];return typeof n==`string`?n:void 0}function lZ(e,t,n){return e.superRefine((e,r)=>{let i=cZ(e,t);i!==void 0&&n.includes(i)&&r.addIssue({code:`custom`,path:[t],message:`${t} ${JSON.stringify(i)} is reserved by a known variant, but the value does not match that variant's schema`})})}function uZ(e,t,n){return z().transform((r,i)=>{let a=e.safeParse(r);if(!a.success){for(let e of a.error.issues)i.addIssue({...e,input:r});return Dt}let o=a.data,s=cZ(r,t);if(s!==void 0&&!n.includes(s)){let e=r;for(let[t,n]of Object.entries(e))t!==`__proto__`&&(Object.hasOwn(o,t)||(o[t]=n))}return o})}function dZ(e){return B(e.catch(oZ)).transform(e=>e.filter(e=>e!==oZ))}const fZ=$i([L(),I()]).nullable(),pZ=I(),mZ=V({sessionId:pZ,path:I(),content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),hZ=V({sessionId:pZ,path:I(),line:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),limit:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gZ=I(),_Z=$i([W(`read`),W(`edit`),W(`delete`),W(`move`),W(`search`),W(`execute`),W(`think`),W(`fetch`),W(`switch_mode`),W(`other`)]),vZ=$i([W(`pending`),W(`in_progress`),W(`completed`),W(`failed`)]),yZ=V({audience:$(dZ($i([W(`assistant`),W(`user`)])).nullish(),()=>void 0),lastModified:$(I().nullish(),()=>void 0),priority:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),Zxe=V({annotations:$(yZ.nullish(),()=>void 0),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),Qxe=V({annotations:$(yZ.nullish(),()=>void 0),data:I(),mimeType:I(),uri:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),$xe=V({annotations:$(yZ.nullish(),()=>void 0),data:I(),mimeType:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),eSe=V({annotations:$(yZ.nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),mimeType:$(I().nullish(),()=>void 0),name:I(),size:$(L().nullish(),()=>void 0),title:$(I().nullish(),()=>void 0),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),tSe=$i([V({mimeType:$(I().nullish(),()=>void 0),text:I(),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),V({blob:I(),mimeType:$(I().nullish(),()=>void 0),uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)})]),nSe=V({annotations:$(yZ.nullish(),()=>void 0),resource:tSe,_meta:$(H(I(),z()).nullish(),()=>void 0)}),bZ=$i([Zxe.and(V({type:W(`text`)})),Qxe.and(V({type:W(`image`)})),$xe.and(V({type:W(`audio`)})),eSe.and(V({type:W(`resource_link`)})),nSe.and(V({type:W(`resource`)}))]),rSe=V({content:bZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),iSe=V({path:I(),oldText:$(I().nullish(),()=>void 0),newText:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xZ=I(),aSe=V({terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),SZ=$i([rSe.and(V({type:W(`content`)})),iSe.and(V({type:W(`diff`)})),aSe.and(V({type:W(`terminal`)}))]),CZ=V({path:I(),line:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),wZ=V({toolCallId:gZ,kind:$(_Z.nullish(),()=>void 0),status:$(vZ.nullish(),()=>void 0),title:$(I().nullish(),()=>void 0),content:$(dZ(SZ).nullish(),()=>void 0),locations:$(dZ(CZ).nullish(),()=>void 0),rawInput:$(z().optional(),()=>void 0),rawOutput:$(z().optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TZ=I(),oSe=$i([W(`allow_once`),W(`allow_always`),W(`reject_once`),W(`reject_always`)]),EZ=V({sessionId:pZ,toolCall:wZ,options:B(V({optionId:TZ,name:I(),kind:oSe,_meta:$(H(I(),z()).nullish(),()=>void 0)})),_meta:$(H(I(),z()).nullish(),()=>void 0)}),DZ=V({name:I(),value:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OZ=V({sessionId:pZ,command:I(),args:$(dZ(I()).optional(),()=>[]),env:$(dZ(DZ).optional(),()=>[]),cwd:$(I().nullish(),()=>void 0),outputByteLimit:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),kZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),AZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),jZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),MZ=V({sessionId:pZ,terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NZ=V({sessionId:pZ,toolCallId:$(gZ.nullish(),()=>void 0)}),PZ=V({requestId:fZ}),sSe=W(`object`),cSe=$i([W(`email`),W(`uri`),W(`date`),W(`date-time`)]),FZ=V({const:I(),title:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),IZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minLength:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),maxLength:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),pattern:I().nullish(),format:cSe.nullish(),default:$(I().nullish(),()=>void 0),enum:B(I()).nullish(),oneOf:B(FZ).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),LZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minimum:L().nullish(),maximum:L().nullish(),default:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),RZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minimum:L().nullish(),maximum:L().nullish(),default:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),default:$(R().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),BZ=V({enum:B(I()),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lSe=V({anyOf:B(FZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),uSe=uZ($i([BZ.and(V({type:W(`string`)})),lZ(V({type:I()}),`type`,[`string`]),lSe]),`type`,[`string`]),VZ=V({title:$(I().nullish(),()=>void 0),description:$(I().nullish(),()=>void 0),minItems:L().nullish(),maxItems:L().nullish(),items:uSe,default:$(dZ(I()).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),dSe=uZ($i([IZ.and(V({type:W(`string`)})),LZ.and(V({type:W(`number`)})),RZ.and(V({type:W(`integer`)})),zZ.and(V({type:W(`boolean`)})),VZ.and(V({type:W(`array`)})),lZ(V({type:I()}),`type`,[`array`,`boolean`,`integer`,`number`,`string`])]),`type`,[`array`,`boolean`,`integer`,`number`,`string`]),fSe=V({type:$(sSe.optional().default(`object`),()=>`object`),title:$(I().nullish(),()=>void 0),properties:H(I(),dSe).optional().default({}),required:B(I()).nullish(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),HZ=ta($i([NZ,PZ]),V({requestedSchema:fSe})),UZ=I(),WZ=ta($i([NZ,PZ]),V({elicitationId:UZ,url:Wi()})),GZ=uZ(ta($i([HZ.and(V({mode:W(`form`)})),WZ.and(V({mode:W(`url`)})),lZ(ta($i([NZ,PZ]),V({mode:I()})),`mode`,[`form`,`url`])]),V({message:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)})),`mode`,[`form`,`url`]),KZ=I(),pSe=V({serverId:KZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),qZ=I(),JZ=V({connectionId:qZ,method:I(),params:H(I(),z()).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),mSe=V({connectionId:qZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),YZ=z();V({id:fZ,method:I(),params:$i([mZ,hZ,EZ,OZ,kZ,AZ,jZ,MZ,GZ,pSe,JZ,mSe,YZ]).nullish()});const XZ=Ki().gte(0).lte(65535),hSe=V({image:$(R().optional().default(!1),()=>!1),audio:$(R().optional().default(!1),()=>!1),embeddedContext:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gSe=V({http:$(R().optional().default(!1),()=>!1),sse:$(R().optional().default(!1),()=>!1),acp:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Se=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),vSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ySe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),bSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),xSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),SSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),CSe=V({list:$(_Se.nullish(),()=>void 0),delete:$(vSe.nullish(),()=>void 0),additionalDirectories:$(ySe.nullish(),()=>void 0),fork:$(bSe.nullish(),()=>void 0),resume:$(xSe.nullish(),()=>void 0),close:$(SSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),wSe=V({logout:$(V({_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ESe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),DSe=V({syncKind:$i([W(`full`),W(`incremental`)]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),kSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ASe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),jSe=V({document:$(V({didOpen:$(ESe.nullish(),()=>void 0),didChange:$(DSe.nullish(),()=>void 0),didClose:$(OSe.nullish(),()=>void 0),didSave:$(kSe.nullish(),()=>void 0),didFocus:$(ASe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),NSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),PSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FSe=V({maxCount:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ISe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),LSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),RSe=V({recentFiles:$(MSe.nullish(),()=>void 0),relatedSnippets:$(NSe.nullish(),()=>void 0),editHistory:$(PSe.nullish(),()=>void 0),userActions:$(FSe.nullish(),()=>void 0),openFiles:$(ISe.nullish(),()=>void 0),diagnostics:$(LSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zSe=V({events:$(jSe.nullish(),()=>void 0),context:$(RSe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZZ=$i([W(`utf-16`),W(`utf-32`),W(`utf-8`)]),BSe=V({loadSession:$(R().optional().default(!1),()=>!1),promptCapabilities:$(hSe.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:$(gSe.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:$(CSe.optional().default({}),()=>({})),auth:$(wSe.optional().default({}),()=>({})),providers:$(TSe.nullish(),()=>void 0),nes:$(zSe.nullish(),()=>void 0),positionEncoding:$(ZZ.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),QZ=I(),VSe=V({name:I(),label:$(I().nullish(),()=>void 0),secret:$(R().optional().default(!0),()=>!0),optional:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),HSe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),vars:sZ(dZ(VSe),()=>[]),link:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),USe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),args:$(dZ(I()).optional(),()=>[]),env:$(H(I(),I()).optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),WSe=V({id:QZ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),GSe=$i([HSe.and(V({type:W(`env_var`)})),USe.and(V({type:W(`terminal`)})),WSe]),$Z=V({name:I(),title:$(I().nullish(),()=>void 0),version:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),KSe=V({protocolVersion:XZ,agentCapabilities:$(BSe.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:$(dZ(GSe).optional().default([]),()=>[]),agentInfo:$($Z.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),qSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),eQ=I(),tQ=$i([W(`anthropic`),W(`openai`),W(`azure`),W(`vertex`),W(`bedrock`),I()]),JSe=V({apiType:tQ,baseUrl:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),YSe=V({providers:B(V({providerId:eQ,supported:sZ(dZ(tQ),()=>[]),required:R(),current:JSe.nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)})),_meta:$(H(I(),z()).nullish(),()=>void 0)}),XSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),QSe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),nQ=I(),rQ=V({currentModeId:nQ,availableModes:sZ(dZ(V({id:nQ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iQ=I(),$Se=$i([W(`mode`),W(`model`),W(`model_config`),W(`thought_level`),I()]),aQ=I(),oQ=V({value:aQ,name:I(),description:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),eCe=V({group:I(),name:I(),options:sZ(dZ(oQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),tCe=V({currentValue:aQ,options:$i([B(oQ),B(eCe)])}),nCe=V({currentValue:R()}),sQ=ta($i([tCe.and(V({type:W(`select`)})),nCe.and(V({type:W(`boolean`)}))]),V({id:iQ,name:I(),description:$(I().nullish(),()=>void 0),category:$($Se.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),rCe=V({sessionId:pZ,modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iCe=V({modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),aCe=V({sessions:sZ(dZ(V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),title:$(I().nullish(),()=>void 0),updatedAt:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),nextCursor:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),oCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),sCe=V({sessionId:pZ,modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),cCe=V({modes:$(rQ.nullish(),()=>void 0),configOptions:$(dZ(sQ).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),uCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dCe=V({configOptions:sZ(dZ(sQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),fCe=V({stopReason:$i([W(`end_turn`),W(`max_tokens`),W(`max_turn_requests`),W(`refusal`),W(`cancelled`)]),usage:$(V({totalTokens:L(),inputTokens:L(),outputTokens:L(),thoughtTokens:$(L().nullish(),()=>void 0),cachedReadTokens:$(L().nullish(),()=>void 0),cachedWriteTokens:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),pCe=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),cQ=I(),lQ=V({line:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),character:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),_meta:$(H(I(),z()).nullish(),()=>void 0)}),uQ=V({start:lQ,end:lQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),mCe=V({range:uQ,newText:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),hCe=V({id:cQ,uri:I(),edits:B(mCe),cursorPosition:$(lQ.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gCe=V({id:cQ,uri:I(),position:lQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Ce=V({id:cQ,uri:I(),position:lQ,newName:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),vCe=V({id:cQ,uri:I(),search:I(),replace:I(),isRegex:R().nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),yCe=V({suggestions:B($i([hCe.and(V({kind:W(`edit`)})),gCe.and(V({kind:W(`jump`)})),_Ce.and(V({kind:W(`rename`)})),vCe.and(V({kind:W(`searchAndReplace`)}))])),_meta:$(H(I(),z()).nullish(),()=>void 0)}),bCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dQ=z(),fQ=z(),pQ=V({code:$i([W(-32700),W(-32600),W(-32601),W(-32602),W(-32603),W(-32800),W(-32e3),W(-32002),Ki().min(-2147483648,{error:`Invalid value: Expected int32 to be >= -2147483648`}).max(2147483647,{error:`Invalid value: Expected int32 to be <= 2147483647`})]),message:I(),data:$(z().optional(),()=>void 0)});$i([V({id:fZ,result:$i([KSe,qSe,YSe,XSe,ZSe,QSe,rCe,iCe,aCe,oCe,sCe,cCe,lCe,uCe,dCe,fCe,pCe,yCe,bCe,dQ,fQ])}),V({id:fZ,error:pQ})]);const mQ=V({content:bZ,messageId:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xCe=V({toolCallId:gZ,title:I(),kind:$(_Z.optional(),()=>void 0),status:$(vZ.optional(),()=>void 0),content:$(dZ(SZ).optional(),()=>[]),locations:$(dZ(CZ).optional(),()=>[]),rawInput:$(z().optional(),()=>void 0),rawOutput:$(z().optional(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),SCe=$i([W(`high`),W(`medium`),W(`low`)]),CCe=$i([W(`pending`),W(`in_progress`),W(`completed`)]),hQ=V({content:I(),priority:SCe,status:CCe,_meta:$(H(I(),z()).nullish(),()=>void 0)}),wCe=V({entries:sZ(dZ(hQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gQ=I(),TCe=V({planId:gQ,entries:sZ(dZ(hQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ECe=V({planId:gQ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),DCe=V({planId:gQ,content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OCe=V({plan:$i([TCe.and(V({type:W(`items`)})),ECe.and(V({type:W(`file`)})),DCe.and(V({type:W(`markdown`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),kCe=V({planId:gQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),ACe=V({hint:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),jCe=V({availableCommands:sZ(dZ(V({name:I(),description:I(),input:$(ACe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)})),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MCe=V({currentModeId:nQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NCe=V({configOptions:sZ(dZ(sQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),PCe=V({title:$(I().nullish(),()=>void 0),updatedAt:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FCe=V({amount:L(),currency:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ICe=V({used:L(),size:L(),cost:$(FCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_Q=V({sessionId:pZ,update:$i([mQ.and(V({sessionUpdate:W(`user_message_chunk`)})),mQ.and(V({sessionUpdate:W(`agent_message_chunk`)})),mQ.and(V({sessionUpdate:W(`agent_thought_chunk`)})),xCe.and(V({sessionUpdate:W(`tool_call`)})),wZ.and(V({sessionUpdate:W(`tool_call_update`)})),wCe.and(V({sessionUpdate:W(`plan`)})),OCe.and(V({sessionUpdate:W(`plan_update`)})),kCe.and(V({sessionUpdate:W(`plan_removed`)})),jCe.and(V({sessionUpdate:W(`available_commands_update`)})),MCe.and(V({sessionUpdate:W(`current_mode_update`)})),NCe.and(V({sessionUpdate:W(`config_option_update`)})),PCe.and(V({sessionUpdate:W(`session_info_update`)})),ICe.and(V({sessionUpdate:W(`usage_update`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),vQ=V({elicitationId:UZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),yQ=V({connectionId:qZ,method:I(),params:$(H(I(),z()).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),bQ=z();V({method:I(),params:$i([_Q,vQ,yQ,bQ]).nullish()});const LCe=V({readTextFile:$(R().optional().default(!1),()=>!1),writeTextFile:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),RCe=V({configOptions:$(V({boolean:$(V({_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),BCe=V({terminal:$(R().optional().default(!1),()=>!1),_meta:$(H(I(),z()).nullish(),()=>void 0)}),VCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),HCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),UCe=V({form:$(VCe.nullish(),()=>void 0),url:$(HCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),WCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),GCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),KCe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),qCe=V({jump:$(WCe.nullish(),()=>void 0),rename:$(GCe.nullish(),()=>void 0),searchAndReplace:$(KCe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xQ=V({protocolVersion:XZ,clientCapabilities:$(V({fs:$(LCe.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:$(R().optional().default(!1),()=>!1),session:$(RCe.nullish(),()=>void 0),plan:$(zCe.nullish(),()=>void 0),auth:$(BCe.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:$(UCe.nullish(),()=>void 0),nes:$(qCe.nullish(),()=>void 0),positionEncodings:$(dZ(ZZ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}).optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:$($Z.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),SQ=V({methodId:QZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),CQ=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),wQ=V({providerId:eQ,apiType:tQ,baseUrl:I(),headers:H(I(),I()).optional(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),TQ=V({providerId:eQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),EQ=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),DQ=V({name:I(),value:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),JCe=V({name:I(),url:I(),headers:B(DQ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),YCe=V({name:I(),url:I(),headers:B(DQ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),XCe=V({name:I(),serverId:KZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),ZCe=V({name:I(),command:I(),args:B(I()),env:B(DZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),OQ=$i([JCe.and(V({type:W(`http`)})),YCe.and(V({type:W(`sse`)})),XCe.and(V({type:W(`acp`)})),ZCe]),kQ=V({cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:sZ(dZ(OQ),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),AQ=V({mcpServers:sZ(dZ(OQ),()=>[]),cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),jQ=V({cwd:I().nullish(),cursor:I().nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),MQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),NQ=V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:$(dZ(OQ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),PQ=V({sessionId:pZ,cwd:I(),additionalDirectories:$(dZ(I()).optional(),()=>[]),mcpServers:$(dZ(OQ).optional(),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),FQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),IQ=V({sessionId:pZ,modeId:nQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),LQ=ta($i([V({value:R(),type:W(`boolean`)}),V({value:aQ})]),V({sessionId:pZ,configId:iQ,_meta:$(H(I(),z()).nullish(),()=>void 0)})),RQ=V({sessionId:pZ,prompt:B(bZ),_meta:$(H(I(),z()).nullish(),()=>void 0)}),QCe=V({uri:I(),name:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),$Ce=V({name:I(),owner:I(),remoteUrl:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),zQ=V({workspaceUri:$(I().nullish(),()=>void 0),workspaceFolders:B(QCe).nullish(),repository:$($Ce.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ewe=$i([W(`automatic`),W(`diagnostic`),W(`manual`)]),twe=V({uri:I(),languageId:I(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),nwe=V({startLine:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),endLine:Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),rwe=V({uri:I(),excerpts:B(nwe),_meta:$(H(I(),z()).nullish(),()=>void 0)}),iwe=V({uri:I(),diff:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),awe=V({action:I(),uri:I(),position:lQ,timestampMs:L(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),owe=V({uri:I(),languageId:I(),visibleRange:$(uQ.nullish(),()=>void 0),lastFocusedMs:$(L().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),swe=$i([W(`error`),W(`warning`),W(`information`),W(`hint`)]),cwe=V({uri:I(),range:uQ,severity:swe,message:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),lwe=V({recentFiles:B(twe).nullish(),relatedSnippets:B(rwe).nullish(),editHistory:B(iwe).nullish(),userActions:B(awe).nullish(),openFiles:B(owe).nullish(),diagnostics:B(cwe).nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),BQ=V({sessionId:pZ,uri:I(),version:L(),position:lQ,selection:uQ.nullish(),triggerKind:ewe,context:lwe.nullish(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),VQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)});V({id:fZ,method:I(),params:$i([xQ,SQ,CQ,wQ,TQ,EQ,kQ,AQ,jQ,MQ,NQ,PQ,FQ,IQ,LQ,RQ,zQ,BQ,VQ,JZ,YZ]).nullish()});const uwe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),dwe=V({content:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),fwe=V({optionId:TZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),pwe=V({outcome:$i([V({outcome:W(`cancelled`)}),fwe.and(V({outcome:W(`selected`)}))]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),mwe=V({terminalId:xZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),hwe=V({exitCode:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),signal:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),gwe=V({output:I(),truncated:R(),exitStatus:$(hwe.nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),_we=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),vwe=V({exitCode:$(Ki().gte(0).max(4294967295,{error:`Invalid value: Expected uint32 to be <= 4294967295`}).nullish(),()=>void 0),signal:$(I().nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)}),ywe=V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),bwe=$i([I(),L(),L(),R(),B(I())]),HQ=V({content:H(I(),bwe).nullish()});$i([V({id:fZ,result:$i([uwe,dwe,pwe,mwe,gwe,_we,vwe,ywe,uZ(ta($i([HQ.and(V({action:W(`accept`)})),V({action:W(`decline`)}),V({action:W(`cancel`)}),lZ(V({action:I()}),`action`,[`accept`,`cancel`,`decline`])]),V({_meta:$(H(I(),z()).nullish(),()=>void 0)})),`action`,[`accept`,`cancel`,`decline`]),V({connectionId:qZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),V({_meta:$(H(I(),z()).nullish(),()=>void 0)}),fQ,dQ])}),V({id:fZ,error:pQ})]);const UQ=V({sessionId:pZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),WQ=V({sessionId:pZ,uri:I(),languageId:I(),version:L(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),xwe=V({range:uQ.nullish(),text:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),GQ=V({sessionId:pZ,uri:I(),version:L(),contentChanges:sZ(dZ(xwe),()=>[]),_meta:$(H(I(),z()).nullish(),()=>void 0)}),KQ=V({sessionId:pZ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),qQ=V({sessionId:pZ,uri:I(),_meta:$(H(I(),z()).nullish(),()=>void 0)}),JQ=V({sessionId:pZ,uri:I(),version:L(),position:lQ,visibleRange:uQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),YQ=V({sessionId:pZ,id:cQ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),XQ=V({sessionId:pZ,id:cQ,reason:$($i([W(`rejected`),W(`ignored`),W(`replaced`),W(`cancelled`)]).nullish(),()=>void 0),_meta:$(H(I(),z()).nullish(),()=>void 0)});V({method:I(),params:$i([UQ,WQ,GQ,KQ,qQ,JQ,YQ,XQ,yQ,bQ]).nullish()}),V({requestId:fZ,_meta:$(H(I(),z()).nullish(),()=>void 0)}),HZ.and(V({mode:W(`form`)})).and(V({message:I()})),WZ.and(V({mode:W(`url`)})).and(V({message:I()})),$i([NZ,PZ]).and(V({message:I()})),IZ.and(V({type:W(`string`)})),LZ.and(V({type:W(`number`)})),RZ.and(V({type:W(`integer`)})),zZ.and(V({type:W(`boolean`)})),VZ.and(V({type:W(`array`)})),BZ.and(V({type:W(`string`)})),HQ.and(V({action:W(`accept`)})),V({action:W(`decline`)}),V({action:W(`cancel`)});function ZQ(e){return e??{}}iZ.initialize,iZ.authenticate,iZ.logout,iZ.providers_list,iZ.providers_set,iZ.providers_disable,iZ.session_new,iZ.session_load,iZ.session_list,iZ.session_delete,iZ.session_fork,iZ.session_resume,iZ.session_close,iZ.session_set_mode,iZ.session_set_config_option,iZ.session_prompt,iZ.session_cancel,iZ.nes_start,iZ.nes_suggest,iZ.nes_accept,iZ.nes_reject,iZ.nes_close,iZ.document_did_open,iZ.document_did_change,iZ.document_did_close,iZ.document_did_save,iZ.document_did_focus,aZ.session_request_permission,aZ.session_update,aZ.fs_write_text_file,aZ.fs_read_text_file,aZ.terminal_create,aZ.terminal_output,aZ.terminal_release,aZ.terminal_wait_for_exit,aZ.terminal_kill,aZ.elicitation_create,aZ.elicitation_complete,Xxe.cancel_request;function QQ(e,t,n){return{method:e,params:t,mapResponse:n}}function $Q(e,t){return{method:e,params:t}}function e$(e){let t={};for(let n of Object.values(e))t[n.method]=n;return t}const Swe={initialize:QQ(iZ.initialize,xQ),newSession:QQ(iZ.session_new,kQ),loadSession:QQ(iZ.session_load,AQ,ZQ),unstable_forkSession:QQ(iZ.session_fork,NQ),listSessions:QQ(iZ.session_list,jQ),deleteSession:QQ(iZ.session_delete,MQ,ZQ),resumeSession:QQ(iZ.session_resume,PQ),closeSession:QQ(iZ.session_close,FQ,ZQ),setSessionMode:QQ(iZ.session_set_mode,IQ,ZQ),setSessionConfigOption:QQ(iZ.session_set_config_option,LQ),authenticate:QQ(iZ.authenticate,SQ,ZQ),unstable_listProviders:QQ(iZ.providers_list,CQ),unstable_setProvider:QQ(iZ.providers_set,wQ,ZQ),unstable_disableProvider:QQ(iZ.providers_disable,TQ,ZQ),logout:QQ(iZ.logout,EQ,ZQ),prompt:QQ(iZ.session_prompt,RQ),unstable_startNes:QQ(iZ.nes_start,zQ),unstable_suggestNes:QQ(iZ.nes_suggest,BQ),unstable_closeNes:QQ(iZ.nes_close,VQ,ZQ)},Cwe={cancel:$Q(iZ.session_cancel,UQ),unstable_didOpenDocument:$Q(iZ.document_did_open,WQ),unstable_didChangeDocument:$Q(iZ.document_did_change,GQ),unstable_didCloseDocument:$Q(iZ.document_did_close,KQ),unstable_didSaveDocument:$Q(iZ.document_did_save,qQ),unstable_didFocusDocument:$Q(iZ.document_did_focus,JQ),unstable_acceptNes:$Q(iZ.nes_accept,YQ),unstable_rejectNes:$Q(iZ.nes_reject,XQ)},wwe={requestPermission:QQ(aZ.session_request_permission,EZ),writeTextFile:QQ(aZ.fs_write_text_file,mZ,ZQ),readTextFile:QQ(aZ.fs_read_text_file,hZ),createTerminal:QQ(aZ.terminal_create,OZ),terminalOutput:QQ(aZ.terminal_output,kZ),releaseTerminal:QQ(aZ.terminal_release,AZ,ZQ),waitForTerminalExit:QQ(aZ.terminal_wait_for_exit,jZ),killTerminal:QQ(aZ.terminal_kill,MZ,ZQ),unstable_createElicitation:QQ(aZ.elicitation_create,GZ)},Twe={sessionUpdate:$Q(aZ.session_update,_Q),unstable_completeElicitation:$Q(aZ.elicitation_complete,vQ)};e$(Swe),e$(Cwe),e$(wwe),e$(Twe),iZ.initialize,iZ.authenticate,iZ.providers_list,iZ.providers_set,iZ.providers_disable,iZ.session_new,iZ.session_load,iZ.session_set_mode,iZ.session_set_config_option,iZ.session_prompt,iZ.session_list,iZ.session_delete,iZ.session_fork,iZ.session_resume,iZ.session_close,iZ.logout,iZ.nes_start,iZ.nes_suggest,iZ.nes_close,iZ.session_cancel,iZ.nes_accept,iZ.nes_reject,iZ.document_did_open,iZ.document_did_change,iZ.document_did_close,iZ.document_did_save,iZ.document_did_focus,aZ.session_request_permission,aZ.fs_write_text_file,aZ.fs_read_text_file,aZ.terminal_create,aZ.terminal_output,aZ.terminal_release,aZ.terminal_wait_for_exit,aZ.terminal_kill,aZ.elicitation_create,aZ.session_update,aZ.elicitation_complete;var Ewe=i(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),t$=i(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=Ewe(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Dwe=i(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=t$()(e);let{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),Owe=i(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),kwe=i(((e,n)=>{let r=t(`os`),i=t(`tty`),a=Owe(),{env:o}=process,s;a(`no-color`)||a(`no-colors`)||a(`color=false`)||a(`color=never`)?s=0:(a(`color`)||a(`colors`)||a(`color=true`)||a(`color=always`))&&(s=1),`FORCE_COLOR`in o&&(s=o.FORCE_COLOR===`true`?1:o.FORCE_COLOR===`false`?0:o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function c(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(s===0)return 0;if(a(`color=16m`)||a(`color=full`)||a(`color=truecolor`))return 3;if(a(`color=256`))return 2;if(e&&!t&&s===void 0)return 0;let n=s||0;if(o.TERM===`dumb`)return n;if(process.platform===`win32`){let e=r.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in o)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in o)||o.CI_NAME===`codeship`?1:n;if(`TEAMCITY_VERSION`in o)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION);if(o.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in o){let e=parseInt((o.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(o.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||`COLORTERM`in o?1:n}function u(e){return c(l(e,e&&e.isTTY))}n.exports={supportsColor:u,stdout:c(l(!0,i.isatty(1))),stderr:c(l(!0,i.isatty(2)))}})),Awe=i(((e,n)=>{let r=t(`tty`),i=t(`util`);e.init=d,e.log=c,e.formatArgs=o,e.save=l,e.load=u,e.useColors=a,e.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=kwe();t&&(t.stderr||t).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function a(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(e){let{namespace:t,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${t} \u001B[0m`;e[0]=a+e[0].split(`
|
|
723
723
|
`).join(`
|
|
724
724
|
`+a),e.push(i+`m+`+n.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=s()+t+` `+e[0]}function s(){return e.inspectOpts.hideDate?``:new Date().toISOString()+` `}function c(...t){return process.stderr.write(i.formatWithOptions(e.inspectOpts,...t)+`
|
|
725
725
|
`)}function l(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function u(){return process.env.DEBUG}function d(t){t.inspectOpts={};let n=Object.keys(e.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=e.inspectOpts[n[r]]}n.exports=t$()(e);let{formatters:f}=n.exports;f.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split(`
|
|
@@ -1114,7 +1114,7 @@ caused by: `+i(o,t)):a},a=e=>i(e,new Set),o=(e,t,i)=>{if(!n(e))return``;let a=i?
|
|
|
1114
1114
|
`),process.exit(2));let s=new Set(n),c={roots:[{uri:t.pathToFileURL(i).href,name:`chat files`}]},l=e.spawn(a,o,{cwd:r,stdio:[`pipe`,`pipe`,`inherit`],windowsHide:!0}),u=l.stdin,d=l.stdout;(u===null||d===null)&&(process.stderr.write(`ok-browser relay: the browser server has no pipes
|
|
1115
1115
|
`),process.exit(1));let f=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null,p=e=>{u.write(`${JSON.stringify(e)}\n`)},m=e=>{process.stdout.write(`${JSON.stringify(e)}\n`)},h=(e,t)=>{process.stderr.write(`ok-browser relay: dropped a ${e} line that ${t}\n`)},g=(e,t,n)=>{if(e.trim()===``)return null;let r;try{r=JSON.parse(e)}catch{return h(t,`is not JSON`),null}let i=f(r);if(i!==null)return i;if(Array.isArray(r))for(let e of r){let t=f(e);t?.method!==void 0&&t.id!==void 0&&n({jsonrpc:`2.0`,id:t.id,error:{code:-32600,message:`Batched messages are not supported`}})}return h(t,`is not a single JSON-RPC message`),null},_=e=>{let t=g(e,`client`,m);if(t===null||t.method===`notifications/roots/list_changed`)return null;let n=f(t.params),r=n?.name;return t.method===`tools/call`&&(typeof r!=`string`||!s.has(r))?(t.id!==void 0&&m({jsonrpc:`2.0`,id:t.id,error:{code:-32602,message:`Tool ${String(r)} is not available`}}),null):(t.method===`initialize`&&n!==null&&(n.capabilities={...f(n.capabilities),roots:{listChanged:!1}}),JSON.stringify(t))},v=e=>{let t=g(e,`server`,p);if(t===null)return null;if(t.method===`roots/list`)return t.id!==void 0&&p({jsonrpc:`2.0`,id:t.id,result:c}),null;let n=f(t.result),r=n?.tools;if(n===null||!Array.isArray(r))return e;let i=r.filter(e=>{let t=f(e)?.name;return typeof t==`string`&&s.has(t)});for(let e of i){let t=f(f(e)?.annotations);t!==null&&(t.readOnlyHint=!1)}return n.tools=i,JSON.stringify(t)},y=(e,t,n,r)=>{let i=``,a=e=>{let r=n(e);r!==null&&t.write(`${r}\n`)};e.setEncoding(`utf8`),e.on(`data`,e=>{i+=String(e);let t=i.indexOf(`
|
|
1116
1116
|
`);for(;t!==-1;)a(i.slice(0,t)),i=i.slice(t+1),t=i.indexOf(`
|
|
1117
|
-
`)}),e.on(`end`,()=>{i!==``&&a(i),r&&t.end()})};u.on(`error`,()=>{}),y(process.stdin,u,_,!0),y(d,process.stdout,v,!1);for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])process.on(e,()=>l.kill());l.on(`error`,e=>{process.stderr.write(`${e.message}\n`),process.exit(1)}),l.on(`close`,e=>{process.exitCode=e??1,process.stdin.destroy()})}const G8=V({name:I(),version:I().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/)});$i([B(G8),H(I(),G8).transform(e=>Object.values(e))]).pipe(ire([G8])),`${cje.toString()}${JSON.stringify([`browser_click`,`browser_close`,`browser_console_messages`,`browser_drag`,`browser_drop`,`browser_emulate_media`,`browser_evaluate`,`browser_file_upload`,`browser_fill_form`,`browser_find`,`browser_handle_dialog`,`browser_hover`,`browser_navigate`,`browser_navigate_back`,`browser_network_request`,`browser_network_requests`,`browser_press_key`,`browser_resize`,`browser_select_option`,`browser_snapshot`,`browser_tabs`,`browser_take_screenshot`,`browser_type`,`browser_wait_for`])}`,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`),Fe(x),QX(`agent-registry-apply`),QX(`local-op-security`),new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),Od.cursor,Od.codex,Od[`claude-desktop`],t8(()=>{}),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})}),QX(`external-change-attribution`),QX(`mermaid-validator`),QX(`rename-log`),QX(`history`);function K8(e){return St.filter(t=>g(j(e,t.hostDir)))}function q8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}q8(_t,bS),[...q8(vt,bS)].sort((e,t)=>{let n=b4.indexOf(e.editor),r=b4.indexOf(t.editor);return(n===-1?b4.length:n)-(r===-1?b4.length:r)||e.editor.localeCompare(t.editor)}),QX(`installed-skills-marker`),QX(`skill-import`),QX(`backlinks`),QX(`local-target-inventory`),QX(`tag-index`),EP(),QX(`derived-document-index`);const J8={start:L().int().nonnegative().optional(),end:L().int().nonnegative().optional(),quote:I().min(1).optional(),prefix:I().max(1e3).optional(),suffix:I().max(1e3).optional()};V({docName:I().min(1),...J8,propertyKey:I().min(1).optional(),propertyPath:B($i([I(),L().int().nonnegative()])).optional(),body:I(),queue:R().optional(),summary:I().optional()});const Y8=Hi();ea(`action`,[V({action:W(`edit`),id:Y8,body:I(),summary:I().optional()}),V({action:W(`resolve`),id:Y8,summary:I().optional()}),V({action:W(`reopen`),id:Y8,summary:I().optional()}),V({action:W(`replace`),id:Y8,...J8,summary:I().optional()}),V({action:W(`queue`),id:Y8,summary:I().optional()}),V({action:W(`unqueue`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-prepare`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-complete`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-prepare-batch`),ids:B(Y8).min(1).max(200),summary:I().optional()}),V({action:W(`dispatch-complete-batch`),ids:B(Y8).min(1).max(200),summary:I().optional()})]),QX(`embeddings`),QX(`embeddings`);function lje(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}lje(Nl),QX(`embeddings`),QX(`embeddings`);const uje=/^[A-Za-z0-9-]{8,64}$/;let X8=null;function dje(e){return j(e??_e(),`.ok`,`machine-id`)}function fje(e){if(e===void 0&&X8!==null)return X8;let t=dje(e),n=null;try{let e=S(t,`utf-8`).trim();uje.test(e)&&(n=e)}catch{}if(n===null){n=Ne();try{v(k(t),{recursive:!0}),re(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){QX(`machine-id`).warn({path:t,err:e},`Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(X8=n),n}QX(`process-lock`);function pje(e,t){return N(e,`${t}.lock`)}function mje(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function hje(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=mje(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}QX(`asset-references`),QX(`file-ops`),QX(`upload-streaming`);const Z8=`Absolute OK project/worktree path. Routed stdio: required until set unless one client root exists. Project-bound HTTP: optional, confined to its root.`,Q8=`Canonical ids: ${Fye().map(e=>e.name).join(`, `)}. Call palette({components:[ids]}) before authoring for syntax/props, markdown-native forms, Mermaid and themed html preview for interactive charts/demos. Other JSX stays raw MDX when no canonical fits.`;I().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),I().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),I().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),I().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),I().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const gje=V({value:I(),truncatedFrom:L().optional(),hint:I().optional()}).describe(`Normalized change-note summary, when one was recorded.`),_je=B(H(I(),z()));H(I(),z()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),B(Qd).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves UNLESS `brokenLinkSuppression` is also present, in which case a project policy withheld findings, or `warnings` carries `link-check-deferred`, in which case the links were not checked because the server is still starting or busy with other writes. A withholding that arrives in a shape this build cannot validate is dropped rather than relayed, so `brokenLinkSuppression` stays absent even though findings were withheld. The `audit` tool is the surface that discloses that case, through its `warnings`. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" | "excluded" }`. `excluded` means the file exists on disk but a .gitignore or .okignore rule keeps it out of the project; a `!` rule in .okignore re-includes it or its folder. Report-only — the write landed regardless; fix in a follow-up edit.'),ef.optional().describe('Present ONLY when a project policy omitted detected broken links from `brokenLinks` — so an empty `brokenLinks` beside it does NOT mean every link resolves. `{ reason, count }`; `reason` today is `"reserved-log-policy"` (a reserved `log.md` records history whose links are expected not to resolve) and is an open token, so treat one you do not recognize as a withholding policy all the same. `count` is how many findings were withheld; the hrefs are deliberately not returned, because none of them is yours to repair.'),gje.optional(),B(Xd).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit. `link-check-deferred` means links were not checked because the server is still starting or busy with other writes — that doc is re-checked only by a later write or edit of it, or an `audit`, which can time out until startup finishes."),B(V({name:I(),description:I().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const vje=I().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function $8(e){return{text:vje,...e}}function yje(e){return`Machine-readable codes aligned 1:1 with \`warnings\` (\`warnings[i]\` is the display text for \`warningCodes[i]\`) — switch on these, never on the English. Absent when ${e} sent warning text it did not pair with codes, or paired one with a code this build does not recognise; \`warnings\` still carries the full text either way, so treat a missing field as unknown rather than as an all-clear.`}yje(`the server`);function bje(e){return`Always emitted, \`[]\` when there were none. \`warningCodes\` accompanies this list 1:1 whenever ${e} paired every warning it sent with a code this build recognises; otherwise \`warningCodes\` is absent and this list still carries the full text. \`content[0].text\` lists every warning either way. A \`warnings\` payload in a shape this build cannot read at all becomes one entry saying so, with \`warningCodes\` absent — \`[]\` never means "unreadable".`}bje(`the server`),QX(`git-checkout`),QX(`git-worktree-status`),QX(`managed-artifact-persistence`),QX(`timeline`),QX(`suggest-links`),QX(`git-context`),QX(`clone-flow`),Fe(o),B8.project,Object.fromEntries(Object.entries(xS).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
|
|
1117
|
+
`)}),e.on(`end`,()=>{i!==``&&a(i),r&&t.end()})};u.on(`error`,()=>{}),y(process.stdin,u,_,!0),y(d,process.stdout,v,!1);for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])process.on(e,()=>l.kill());l.on(`error`,e=>{process.stderr.write(`${e.message}\n`),process.exit(1)}),l.on(`close`,e=>{process.exitCode=e??1,process.stdin.destroy()})}const G8=V({name:I(),version:I().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/)});$i([B(G8),H(I(),G8).transform(e=>Object.values(e))]).pipe(ire([G8])),`${cje.toString()}${JSON.stringify([`browser_click`,`browser_close`,`browser_console_messages`,`browser_drag`,`browser_drop`,`browser_emulate_media`,`browser_evaluate`,`browser_file_upload`,`browser_fill_form`,`browser_find`,`browser_handle_dialog`,`browser_hover`,`browser_navigate`,`browser_navigate_back`,`browser_network_request`,`browser_network_requests`,`browser_press_key`,`browser_resize`,`browser_select_option`,`browser_snapshot`,`browser_tabs`,`browser_take_screenshot`,`browser_type`,`browser_wait_for`])}`,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`),Fe(x),QX(`agent-registry-apply`),QX(`local-op-security`),new class{capacity;store;writeIndex=0;filled=!1;constructor(e){if(!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer, got ${e}`);this.capacity=e,this.store=Array(e)}push(e){this.store[this.writeIndex]=e,this.writeIndex=(this.writeIndex+1)%this.capacity,this.writeIndex===0&&(this.filled=!0)}read(){let e=[],t=this.filled?this.capacity:this.writeIndex;for(let n=1;n<=t;n++){let t=(this.writeIndex-n+this.capacity)%this.capacity,r=this.store[t];r!==void 0&&e.push(r)}return e}get size(){return this.filled?this.capacity:this.writeIndex}}(256),Od.cursor,Od.codex,Od[`claude-desktop`],t8(()=>{}),Object.freeze({source:`local`,skipStoreHooks:!0,context:Object.freeze({origin:`effect-capture`,paired:!1})}),QX(`external-change-attribution`),QX(`mermaid-validator`),QX(`rename-log`),QX(`history`);function K8(e){return St.filter(t=>g(j(e,t.hostDir)))}function q8(e,t){return[...Object.entries(e).filter(e=>e[1]!==null).map(([e,t])=>({editor:e,root:t})),{editor:`agents`,root:t}]}q8(_t,bS),[...q8(vt,bS)].sort((e,t)=>{let n=b4.indexOf(e.editor),r=b4.indexOf(t.editor);return(n===-1?b4.length:n)-(r===-1?b4.length:r)||e.editor.localeCompare(t.editor)}),QX(`installed-skills-marker`),QX(`skill-import`),QX(`backlinks`),QX(`local-target-inventory`),QX(`tag-index`),EP(),QX(`derived-document-index`);const J8={start:L().int().nonnegative().optional(),end:L().int().nonnegative().optional(),quote:I().min(1).optional(),prefix:I().max(1e3).optional(),suffix:I().max(1e3).optional()};V({docName:I().min(1),...J8,propertyKey:I().min(1).optional(),propertyPath:B($i([I(),L().int().nonnegative()])).optional(),body:I(),queue:R().optional(),summary:I().optional()});const Y8=Hi();ea(`action`,[V({action:W(`edit`),id:Y8,body:I(),summary:I().optional()}),V({action:W(`resolve`),id:Y8,summary:I().optional()}),V({action:W(`reopen`),id:Y8,summary:I().optional()}),V({action:W(`replace`),id:Y8,...J8,summary:I().optional()}),V({action:W(`queue`),id:Y8,summary:I().optional()}),V({action:W(`unqueue`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-prepare`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-complete`),id:Y8,summary:I().optional()}),V({action:W(`dispatch-prepare-batch`),ids:B(Y8).min(1).max(200),summary:I().optional()}),V({action:W(`dispatch-complete-batch`),ids:B(Y8).min(1).max(200),summary:I().optional()})]),QX(`embeddings`),QX(`embeddings`);function lje(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return`${t.protocol}//${t.host.toLowerCase()}${n}`}catch{return e.trim().replace(/\/+$/,``)}}lje(Nl),QX(`embeddings`),QX(`embeddings`);const uje=/^[A-Za-z0-9-]{8,64}$/;let X8=null;function dje(e){return j(e??_e(),`.ok`,`machine-id`)}function fje(e){if(e===void 0&&X8!==null)return X8;let t=dje(e),n=null;try{let e=S(t,`utf-8`).trim();uje.test(e)&&(n=e)}catch{}if(n===null){n=Ee();try{v(k(t),{recursive:!0}),re(t,`${n}\n`,{encoding:`utf-8`,mode:384})}catch(e){QX(`machine-id`).warn({path:t,err:e},`Failed to persist ${t} — using an ephemeral per-process id; lock ownership checks will fail closed (collision) instead of recognizing this machine: ${e instanceof Error?e.message:String(e)}`)}}return e===void 0&&(X8=n),n}QX(`process-lock`);function pje(e,t){return N(e,`${t}.lock`)}function mje(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname;return n===`localhost`||n===`[::1]`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n)?t.origin:null}function hje(e,t){if(typeof e.url==`string`&&e.url.length>0){let t=mje(e.url);if(t!==null)return t}if(e.port>0){let n=t?.fallbackHost??`localhost`;return`http://${n===`0.0.0.0`||n===`::`?`localhost`:n.includes(`:`)&&!n.startsWith(`[`)?`[${n}]`:n}:${e.port}`}return null}QX(`asset-references`),QX(`file-ops`),QX(`upload-streaming`);const Z8=`Absolute OK project/worktree path. Routed stdio: required until set unless one client root exists. Project-bound HTTP: optional, confined to its root.`,Q8=`Canonical ids: ${Fye().map(e=>e.name).join(`, `)}. Call palette({components:[ids]}) before authoring for syntax/props, markdown-native forms, Mermaid and themed html preview for interactive charts/demos. Other JSX stays raw MDX when no canonical fits.`;I().max(200).optional().describe(`Optional one-line user-outcome description (≤80 chars). Appears as a bullet in the timeline.`),I().length(40).regex(/^[0-9a-f]+$/i).describe("A 40-character commit SHA identifying a saved version. Produced by `checkpoint`, listed by `history` as `entries[].version`, and consumed here — the same `version` field name across all three."),I().nullable().describe("Route-only preview URL (`/#/<doc>`, no host:port), or null when no UI is running."),I().optional().describe(`How the previewUrl was resolved (e.g. the UI lock).`),I().optional().describe(`Route of the prior/removed path, for closing a stale preview tab.`);const gje=V({value:I(),truncatedFrom:L().optional(),hint:I().optional()}).describe(`Normalized change-note summary, when one was recorded.`),_je=B(H(I(),z()));H(I(),z()).optional().describe("Preview-attach hint (`{ action, previewUrl?, message? }`) when relevant."),B(Qd).describe('Outbound internal links in the just-written doc that do not resolve. Always present — `[]` means every link resolves UNLESS `brokenLinkSuppression` is also present, in which case a project policy withheld findings, or `warnings` carries `link-check-deferred`, in which case the links were not checked because the server is still starting or busy with other writes. A withholding that arrives in a shape this build cannot validate is dropped rather than relayed, so `brokenLinkSuppression` stays absent even though findings were withheld. The `audit` tool is the surface that discloses that case, through its `warnings`. Each: `{ href (as written), resolvedTo (the docName or content-root file path it pointed at, or null), reason: "no-such-doc" | "no-such-file" | "unresolvable" | "excluded" }`. `excluded` means the file exists on disk but a .gitignore or .okignore rule keeps it out of the project; a `!` rule in .okignore re-includes it or its folder. Report-only — the write landed regardless; fix in a follow-up edit.'),ef.optional().describe('Present ONLY when a project policy omitted detected broken links from `brokenLinks` — so an empty `brokenLinks` beside it does NOT mean every link resolves. `{ reason, count }`; `reason` today is `"reserved-log-policy"` (a reserved `log.md` records history whose links are expected not to resolve) and is an open token, so treat one you do not recognize as a withholding policy all the same. `count` is how many findings were withheld; the hrefs are deliberately not returned, because none of them is yours to repair.'),gje.optional(),B(Xd).min(1).optional().describe("Advisory entries discriminated by `kind`. Write-integrity kinds — `content-divergence` (converged Y.Text didn't byte-match what you composed) and `disk-edit-reconciled` (an out-of-band disk edit was folded in before your write) — mean re-read the doc. The renderability kind `mermaid-parse-error` means the write landed but that fence will not render — fix it and re-edit. `link-check-deferred` means links were not checked because the server is still starting or busy with other writes — that doc is re-checked only by a later write or edit of it, or an `audit`, which can time out until startup finishes."),B(V({name:I(),description:I().optional()})).min(1).optional().describe("Templates the parent folder offers, present only when a create passed no `template`. A nudge — the write already landed; pass `template` next time to match the folder's shape.");const vje=I().optional().describe("Auto-duplicated body text. `textPlusStructured` mirrors the visible body here as a Claude / Claude Desktop client-quirk workaround (those clients hide `content[]` when `structuredContent` is present). Internal — programmatic consumers should prefer the `content[0].text` channel.");function $8(e){return{text:vje,...e}}function yje(e){return`Machine-readable codes aligned 1:1 with \`warnings\` (\`warnings[i]\` is the display text for \`warningCodes[i]\`) — switch on these, never on the English. Absent when ${e} sent warning text it did not pair with codes, or paired one with a code this build does not recognise; \`warnings\` still carries the full text either way, so treat a missing field as unknown rather than as an all-clear.`}yje(`the server`);function bje(e){return`Always emitted, \`[]\` when there were none. \`warningCodes\` accompanies this list 1:1 whenever ${e} paired every warning it sent with a code this build recognises; otherwise \`warningCodes\` is absent and this list still carries the full text. \`content[0].text\` lists every warning either way. A \`warnings\` payload in a shape this build cannot read at all becomes one entry saying so, with \`warningCodes\` absent — \`[]\` never means "unreadable".`}bje(`the server`),QX(`git-checkout`),QX(`git-worktree-status`),QX(`managed-artifact-persistence`),QX(`timeline`),QX(`suggest-links`),QX(`git-context`),QX(`clone-flow`),Fe(o),B8.project,Object.fromEntries(Object.entries(xS).map(([e,t])=>[t,e])),[`These are patterns to adapt to your domain, not a layout to copy verbatim.`,"To build a variant: create your own folders (via `write` or your editor) and reuse only the ideas that fit.","To adopt this pack as-is: re-run without `--dry-run`."].join(`
|
|
1118
1118
|
`),QX(`skills-leaderboard`),QX(`handoff-dispatch`),V({target:U(Object.keys({"claude-cowork":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},"claude-code":{type:`app-bundle`,appName:`Claude`,urlScheme:`claude:`,probeScheme:`claude`,quitFirst:!1},codex:{type:`app-bundle`,appName:`Codex`,urlScheme:`codex:`,probeScheme:`codex`,quitFirst:!0},cursor:{type:`cli-binary`,binaryName:`cursor`,urlScheme:`cursor:`}})),url:I().min(1).max(4096),workspacePath:I().optional()}),V({}).loose(),QX(`github-permissions`),QX(`github-reference`),QX(`github-reference`),QX(`link-preview.guarded-fetch`),QX(`link-preview.cache`),QX(`saved-themes`),V({enabled:R(),active:R(),git:V({state:U([`not-applicable`,`ready`,`missing`,`conflict`,`unavailable`]),ownership:U([`open-knowledge`,`existing`]).optional()}),applied:R().optional(),reason:U([`git-conflict`,`git-unavailable`,`config-write`]).optional()}),V({enabled:R()}).strict(),QX(`managed-rename`),Object.assign(fOe,{m4v:`video/mp4`,mkv:`video/x-matroska`,flac:`audio/flac`,toml:`application/toml`,lock:`text/plain`,"7z":`application/x-7z-compressed`,tar:`application/x-tar`,rar:`application/vnd.rar`,xls:`application/vnd.ms-excel`,ppt:`application/vnd.ms-powerpoint`,odt:`application/vnd.oasis.opendocument.text`,ods:`application/vnd.oasis.opendocument.spreadsheet`,odp:`application/vnd.oasis.opendocument.presentation`,pages:`application/vnd.apple.pages`,numbers:`application/vnd.apple.numbers`,key:`application/vnd.apple.keynote`,mobi:`application/x-mobipocket-ebook`}),QX(`search`),QX(`skill-install`),QX(`write-advisory`),QX(`api`),V({principalId:I().optional(),tabSessionId:I().optional(),expectedServerInstanceId:I().optional(),expectedBranch:I().optional(),expectedDocLineageEpoch:I().optional(),clientProtocolVersion:L().optional(),clientRuntimeVersion:I().optional(),clientKind:I().optional()}).loose(),new He,t8(()=>{}),[...Aae],["Read-only validation of markdownlint, frontmatter, OKF and broken internal links. Requires the Hocuspocus server. No args scans all in-scope .md/.mdx; `path` narrows to file/folder. `links` is the navigation/graph tool.","ran names selected `markdownlint`, `frontmatter`, `okf`, `links`. A family absent from `ran` was not checked. A selected family remains in ran if degraded; warnings explain why and it may still have contributed findings. okf covers document and project-tree OKF checks here.",`Broken links are reported under the source doc. Default-on validation.suppressLogLinkAdvisories omits links inside lowercase log.md/log.mdx at any depth; LOG.md is ordinary. brokenLinkSuppression reports reason reserved-log-policy and count without paths/hrefs. Logs are append-only history: never rewrite old entries to clear links. links({kind:'dead'}) reads raw state.`,`Diagnostics carry source, code, message, 0-based LSP range (link columns approximate) and severity. Broken links default to warning; validation.links can raise/hide them. Only problematic files are listed; fileCount/errorCount/warningCount reflect full scan. Output is capped at 10 files × 10 diagnostics each and project-wide at 10 warnings; omittedWarningCount reports dropped warnings. Narrow path reduces competing files; per-file caps still apply. Follow runtime hints for document lint and raw dead links; project-tree OKF findings remain capped.`,`Nothing is modified. Auto-fix document lint with lint({document,fix:true}); fix broken links with edit/write.`].join(`
|
|
1119
1119
|
`),[`Save a project-wide checkpoint of every document. Requires the Hocuspocus server. Optional summary ≤80 chars defaults to "Checkpoint version"; avoid secrets or PII because it persists in git history. Returns version (40-char SHA). Find it with history and restore one doc with restore_version({document,version}).`].join(`
|
|
1120
1120
|
`),[`Read effective config merged defaults → user → project; no running OK server needed. Optional key is a dotted path (content, appearance.theme); omit for the full config. All fields are readable. Re-read after disk changes or before relying on an old value.`,"Removed server.*, mcp.*, github.*, preview.baseUrl and preview.scriptSrc return exists:false; appearance.preview.autoOpen remains live. This is a pure read. Use `install` skillFolders for folder topology."].join(`
|
|
@@ -1524,11 +1524,11 @@ export default function okBridge(pi: {
|
|
|
1524
1524
|
`).replace(/\n/g,`\r
|
|
1525
1525
|
`));let _=`${s?``:``}${m}`;return _!==o&&VJ(e,_,{mode:N5(e)}),a&&_===o?{kind:`unchanged`}:{kind:d?`overwritten`:`written`}}const TMe=`A dev build registers OpenKnowledge MCP in project config only, never in user-level editor config. Run \`${ht} init --dev-mcp\` in the project, or set OK_CHANNEL=stable.`,EMe=`open-knowledge-ui`;function H5(e,t,n){try{let r=e.detectPath?.(t,n)??k(e.configPath(t,n));return g(r)}catch{return!1}}function U5(e,t,n){try{let r=N(k(e.configPath(t,n))),i=N(e.detectPath?.(t,n)??r);return i===r||r.startsWith(i+le)}catch{return!1}}function W5(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=n.pruneOnly===!0;if(s&&(e.format===`file`||!g(o)))return{editorId:e.id,label:e.label,action:`skipped-flag`,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}};let c=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0||U5(e,t,r);if(!i&&c&&!H5(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{d5(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return OMe(e,o,a,n,{isProjectScope:i!==void 0});let l;try{l=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{s||v(k(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let u={action:`written`},d;try{UJ(`${o}.lock`,()=>{let t=y5(o).writePath;if(s||v(k(t),{recursive:!0}),e.format===`toml`){let r=xMe(_Y(),t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}if(e.format===`yaml`){let r=wMe(t,e.topLevelKey,a,l,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason);return}let r=bMe(t,e.topLevelKey,a,l,e.serverMapSubKey,n.replaceEntry===!0,n.pruneOnly===!0);u.action=r.kind,r.kind===`declined`&&(u.declineReason=r.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){d=e instanceof Error?e:Error(String(e))}return d?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:d.message,...i===void 0?{}:{configScope:`project`}}:u.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:u.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:u.action===`unchanged`?`skipped-flag`:u.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const DMe={pi:l5};function OMe(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=DMe[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{v(k(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{UJ(`${t}.lock`,()=>{let e=null;try{e=S(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}VJ(t,c,e===null?void 0:{mode:N5(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}async function kMe(e){let t=exe(e.editors).filter(e=>e.scope===`global`);if(ut())return t.map(t=>({editorId:t.id,label:t.label,action:`failed`,configPath:t.configPath(``,e.home),serverName:t.serverName(``),error:TMe}));let n={mode:`published`,skipAvailabilityCheck:!0,...e.replaceEntry===!0?{replaceEntry:!0}:{},...e.pruneOnly===!0?{pruneOnly:!0}:{}};return t.map(t=>W5(t,``,n,e.home))}function G5(e,t,n,r){let i=q5(e,t,n,r);return i.kind===`present`?i.entry:null}function K5(e,t,n,r){let i=V5(e,t,r);if(!dY(i))return{kind:`no-entry`};let a=i[n];return dY(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function q5(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!g(i))return{kind:`absent`};try{if(te(i).size>L5)return{kind:`decline`,reason:`oversize`}}catch(e){return{kind:`decline`,reason:A5(e)}}let a;try{a=S(i,`utf-8`)}catch(e){return{kind:`decline`,reason:A5(e)}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Wje(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=_Y().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return K5(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,xs.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:K5(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=P5(a);return s?F5(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:K5(L4(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}function AMe(e,t){let n=[];for(let r of vY)r!==`claude-desktop`&&H5($Y[r],e,t)&&n.push(r);return n}function J5(e){return e===`opencode`?Ube:Hbe}function jMe(e,t,n){let r=$Y[e],i=J5(e),a=[],o=r.projectConfigPath?.(t);o!==void 0&&a.push({scope:`project`,configPath:o});try{a.push({scope:`user`,configPath:r.configPath(t,n)})}catch{}for(let o of a){let a=G5(r,t,n,o.configPath);if(a!==null&&i(a))return{editorId:e,scope:o.scope,configPath:o.configPath}}return null}const Y5=8192;function X5(e,t){if(e.outcome===`not-present`)return`not-present (no DiagnosticReports directory)`;if(e.outcome===`unreadable-directory`)return`unreadable (${e.directoryErrorCode??`unknown`} reading DiagnosticReports)`;let n=[`${e.windowDays}d`,`${e.foreignIgnored} other-process report(s) ignored`,`${e.unparseable} unparseable`];e.droppedOverCap>0&&n.push(`${e.droppedOverCap} older dropped over cap`);let r=e.files.length-t;return r>0&&n.push(`${r} vanished before staging`),e.outcome===`none-in-window`?`none found in window (${n.join(`; `)})`:`${t} collected (${n.join(`; `)})`}function MMe(e){return e.replace(/\\+\/?/g,e=>{if(!e.endsWith(`/`))return e;let t=e.length-1;return`${`\\`.repeat(t-t%2)}/`})}const NMe=RegExp(`("(?:${[`crashReporterKey`,`bootSessionUUID`,`deviceIdentifierForVendor`].join(`|`)})"\\s*:\\s*)"[^"]*"`,`g`);function PMe(e){return e.replace(NMe,`$1"[REDACTED-DEVICE-ID]"`)}function Z5(e){return PMe(MMe(e))}const FMe=/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(\.\d+)? ([+-]\d{2})(\d{2})$/;function Q5(e){if(typeof e!=`string`)return null;let t=FMe.exec(e.trim());if(t===null)return null;let[,n,r,i=``,a,o]=t,s=Date.parse(`${n}T${r}${i}${a}:${o}`);return Number.isNaN(s)?null:s}function IMe(e){let t=b(e,`r`);try{let e=Buffer.alloc(Y5),n=0,r=!1;for(;n<Y5;){let i=C(t,e,n,Y5-n,n);if(i===0){r=!0;break}let a=n;n+=i;let o=e.subarray(0,n).indexOf(10,a);if(o!==-1)return e.subarray(0,o).toString(`utf-8`)}return r?e.subarray(0,n).toString(`utf-8`):null}finally{f(t)}}function LMe(e){try{let t=IMe(e);if(t===null)return{kind:`unreadable`};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{kind:`unreadable`};let{name:r,app_name:i,timestamp:a}=n,o=typeof r==`string`?r:typeof i==`string`?i:null;return o===null?{kind:`unreadable`}:{kind:`named`,name:o,timestampMs:Q5(a)}}catch{return{kind:`unreadable`}}}function $5(e){return e===`OpenKnowledge`||e.startsWith(`OpenKnowledge `)}function RMe(e,t){let n={files:[],foreignIgnored:0,unparseable:0,droppedOverCap:0,windowDays:7},r;try{r=w(e,{withFileTypes:!0})}catch(e){let t=e.code;return t===`ENOENT`?{...n,outcome:`not-present`}:{...n,outcome:`unreadable-directory`,directoryErrorCode:t??`unknown`}}let i=t.getTime()-6048e5,a=[],o=0,s=0;for(let t of r){if(!t.isFile()||!t.name.endsWith(`.ips`))continue;let n=j(e,t.name),r;try{r=te(n).mtimeMs}catch{continue}if(r<i)continue;let c=LMe(n),l=c.kind===`named`&&c.timestampMs!==null?c.timestampMs:r;if(c.kind===`unreadable`){s+=1;continue}if(!$5(c.name)){o+=1;continue}a.push({path:n,atMs:l})}a.sort((e,t)=>t.atMs-e.atMs);let c=a.slice(0,25),l={foreignIgnored:o,unparseable:s,droppedOverCap:a.length-c.length,windowDays:7};return c.length===0?{...l,files:[],outcome:`none-in-window`}:{...l,files:c.map(e=>e.path),outcome:`collected`}}const e7=`state/os-termination-evidence.json`,t7=6048e5,n7=`/Library/Logs/DiagnosticReports`,r7=/openknowledge/i,zMe=it.map(e=>at(rt[e]));function BMe(e={}){return(t,n)=>new Promise(r=>{try{o(t,n,{encoding:`utf8`,timeout:e.timeoutMs??15e3,maxBuffer:e.maxBuffer??16777216,windowsHide:!0},(e,t,n)=>{r({...VMe(e),stdout:t,stderr:n})})}catch(e){let t=e.code;r({status:null,stdout:``,stderr:``,errorCode:typeof t==`string`?t:`spawn-failed`})}})}function VMe(e){return e===null?{status:0}:typeof e.code==`string`?{status:null,errorCode:e.code}:typeof e.code==`number`?{status:e.code}:e.killed===!0?{status:null,errorCode:`ETIMEDOUT`}:e.signal?{status:null,signal:e.signal}:{status:null}}function i7(e){if(e.errorCode!==void 0)return e.errorCode;if(e.signal!==void 0)return`signal ${e.signal}`;let t=(e.stderr.trim().split(`
|
|
1526
1526
|
`)[0]??``).replace(/\S*\/journal\/\S*/g,`<journal path>`).replace(/\b[0-9a-f]{32}\b/gi,`<id>`);return`exit ${e.status}${t===``?``:`: ${t}`}`}function a7(e,t,n){return{schemaVersion:1,platform:e,source:t,outcome:`none-in-window`,readFrom:n,windowDays:7,foreignIgnored:0,unparseable:0,droppedOverCap:0,events:[]}}function o7(e,t){return{...e,outcome:`unavailable`,unavailableReason:t}}function s7(e){return{...e,outcome:e.events.length>0?`collected`:`none-in-window`}}function c7(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function l7(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function u7(e,t){let n=t.indexOf(`
|
|
1527
|
-
`);if(n===-1)return null;let r,i;try{r=l7(JSON.parse(t.slice(0,n))),i=l7(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=l7(e);t===null||typeof t.name!=`string`||!$5(t.name)||a.push({name:t.name,pid:c7(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:c7(t.rpages),lifetimeMaxPages:c7(t.lifetimeMax)})}let o=Q5(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:c7(l7(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?$5(i.largestProcess):null,ownedProcesses:a}}const d7=/^JetsamEvent-.*\.ips$/;function f7(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function HMe(e,t){let n=a7(`darwin`,`macos-jetsam`,[j(e,`JetsamEvent-*.ips`)]),r;try{r=await
|
|
1527
|
+
`);if(n===-1)return null;let r,i;try{r=l7(JSON.parse(t.slice(0,n))),i=l7(JSON.parse(t.slice(n+1)))}catch{return null}if(r===null||i===null||!Array.isArray(i.processes))return null;let a=[];for(let e of i.processes){let t=l7(e);t===null||typeof t.name!=`string`||!$5(t.name)||a.push({name:t.name,pid:c7(t.pid),killReason:typeof t.reason==`string`?t.reason:null,residentPages:c7(t.rpages),lifetimeMaxPages:c7(t.lifetimeMax)})}let o=Q5(r.timestamp);return{kind:`jetsam`,at:o===null?null:new Date(o).toISOString(),file:e,pageSize:c7(l7(i.memoryStatus)?.pageSize),largestProcessOwned:typeof i.largestProcess==`string`?$5(i.largestProcess):null,ownedProcesses:a}}const d7=/^JetsamEvent-.*\.ips$/;function f7(e,t,n,r){let i=e.flatMap(({file:e,mtimeMs:n})=>n!==null&&n>=t?[{file:e,mtimeMs:n}]:[]);return i.sort((e,t)=>r===`newest-first`?t.mtimeMs-e.mtimeMs:e.mtimeMs-t.mtimeMs),{files:i.slice(0,n).map(({file:e})=>e),statFailed:e.filter(({mtimeMs:e})=>e===null).length,droppedOverCap:Math.max(0,i.length-n)}}async function HMe(e,t){let n=a7(`darwin`,`macos-jetsam`,[j(e,`JetsamEvent-*.ips`)]),r;try{r=await ke(e)}catch(e){return o7(n,e.code??`unknown`)}let i=f7(await Promise.all(r.filter(e=>d7.test(e)).map(async t=>{try{return{file:t,mtimeMs:(await Me(j(e,t))).mtimeMs}}catch{return{file:t,mtimeMs:null}}})),t.getTime()-t7,50,`newest-first`);n.unparseable+=i.statFailed,n.droppedOverCap=i.droppedOverCap;for(let t of i.files){let r=null;try{r=u7(t,await Oe(j(e,t),`utf8`))}catch{}r===null?n.unparseable+=1:r.ownedProcesses.length===0?n.foreignIgnored+=1:n.events.push(r)}return s7(n)}const UMe=new Set([`vm-pageshortage`,`vm-compressor-thrashing`,`vm-pageout-starvation`,`low-swap`,`sustained-memory-pressure`]);function WMe(e,t=n7){let n;try{n=w(t)}catch(e){return{outcome:`unavailable`,unavailableReason:e.code??`unknown`}}let r=e.fromMs-1e3,i=null,a=n.filter(e=>d7.test(e)).map(e=>{try{return{file:e,mtimeMs:te(j(t,e)).mtimeMs}}catch(t){return i??=t.code??`unknown`,{file:e,mtimeMs:null}}}),o=f7(a,r,5,`oldest-first`),s=0,c=o.statFailed,l=0,u=null;for(let n of o.files){let i;try{i=S(j(t,n),`utf8`)}catch(e){c+=1,u??=e.code??`unknown`;continue}s+=1;let a=u7(n,i);if(a===null){l+=1;continue}let o=a.at===null?null:Date.parse(a.at);if(o!==null&&(o<r||o>e.toMs))continue;let d=a.ownedProcesses.find(t=>t.pid===e.pid&&t.killReason!==null);if(d!==void 0&&d.killReason!==null)return{outcome:`killed`,source:`macos-jetsam`,at:a.at,killReason:d.killReason,victimChosenByPriority:UMe.has(d.killReason),largestProcessOwned:a.largestProcessOwned,residentBytes:d.residentPages===null||a.pageSize===null?null:d.residentPages*a.pageSize,reportsRead:s}}if(i!==null&&o.statFailed===a.length)return{outcome:`unavailable`,unavailableReason:i};if(s===0&&u!==null)return{outcome:`unavailable`,unavailableReason:u};let d=o.droppedOverCap;return c===0&&l===0&&d===0?{outcome:`not-killed`,reportsRead:s,unreadable:0,unparseable:0,skippedNewerOverCap:0}:{outcome:`inconclusive`,reportsRead:s,unreadable:c,unparseable:l,skippedNewerOverCap:d}}const p7=[`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Out of memory|oom-kill|Killed process|Killed /|memory pressure`,`_TRANSPORT=kernel`,`+`,`_SYSTEMD_UNIT=systemd-oomd.service`],m7=[`--user`,`--no-pager`,`--output=short-iso-precise`,`--since=-7d`,`--grep=Fatal Wayland communication error|Wayland protocol error|X IO error|Missing X server`],h7=/^(\S+) \S+ ([^:\s[]+)(?:\[\d+\])?: (.*)$/,GMe=/\[(\d+)(?::\d+)?:\d{4}\/\d{6}\.\d+:[A-Z0-9]+:[^\]]*\]\s*(.*)$/,KMe=/^desktop\.\d{4}-\d{2}-\d{2}\.log$/;async function qMe(e,t){let n=new Set,r;try{r=await ke(e)}catch{return{pids:n,unreadable:!0}}let i=!1;for(let a of r){if(!KMe.test(a))continue;let r=j(e,a);try{if(t.getTime()-(await Me(r)).mtimeMs>t7)continue;for(let e of(await Oe(r,`utf8`)).split(`
|
|
1528
1528
|
`)){if(!e.includes(`"event":"desktop.boot"`))continue;let t=/"pid":(\d+)/.exec(e)?.[1];t!==void 0&&n.add(Number(t))}}catch{i=!0}}return{pids:n,unreadable:i}}function JMe(e,t){if(e===`systemd-oomd`){let e=/^Killed (\S+)/.exec(t);if(e===null)return null;let n=e[1]?.split(`/`).pop()??``;return{origin:`systemd-oomd`,action:`oomd-kill`,pid:null,processName:null,unit:r7.test(n)?n:null,trigger:/swap used/.test(t)?`swap`:/memory pressure/.test(t)?`memory-pressure`:null}}if(e!==`kernel`)return null;let n=/Killed process (\d+) \(([^)]+)\)/.exec(t);if(n!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(n[1]),processName:n[2]??null,unit:null,trigger:null};let r=/task=([^,]+),pid=(\d+)/.exec(t);if(r!==null)return{origin:`kernel`,action:`oom-kill`,pid:Number(r[2]),processName:r[1]??null,unit:null,trigger:null};let i=/^(\S+) invoked oom-killer/.exec(t);return i===null?null:{origin:`kernel`,action:`oom-invoked`,pid:null,processName:i[1]??null,unit:null,trigger:null}}function YMe(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
1529
1529
|
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=h7.exec(i);if(e===null){r+=1;continue}let[,a=``,o=``,s=``]=e;if(!r7.test(s)){n+=1;continue}let c=JMe(o,s);if(c===null){r+=1;continue}t.push({kind:`journal`,at:a,...c})}return{events:t,foreignIgnored:n,unparseable:r}}function XMe(e){let t=[],n=0,r=0;for(let i of e.split(`
|
|
1530
|
-
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=h7.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=GMe.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function ZMe(e,t,n){let r=XMe(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await qMe(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function g7(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function QMe(e,t,n){let r=a7(`linux`,`linux-journal`,[`journalctl ${p7.join(` `)}`,`journalctl ${m7.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...p7]),e(`journalctl`,[...m7])]),o=[];if(g7(i)){let e=YMe(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${i7(i)}`);if(g7(a)){let e=await ZMe(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${i7(a)}`);return o.length===2?o7(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:s7(r)}const $Me={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},eNe={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function _7(e){return e===`System`?$Me:eNe}function tNe(e){let t=`System[(${Object.keys(_7(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${t7}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${zMe.map(e=>`Data='${e}'`).join(` or `)}]]`}function v7(e){return[`qe`,e,`/q:${tNe(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function nNe(e){return ue.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function rNe(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function iNe(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function y7(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>rNe(e[1]??``).trim())}function aNe(e,t){let n=_7(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=y7(o,`Data`),u=y7(o,`Name`),d=[...l,...u].some(e=>r7.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!iNe(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function oNe(e,t){let n=nNe(t),r=[`System`,`Application`],i=a7(`win32`,`windows-event-log`,r.map(e=>`${n} ${v7(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,v7(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${i7(t)}`);continue}let n=aNe(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?o7(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:s7(i)}async function b7(e={}){let t=e.platform??process.platform,n=e.runCommand??BMe(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return HMe(e.macosReportsDir??n7,r);case`linux`:return QMe(n,r,e.desktopLogsDir??j(RJ(),`logs`));case`win32`:return oNe(n,e.systemRoot??process.env.SystemRoot);default:return{...a7(t,null,[]),outcome:`unsupported`}}}const sNe={schemaVersion:1,outcome:`not-collected`};function x7(e){return`${JSON.stringify(e??sNe,null,2)}\n`}const cNe=rt.stable.appId;function S7(){return j(RJ(),`bug-reports`)}function lNe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=S7(),r=`${t}-bugreport`,i=j(n,`${r}.zip`);for(let e=2;g(i);e+=1)i=j(n,`${r}-${e}.zip`);return i}function C7(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function w7(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let e=S(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 g(j(e,`.ok`))?Me(`sha256`).update(N(e)).digest(`hex`).slice(0,12):null}function uNe(){let e={timestamp:new Date().toISOString(),platform:ye(),osType:Ce(),osRelease:be(),hostname:`[redacted]`,uptime:we(),freeMem:ge(),totalMem:Se(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=c(`sw_vers -productVersion 2>/dev/null`,c8({encoding:`utf8`})).trim()}catch{}try{let t=j(__dirname,`..`,`..`,`package.json`);g(t)&&(e.okVersion=JSON.parse(S(t,`utf8`)).version)}catch{}return e}const dNe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function T7(e){let t=ae(e);return dNe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function fNe(e,t){return O7(e,t).files}const pNe=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function E7(e,t=cNe){let n=j(e,`${t}.ShipIt`);if(!g(n))return[];let r;try{r=w(n)}catch{return[]}return pNe.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>j(n,e.entry)))}function D7(e){if(!g(e))return[];try{let t=new Map;for(let n of w(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-10):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>j(e,t))}catch{return[]}}function O7(e,t){if(!g(t))return{files:[],excludedByProjectSlug:0};let n=w(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>j(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(T7),i=[],a=r.filter(t=>{try{return S(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=>!T7(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function mNe(e){let t=j(e,`.ok`,`local`);return g(t)?{files:[`server.lock`,`last-spawn-error.log`,sd,ad].map(e=>j(t,e)).filter(e=>g(e))}:{files:[]}}function hNe(e){let t=j(e,`.ok`,`local`,`logs`);return g(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>j(t,e)).filter(e=>g(e))}:{files:[]}}function gNe(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Me(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function k7(e){let t=e.revealDocNames?e.content:gNe(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=BP(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function A7(e){for(let t of e.files)try{let n=S(t,`utf8`);k7({zipfile:e.zipfile,name:`${e.prefix}/${ae(t)}`,content:t.endsWith(`.ips`)?Z5(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function _Ne(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??j(RJ(),`logs`),s=t.projectDir?w7(t.projectDir,i):null;v(k(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=uNe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=O7(s,o),{files:d}=t.projectDir?mNe(t.projectDir):{files:[]},{files:f}=t.projectDir?hNe(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let g=[],_=[],{ZipFile:y}=await Promise.resolve().then(()=>e(v4(),1)),b=new y;A7({zipfile:b,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:t.bugReportLedgerFiles??[],prefix:TJ,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i});for(let e of t.extraFiles??[])try{let t=S(e.sourcePath),n=`extra/${e.zipName??ae(e.sourcePath)}`;b.addBuffer(t,n),_.push(n);let r=C7(e,n);r!==null&&g.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&k7({zipfile:b,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:_,redactions:g});let x=new Set(m.map(e=>`diagnostic-reports/${ae(e)}`)),C=_.filter(e=>x.has(e)),w=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:X5(t.diagnosticReports,C.length);b.addBuffer(Buffer.from(`${w}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`),k7({zipfile:b,name:e7,content:x7(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:_,redactions:g});let T=JSON.stringify(c,null,2);b.addBuffer(Buffer.from(T,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let E={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:_,redactions:g,sysinfo:c};b.addBuffer(Buffer.from(JSON.stringify(E,null,2),`utf8`),`MANIFEST.json`);let D=g.reduce((e,t)=>e+t.lineCount,0),O=new Set(p.map(e=>`logs/${ae(e)}`)),ee=_.filter(e=>O.has(e)),te=new Set((t.bugReportLedgerFiles??[]).map(e=>`${TJ}/${ae(e)}`)),ne=_.filter(e=>te.has(e)),re=s?_.filter(e=>e.startsWith(`logs/`)&&!T7(e)&&!O.has(e)):[],ie=C.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],oe=ie.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...ie]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${E.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${E.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...re.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:`,...re.map(e=>`- ${e}`),``]:[],...ee.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:`,...ee.map(e=>`- ${e}`),``]:[],...C.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...C.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system's own logs, covering`,`the last 7 days, to explain an exit the app could not record itself. On`,`macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${e7}`,``]:[],...ne.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...ne.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${zP.join(`, `)}`,D>0?`${D} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...ie,``,`This bundle is safe to attach to a GitHub issue.`]:oe].join(`
|
|
1531
|
-
`);b.addBuffer(Buffer.from(A,`utf8`),`README.md`),b.end();let se=h(r);return b.outputStream.pipe(se),await new Promise((e,t)=>{se.on(`close`,e),se.on(`error`,t)}),i?.info({bundlePath:r,fileCount:_.length,redactionCount:D},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:_,redactions:g,redactedLineCount:D,generatedAt:E.generatedAt}}}function j7(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function M7(e){return Me(`sha256`).update(e).digest(`hex`)}function N7(e){return j(RJ(N(e)),`pi-trust`)}function P7(e,t){return j(N7(e),M7(N(t)))}function F7(e,t,n){return j(P7(e,t),`${M7(n)}.json`)}var I7=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${j7(e)} ${j7(t)}; ${j7(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function L7(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new I7(e,`could not ${t}: ${i}`,a,n)}function R7(e){let t;try{t=_(e)}catch(t){if(t.code===`ENOENT`)return!1;throw L7(e,`be inspected`,t)}if(!t.isDirectory())throw new I7(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function z7(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function B7(e,t){if(!dY(e)||!z7(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==N(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==N(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==N(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!dY(e.previous))throw new I7(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&z7(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&z7(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new I7(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function V7(e,t,n){let r;try{r=_(n)}catch(e){throw L7(n,`be inspected`,e)}if(!r.isFile())throw new I7(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=S(n,`utf8`)}catch(e){throw L7(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new I7(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=B7(a,n);if(o.cwd!==N(t)||n!==F7(e,t,o.canonicalTrustPath))throw new I7(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function H7(e,t){let{record:n,path:r}=t;for(let t of[N7(e),P7(e,n.cwd)])if(!R7(t))throw new I7(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=V7(e,n.cwd,r);if(!Pe(i.record,n))throw new I7(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function vNe(e,t,n,r,i){let a={version:1,cwd:N(t),configuredTrustPath:N(n),canonicalTrustPath:N(r),state:`pending`,previous:i},o=F7(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Pe(B7(JSON.parse(s),o),a))throw new I7(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);R7(N7(e)),R7(k(o));try{v(k(o),{recursive:!0,mode:448})}catch(e){throw L7(k(o),`be created`,e)}let c;try{c=_(o,{throwIfNoEntry:!1})}catch(e){throw L7(o,`be inspected`,e)}if(c)throw new I7(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{VJ(o,s,{mode:384})}catch(e){throw L7(o,`be written`,e)}return{path:o,record:a}}function yNe(e,t){let n=H7(e,t);if(n.record.state!==`pending`)throw new I7(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{VJ(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw L7(n.path,`be committed`,e)}return{path:n.path,record:r}}function U7(e,t){if(!R7(N7(e)))return[];let n=P7(e,t);if(!R7(n))return[];let r;try{r=w(n).sort()}catch(e){throw L7(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>V7(e,t,j(n,r)))}function W7(e,t){let n=H7(e,t);try{ne(n.path)}catch(e){throw L7(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),N7(e)])try{ee(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw L7(t,`be removed after reconciling its grant`,e)}}var bNe=i(((e,n)=>{var r=t(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),xNe=i(((e,n)=>{var r=t(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),SNe=i(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),G7=i(((e,n)=>{var r=t(`fs`),i=bNe(),a=xNe(),o=SNe(),s=t(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
1530
|
+
`)){if(i.trim()===``||i.startsWith(`-- `))continue;let e=h7.exec(i);if(e===null){r+=1;continue}let[,a=``,,o=``]=e,s=GMe.exec(o);if(s===null){n+=1;continue}t.push({at:a,pid:Number(s[1]),detail:(s[2]??``).slice(0,200)})}return{lines:t,foreignIgnored:n,unparseable:r}}async function ZMe(e,t,n){let r=XMe(e);if(r.lines.length===0)return{...r,events:[],unattributed:null};let i=await qMe(t,n),a=[],o=0;for(let e of r.lines){if(!i.pids.has(e.pid)){o+=1;continue}a.push({kind:`journal`,at:e.at,origin:`chromium`,action:`display-connection-lost`,pid:e.pid,processName:null,unit:null,trigger:/Wayland/.test(e.detail)?`wayland`:`x11`,detail:e.detail})}let s=i.pids.size>0&&!i.unreadable;if(o>0&&!s){let e=i.unreadable?`desktop logs unreadable`:`no desktop.boot pid in desktop logs`;return{events:a,foreignIgnored:r.foreignIgnored,unparseable:r.unparseable,unattributed:`${o} Chromium display line(s) not attributed, ${e}`}}return{events:a,foreignIgnored:r.foreignIgnored+o,unparseable:r.unparseable,unattributed:null}}function g7(e){return e.status===0||e.status===1&&/^-- No entries --$/m.test(e.stdout)}async function QMe(e,t,n){let r=a7(`linux`,`linux-journal`,[`journalctl ${p7.join(` `)}`,`journalctl ${m7.join(` `)}`]),[i,a]=await Promise.all([e(`journalctl`,[...p7]),e(`journalctl`,[...m7])]),o=[];if(g7(i)){let e=YMe(i.stdout);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,/not seeing messages from other users/i.test(`${i.stdout}\n${i.stderr}`)&&(r.restrictedToCurrentUser=!0)}else o.push(`system journal: ${i7(i)}`);if(g7(a)){let e=await ZMe(a.stdout,n,t);r.droppedOverCap+=Math.max(0,e.events.length-50),r.events.push(...e.events.slice(-50)),r.foreignIgnored+=e.foreignIgnored,r.unparseable+=e.unparseable,e.unattributed!==null&&o.push(`user journal: ${e.unattributed}`)}else o.push(`user journal: ${i7(a)}`);return o.length===2?o7(r,o.join(`; `)):o.length===1?{...r,outcome:`partial`,unavailableReason:o.join(`; `)}:s7(r)}const $Me={41:`Microsoft-Windows-Kernel-Power`,1074:`User32`,2004:`Microsoft-Windows-Resource-Exhaustion-Detector`,6008:`EventLog`},eNe={1e3:`Application Error`,1001:`Windows Error Reporting`,1002:`Application Hang`};function _7(e){return e===`System`?$Me:eNe}function tNe(e){let t=`System[(${Object.keys(_7(e)).map(e=>`EventID=${e}`).join(` or `)}) and TimeCreated[timediff(@SystemTime) <= ${t7}]]`;return e===`System`?`*[${t}]`:`*[${t} and EventData[${zMe.map(e=>`Data='${e}'`).join(` or `)}]]`}function v7(e){return[`qe`,e,`/q:${tNe(e)}`,`/f:xml`,`/rd:true`,`/c:200`]}function nNe(e){return ue.join(e??`C:\\Windows`,`System32`,`wevtutil.exe`)}function rNe(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/&/g,`&`)}function iNe(e){return/[\\/]/.test(e)||/^[a-z]:/i.test(e)}function y7(e,t){let n=RegExp(`<${t}(?:\\s[^>]*)?>([\\s\\S]*?)</${t}>`,`g`);return[...e.matchAll(n)].map(e=>rNe(e[1]??``).trim())}function aNe(e,t){let n=_7(e),r=[],i=0,a=0;for(let o of t.match(/<Event[\s>][\s\S]*?<\/Event>/g)??[]){let t=/<Provider\s+Name=['"]([^'"]+)['"]/.exec(o)?.[1],s=Number(/<EventID[^>]*>(\d+)<\/EventID>/.exec(o)?.[1]),c=/<TimeCreated\s+SystemTime=['"]([^'"]+)['"]/.exec(o)?.[1];if(t===void 0||!Number.isInteger(s)||c===void 0){a+=1;continue}if(n[s]!==t){i+=1;continue}let l=y7(o,`Data`),u=y7(o,`Name`),d=[...l,...u].some(e=>r7.test(e));if(e===`Application`&&!d){i+=1;continue}r.push({kind:`windows-event`,at:c,log:e,provider:t,eventId:s,mentionsOpenKnowledge:d,data:e===`Application`?l.filter(e=>e!==``&&!iNe(e)):[]})}return{events:r,foreignIgnored:i,unparseable:a}}async function oNe(e,t){let n=nNe(t),r=[`System`,`Application`],i=a7(`win32`,`windows-event-log`,r.map(e=>`${n} ${v7(e).join(` `)}`)),a=await Promise.all(r.map(async t=>({log:t,result:await e(n,v7(t))}))),o=[];for(let{log:e,result:t}of a){if(t.status!==0){o.push(`${e}: ${i7(t)}`);continue}let n=aNe(e,t.stdout);i.droppedOverCap+=Math.max(0,n.events.length-50),i.events.push(...n.events.slice(0,50)),i.foreignIgnored+=n.foreignIgnored,i.unparseable+=n.unparseable}return o.length===r.length?o7(i,o.join(`; `)):o.length>0?{...i,outcome:`partial`,unavailableReason:o.join(`; `)}:s7(i)}async function b7(e={}){let t=e.platform??process.platform,n=e.runCommand??BMe(),r=(e.now??(()=>new Date))();switch(t){case`darwin`:return HMe(e.macosReportsDir??n7,r);case`linux`:return QMe(n,r,e.desktopLogsDir??j(RJ(),`logs`));case`win32`:return oNe(n,e.systemRoot??process.env.SystemRoot);default:return{...a7(t,null,[]),outcome:`unsupported`}}}const sNe={schemaVersion:1,outcome:`not-collected`};function x7(e){return`${JSON.stringify(e??sNe,null,2)}\n`}const cNe=rt.stable.appId;function S7(){return j(RJ(),`bug-reports`)}function lNe(e=new Date){let t=e.toISOString().replace(/[:.]/g,`-`),n=S7(),r=`${t}-bugreport`,i=j(n,`${r}.zip`);for(let e=2;g(i);e+=1)i=j(n,`${r}-${e}.zip`);return i}function C7(e,t){let{scrubbed:n}=e;return n!==void 0&&n.patterns.length>0?{file:t,lineCount:n.lineCount,patterns:[...n.patterns]}:null}function w7(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let e=S(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 g(j(e,`.ok`))?Te(`sha256`).update(N(e)).digest(`hex`).slice(0,12):null}function uNe(){let e={timestamp:new Date().toISOString(),platform:ye(),osType:Ce(),osRelease:be(),hostname:`[redacted]`,uptime:we(),freeMem:ge(),totalMem:Se(),nodeVersion:process.version,bunVersion:process.versions.bun??null,v8Version:process.versions.v8??null,pid:process.pid};try{e.macosVersion=c(`sw_vers -productVersion 2>/dev/null`,c8({encoding:`utf8`})).trim()}catch{}try{let t=j(__dirname,`..`,`..`,`package.json`);g(t)&&(e.okVersion=JSON.parse(S(t,`utf8`)).version)}catch{}return e}const dNe=[{prefix:`cli`,projectTagged:!0},{prefix:`desktop`,projectTagged:!1},{prefix:`mcp`,projectTagged:!1}];function T7(e){let t=ae(e);return dNe.some(e=>e.projectTagged&&t.startsWith(`${e.prefix}.`))}function fNe(e,t){return O7(e,t).files}const pNe=[`ShipIt_stderr.log`,`ShipIt_stdout.log`];function E7(e,t=cNe){let n=j(e,`${t}.ShipIt`);if(!g(n))return[];let r;try{r=w(n)}catch{return[]}return pNe.flatMap(e=>r.map(t=>{if(t===e)return{entry:t,suffix:-1};if(!t.startsWith(`${e}.`))return null;let n=t.slice(e.length+1);return/^\d+$/.test(n)?{entry:t,suffix:Number(n)}:null}).filter(e=>e!==null).sort((e,t)=>e.suffix-t.suffix).slice(0,4).map(e=>j(n,e.entry)))}function D7(e){if(!g(e))return[];try{let t=new Map;for(let n of w(e).filter(e=>e.endsWith(`.yaml`)).sort()){let e=n.endsWith(`.sent.yaml`)?n.slice(0,-10):n.slice(0,-5),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return[...t.values()].slice(-25).flat().map(t=>j(e,t))}catch{return[]}}function O7(e,t){if(!g(t))return{files:[],excludedByProjectSlug:0};let n=w(t).filter(e=>e.endsWith(`.log`)||/\.log\.\d+$/.test(e)).map(e=>j(t,e));if(!e)return{files:n,excludedByProjectSlug:0};let r=n.filter(T7),i=[],a=r.filter(t=>{try{return S(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=>!T7(e)||o.has(e)),excludedByProjectSlug:r.length-o.size}}function mNe(e){let t=j(e,`.ok`,`local`);return g(t)?{files:[`server.lock`,`last-spawn-error.log`,sd,ad].map(e=>j(t,e)).filter(e=>g(e))}:{files:[]}}function hNe(e){let t=j(e,`.ok`,`local`,`logs`);return g(t)?{files:[`server-current.jsonl`,`server-prev.jsonl`].map(e=>j(t,e)).filter(e=>g(e))}:{files:[]}}function gNe(e){let t=0,n=new Map,r=e.replace(/("(?:docName|doc\.name|documentName)"\s*:\s*")((?:[^"\\]|\\.)*)"/g,(e,r,i)=>{t+=1;let a=n.get(i);return a===void 0&&(a=`doc#${Te(`sha256`).update(i).digest(`hex`).slice(0,12)}`,n.set(i,a)),`${r}${a}"`});for(let[e,i]of[...n].sort(([e],[t])=>t.length-e.length)){if(e.length===0||!r.includes(e))continue;let n=r.split(e);t+=n.length-1,r=n.join(i)}return{text:r,count:t}}function k7(e){let t=e.revealDocNames?e.content:gNe(e.content).text;if(e.redact){let{redacted:n,patterns:r,lineCount:i}=BP(t);e.zipfile.addBuffer(Buffer.from(n,`utf8`),e.name),e.bundleFiles.push(e.name),r.length>0&&e.redactions.push({file:e.name,lineCount:i,patterns:r})}else e.zipfile.addBuffer(Buffer.from(t,`utf8`),e.name),e.bundleFiles.push(e.name)}function A7(e){for(let t of e.files)try{let n=S(t,`utf8`);k7({zipfile:e.zipfile,name:`${e.prefix}/${ae(t)}`,content:t.endsWith(`.ips`)?Z5(n):n,redact:e.redact,revealDocNames:e.revealDocNames,bundleFiles:e.bundleFiles,redactions:e.redactions})}catch(n){e.logger?.warn({file:t,prefix:e.prefix,err:n},`bug-report: skipped unreadable file`)}}async function _Ne(t){let{redact:n,outputPath:r,logger:i}=t,a=t.revealDocNames??!1,o=t.userLogsDir??j(RJ(),`logs`),s=t.projectDir?w7(t.projectDir,i):null;v(k(r),{recursive:!0}),i?.info({projectSlug:s},`gathering diagnostic data`);let c=uNe();c.desktop=t.desktop??null,c.language=t.language??null;let{files:l,excludedByProjectSlug:u}=O7(s,o),{files:d}=t.projectDir?mNe(t.projectDir):{files:[]},{files:f}=t.projectDir?hNe(t.projectDir):{files:[]},p=t.shipItLogFiles??[],m=t.diagnosticReports?.files??[];i?.info({logFileCount:l.length,logFilesExcludedByProjectSlug:u,lockFileCount:d.length,localSinkFileCount:f.length,shipItLogFileCount:p.length,diagnosticReportCount:m.length},`files collected`);let g=[],_=[],{ZipFile:y}=await Promise.resolve().then(()=>e(v4(),1)),b=new y;A7({zipfile:b,files:[...l,...p],prefix:`logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:d,prefix:`lockdir`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:f,prefix:`local-logs`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:t.bugReportLedgerFiles??[],prefix:TJ,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i}),A7({zipfile:b,files:m,prefix:`diagnostic-reports`,redact:n,revealDocNames:a,bundleFiles:_,redactions:g,logger:i});for(let e of t.extraFiles??[])try{let t=S(e.sourcePath),n=`extra/${e.zipName??ae(e.sourcePath)}`;b.addBuffer(t,n),_.push(n);let r=C7(e,n);r!==null&&g.push(r)}catch(t){i?.warn({sourcePath:e.sourcePath,err:t},`extra file unreadable; omitted from bundle`)}t.note&&k7({zipfile:b,name:`note.txt`,content:t.note,redact:n,revealDocNames:a,bundleFiles:_,redactions:g});let x=new Set(m.map(e=>`diagnostic-reports/${ae(e)}`)),C=_.filter(e=>x.has(e)),w=t.diagnosticReports===void 0?`not-collected (no collection attempted)`:X5(t.diagnosticReports,C.length);b.addBuffer(Buffer.from(`${w}\n`,`utf8`),`state/diagnostic-reports-status.txt`),_.push(`state/diagnostic-reports-status.txt`),k7({zipfile:b,name:e7,content:x7(t.osTerminationEvidence),redact:n,revealDocNames:!0,bundleFiles:_,redactions:g});let T=JSON.stringify(c,null,2);b.addBuffer(Buffer.from(T,`utf8`),`sysinfo.json`),_.push(`sysinfo.json`);let E={generatedAt:new Date().toISOString(),disciplineVersion:`1.0.0`,projectSlug:s,files:_,redactions:g,sysinfo:c};b.addBuffer(Buffer.from(JSON.stringify(E,null,2),`utf8`),`MANIFEST.json`);let D=g.reduce((e,t)=>e+t.lineCount,0),O=new Set(p.map(e=>`logs/${ae(e)}`)),ee=_.filter(e=>O.has(e)),te=new Set((t.bugReportLedgerFiles??[]).map(e=>`${TJ}/${ae(e)}`)),ne=_.filter(e=>te.has(e)),re=s?_.filter(e=>e.startsWith(`logs/`)&&!T7(e)&&!O.has(e)):[],ie=C.length>0?[`Crash reports under diagnostic-reports/ are rewritten on the way in,`,`independently of this setting: escaped path separators are normalised`,`so the scrub above can read them, and the identifiers that link this`,`machine's bundles to each other are replaced. Nothing else is changed;`,`they are not byte-identical to the files macOS wrote.`]:[],oe=ie.length>0?[`Redaction was disabled for this bundle; file contents are unmodified,`,`with one exception.`,...ie]:[`Redaction was disabled for this bundle; file contents are unmodified.`],A=[`# Bug Report Bundle`,``,`Generated: ${E.generatedAt}`,`Project: ${s??`(unscoped)`}`,`Discipline version: ${E.disciplineVersion}`,``,`## Contents`,``,..._.map(e=>`- ${e}`),``,`## Privacy`,``,...re.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:`,...re.map(e=>`- ${e}`),``]:[],...ee.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:`,...ee.map(e=>`- ${e}`),``]:[],...C.length>0?[`Crash reports: written by macOS itself rather than by OpenKnowledge,`,`and machine-wide rather than scoped to any one project. They record`,`why the operating system ended a process of this app — the signal or`,`exception, the code-signing verdict, and whatever text the process`,`left behind as it died. They also carry machine details the OS puts`,`in every report: the account uid, the Mac model, and the name of the`,`process that launched this app, which on a managed machine can be`,`internal tooling. The identifiers that would link this machine's`,`bundles to each other are replaced before bundling. Only this`,`app's own reports are collected, never another application's, though`,`a report of ours still names the processes it ran alongside:`,...C.map(e=>`- ${e}`),``]:[],...(t.osTerminationEvidence?.events.length??0)>0?[`Termination records: read from the operating system's own logs, covering`,`the last 7 days, to explain an exit the app could not record itself. On`,`macOS: the memory-pressure (jetsam) reports`,`that list processes of this app, with each one's memory use and whether`,`it was killed. On Linux: kernel and systemd-oomd out-of-memory kills of`,`this app, as structured fields with the machine name, cgroup paths and`,`user id left out, plus display-connection errors this app's desktop`,`process wrote to the user's own journal, with Chromium's message cut to`,`200 characters. On Windows: crash and hang records for this app with`,`file paths left out, plus the time of every shutdown, restart, power`,`loss and low-memory warning on the machine, whatever caused it:`,`- ${e7}`,``]:[],...ne.length>0?[`Send history: a small record for each bug report previously generated`,`on this machine — when it was generated, whether sending it`,`succeeded, and why it failed if it did. This is what makes a failed`,`send diagnosable at all. It is machine-wide rather than scoped to`,`this project, so it names the other projects reports were filed`,`from. It carries no document content:`,...ne.map(e=>`- ${e}`),``]:[],...n?[`This bundle was auto-redacted before packaging.`,`Patterns checked: ${zP.join(`, `)}`,D>0?`${D} line(s) were scrubbed across ${g.length} file(s).`:`No redactions were needed.`,`See MANIFEST.json for the full redaction audit report.`,...ie,``,`This bundle is safe to attach to a GitHub issue.`]:oe].join(`
|
|
1531
|
+
`);b.addBuffer(Buffer.from(A,`utf8`),`README.md`),b.end();let se=h(r);return b.outputStream.pipe(se),await new Promise((e,t)=>{se.on(`close`,e),se.on(`error`,t)}),i?.info({bundlePath:r,fileCount:_.length,redactionCount:D},`bundle written`),{zipPath:r,summary:{projectSlug:s,files:_,redactions:g,redactedLineCount:D,generatedAt:E.generatedAt}}}function j7(e){return e.replace(/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\u200b\ufeff]/gu,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function M7(e){return Te(`sha256`).update(e).digest(`hex`)}function N7(e){return j(RJ(N(e)),`pi-trust`)}function P7(e,t){return j(N7(e),M7(N(t)))}function F7(e,t,n){return j(P7(e,t),`${M7(n)}.json`)}var I7=class extends Error{constructor(e,t,n,r){super(`Pi trust receipt at ${j7(e)} ${j7(t)}; ${j7(n)}`,{cause:r}),this.name=`PiTrustReceiptError`}};function L7(e,t,n){let r=n.code,i=n instanceof Error?n.message:String(n),a;switch(r){case`EACCES`:case`EPERM`:a=`check receipt and parent-directory permissions, then retry`;break;case`ENOENT`:a=`the location no longer exists; restore access to its expected location, then retry`;break;default:a=`check the path and available storage, then retry`}return new I7(e,`could not ${t}: ${i}`,a,n)}function R7(e){let t;try{t=_(e)}catch(t){if(t.code===`ENOENT`)return!1;throw L7(e,`be inspected`,t)}if(!t.isDirectory())throw new I7(e,`is not a regular directory`,`restore the intended receipt directory without a symlink, then retry`);return!0}function z7(e,t){return Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t))}function B7(e,t){if(!dY(e)||!z7(e,[`version`,`cwd`,`configuredTrustPath`,`canonicalTrustPath`,`state`,`previous`])||e.version!==1||typeof e.cwd!=`string`||e.cwd!==N(e.cwd)||typeof e.configuredTrustPath!=`string`||e.configuredTrustPath!==N(e.configuredTrustPath)||typeof e.canonicalTrustPath!=`string`||e.canonicalTrustPath!==N(e.canonicalTrustPath)||e.state!==`pending`&&e.state!==`committed`||!dY(e.previous))throw new I7(t,`has invalid contents`,`restore a valid ownership record from a backup without guessing its trust decision, then retry`);let n;if(e.previous.present===!1&&z7(e.previous,[`present`]))n={present:!1};else if(e.previous.present===!0&&z7(e.previous,[`present`,`value`]))n={present:!0,value:e.previous.value};else throw new I7(t,`has an invalid previous decision`,`restore the recorded previous decision from a backup without guessing its value, then retry`);return{version:1,cwd:e.cwd,configuredTrustPath:e.configuredTrustPath,canonicalTrustPath:e.canonicalTrustPath,state:e.state,previous:n}}function V7(e,t,n){let r;try{r=_(n)}catch(e){throw L7(n,`be inspected`,e)}if(!r.isFile())throw new I7(n,`is not a regular file`,`restore the intended receipt as a regular file without a symlink, then retry`);let i;try{i=S(n,`utf8`)}catch(e){throw L7(n,`be read`,e)}let a;try{a=JSON.parse(i)}catch(e){throw new I7(n,`is not valid JSON`,`repair its JSON syntax without changing the recorded decision, then retry`,e)}let o=B7(a,n);if(o.cwd!==N(t)||n!==F7(e,t,o.canonicalTrustPath))throw new I7(n,`does not match its project or trust-store location`,`restore the ownership record to its original project and trust-store location, then retry`);return{path:n,record:o}}function H7(e,t){let{record:n,path:r}=t;for(let t of[N7(e),P7(e,n.cwd)])if(!R7(t))throw new I7(t,`no longer exists`,`restore access to the expected receipt directory, then retry`);let i=V7(e,n.cwd,r);if(!Pe(i.record,n))throw new I7(r,`changed while its trust decision was being updated`,`retry to read its current ownership record`);return i}function vNe(e,t,n,r,i){let a={version:1,cwd:N(t),configuredTrustPath:N(n),canonicalTrustPath:N(r),state:`pending`,previous:i},o=F7(e,a.cwd,a.canonicalTrustPath),s=`${JSON.stringify(a,null,2)}\n`;if(!Pe(B7(JSON.parse(s),o),a))throw new I7(o,`cannot preserve the previous decision as JSON`,`provide the original decision as a JSON value before retrying`);R7(N7(e)),R7(k(o));try{v(k(o),{recursive:!0,mode:448})}catch(e){throw L7(k(o),`be created`,e)}let c;try{c=_(o,{throwIfNoEntry:!1})}catch(e){throw L7(o,`be inspected`,e)}if(c)throw new I7(o,`already exists`,`reconcile the existing ownership record before recording another grant`);try{VJ(o,s,{mode:384})}catch(e){throw L7(o,`be written`,e)}return{path:o,record:a}}function yNe(e,t){let n=H7(e,t);if(n.record.state!==`pending`)throw new I7(n.path,`is already committed`,`use the current ownership record without committing it again`);let r={...n.record,state:`committed`};try{VJ(n.path,`${JSON.stringify(r,null,2)}\n`,{mode:384})}catch(e){throw L7(n.path,`be committed`,e)}return{path:n.path,record:r}}function U7(e,t){if(!R7(N7(e)))return[];let n=P7(e,t);if(!R7(n))return[];let r;try{r=w(n).sort()}catch(e){throw L7(n,`be listed`,e)}return r.filter(e=>/^[a-f0-9]{64}\.json$/.test(e)).map(r=>V7(e,t,j(n,r)))}function W7(e,t){let n=H7(e,t);try{ne(n.path)}catch(e){throw L7(n.path,`be removed after reconciling its grant`,e)}for(let t of[k(n.path),N7(e)])try{ee(t)}catch(e){let n=e.code;if(n!==`ENOTEMPTY`&&n!==`EEXIST`&&n!==`ENOENT`)throw L7(t,`be removed after reconciling its grant`,e)}}var bNe=i(((e,n)=>{var r=t(`constants`),i=process.cwd,a=null,o=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return a||=i.call(process),a};try{process.cwd()}catch{}if(typeof process.chdir==`function`){var s=process.chdir;process.chdir=function(e){a=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}n.exports=c;function c(e){r.hasOwnProperty(`O_SYMLINK`)&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=s(e.chown),e.fchown=s(e.fchown),e.lchown=s(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=c(e.chownSync),e.fchownSync=c(e.fchownSync),e.lchownSync=c(e.lchownSync),e.chmodSync=a(e.chmodSync),e.fchmodSync=a(e.fchmodSync),e.lchmodSync=a(e.lchmodSync),e.stat=l(e.stat),e.fstat=l(e.fstat),e.lstat=l(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(e,t,n){n&&process.nextTick(n)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(e,t,n,r){r&&process.nextTick(r)},e.lchownSync=function(){}),o===`win32`&&(e.rename=typeof e.rename==`function`?(function(t){function n(n,r,i){var a=Date.now(),o=0;t(n,r,function s(c){if(c&&(c.code===`EACCES`||c.code===`EPERM`||c.code===`EBUSY`)&&Date.now()-a<6e4){setTimeout(function(){e.stat(r,function(e,a){e&&e.code===`ENOENT`?t(n,r,s):i(c)})},o),o<100&&(o+=10);return}i&&i(c)})}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.rename):e.rename),e.read=typeof e.read==`function`?(function(t){function n(n,r,i,a,o,s){var c;if(s&&typeof s==`function`){var l=0;c=function(u,d,f){if(u&&u.code===`EAGAIN`&&l<10)return l++,t.call(e,n,r,i,a,o,c);s.apply(this,arguments)}}return t.call(e,n,r,i,a,o,c)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n})(e.read):e.read,e.readSync=typeof e.readSync==`function`?(function(t){return function(n,r,i,a,o){for(var s=0;;)try{return t.call(e,n,r,i,a,o)}catch(e){if(e.code===`EAGAIN`&&s<10){s++;continue}throw e}}})(e.readSync):e.readSync;function t(e){e.lchmod=function(t,n,i){e.open(t,r.O_WRONLY|r.O_SYMLINK,n,function(t,r){if(t){i&&i(t);return}e.fchmod(r,n,function(t){e.close(r,function(e){i&&i(t||e)})})})},e.lchmodSync=function(t,n){var i=e.openSync(t,r.O_WRONLY|r.O_SYMLINK,n),a=!0,o;try{o=e.fchmodSync(i,n),a=!1}finally{if(a)try{e.closeSync(i)}catch{}else e.closeSync(i)}return o}}function n(e){r.hasOwnProperty(`O_SYMLINK`)&&e.futimes?(e.lutimes=function(t,n,i,a){e.open(t,r.O_SYMLINK,function(t,r){if(t){a&&a(t);return}e.futimes(r,n,i,function(t){e.close(r,function(e){a&&a(t||e)})})})},e.lutimesSync=function(t,n,i){var a=e.openSync(t,r.O_SYMLINK),o,s=!0;try{o=e.futimesSync(a,n,i),s=!1}finally{if(s)try{e.closeSync(a)}catch{}else e.closeSync(a)}return o}):e.futimes&&(e.lutimes=function(e,t,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}function i(t){return t&&function(n,r,i){return t.call(e,n,r,function(e){d(e)&&(e=null),i&&i.apply(this,arguments)})}}function a(t){return t&&function(n,r){try{return t.call(e,n,r)}catch(e){if(!d(e))throw e}}}function s(t){return t&&function(n,r,i,a){return t.call(e,n,r,i,function(e){d(e)&&(e=null),a&&a.apply(this,arguments)})}}function c(t){return t&&function(n,r,i){try{return t.call(e,n,r,i)}catch(e){if(!d(e))throw e}}}function l(t){return t&&function(n,r,i){typeof r==`function`&&(i=r,r=null);function a(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),i&&i.apply(this,arguments)}return r?t.call(e,n,r,a):t.call(e,n,a)}}function u(t){return t&&function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}}function d(e){return!e||e.code===`ENOSYS`||(!process.getuid||process.getuid()!==0)&&(e.code===`EINVAL`||e.code===`EPERM`)}}})),xNe=i(((e,n)=>{var r=t(`stream`).Stream;n.exports=i;function i(e){return{ReadStream:t,WriteStream:n};function t(n,i){if(!(this instanceof t))return new t(n,i);r.call(this);var a=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags=`r`,this.mode=438,this.bufferSize=65536,i||={};for(var o=Object.keys(i),s=0,c=o.length;s<c;s++){var l=o[s];this[l]=i[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.end===void 0)this.end=1/0;else if(typeof this.end!=`number`)throw TypeError(`end must be a Number`);if(this.start>this.end)throw Error(`start must be <= end`);this.pos=this.start}if(this.fd!==null){process.nextTick(function(){a._read()});return}e.open(this.path,this.flags,this.mode,function(e,t){if(e){a.emit(`error`,e),a.readable=!1;return}a.fd=t,a.emit(`open`,t),a._read()})}function n(t,i){if(!(this instanceof n))return new n(t,i);r.call(this),this.path=t,this.fd=null,this.writable=!0,this.flags=`w`,this.encoding=`binary`,this.mode=438,this.bytesWritten=0,i||={};for(var a=Object.keys(i),o=0,s=a.length;o<s;o++){var c=a[o];this[c]=i[c]}if(this.start!==void 0){if(typeof this.start!=`number`)throw TypeError(`start must be a Number`);if(this.start<0)throw Error(`start must be >= zero`);this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}})),SNe=i(((e,t)=>{t.exports=r;var n=Object.getPrototypeOf||function(e){return e.__proto__};function r(e){if(typeof e!=`object`||!e)return e;if(e instanceof Object)var t={__proto__:n(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}})),G7=i(((e,n)=>{var r=t(`fs`),i=bNe(),a=xNe(),o=SNe(),s=t(`util`),c,l;typeof Symbol==`function`&&typeof Symbol.for==`function`?(c=Symbol.for(`graceful-fs.queue`),l=Symbol.for(`graceful-fs.previous`)):(c=`___graceful-fs.queue`,l=`___graceful-fs.previous`);function u(){}function d(e,t){Object.defineProperty(e,c,{get:function(){return t}})}var f=u;s.debuglog?f=s.debuglog(`gfs4`):/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&(f=function(){var e=s.format.apply(s,arguments);e=`GFS4: `+e.split(/\n/).join(`
|
|
1532
1532
|
GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){function t(t,n){return e.call(r,t,function(e){e||g(),typeof n==`function`&&n.apply(this,arguments)})}return Object.defineProperty(t,l,{value:e}),t})(r.close),r.closeSync=(function(e){function t(t){e.apply(r,arguments),g()}return Object.defineProperty(t,l,{value:e}),t})(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||``)&&process.on(`exit`,function(){f(r[c]),t(`assert`).equal(r[c].length,0)})),global[c]||d(global,r[c]),n.exports=p(o(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(n.exports=p(r),r.__patched=!0);function p(e){i(e),e.gracefulify=p,e.createReadStream=T,e.createWriteStream=E;var t=e.readFile;e.readFile=n;function n(e,n,r){return typeof n==`function`&&(r=n,n=null),i(e,n,r);function i(e,n,r,a){return t(e,n,function(t){t&&(t.code===`EMFILE`||t.code===`ENFILE`)?m([i,[e,n,r],t,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=o;function o(e,t,n,i){return typeof n==`function`&&(i=n,n=null),a(e,t,n,i);function a(e,t,n,i,o){return r(e,t,n,function(r){r&&(r.code===`EMFILE`||r.code===`ENFILE`)?m([a,[e,t,n,i],r,o||Date.now(),Date.now()]):typeof i==`function`&&i.apply(this,arguments)})}}var s=e.appendFile;s&&(e.appendFile=c);function c(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return s(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var l=e.copyFile;l&&(e.copyFile=u);function u(e,t,n,r){return typeof n==`function`&&(r=n,n=0),i(e,t,n,r);function i(e,t,n,r,a){return l(e,t,n,function(o){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}var d=e.readdir;e.readdir=h;var f=/^v[0-5]\./;function h(e,t,n){typeof t==`function`&&(n=t,t=null);var r=f.test(process.version)?function(e,t,n,r){return d(e,i(e,t,n,r))}:function(e,t,n,r){return d(e,t,i(e,t,n,r))};return r(e,t,n);function i(e,t,n,i){return function(a,o){a&&(a.code===`EMFILE`||a.code===`ENFILE`)?m([r,[e,t,n],a,i||Date.now(),Date.now()]):(o&&o.sort&&o.sort(),typeof n==`function`&&n.call(this,a,o))}}}if(process.version.substr(0,4)===`v0.8`){var g=a(e);x=g.ReadStream,C=g.WriteStream}var _=e.ReadStream;_&&(x.prototype=Object.create(_.prototype),x.prototype.open=S);var v=e.WriteStream;v&&(C.prototype=Object.create(v.prototype),C.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return x},set:function(e){x=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return C},set:function(e){C=e},enumerable:!0,configurable:!0});var y=x;Object.defineProperty(e,"FileReadStream",{get:function(){return y},set:function(e){y=e},enumerable:!0,configurable:!0});var b=C;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(e){b=e},enumerable:!0,configurable:!0});function x(e,t){return this instanceof x?(_.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.autoClose&&e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n),e.read())})}function C(e,t){return this instanceof C?(v.apply(this,arguments),this):C.apply(Object.create(C.prototype),arguments)}function w(){var e=this;O(e.path,e.flags,e.mode,function(t,n){t?(e.destroy(),e.emit(`error`,t)):(e.fd=n,e.emit(`open`,n))})}function T(t,n){return new e.ReadStream(t,n)}function E(t,n){return new e.WriteStream(t,n)}var D=e.open;e.open=O;function O(e,t,n,r){return typeof n==`function`&&(r=n,n=null),i(e,t,n,r);function i(e,t,n,r,a){return D(e,t,n,function(o,s){o&&(o.code===`EMFILE`||o.code===`ENFILE`)?m([i,[e,t,n,r],o,a||Date.now(),Date.now()]):typeof r==`function`&&r.apply(this,arguments)})}}return e}function m(e){f(`ENQUEUE`,e[0].name,e[1]),r[c].push(e),_()}var h;function g(){for(var e=Date.now(),t=0;t<r[c].length;++t)r[c][t].length>2&&(r[c][t][3]=e,r[c][t][4]=e);_()}function _(){if(clearTimeout(h),h=void 0,r[c].length!==0){var e=r[c].shift(),t=e[0],n=e[1],i=e[2],a=e[3],o=e[4];if(a===void 0)f(`RETRY`,t.name,n),t.apply(null,n);else if(Date.now()-a>=6e4){f(`TIMEOUT`,t.name,n);var s=n.pop();typeof s==`function`&&s.call(null,i)}else{var l=Date.now()-o,u=Math.max(o-a,1);l>=Math.min(u*1.2,100)?(f(`RETRY`,t.name,n),t.apply(null,n.concat([a]))):r[c].push(e)}h===void 0&&(h=setTimeout(_,0))}}})),CNe=i(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0){if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1}var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),wNe=i((e=>{var t=CNe();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),TNe=i(((e,t)=>{t.exports=wNe()})),ENe=i(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),DNe=i(((e,n)=>{var r=global.process;let i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=t(`assert`),o=ENe(),s=/^win/i.test(r.platform),c=t(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}return _.apply(this,arguments)}}})),ONe=i(((e,t)=>{let n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),kNe=i(((e,n)=>{let r=t(`path`),i=G7(),a=TNe(),o=DNe(),s=ONe(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function d(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?d(e,{...t,stale:0},n):n(r);if(!f(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));p(e,t,r=>{if(r)return n(r);d(e,{...t,stale:0},n)})})})}function f(e,t){return e.mtime.getTime()<Date.now()-t.stale}function p(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function m(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return h(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?h(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,m(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,m(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function h(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function g(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{d(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};m(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));_(r,{...t,realpath:!1},e)})})})})}function _(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],p(r,t,n)})}function v(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!f(r,t)))})}function y(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=g,n.exports.unlock=_,n.exports.check=v,n.exports.getLocks=y})),ANe=i(((e,t)=>{let n=G7();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),K7=e(i(((e,t)=>{let n=kNe(),{toPromise:r,toSync:i,toSyncOptions:a}=ANe();async function o(e,t){let i=await r(n.lock)(e,t);return r(i)}function s(e,t){let r=i(n.lock)(e,a(t));return i(r)}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}))(),1);const q7=5e3;function J7(e,t,n){if(!(e instanceof Error)||!(`code`in e)||e.code!==`ELOCKED`)throw e;let r=t-performance.now();if(r<=0)throw Object.assign(Error(`Could not acquire Pi trust lock at ${n}.lock within ${q7}ms`,{cause:e}),{code:`ELOCKED`});return Math.min(25,r)}function Y7(e,t){}function X7(e,t){if(e.length===0)return;if(e.length===1)throw e[0];let[n,r]=e,i=n instanceof Error?n.message:String(n),a=r instanceof Error?r.message:String(r);throw AggregateError(e,`Pi trust update failed: ${i}\nReleasing Pi trust lock ${t}.lock also failed: ${a}`)}async function jNe(e,t,n){await Jye(`${t}.ok.lock`,async()=>{let t=performance.now()+q7,r;for(;;)try{r=await K7.default.lock(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){await Ve(J7(n,t,e))}let i=[];try{n()}catch(e){i.push(e)}finally{try{await r()}catch(e){i.push(e)}}X7(i,e)},{onWarn:Y7})}function MNe(e,t,n){UJ(`${t}.ok.lock`,()=>{let t=performance.now()+q7,r=new Int32Array(new SharedArrayBuffer(4)),i;for(;;)try{i=K7.default.lockSync(k(e),{realpath:!1,lockfilePath:`${e}.lock`});break}catch(n){Atomics.wait(r,0,0,J7(n,t,e))}let a=[];try{n()}catch(e){a.push(e)}finally{try{i()}catch(e){a.push(e)}}X7(a,e)},{onWarn:Y7})}const NNe=[`settings.json`,`prompts`,`themes`,`SYSTEM.md`,`APPEND_SYSTEM.md`];var Z7=class extends Error{name=`PiResourceInspectionError`};function Q7(e){let t;try{t=_(e)}catch(e){if(e.code===`ENOENT`)return!1;throw e}let n;try{n=te(e)}catch(e){throw t.isSymbolicLink()&&e.code===`ENOENT`?new Z7(j5(`missing-symlink-target`),{cause:e}):e}return d(e,p.R_OK|(n.isDirectory()?p.X_OK:0)),!0}function PNe(e){return e===`open-knowledge`||e.startsWith(`open-knowledge-`)}function FNe(e,t,n){let r=e;try{let i=E(e),a;r=t;try{a=E(t)}catch(e){if(e.code!==`ENOENT`)throw e;a=N(t)}let o=j(a,`.agents`,`skills`),s=[];for(let e of NNe)r=j(i,`.pi`,e),Q7(r)&&s.push(r);if(r=j(i,`.pi`,`extensions`),Q7(r))for(let t of w(r).sort()){let i=j(r,t);N(n)!==j(N(e),`.pi`,`extensions`,t)&&s.push(i)}for(let e of[j(i,`.pi`,`skills`),j(i,`.agents`,`skills`)])if(e!==o&&(r=e,Q7(e)))for(let t of w(e).sort())PNe(t)||s.push(j(e,t));let c=k(i);for(;c!==i;){r=j(c,`.agents`,`skills`),r!==o&&Q7(r)&&s.push(r);let e=k(c);if(e===c)break;c=e}return s.length===0?{kind:`none`}:{kind:`shared`,paths:s.sort()}}catch(e){return{kind:`unreadable`,error:`Could not inspect Pi project resources at ${j7(r)}: ${e instanceof Z7?e.message:j5(A5(e))}`}}}function $7(e){let t;try{t=_(e).isSymbolicLink()}catch(e){return e.code===`ENOENT`?{kind:`not-present`}:{kind:`declined`,reason:A5(e)}}let n=y5(e);if(n.readPath===null)return{kind:`declined`,reason:`unresolved-symlink`};try{if(!te(n.readPath).isFile())return{kind:`declined`,reason:`not-a-file`}}catch(e){return{kind:`declined`,reason:t&&e.code===`ENOENT`?`missing-symlink-target`:A5(e)}}return{kind:`ready`,path:n.writePath,symlink:t}}function e9(e,t,n){let r=N(e),i=ZY({home:t,env:n??(t===void 0?process.env:{})});return{cwd:r,bridgePath:$Y.pi.projectConfigPath(r),trustPath:j(i,`trust.json`)}}function t9(e){try{let t=E(e);return te(t).isDirectory()?(d(t,p.X_OK),{kind:`ready`,project:{path:e,canonical:t}}):{kind:`refused`,error:`Pi project path ${j7(e)} is not a directory; restore the intended project directory, then retry`}}catch(t){return{kind:`refused`,error:`Pi project directory ${j7(e)} could not be resolved or accessed: ${j7(t instanceof Error?t.message:String(t))}; restore the directory or symlink and check its permissions, then retry`}}}function n9(e){let t=t9(e.path);if(t.kind===`refused`)return t.error;if(t.project.canonical!==e.canonical)return`Pi project path ${j7(e.path)} changed while waiting for its trust lock; restore the intended project location, then retry`}function r9(e,t,n){let r=q5($Y.pi,e,n,t);if(r.kind===`absent`)return{state:`absent`,text:null};if(r.kind!==`present`)return{state:`unreadable`,text:null};let i=r.entry,a=Array.isArray(i.args)&&typeof i.args[0]==`string`?i.args[0]:null;return MY(i)?{state:`own-current`,text:a}:c5(i)?{state:`own-stale`,text:a}:{state:`foreign`,text:a}}function i9(e,t){let n;try{n=S(e.path,`utf-8`)}catch(t){let n=t.code;return e.kind===`missing`&&n===`ENOENT`?{state:`untrusted`,entries:{},trailingNewline:!1}:{state:`unreadable`,reason:A5(t)}}if(n.trim()===``)return{state:`untrusted`,entries:{},trailingNewline:!1};let r;try{r=JSON.parse(n)}catch{return{state:`unreadable`,reason:`invalid-json`}}return dY(r)?{state:r[t]===!0?`trusted`:`untrusted`,entries:r,trailingNewline:n.endsWith(`
|
|
1533
1533
|
`)}:{state:`unreadable`,reason:`invalid-json`}}function INe(e){switch(e){case`invalid-json`:return`the file is not a valid JSON object; repair its JSON, then retry`;case`path-changed`:return`the path changed while waiting for its lock; retry to check its current state`;case`unavailable-root`:return`the filesystem root is unavailable; reconnect the drive or network share, then retry`;default:return j5(e)}}function a9(e,t){return{kind:`refused`,error:`trust store ${j7(e)}: ${INe(t)}`}}function o9(e){let t=$7(e);try{switch(t.kind){case`declined`:return a9(e,t.reason);case`ready`:return{kind:`ready`,path:E(t.path)};case`not-present`:break;default:throw Error(`unhandled trust file resolution: ${t}`)}let n=k(e),r=[ae(e)],i=_(n,{throwIfNoEntry:!1});for(;!i;){let t=k(n);if(t===n)return a9(e,`unavailable-root`);r.unshift(ae(n)),n=t,i=_(n,{throwIfNoEntry:!1})}try{return{kind:`missing`,path:j(E(n),...r)}}catch(t){return a9(e,i.isSymbolicLink()&&t.code===`ENOENT`?`missing-symlink-target`:A5(t))}}catch(t){return a9(e,A5(t))}}function s9(e,t){let n=o9(e);return n.kind===`refused`?n:n.path!==t.path||t.kind===`ready`&&n.kind===`missing`?a9(e,`path-changed`):n}function LNe(e,t,n){let r=e9(e,t,n),i=t9(r.cwd);if(i.kind===`refused`)return{...r,project:`unavailable`,error:i.error};let a=r9(r.cwd,r.bridgePath,t).state,o=o9(r.trustPath),s=o.kind===`refused`?`unreadable`:o.kind===`missing`?`untrusted`:i9(o,i.project.canonical).state;return{...r,project:`ready`,canonicalCwd:i.project.canonical,bridge:a,trust:s,bridgeLoadable:(a===`own-current`||a===`own-stale`)&&s===`trusted`,otherExtensions:RNe(r.bridgePath).displayNames}}function RNe(e){let t=k(e),n=ae(e);try{return{displayNames:w(t).filter(e=>e!==n&&e.endsWith(`.ts`)).sort().map(e=>j7(JSON.stringify(e)))}}catch{return{displayNames:[]}}}async function zNe(e,t={mode:`published`},n,r,i){let a=e9(e,n,r),o=t9(a.cwd);if(o.kind===`refused`)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:o.error};if(i!==void 0&&o.project.canonical!==i)return{...a,ok:!1,bridge:`refused-project-path`,trust:`skipped`,error:`The approved Pi project directory ${j7(i)} no longer matches the current directory ${j7(o.project.canonical)}. Reopen the intended project and approve the Pi integration again; no bridge or trust settings were changed.`};let s=r9(a.cwd,a.bridgePath,n);if(s.state===`foreign`)return{...a,ok:!1,bridge:`refused-foreign`,trust:`skipped`};if(s.state===`unreadable`)return{...a,ok:!1,bridge:`refused-unreadable`,trust:`skipped`};let c;if(s.state===`absent`)c=`written`;else{let e;try{e=l5(t)}catch{e=void 0}c=e!==void 0&&s.text===e?`unchanged`:`refreshed`}if(c!==`unchanged`){let e=W5($Y.pi,a.cwd,t,n,a.bridgePath);if(e.action!==`written`&&e.action!==`overwritten`)return{...a,ok:!1,bridge:`failed`,trust:`skipped`,error:e.error===void 0?`bridge write ${e.action}`:j7(e.error)}}let l=await BNe(a.trustPath,o.project,n??_e());return{...a,ok:l.action===`already-trusted`||l.action===`added`,bridge:c,trust:l.action,...l.error===void 0?{}:{error:l.error}}}async function BNe(e,t,n){let r=t.canonical,i=o9(e);if(i.kind===`refused`)return{action:`refused-unreadable`,error:i.error};try{v(k(i.path),{recursive:!0})}catch(e){return{action:`failed`,error:j7(e instanceof Error?e.message:String(e))}}let a={action:`added`};try{await jNe(e,i.path,()=>{let o=n9(t);if(o){a.action=`refused-unreadable`,a.error=o;return}let s=s9(e,i);if(s.kind===`refused`){a.action=`refused-unreadable`,a.error=s.error;return}let c=i9(s,r);if(c.state===`trusted`){a.action=`already-trusted`;return}if(c.state===`unreadable`){a.action=`refused-unreadable`,a.error=a9(e,c.reason).error;return}let l=l9(n,()=>{let t=U7(n,r).find(e=>e.record.canonicalTrustPath===s.path);return t&&W7(n,t),vNe(n,r,e,s.path,Object.hasOwn(c.entries,r)?{present:!0,value:c.entries[r]}:{present:!1})}),u={...c.entries,[r]:!0},d=JSON.stringify(u,null,2)+(c.trailingNewline?`
|
|
1534
1534
|
`:``),f=N5(s.path);VJ(s.path,d,f===void 0?void 0:{mode:f}),l9(n,()=>yNe(n,l)),a.action=`added`})}catch(e){return{action:`failed`,error:j7(e instanceof Error?e.message:String(e))}}return a}function VNe(e){let t=[],n=e;try{for(;;){if(_(n,{throwIfNoEntry:!1})){if(t.length===0)return;let e=E(n);return te(e).isDirectory()?(d(e,p.X_OK),j(e,...t)):void 0}let e=k(n);if(e===n)return;t.unshift(ae(n)),n=e}}catch{return}}function c9(e){let t={"not-present":0,removed:1,"kept-unowned":2,"kept-shared":3,"kept-unverified":4,"refused-unreadable":5,failed:6},n=e.reduce((e,n)=>t[n.action]>t[e.action]?n:e,{action:`not-present`}),r=e.flatMap(e=>e.error??[]),i=e.flatMap(e=>e.detail??[]);return r.length>0?{action:n.error===void 0?`failed`:n.action,error:[...r,...i].join(`
|
|
@@ -1543,13 +1543,13 @@ GFS4: `),console.error(e)}),r[c]||(d(r,global[c]||[]),r.close=(function(e){funct
|
|
|
1543
1543
|
`),c;try{c=n.removeEntry(a,t)}catch{return{kind:`declined`,reason:`unparseable`}}if(!c.existed)return{kind:`not-present`};let l=c.text;s?l.endsWith(`
|
|
1544
1544
|
`)||(l=`${l}\n`):l=l.replace(/\n+$/,``),o&&(l=l.replace(/\r\n/g,`
|
|
1545
1545
|
`).replace(/\n/g,`\r
|
|
1546
|
-
`));let u=`${i?``:``}${l}`;return u!==r&&VJ(e,u,{mode:N5(e)}),{kind:`removed`}}function XNe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function ZNe(e){let{priorCommand:t,priorArgs:n}=p9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function p9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function m9(e,t,n={}){let r=pje(e,t),i;try{i=S(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??fje()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ve());if(!a||typeof a!=`object`||!mAe(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??r8)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}async function QNe(e,t=void 0){let n=m9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=hje(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function $Ne(e,t={}){return{targets:nPe(e,t.isAlive??r8)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function ePe(e){try{return dt()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function tPe(e){let t=e.inspect??(()=>m9(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??QNe,o=e.logger??void 0,s=t(),c=$Ne(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let l=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof l==`string`&&l.length>0){let t=e.selfChannel??ePe(o);if(t!==void 0&&l!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${eee(l)}. `+(l===`dev`?`Stop it from that dev build, or run \`${ht} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),o?.warn({lockDir:e.lockDir,holderChannel:l,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:l}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let u=[],d=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),u.push(e)}catch(t){d.push({target:e,error:t instanceof Error?t.message:String(t)})}return u.length>0&&r(`Stopped: ${u.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:u.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:d.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),d.length>0&&i(`Failed to stop: ${d.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:u,failed:d,hadTargets:!0}}function nPe(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}function h9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,xs.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return dY(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function rPe(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=Zu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function iPe(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=GJ(`user`,t),s=LJ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=h9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=nd({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?id(i.value):i.value;return t&&a.push(...Tye({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=N(t,`.ok`,`config.yml`),u=c(l,!0),d=c(GJ(`project-local`,t)),f=tae(s.value,u,d),p=Oje.safeParse(f);if(!p.success){let e=h9(l),t={code:`SCHEMA_INVALID`,issues:rPe(p.error.issues,e)};throw Error(eae(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function g9(e){return e.replace(/:\d+$/,``)}function _9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function v9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=gc(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function y9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=gc(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function aPe(e){let t=v9(e);if(t)return{kind:`doc`,...t};let n=y9(e);return n?{kind:`folder`,...n}:null}async function oPe(e,t){let n,r;try{n=await Oe(N(e)),r=await Oe(N(k(e)))}catch{return{kind:`not-git`}}if(!b9(n,r))return{kind:`symlink-escape`};let i=j(n,`.git`),a;try{a=te(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await Oe(i)}catch{return{kind:`not-git`}}if(!b9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=Uxe(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=_9(c);if(l===null)return{kind:`non-github`};let u=gc(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function b9(e,t){if(e===t)return!0;let n=M(t,e);return n.length>0&&!n.startsWith(`..`)&&!A(n)}const sPe=`# >>> open-knowledge cli >>>`,cPe=`# <<< open-knowledge cli <<<`,lPe=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function uPe(e){return Dye(dt(),e)}function x9(e,t,n=[]){let r=g(j(e,B8[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function dPe(e,t){let n=vY.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=yt.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:bS}));return[...n,...r]}function S9(e,t,n,r){let i=dOe(e,dPe(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function fPe(e,t){let n=(t??_e()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function pPe(e,t){let n=$Y[e];return U5(n,``,t)&&!H5(n,``,t)}function C9(e,t,n,r,i){let a=$Y[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?fPe(o,r):void 0,c=q5(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&pPe(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];MY(r)&&i.push(`reclaim-permissive`),FY(r)&&i.push(`pre-approval-exact`),J5(e)(r)&&i.push(`injection-functional`);let o=WY(a,n);return i.length>0&&(o!==null&&Vbe(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:Ibe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function mPe(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Oa(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:x9(j(n,bS),`discovery`,S9(n,vt,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=vt[i];return e===null||n===void 0?null:K8(n).some(e=>e.editorId===i)?x9(j(n,e),`discovery`,S9(n,vt,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=_t[i];return e===null?null:x9(j(t,e),`project`,S9(t,_t,i,`project`))}case`editor-user-config`:return C9(i,e.strictness,t,n);case`editor-project-config`:{let r=$Y[i].projectConfigPath?.(t);return r===void 0?null:C9(i,e.strictness,t,n,r)}}}}[...V8.map(e=>B8[e])];function hPe(e){if(!A(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=N(e);if(t===le||k(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function w9(e){let t=hPe(e),n=[];for(let e of V8){let r=B8[e];n.push({path:j(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of St)n.push({path:j(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function gPe(e,t){let n=[];for(let r of w9(e))if(r.bundleId===t)try{O(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}`)}const _Pe=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=W5(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=_5(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function vPe(e,t,n={},r=_Pe){let i=[];for(let a of t){let t=$Y[a];for(let a of r)i.push(a.write(t,e,n))}let a=Qje(e,t);return a&&i.push({integration:`project-skill`,editorId:a.editorId,action:a.action,...a.path?{path:a.path}:{},...a.error?{error:a.error}:{}}),i}function yPe(e,t,n={}){return{integrations:vPe(e,t,n)}}function T9(e,t){let n=vt[e];return n===null?null:j(t,...n.split(`/`),B8.discovery,`SKILL.md`)}function bPe(e,t){let n=T9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!K8(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=W8(`discovery`,{checkDesktop:!0});return p5(k(n),t),{editorId:e,label:e,action:m5(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function xPe(e){return g(j(e,...`.agents/skills`.split(`/`),B8.discovery))?!0:gt.some(t=>{let n=T9(t,e);return n!==null&&g(k(n))})}function SPe(e,t){let n=T9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=k(n);try{return g(n)?(p5(r,t),O(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function CPe(e){return LJ({absPath:GJ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function E9({home:e=_e(),env:t=process.env}={}){let n=CPe(e),{override:r,preferenceList:i}=$ye(t),{locale:a,source:o}=PP({override:r,storedPreference:n,supportedLocales:Kc,preferenceList:i,autoDetectableLocales:Jc});return{preference:n,locale:a,source:o,systemLanguages:i}}function D9(e){let t=new Set([e]);try{t.add(E.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function O9(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function wPe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k9(e,t){if(typeof e==`string`)return O9(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>k9(e,t));if(!wPe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=k9(i,t);return n}function A9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
1546
|
+
`));let u=`${i?``:``}${l}`;return u!==r&&VJ(e,u,{mode:N5(e)}),{kind:`removed`}}function XNe(e){return{event:`mcp-config-decline`,scope:e.scope,surface:e.surface,editorId:e.editorId,reason:e.reason}}function ZNe(e){let{priorCommand:t,priorArgs:n}=p9(e.priorEntry);return{event:`mcp-config-migrate`,scope:e.scope,surface:e.surface,editorId:e.editorId,configPath:e.configPath,priorCommand:t,priorArgs:n}}function p9(e){return{priorCommand:typeof e.command==`string`?e.command.slice(0,200):null,priorArgs:Array.isArray(e.args)?e.args.slice(0,10).map(e=>typeof e==`string`?e.slice(0,200):e):null}}function m9(e,t,n={}){let r=pje(e,t),i;try{i=S(r,`utf-8`)}catch(e){return e&&typeof e==`object`&&`code`in e&&e.code===`ENOENT`?{status:`missing`,lockPath:r}:{status:`read-error`,lockPath:r,error:e instanceof Error?e.message:String(e)}}let a;try{a=JSON.parse(i)}catch{return{status:`corrupt`,lockPath:r}}let o=a&&typeof a==`object`?a:{},s=`machineId`in o&&typeof o.machineId==`string`?o.machineId!==(n.machineId??fje()):`hostname`in o&&typeof o.hostname==`string`&&o.hostname!==(n.host??ve());if(!a||typeof a!=`object`||!mAe(a.pid))return{status:`corrupt`,lockPath:r,...s?{foreignHost:!0}:{}};let c=a.pid,l=`machineId`in o&&typeof o.machineId==`string`||`hostname`in o&&typeof o.hostname==`string`;return s?{status:`foreign-host`,lockPath:r,lock:a}:(n.isAlive??r8)(c)?l?{status:`alive`,lockPath:r,lock:a}:{status:`unverified-owner`,lockPath:r,pid:c}:{status:`dead-pid`,lockPath:r,lock:a}}async function QNe(e,t=void 0){let n=m9(e,`server`);if(n.status!==`alive`&&n.status!==`foreign-host`)return null;let r=hje(n.lock);if(r===null)return null;try{let n=await fetch(`${r}/api/server-info`,{signal:AbortSignal.timeout(1500),redirect:`manual`});if(!n.ok)return t?.warn({lockDir:e,baseUrl:r,outcome:`http-error`,status:n.status},`stop client-probe failed`),null;let i=(await n.json())?.collabClients;return typeof i==`number`&&Number.isFinite(i)?i:(t?.warn({lockDir:e,baseUrl:r,outcome:`no-client-count`,received:typeof i},`stop client-probe failed`),null)}catch(n){return t?.warn({lockDir:e,baseUrl:r,outcome:`unreachable`,err:n},`stop client-probe failed`),null}}function $Ne(e,t={}){return{targets:nPe(e,t.isAlive??r8)?[{name:`server`,pid:e.lock.pid,port:e.lock.port}]:[]}}function ePe(e){try{return dt()}catch(t){e?.warn({err:t},`stop channel check skipped: ${t instanceof Error?t.message:String(t)}`);return}}async function tPe(e){let t=e.inspect??(()=>m9(e.lockDir,`server`)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=e.probeClients??QNe,o=e.logger??void 0,s=t(),c=$Ne(s,{isAlive:e.isAlive});if(c.targets.length===0)return r(`No running open-knowledge processes.`),o?.info({lockDir:e.lockDir,targets:0},`stop found nothing to signal`),{stopped:[],failed:[],hadTargets:!1};let l=s.status===`alive`||s.status===`foreign-host`?s.lock.channel:void 0;if(e.force!==!0&&typeof l==`string`&&l.length>0){let t=e.selfChannel??ePe(o);if(t!==void 0&&l!==t)return i(`Not stopping: the server at ${e.lockDir} belongs to ${eee(l)}. `+(l===`dev`?`Stop it from that dev build, or run \`${ht} stop\` with OK_CHANNEL=dev set, or re-run with --force to terminate anyway.`:`Stop it from that app or its CLI, or re-run with --force to terminate anyway.`)),o?.warn({lockDir:e.lockDir,holderChannel:l,selfChannel:t,pids:c.targets.map(e=>e.pid)},`stop declined: server belongs to another channel`),{stopped:[],failed:[],hadTargets:!0,declined:{otherChannel:l}}}if(e.force!==!0){let t=await a(e.lockDir,o);if(t!==null&&t>0)return i(`Not stopping: ${t} collaboration client${t===1?``:`s`} (editor window${t===1?``:`s`} or agents) still connected to the server at ${e.lockDir}. Close them, or re-run with --force to terminate anyway.`),o?.warn({lockDir:e.lockDir,clients:t,pids:c.targets.map(e=>e.pid)},`stop declined: live collaboration clients`),{stopped:[],failed:[],hadTargets:!0,declined:{clients:t}}}let u=[],d=[];for(let e of c.targets)try{n(e.pid,`SIGTERM`),u.push(e)}catch(t){d.push({target:e,error:t instanceof Error?t.message:String(t)})}return u.length>0&&r(`Stopped: ${u.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),o?.info({lockDir:e.lockDir,signalled:u.map(e=>({name:e.name,pid:e.pid,port:e.port})),failed:d.map(({target:e,error:t})=>({pid:e.pid,error:t})),forced:e.force===!0},`stop signalled processes`),d.length>0&&i(`Failed to stop: ${d.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:u,failed:d,hadTargets:!0}}function nPe(e,t){return e.status===`alive`||e.status===`foreign-host`&&t(e.lock.pid)}function h9(e){if(!g(e))return{value:null,path:e,source:null,doc:null};let t;try{t=S(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,xs.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return dY(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function rPe(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),r={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=Zu({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...r,source:e}}return r})}function iPe(e){let t=e??process.cwd(),n=[],r=[],i=[],a=[],o=GJ(`user`,t),s=LJ({absPath:o});r.push(...s.diagnostics),!s.valid&&s.sidelinedTo!==void 0&&i.push({from:o,to:s.sidelinedTo}),s.valid&&s.source!==void 0&&n.push(o);let c=(e,t=!1)=>{let i=h9(e);if(i.diagnostic!==void 0&&r.push(i.diagnostic),i.value===null)return{};let o=nd({value:i.value,file:i.path,source:i.source,doc:i.doc});r.push(...o),n.push(e);let s=o.length>0?id(i.value):i.value;return t&&a.push(...Tye({value:s,file:i.path,source:i.source,doc:i.doc})),s},l=N(t,`.ok`,`config.yml`),u=c(l,!0),d=c(GJ(`project-local`,t)),f=tae(s.value,u,d),p=Oje.safeParse(f);if(!p.success){let e=h9(l),t={code:`SCHEMA_INVALID`,issues:rPe(p.error.issues,e)};throw Error(eae(t))}return{config:p.data,sources:n,diagnostics:r,sidelined:i,ignoredCommittedKeys:a}}function g9(e){return e.replace(/:\d+$/,``)}function _9(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[^/?#]*@)?([^@/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:g9(e[1]),owner:e[2],name:e[3]}}{let e=/^(?:[\w.\-~%]+@)?([\w.-]+):([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e?.[1].includes(`.`)||e&&t.startsWith(`git@`))return{protocol:`ssh`,hostname:e[1],owner:e[2],name:e[3]}}{let e=/^git:([\w.-]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:e[1],owner:e[2],name:e[3]}}if(!t.includes(`://`)&&!t.includes(`@`)&&!t.startsWith(`/`)){let e=/^([\w.-]+)\/([\w.\-~%]+?)(?:\.git)?$/.exec(t);if(e)return{protocol:`https`,hostname:`github.com`,owner:e[1],name:e[2]}}return null}function v9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=gc(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`).filter(e=>e.length>0);if(r.length<5||r[2]!==`blob`)return null;let i,a,o,s;try{i=decodeURIComponent(r[0]),a=decodeURIComponent(r[1]),o=decodeURIComponent(r[3]),s=r.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.length===0||s.some(e=>e.length===0)?null:{host:n,owner:i,repo:a,branch:o,path:s.join(`/`)}}function y9(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`)return null;let n=gc(t.hostname);if(n===null)return null;let r=t.pathname.split(`/`);if(r.length<5||r[0]!==``||r[3]!==`tree`)return null;let i=r.slice(5);i.length===1&&i[0]===``&&i.pop();let a,o,s,c;try{a=decodeURIComponent(r[1]),o=decodeURIComponent(r[2]),s=decodeURIComponent(r[4]),c=i.map(e=>decodeURIComponent(e))}catch{return null}return!a||!o||!s||c.some(e=>e.length===0)?null:{host:n,owner:a,repo:o,branch:s,path:c.join(`/`)}}function aPe(e){let t=v9(e);if(t)return{kind:`doc`,...t};let n=y9(e);return n?{kind:`folder`,...n}:null}async function oPe(e,t){let n,r;try{n=await Ae(N(e)),r=await Ae(N(k(e)))}catch{return{kind:`not-git`}}if(!b9(n,r))return{kind:`symlink-escape`};let i=j(n,`.git`),a;try{a=te(i)}catch{return{kind:`not-git`}}if(a.isDirectory()){let e;try{e=await Ae(i)}catch{return{kind:`not-git`}}if(!b9(e,n))return{kind:`symlink-escape`}}else if(!a.isFile())return{kind:`not-git`};let o=Uxe(n);if(o.kind!==`repository`)return{kind:`not-git`};let s=o.repository.readRemoteUrl(`origin`);if(s.kind===`unreadable`)return{kind:`not-git`};if(s.kind===`absent`)return s.reason===`config-missing`?{kind:`not-git`}:{kind:`no-origin`};let c=s.url,l=_9(c);if(l===null)return{kind:`non-github`};let u=gc(l.hostname);if(u===null)return{kind:`non-github`};let d=u===t.host.toLowerCase(),f=l.owner.toLowerCase()===t.owner.toLowerCase(),p=l.name.toLowerCase()===t.repo.toLowerCase();return!d&&f&&p?{kind:`wrong-host`,actualHost:u}:!d||!f||!p?{kind:`wrong-repo`,actualOwner:l.owner,actualRepo:l.name}:{kind:`ok`,gitRemoteUrl:`https://${u}/${l.owner}/${l.name}.git`}}function b9(e,t){if(e===t)return!0;let n=M(t,e);return n.length>0&&!n.startsWith(`..`)&&!A(n)}const sPe=`# >>> open-knowledge cli >>>`,cPe=`# <<< open-knowledge cli <<<`,lPe=/^# >>> open-knowledge cli >>>\n[\s\S]*?^# <<< open-knowledge cli <<<\n?/m;function uPe(e){return Dye(dt(),e)}function x9(e,t,n=[]){let r=g(j(e,B8[t]))?`satisfied`:`absent`;return{...r===`satisfied`?{state:r,strictness:[`reclaim-permissive`]}:{state:r},...n.length===0?{}:{sharedWith:n}}}function dPe(e,t){let n=vY.flatMap(t=>{let n=e[t];return n===null?[]:[{editor:t,root:n}]}),r=yt.filter(e=>e.scope===t).map(e=>({editor:e.editorId,root:bS}));return[...n,...r]}function S9(e,t,n,r){let i=dOe(e,dPe(t,r)),a=i.find(e=>e.host===n);if(a===void 0||a.state===`absent`)return[];let o=a.real;return i.filter(e=>e.host!==n&&e.state!==`absent`&&e.real===o).map(e=>e.host)}function fPe(e,t){let n=(t??_e()).replace(/[\\/]+$/,``);if(!n.includes(`\\`))return e.startsWith(`${n}/`)?`~/${e.slice(n.length+1)}`:e;let r=e=>e.replace(/\\/g,`/`),i=r(n),a=r(e);return a.startsWith(`${i}/`)?`~/${a.slice(i.length+1)}`:e}function pPe(e,t){let n=$Y[e];return U5(n,``,t)&&!H5(n,``,t)}function C9(e,t,n,r,i){let a=$Y[e],o;if(i===void 0)try{o=a.configPath(n,r)}catch{return{state:`structural-na`}}else o=i;let s=i===void 0?fPe(o,r):void 0,c=q5(a,n,r,i);switch(c.kind){case`absent`:case`no-entry`:return i===void 0&&pPe(e,r)?{state:`structural-na`}:{state:`absent`,path:s};case`decline`:return{state:`unprobed`};case`present`:{let{entry:r}=c,i=[];MY(r)&&i.push(`reclaim-permissive`),FY(r)&&i.push(`pre-approval-exact`),J5(e)(r)&&i.push(`injection-functional`);let o=WY(a,n);return i.length>0&&(o!==null&&Vbe(r,o)||t.includes(`pre-approval-exact`)&&i.includes(`reclaim-permissive`)&&!i.includes(`pre-approval-exact`))?{state:`drifted`,strictness:i,path:s}:i.length>0?{state:`satisfied`,strictness:i,path:s}:Ibe(a)?{state:`foreign-replaceable`,path:s}:{state:`foreign`,path:s}}}}function mPe(e){let{cwd:t,home:n}=e;return e=>{if(e.pathId===null)return null;let r=Oa(e.pathId);if(r===null)return null;if(r.kind===`central-skill-store`)return n===void 0?null:x9(j(n,bS),`discovery`,S9(n,vt,e.agent,`global`));let i=r.editor;switch(r.kind){case`editor-user-skill-root`:{let e=vt[i];return e===null||n===void 0?null:K8(n).some(e=>e.editorId===i)?x9(j(n,e),`discovery`,S9(n,vt,i,`global`)):{state:`structural-na`}}case`editor-project-skill-root`:{let e=_t[i];return e===null?null:x9(j(t,e),`project`,S9(t,_t,i,`project`))}case`editor-user-config`:return C9(i,e.strictness,t,n);case`editor-project-config`:{let r=$Y[i].projectConfigPath?.(t);return r===void 0?null:C9(i,e.strictness,t,n,r)}}}}[...V8.map(e=>B8[e])];function hPe(e){if(!A(e))throw Error(`skill cleanup requires an absolute home directory; got ${JSON.stringify(e)}`);let t=N(e);if(t===le||k(t)===t)throw Error(`skill cleanup refuses to operate on the filesystem root (${t})`);return t}function w9(e){let t=hPe(e),n=[];for(let e of V8){let r=B8[e];n.push({path:j(t,`.agents`,`skills`,r),bundleId:e,scope:`central`});for(let i of St)n.push({path:j(t,i.skillsRoot,r),bundleId:e,scope:`host`,hostDir:i.hostDir})}return n}function gPe(e,t){let n=[];for(let r of w9(e))if(r.bundleId===t)try{O(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}`)}const _Pe=[{id:`mcp-config`,write(e,t,n){let r=e.projectConfigPath?.(t);if(!r)return{integration:`mcp-config`,editorId:e.id,action:`skipped-unsupported`};try{let i=W5(e,t,n,void 0,r);return i.action===`written`||i.action===`overwritten`?{integration:`mcp-config`,editorId:e.id,action:i.action,path:i.configPath}:i.action===`failed`?{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:i.error??`unknown failure`}:i.action===`declined`?{integration:`mcp-config`,editorId:e.id,action:`declined`,path:i.configPath,...i.declineReason===void 0?{}:{reason:i.declineReason}}:{integration:`mcp-config`,editorId:e.id,action:`failed`,path:i.configPath,error:`unexpected project-scope action: ${i.action}`}}catch(t){return{integration:`mcp-config`,editorId:e.id,action:`failed`,path:r,error:t instanceof Error?t.message:String(t)}}}},{id:`project-skill`,write(e,t,n){try{let r=_5(e,t,{home:n.home});return{integration:`project-skill`,editorId:e.id,action:r.action,...r.path?{path:r.path}:{},...r.error?{error:r.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function vPe(e,t,n={},r=_Pe){let i=[];for(let a of t){let t=$Y[a];for(let a of r)i.push(a.write(t,e,n))}let a=Qje(e,t);return a&&i.push({integration:`project-skill`,editorId:a.editorId,action:a.action,...a.path?{path:a.path}:{},...a.error?{error:a.error}:{}}),i}function yPe(e,t,n={}){return{integrations:vPe(e,t,n)}}function T9(e,t){let n=vt[e];return n===null?null:j(t,...n.split(`/`),B8.discovery,`SKILL.md`)}function bPe(e,t){let n=T9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};if(!K8(t).some(t=>t.editorId===e))return{editorId:e,label:e,action:`skipped-unsupported`,path:n};try{let r=W8(`discovery`,{checkDesktop:!0});return p5(k(n),t),{editorId:e,label:e,action:m5(r,n),path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function xPe(e){return g(j(e,...`.agents/skills`.split(`/`),B8.discovery))?!0:gt.some(t=>{let n=T9(t,e);return n!==null&&g(k(n))})}function SPe(e,t){let n=T9(e,t);if(n===null)return{editorId:e,label:e,action:`skipped-unsupported`,path:``};let r=k(n);try{return g(n)?(p5(r,t),O(r,{recursive:!0,force:!0}),{editorId:e,label:e,action:`removed`,path:n}):{editorId:e,label:e,action:`not-present`,path:n}}catch(t){return{editorId:e,label:e,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function CPe(e){return LJ({absPath:GJ(`user`,e,e),sideline:!1,warn:()=>{}}).value.appearance?.language??`system`}function E9({home:e=_e(),env:t=process.env}={}){let n=CPe(e),{override:r,preferenceList:i}=$ye(t),{locale:a,source:o}=PP({override:r,storedPreference:n,supportedLocales:Kc,preferenceList:i,autoDetectableLocales:Jc});return{preference:n,locale:a,source:o,systemLanguages:i}}function D9(e){let t=new Set([e]);try{t.add(E.native(e))}catch{return[e].filter(e=>e.length>0)}return[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length)}function O9(e,t){let n=e;for(let e of t)n.includes(e)&&(n=n.split(e).join(`<CONTENT_DIR>`));return n}function wPe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function k9(e,t){if(typeof e==`string`)return O9(e,t.contentDirSpellings);if(Array.isArray(e))return e.map(e=>k9(e,t));if(!wPe(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=k9(i,t);return n}function A9(e,t){let n=S(e,`utf-8`);if(n.length===0)return;let r=n.endsWith(`
|
|
1547
1547
|
`),i=n.split(`
|
|
1548
1548
|
`),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=k9(JSON.parse(n),t);a.push(JSON.stringify(e))}catch{a.push(n)}}}let o=r?`${a.join(`
|
|
1549
1549
|
`)}\n`:a.join(`
|
|
1550
1550
|
`);re(e,o)}function j9(e,t){let n=S(e,`utf-8`);if(n.trim().length!==0)try{let r=k9(JSON.parse(n),t),i=n.endsWith(`
|
|
1551
1551
|
`)?`
|
|
1552
1552
|
`:``;re(e,`${JSON.stringify(r,null,2)}${i}`)}catch{let r=O9(n,t.contentDirSpellings);r!==n&&re(e,r)}}function M9(e,t){let n=S(e,`utf-8`),r=O9(n,t.contentDirSpellings);r!==n&&re(e,r)}function N9(e){try{return w(e,{withFileTypes:!0}).filter(e=>e.isFile()).map(t=>j(e,t.name))}catch{return[]}}const TPe=new Set([`agent-presence.json`,`agent-effects.json`,`runtime.json`]);function P9(e){return/\.log\.\d+$/.test(e)}function EPe(e){return e.endsWith(`.jsonl`)||e.endsWith(`.log`)||P9(e)}const DPe=[`telemetry`,`logs`,`process`,`diagnostic-reports`];function OPe(e){let t={contentDirSpellings:D9(e.contentDir)};for(let n of DPe)for(let r of N9(j(e.stagingDir,n)))EPe(r)?A9(r,t):r.endsWith(`.json`)?j9(r,t):M9(r,t);for(let n of N9(j(e.stagingDir,`state`))){let e=ae(n);n.endsWith(`.jsonl`)?A9(n,t):TPe.has(e)?j9(n,t):M9(n,t)}}const F9=[`.ok`,`local`,`telemetry`],I9=[`.ok`,`local`,`logs`],L9=[`.ok`,`local`,`loss-capture`],R9=`spans-current.jsonl`,z9=`spans-prev.jsonl`,B9=`server-current.jsonl`,V9=`server-prev.jsonl`,H9=`loss-current.jsonl`,U9=`loss-prev.jsonl`;function kPe(e){return j(e,...F9,R9)}function APe(e){return j(e,...F9,z9)}function jPe(e){return j(e,...I9,B9)}function MPe(e){return j(e,...I9,V9)}function NPe(e){return j(e,...L9,H9)}function PPe(e){return j(e,...L9,U9)}const W9=1e3;async function FPe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-presence`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function IPe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/agent-effects`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}async function LPe(e){try{let t=await fetch(`http://127.0.0.1:${e}/api/metrics/watcher-recent`,{signal:AbortSignal.timeout(W9)});return t.ok?await t.text():null}catch{return null}}function RPe(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t.decisions;return Array.isArray(n)?n.length===0?``:`${n.map(e=>JSON.stringify(e)).join(`
|
|
1553
|
-
`)}\n`:null}catch{return null}}function zPe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],c8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function BPe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],c8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function VPe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function HPe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,xs.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function UPe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return UPe(e.maxBytes)}function WPe(e){let t=q9(GJ(`project`,e)),n=q9(GJ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function GPe(e){return
|
|
1553
|
+
`)}\n`:null}catch{return null}}function zPe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`log`,`--oneline`,`-50`],c8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function BPe(e){let t=j(e,`.git`,`ok`);if(!g(t))return null;let n=l(`git`,[`-C`,t,`for-each-ref`,`--sort=-creatordate`,`--count=50`,`--format=%(refname)%09%(creatordate:iso-strict)%09%(contents:subject)`,`refs/checkpoints/`],c8({encoding:`utf-8`,timeout:2e3}));return n.error||n.status!==0?null:n.stdout??``}function G9(){let e=process.env.OK_DESKTOP_VERSION,t=process.env.OK_DESKTOP_PACKAGED,n=process.env.OK_DESKTOP_CHANNEL;return e===void 0||t===void 0||n===void 0?null:{electronVersion:e,packaged:t===`1`||t.toLowerCase()===`true`,channel:n}}function VPe(){return{nodeVersion:process.version,platform:ye(),arch:me()}}function HPe(){return process.env.OTEL_SDK_DISABLED===`false`}function K9(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q9(e){if(!g(e))return{};let t;try{t=(0,xs.parse)(S(e,`utf-8`))}catch(t){return console.warn(`[ok diagnose bundle] failed to parse ${e} for manifest config; manifest will report schema defaults. Reason: ${t instanceof Error?t.message:String(t)}`),{}}if(!K9(t))return{};let n=t.telemetry;if(!K9(n))return{};let r=n.localSink;return K9(r)?r:{}}function J9(e){return typeof e==`boolean`?e:void 0}function UPe(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function Y9(e){if(K9(e))return UPe(e.maxBytes)}function WPe(e){let t=q9(GJ(`project`,e)),n=q9(GJ(`project-local`,e));return{enabled:J9(n.enabled)??J9(t.enabled)??!0,spansMaxBytes:Y9(n.spans)??Y9(t.spans)??52428800,logsMaxBytes:Y9(n.logs)??Y9(t.logs)??26214400}}function GPe(e){return Te(`sha256`).update(e).digest(`hex`)}function KPe(e){let t=S(e),n=0;for(let e=0;e<t.length;e++)t[e]===10&&n++;return n}const qPe=[`"doc.name"`,`"docName"`];function JPe(e){let t=S(e,`utf-8`),n=0;for(let e of qPe){let r=t.indexOf(e);for(;r!==-1;)n++,r=t.indexOf(e,r+e.length)}return n}function X9(e,t){if(!g(e))return!1;try{return v(k(t),{recursive:!0}),e.endsWith(`.ips`)?re(t,Z5(S(e,`utf-8`))):m(e,t),!0}catch{return!1}}function Z9(e){let t=[],n=e=>{let r=w(e,{withFileTypes:!0});for(let i of r){let r=j(e,i.name);i.isDirectory()?n(r):i.isFile()&&t.push(r)}};return n(e),t.sort()}const YPe=new Set([`.jsonl`]);function Q9(e){let t=e.lastIndexOf(`.`);return t!==-1&&YPe.has(e.slice(t))}const XPe=new Set([`.jsonl`,`.json`,`.txt`,`.log`,`.lock`,`.yaml`,`.yml`,`.ips`]);function ZPe(e){if(P9(e))return!0;let t=e.lastIndexOf(`.`);return t!==-1&&XPe.has(e.slice(t))}function QPe(e){let t=[];for(let n of Z9(e)){let r=$9(e,n);if(!ZPe(r))continue;let{redacted:i,patterns:a,lineCount:o}=BP(S(n,`utf-8`));a.length!==0&&(re(n,i),t.push({file:r,lineCount:o,patterns:a}))}return{redactions:t,redactedLineCount:t.reduce((e,t)=>e+t.lineCount,0)}}function $9(e,t){return M(e,t).split(le).join(`/`)}async function $Pe(e){let t=N(e.contentDir),n=N(e.projectDir??e.contentDir),r=e.deps??{},i=r.fetchAgentPresence??FPe,a=r.fetchAgentEffects??IPe,o=r.fetchWatcherRecent??LPe,s=r.readShadowHead??zPe,c=r.readCheckpointRefs??BPe,l=r.now??(()=>new Date),u=r.okVersion??(()=>`0.86.13-beta.9`),d=r.readDesktopEnv??G9,f=r.readLanguage??E9,p=r.readRuntime??VPe,h=r.isOtlpPushEnabled??HPe,_=y(j(xe(),`ok-bundle-`));try{v(j(_,`telemetry`),{recursive:!0}),v(j(_,`logs`),{recursive:!0}),v(j(_,`state`),{recursive:!0}),X9(kPe(n),j(_,`telemetry`,R9)),X9(APe(n),j(_,`telemetry`,z9)),X9(jPe(n),j(_,`logs`,B9)),X9(MPe(n),j(_,`logs`,V9));for(let t of e.userLogFiles??[])X9(t,j(_,`logs`,ae(t)));for(let t of e.userStateFiles??[])X9(t,j(_,TJ,ae(t)));let y=0;for(let t of e.diagnosticReports?.files??[])X9(t,j(_,`diagnostic-reports`,ae(t)))&&(y+=1);let b=j(n,`.ok`,`local`),x=j(b,`server.lock`),C=`not-running`,w=`no server.lock`,T=null;if(g(x)){X9(x,j(_,`state`,`server.lock`));try{let e=S(x,`utf-8`),t=JSON.parse(e);typeof t.port==`number`?T=t.port:w=`lock present but no port`}catch{w=`lock present but unparseable`}}if(T!==null){let e=await i(T);e===null?w=`agent-presence endpoint at :${T} unreachable`:(re(j(_,`state`,`agent-presence.json`),e),C=`running`,w=``);let t=await a(T);t!==null&&re(j(_,`state`,`agent-effects.json`),t);let n=await o(T);if(n!==null){let e=RPe(n);e!==null&&re(j(_,`state`,`watcher-recent.jsonl`),e)}}let E=s(t);E!==null&&re(j(_,`state`,`shadow-head.txt`),E);let D=c(t);D!==null&&re(j(_,`state`,`checkpoint-refs.txt`),D),X9(NPe(n),j(_,`state`,H9)),X9(PPe(n),j(_,`state`,U9)),X9(j(b,`last-spawn-error.log`),j(_,`state`,`last-spawn-error.log`)),X9(j(b,od),j(_,`state`,od)),X9(j(b,sd),j(_,`state`,sd)),X9(j(b,ad),j(_,`state`,ad));let ee=p(),ne=d(),ie=f(),k={ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie}};re(j(_,`state`,`runtime.json`),`${JSON.stringify(k,null,2)}\n`);let oe=C===`running`?`running
|
|
1554
1554
|
`:`not-running (${w})\n`;re(j(_,`state`,`server-status.txt`),oe);let A=e.diagnosticReports===void 0?`not-collected (no collection attempted)`:X5(e.diagnosticReports,y);if(re(j(_,`state`,`diagnostic-reports-status.txt`),`${A}\n`),re(j(_,e7),x7(e.osTerminationEvidence)),e.processDir&&g(e.processDir)){let t=j(_,`process`);v(t,{recursive:!0}),m(e.processDir,t,{recursive:!0})}let se=e.redact===!0;se&&OPe({stagingDir:_,contentDir:t}),e.note&&re(j(_,`note.txt`),e.note);let ce=null;e.scrubSecrets===!0&&(ce=QPe(_));for(let t of e.extraFiles??[]){let e=t.zipName??ae(t.sourcePath);if(!X9(t.sourcePath,j(_,`extra`,e))){r.logger?.warn({sourcePath:t.sourcePath},`extra file missing; omitted from bundle`);continue}let n=C7(t,`extra/${e}`);n!==null&&(ce??={redactions:[],redactedLineCount:0},ce.redactions.push(n),ce.redactedLineCount+=n.lineCount)}let M=WPe(n),N=Z9(_),le=[],ue=0,de=0;for(let e of N){let t=$9(_,e),n=te(e).size,r=Q9(t)?KPe(e):0;le.push({path:t,bytes:n,lines:r}),ue+=n,(t.startsWith(`telemetry/`)||t.startsWith(`logs/`))&&(de+=JPe(e))}let fe={applied:se};ce!==null&&(fe.secretScrub=ce);let P={schemaVersion:2,createdAt:l().toISOString(),ok:{version:u(),nodeVersion:ee.nodeVersion,platform:ee.platform,arch:ee.arch},host:{desktop:ne,language:ie},contentDir:{pathSha256:GPe(t),absolutePath:se?`<CONTENT_DIR>`:t},telemetry:{localSink:M,otlpPushEnabled:h()},redaction:fe,serverStatus:C,files:le};re(j(_,`manifest.json`),`${JSON.stringify(P,null,2)}\n`);let pe=D9(t),me=N.some(e=>{try{let t=S(e,`utf-8`);return pe.some(e=>t.includes(e))}catch{return!1}}),he={stagedDiagnosticReports:y,totalBytes:ue,fileCount:le.length,docNameCount:de,contentDirVisible:me,redacted:se},ge=!1;return{stagingDir:_,manifest:P,summary:he,cleanup:()=>{ge||(ge=!0,O(_,{recursive:!0,force:!0}))}}}catch(e){throw O(_,{recursive:!0,force:!0}),e}}async function eFe(e){let{collected:t,outputPath:n}=e,r=k(n);if(!g(r))throw Error(`ok diagnose bundle: parent directory does not exist: ${r}. Create it or pass --out with an existing parent.`);let i=new TDe.ZipFile,a=Z9(t.stagingDir);for(let e of a){let n=$9(t.stagingDir,e);i.addFile(e,n)}i.end();let o=h(n);return i.outputStream.pipe(o),await new Promise((e,t)=>{o.on(`close`,e),o.on(`error`,t),i.outputStream.on(`error`,t)}),n}function tFe(e,t){let n=j(e,`.ok`,`config.yml`);if(g(n))try{let t=(0,xs.parse)(S(n,`utf-8`)),r=dY(t)?t.content:void 0,i=dY(r)?r.dir:void 0;if(typeof i==`string`&&i.length>0)return N(e,i)}catch(e){t?.warn({configPath:n,err:e},`bug-report: failed to read .ok/config.yml; falling back to project root as content dir`)}return N(e)}async function nFe(e,t,n,r,i,a){let o=w7(t,e.logger),s=await $Pe({contentDir:tFe(t,e.logger),projectDir:t,redact:e.redact,scrubSecrets:e.redact,note:e.note,extraFiles:e.extraFiles,userLogFiles:[...fNe(o,e.userLogsDir??j(RJ(),`logs`)),...E7(e.cachesDir??j(_e(),`Library`,`Caches`))],userStateFiles:D7(e.bugReportsDir??S7()),diagnosticReports:i,osTerminationEvidence:a,deps:{readDesktopEnv:n,readLanguage:r,logger:e.logger}});try{v(k(e.outputPath),{recursive:!0}),await eFe({collected:s,outputPath:e.outputPath});let t=s.manifest.redaction.secretScrub;return{zipPath:e.outputPath,summary:{level:`full`,systemWide:!1,projectSlug:o,files:s.manifest.files.map(e=>e.path),redactions:t?.redactions??[],redactedLineCount:t?.redactedLineCount??0,generatedAt:s.manifest.createdAt}}}finally{s.cleanup()}}async function rFe(e){let{projectDir:t}=e,n=e.readDesktopEnv??G9,r=e.readLanguage??E9,i=()=>RMe(e.diagnosticReportsDir??j(_e(),`Library`,`Logs`,`DiagnosticReports`),new Date);if(e.level===`full`&&t!==void 0)return nFe(e,t,n,r,i(),await b7(e.osTerminationEvidenceDeps));let{zipPath:a,summary:o}=await _Ne({projectDir:t,redact:e.redact,revealDocNames:e.level===`full`,outputPath:e.outputPath,userLogsDir:e.userLogsDir,shipItLogFiles:E7(e.cachesDir??j(_e(),`Library`,`Caches`)),bugReportLedgerFiles:D7(e.bugReportsDir??S7()),diagnosticReports:e.level===`full`?i():void 0,osTerminationEvidence:e.level===`full`?await b7(e.osTerminationEvidenceDeps):void 0,logger:e.logger,note:e.note,extraFiles:e.extraFiles,desktop:n(),language:r()});return{zipPath:a,summary:{level:e.level,systemWide:t===void 0,projectSlug:o.projectSlug,files:o.files,redactions:o.redactions,redactedLineCount:o.redactedLineCount,generatedAt:o.generatedAt}}}export{vY as ALL_EDITOR_IDS,yY as EDITOR_LABELS,$Y as EDITOR_TARGETS,Mbe as HOSTS_WITH_USER_SKILL_DIR,EMe as LAUNCH_CONFIG_NAME,sPe as PATH_SHIM_BEGIN,lPe as PATH_SHIM_BLOCK_RE,cPe as PATH_SHIM_END,u5 as ProjectPathSafetyError,rMe as addOkPathsToGitExclude,d5 as assertProjectPathSafe,PY as buildManagedServerEntry,XNe as buildMcpConfigDeclineEvent,ZNe as buildMcpConfigMigrateEvent,WY as canonicalEntryFor,q5 as classifyExistingMcpEntry,rFe as collectReportBundle,mPe as createCliProbeResolver,ZJ as createTokenStore,lNe as defaultBugReportZipPath,Ke as detectGh,Ye as detectGhAccounts,AMe as detectInstalledEditors,UY as droppedManagedKeys,$be as editorConfigPathDisplay,Qbe as editorEntryLocator,zNe as ensurePiBridge,WMe as findJetsamKillSync,T5 as formatTrackedRemediation,oMe as getExcludedOkPaths,C5 as getInstalledSkillProjectionPaths,jbe as getNativeTomlMcpEditor,S5 as getOkArtifactPaths,MY as isEntryUpToDate,FY as isOwnManagedEntry,iPe as loadConfig,rbe as makeLazyProbeTokenStore,S7 as okBugReportsDir,v9 as parseGitHubBlobUrl,aPe as parseGitHubShareUrl,y9 as parseGitHubTreeUrl,_9 as parseGitUrl,uPe as pathInstallMarkerPath,Hje as previewContent,jMe as probeOwnManagedEditorMcpEntry,LNe as probePiBridgeState,w5 as probeTrackedOkPaths,G5 as readExistingMcpEntry,aMe as readSharingMode,BP as redactContent,iMe as removeOkPathsFromGitExclude,KNe as removeOwnMcpEntry,$je as removeProjectSkill,gPe as removeUserGlobalSkillBundle,SPe as removeUserSkill,qje as resolveProjectRoot,tPe as runStop,p9 as truncatePriorEntry,w9 as userGlobalSkillBundleTargets,xPe as userSkillPresentAnywhere,oPe as validateLocalFolderForShare,W5 as writeEditorMcpConfig,yPe as writeProjectAiIntegrations,_5 as writeProjectSkill,kMe as writeUserMcpConfigs,bPe as writeUserSkill};
|
|
1555
1555
|
//# sourceMappingURL=index.mjs.map
|