@inkeep/open-knowledge 0.11.0 → 0.11.1-beta.0
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/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +8 -8
- package/dist/config-schema.json +9 -0
- package/dist/config.project-local.schema.json +9 -0
- package/dist/constants-BLJc6MOZ.mjs +2 -0
- package/dist/{dist-PzyBKLCf.mjs → dist-B2QcMC3d.mjs} +1 -1
- package/dist/{dist-9gkYdouR.mjs → dist-Bms63Kbz.mjs} +11 -11
- package/dist/{gh-detect-BiKqq3fe.mjs → gh-detect-TiuAfW0N.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{init-DTN3nfbv.mjs → init-ClLEt0k7.mjs} +4 -4
- package/dist/init-YGnAcdfz.mjs +1 -0
- package/dist/loader-DvqvLN6q.mjs +1 -0
- package/dist/{loader-C0hzrFB3.mjs → loader-x4Hpo3YH.mjs} +2 -2
- package/dist/preview-DUXc51R-.mjs +1 -0
- package/dist/{preview-8OV1Kc4m.mjs → preview-slpAYVBO.mjs} +2 -2
- package/dist/public/assets/{ActivityModeContent-BsurnqDs.js → ActivityModeContent-Dv5Y8bcN.js} +1 -1
- package/dist/public/assets/{DocumentContext-ywaSbgZy.js → DocumentContext-CGZbRc-L.js} +2 -2
- package/dist/public/assets/{GraphPanel-DACQCEp9.js → GraphPanel-DLvT2Kzo.js} +1 -1
- package/dist/public/assets/SettingsDialogBody-Vak-yX1q.js +7 -0
- package/dist/public/assets/{SourceEditor-CPUnHIDu.js → SourceEditor-BhyrFsfA.js} +1 -1
- package/dist/public/assets/{agent-presence-DxGcS3q2.js → agent-presence-B9GoWq0r.js} +1 -1
- package/dist/public/assets/{config-validation-events-Dtuvx7eU.js → config-validation-events-BmFSWND9.js} +6 -6
- package/dist/public/assets/{index-D3rLIkvo.js → index-Cq-7omOp.js} +84 -84
- package/dist/public/assets/{keyboard-shortcuts-BtfhTJ-K.js → keyboard-shortcuts-BgxXrRkA.js} +1 -1
- package/dist/public/assets/{prop-types-BLvAnH2n.js → prop-types-CKBOLBuy.js} +2 -2
- package/dist/public/assets/{target-navigation-intent-BUfApF6Q.js → target-navigation-intent-J4G_G74p.js} +1 -1
- package/dist/public/assets/{telemetry-impl-aspahMYR.js → telemetry-impl-l-VsaBiG.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-BjfA2X2R.js → typing-burst-detector-DTgHmtHd.js} +1 -1
- package/dist/public/index.html +8 -8
- package/dist/{repair-launch-json-FQjShJhA.mjs → repair-launch-json-BKtGkB0B.mjs} +2 -2
- package/dist/{repair-mcp-configs-DnsD7NrD.mjs → repair-mcp-configs-Hd_Owqnp.mjs} +2 -2
- package/dist/{repair-skills--P4hyOt3.mjs → repair-skills-B9dEoHjt.mjs} +2 -2
- package/dist/repair-skills-BsQTjR1m.mjs +1 -0
- package/dist/schemas/v0/config.project-local.schema.json +9 -0
- package/dist/{server-lock-BpjJj3OD-CGDmzK2V.mjs → server-lock-BpjJj3OD-CfUjMF3O.mjs} +3 -3
- package/dist/server-lock-CyhBidkz-D9A193jJ.mjs +1 -0
- package/dist/{src-DvKnRm2f.mjs → src-Lw06Pp2P.mjs} +2 -2
- package/dist/{start-DEFyhc0J.mjs → start-BOWAtuDV.mjs} +2 -2
- package/dist/start-Clj6qMIe.mjs +1 -0
- package/dist/{write-project-skill-DozAMZpM.mjs → write-project-skill-CoFl-uBP.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CaDA1CnW.mjs +0 -2
- package/dist/init-Brz9U_8C.mjs +0 -1
- package/dist/loader-p0Oq4pHG.mjs +0 -1
- package/dist/preview-DZTHkwzi.mjs +0 -1
- package/dist/public/assets/SettingsDialogBody-m4zzZa4Q.js +0 -7
- package/dist/repair-skills-BQA-lmTE.mjs +0 -1
- package/dist/server-lock-CyhBidkz-CrazWnBM.mjs +0 -1
- package/dist/start-B1nVQCdb.mjs +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as e}from"./esm-CEs3LWY3.mjs";import{Er as t,Mr as n,Pi as r,Sr as i,vr as a}from"./dist-
|
|
1
|
+
import{t as e}from"./esm-CEs3LWY3.mjs";import{Er as t,Mr as n,Pi as r,Sr as i,vr as a}from"./dist-Bms63Kbz.mjs";import{t as o}from"./write-project-skill-CoFl-uBP.mjs";import{existsSync as s,mkdirSync as c,readFileSync as l,readdirSync as u,rmSync as d,statSync as f,writeFileSync as p}from"node:fs";import{dirname as m,join as h,resolve as g}from"node:path";import{homedir as _}from"node:os";const v=[{hostDir:`.claude`,editorId:`claude`},{hostDir:`.cursor`,editorId:`cursor`},{hostDir:`.agents`,editorId:`codex`}],y=`open-knowledge-discovery`,b=[`.agents`,`skills`,y],x={existsSync:e=>s(e),isDirectory:e=>{try{return f(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>u(e),readFileSync:e=>l(e),writeFileSync:(e,t)=>{p(e,t)},mkdirSync:(e,t)=>{c(e,t)},rmSync:(e,t)=>{d(e,t)}},S={resolveProjectBundledSkillDir:()=>n(`project`,{checkDesktop:!1}),resolveDiscoveryBundledSkillDir:()=>n(`discovery`,{checkDesktop:!1}),readBundledVersion:()=>a(),readRecordedVersion:e=>i(e,`cli-hosts`),writeRecordedVersion:(e,t)=>r(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e)};function C(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function w(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(m(t),{recursive:!0}),T(e,t,n)}function T(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=h(e,r),a=h(t,r);n.isDirectory(i)?T(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function E(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of v){let s=h(e,t.hostDir,`skills`,`open-knowledge`),c=h(s,`SKILL.md`);if(!n.existsSync(c)){a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:s});continue}try{o(s,e),w(i,s,n),a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`reclaimed`}),r({event:`project-skill-reclaim-reclaimed`,scope:`project`,editorId:t.editorId,path:s})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:s,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:s,error:n})}}return{outcome:`done`,entries:a}}async function D(e,t,n,r){let i=e=>{t.recordEvent(e).catch(()=>{})},a=()=>new Date().toISOString(),o;try{o=await t.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let s;try{s=await t.readRecordedVersion(e)}catch(e){r({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),s=null}if(s!==null&&s===o)return r({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:o}),{outcome:`skipped`,reason:`version-current`};let c;try{c=t.resolveDiscoveryBundledSkillDir()}catch(e){let t=e instanceof Error?e.message:String(e);return r({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:t}),i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`bundle-missing:${t}`}),{outcome:`skipped`,reason:`bundle-missing`}}let l=[],u=h(e,...b),d=n.existsSync(u);try{w(c,u,n),l.push({kind:`central`,path:u,outcome:d?`overwritten`:`written`}),r({event:`user-skill-reclaim-central-written`,scope:`user`,path:u,preexisting:d,version:o})}catch(e){let t=e instanceof Error?e.message:String(e);l.push({kind:`central`,path:u,outcome:`failed`,error:t}),r({event:`user-skill-reclaim-central-failed`,scope:`user`,path:u,error:t})}for(let t of v){let i=h(e,t.hostDir),a=h(i,`skills`,y);if(a===u){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-collapsed-with-central`});continue}if(!n.existsSync(i)){l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`skipped-host-absent`});continue}let s=n.existsSync(a);try{w(c,a,n),l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:s?`overwritten`:`written`}),r({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,preexisting:s,version:o})}catch(e){let n=e instanceof Error?e.message:String(e);l.push({kind:`host`,editorId:t.editorId,hostDir:t.hostDir,path:a,outcome:`failed`,error:n}),r({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:t.editorId,hostDir:t.hostDir,path:a,error:n})}}let f=l.find(e=>e.kind===`central`);if(f?.outcome===`written`||f?.outcome===`overwritten`){let n=null;try{await t.writeRecordedVersion(e,o),r({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:o})}catch(e){n=e instanceof Error?e.message:String(e),r({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:o,error:n})}i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:n===null?`installed`:`failed`,version:o,...n===null?{}:{reason:`state-write-failed:${n}`}})}else{let e=l.some(e=>e.kind===`host`&&e.outcome===`failed`);i({ts:a(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,version:o,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:o,entries:l}}async function O(e){let t=e.logger??C,n=e.fs??x,r=e.home??_(),i={...S,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:E(e.projectDir,i,n,t),user:await D(r,i,n,t)}}function k(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function A(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`no-token`).length,i=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} no-token, ${i} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
|
|
2
2
|
`)}function j(){return new e(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await O({projectDir:g(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${A(e)}\n`),process.exitCode=k(e)})}export{j as n,O as t};
|
|
3
|
-
//# sourceMappingURL=repair-skills
|
|
3
|
+
//# sourceMappingURL=repair-skills-B9dEoHjt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-B9dEoHjt.mjs";export{e as repairSkills};
|
|
@@ -109,6 +109,15 @@
|
|
|
109
109
|
"agentSettable": false,
|
|
110
110
|
"defaultScope": "project-local",
|
|
111
111
|
"description": "Optional output vector dimensions. Omit to use the model's native size (1536 for text-embedding-3-small). Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality. Changing it re-embeds the corpus."
|
|
112
|
+
},
|
|
113
|
+
"similarityFloor": {
|
|
114
|
+
"type": "number",
|
|
115
|
+
"minimum": 0,
|
|
116
|
+
"maximum": 1,
|
|
117
|
+
"scope": "project-local",
|
|
118
|
+
"agentSettable": false,
|
|
119
|
+
"defaultScope": "project-local",
|
|
120
|
+
"description": "Optional hard cutoff: drop any \"by meaning\" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap."
|
|
112
121
|
}
|
|
113
122
|
},
|
|
114
123
|
"additionalProperties": {}
|
|
@@ -151,7 +151,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
151
151
|
|
|
152
152
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=jt,s=!gt.jitless,c=s&&Mt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ii([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function si(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!qt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Xt(e,r,_t())))}),t)}const ci=D(`$ZodUnion`,(e,t)=>{vr.init(e,t),Tt(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Tt(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Tt(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Tt(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>St(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>si(t,i,e,a)):si(s,i,e,a)}}),li=D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ci.init(e,t);let n=e._zod.parse;Tt(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=bt(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!jt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),ui=D(`$ZodIntersection`,(e,t)=>{vr.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>fi(e,t,n)):fi(e,i,a)}});function di(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Nt(e)&&Nt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=di(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=di(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function fi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),qt(e))return e;let o=di(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const pi=D(`$ZodRecord`,(e,t)=>{vr.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Nt(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Jt(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Jt(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Jn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Xt(e,r,_t())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Jt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Jt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),mi=D(`$ZodEnum`,(e,t)=>{vr.init(e,t);let n=vt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ft.has(typeof e)).map(e=>typeof e==`string`?It(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),hi=D(`$ZodLiteral`,(e,t)=>{if(vr.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?It(e):e?It(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),gi=D(`$ZodTransform`,(e,t)=>{vr.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ht(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new mt;return n.value=i,n}});function _i(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const vi=D(`$ZodOptional`,(e,t)=>{vr.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Tt(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Tt(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${St(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>_i(t,e.value)):_i(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),yi=D(`$ZodExactOptional`,(e,t)=>{vi.init(e,t),Tt(e._zod,`values`,()=>t.innerType._zod.values),Tt(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),bi=D(`$ZodNullable`,(e,t)=>{vr.init(e,t),Tt(e._zod,`optin`,()=>t.innerType._zod.optin),Tt(e._zod,`optout`,()=>t.innerType._zod.optout),Tt(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${St(e.source)}|null)$`):void 0}),Tt(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),xi=D(`$ZodDefault`,(e,t)=>{vr.init(e,t),e._zod.optin=`optional`,Tt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Si(e,t)):Si(r,t)}});function Si(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ci=D(`$ZodPrefault`,(e,t)=>{vr.init(e,t),e._zod.optin=`optional`,Tt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),wi=D(`$ZodNonOptional`,(e,t)=>{vr.init(e,t),Tt(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ti(t,e)):Ti(i,e)}});function Ti(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Ei=D(`$ZodCatch`,(e,t)=>{vr.init(e,t),Tt(e._zod,`optin`,()=>t.innerType._zod.optin),Tt(e._zod,`optout`,()=>t.innerType._zod.optout),Tt(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Xt(e,n,_t()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Xt(e,n,_t()))},input:e.value}),e.issues=[]),e)}}),Di=D(`$ZodPipe`,(e,t)=>{vr.init(e,t),Tt(e._zod,`values`,()=>t.in._zod.values),Tt(e._zod,`optin`,()=>t.in._zod.optin),Tt(e._zod,`optout`,()=>t.out._zod.optout),Tt(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Oi(e,t.in,n)):Oi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Oi(e,t.out,n)):Oi(r,t.out,n)}});function Oi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ki=D(`$ZodReadonly`,(e,t)=>{vr.init(e,t),Tt(e._zod,`propValues`,()=>t.innerType._zod.propValues),Tt(e._zod,`values`,()=>t.innerType._zod.values),Tt(e._zod,`optin`,()=>t.innerType?._zod?.optin),Tt(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ai):Ai(r)}});function Ai(e){return e.value=Object.freeze(e.value),e}const ji=D(`$ZodCustom`,(e,t)=>{$n.init(e,t),vr.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Mi(t,n,r,e));Mi(i,n,r,e)}});function Mi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Qt(e))}}var Ni,Pi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Fi(){return new Pi}(Ni=globalThis).__zod_globalRegistry??(Ni.__zod_globalRegistry=Fi());const Ii=globalThis.__zod_globalRegistry;function Li(e,t){return new e({type:`string`,...O(t)})}function Ri(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...O(t)})}function zi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...O(t)})}function Bi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...O(t)})}function Vi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...O(t)})}function Hi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...O(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...O(t)})}function Wi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...O(t)})}function Gi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...O(t)})}function Ki(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...O(t)})}function qi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...O(t)})}function Ji(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...O(t)})}function Yi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...O(t)})}function Xi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...O(t)})}function Zi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...O(t)})}function Qi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...O(t)})}function $i(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...O(t)})}function ea(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...O(t)})}function ta(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...O(t)})}function na(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...O(t)})}function ra(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...O(t)})}function ia(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...O(t)})}function aa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...O(t)})}function oa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...O(t)})}function sa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...O(t)})}function ca(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...O(t)})}function la(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...O(t)})}function ua(e,t){return new e({type:`number`,checks:[],...O(t)})}function da(e,t){return new e({type:`number`,coerce:!0,checks:[],...O(t)})}function fa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...O(t)})}function pa(e,t){return new e({type:`boolean`,...O(t)})}function ma(e,t){return new e({type:`null`,...O(t)})}function ha(e){return new e({type:`any`})}function ga(e){return new e({type:`unknown`})}function _a(e,t){return new e({type:`never`,...O(t)})}function va(e,t){return new tr({check:`less_than`,...O(t),value:e,inclusive:!1})}function ya(e,t){return new tr({check:`less_than`,...O(t),value:e,inclusive:!0})}function ba(e,t){return new nr({check:`greater_than`,...O(t),value:e,inclusive:!1})}function xa(e,t){return new nr({check:`greater_than`,...O(t),value:e,inclusive:!0})}function Sa(e,t){return new rr({check:`multiple_of`,...O(t),value:e})}function Ca(e,t){return new ar({check:`max_length`,...O(t),maximum:e})}function wa(e,t){return new or({check:`min_length`,...O(t),minimum:e})}function Ta(e,t){return new sr({check:`length_equals`,...O(t),length:e})}function Ea(e,t){return new lr({check:`string_format`,format:`regex`,...O(t),pattern:e})}function Da(e){return new ur({check:`string_format`,format:`lowercase`,...O(e)})}function Oa(e){return new dr({check:`string_format`,format:`uppercase`,...O(e)})}function ka(e,t){return new fr({check:`string_format`,format:`includes`,...O(t),includes:e})}function Aa(e,t){return new pr({check:`string_format`,format:`starts_with`,...O(t),prefix:e})}function ja(e,t){return new mr({check:`string_format`,format:`ends_with`,...O(t),suffix:e})}function Ma(e){return new hr({check:`overwrite`,tx:e})}function Na(e){return Ma(t=>t.normalize(e))}function Pa(){return Ma(e=>e.trim())}function Fa(){return Ma(e=>e.toLowerCase())}function Ia(){return Ma(e=>e.toUpperCase())}function La(){return Ma(e=>kt(e))}function Ra(e,t,n){return new e({type:`array`,element:t,...O(n)})}function za(e,t,n){let r=O(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Ba(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...O(n)})}function Va(e){let t=Ha(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Qt(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Qt(r))}},e(n.value,n)));return t}function Ha(e,t){let n=new $n({check:`custom`,...O(t)});return n._zod.check=e,n}function Ua(e){let t=new $n({check:`describe`});return t._zod.onattach=[t=>{let n=Ii.get(t)??{};Ii.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function Wa(e){let t=new $n({check:`meta`});return t._zod.onattach=[t=>{let n=Ii.get(t)??{};Ii.add(t,{...n,...e})}],t._zod.check=()=>{},t}function Ga(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Ii,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Ka(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ka(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ya(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function qa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
153
153
|
|
|
154
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ja(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Za(t,`input`,e.processors),output:Za(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ya(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ya(r.element,n);if(r.type===`set`)return Ya(r.valueType,n);if(r.type===`lazy`)return Ya(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Ya(r.innerType,n);if(r.type===`intersection`)return Ya(r.left,n)||Ya(r.right,n);if(r.type===`record`||r.type===`map`)return Ya(r.keyType,n)||Ya(r.valueType,n);if(r.type===`pipe`)return Ya(r.in,n)||Ya(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ya(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ya(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ya(e,n))return!0;return!!(r.rest&&Ya(r.rest,n))}return!1}const Xa=(e,t={})=>n=>{let r=Ga({...n,processors:t});return Ka(e,r),qa(r,e),Ja(r,e)},Za=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ga({...i??{},target:a,io:t,processors:n});return Ka(e,o),qa(o,e),Ja(o,e)},Qa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$a=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qa[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},eo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},to=(e,t,n,r)=>{n.type=`boolean`},no=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},io=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ao=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{n.not={}},co=(e,t,n,r)=>{},lo=(e,t,n,r)=>{},uo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},fo=(e,t,n,r)=>{let i=e._zod.def,a=vt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},po=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},go=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},_o=(e,t,n,r)=>{n.type=`boolean`},vo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},bo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ka(a.element,t,{...r,path:[...r.path,`items`]})},wo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ka(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ka(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},To=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ka(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Eo=(e,t,n,r)=>{let i=e._zod.def,a=Ka(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ka(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Do=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Ka(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ka(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Oo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ka(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ka(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ka(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ko=(e,t,n,r)=>{let i=e._zod.def,a=Ka(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ao=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Mo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},No=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Po=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Ka(a,t,r);let o=t.seen.get(e);o.ref=a},Fo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Io=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Lo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ro={string:$a,number:eo,boolean:to,bigint:no,symbol:ro,null:io,undefined:ao,void:oo,never:so,any:co,unknown:lo,date:uo,enum:fo,literal:po,nan:mo,template_literal:ho,file:go,success:_o,custom:vo,function:yo,transform:bo,map:xo,set:So,array:Co,object:wo,union:To,intersection:Eo,tuple:Do,record:Oo,nullable:ko,nonoptional:Ao,default:jo,prefault:Mo,catch:No,pipe:Po,readonly:Fo,promise:Io,optional:Lo,lazy:(e,t,n,r)=>{let i=e._zod.innerType;Ka(i,t,r);let a=t.seen.get(e);a.ref=i}};function zo(e,t){if(`_idmap`in e){let n=e,r=Ga({...t,processors:Ro}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Ka(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;qa(r,n),a[t]=Ja(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ga({...t,processors:Ro});return Ka(e,n),qa(n,e),Ja(n,e)}const Bo=D(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),fs.init(e,t)});function Vo(e){return oa(Bo,e)}const Ho=D(`ZodISODate`,(e,t)=>{Nr.init(e,t),fs.init(e,t)});function Uo(e){return sa(Ho,e)}const Wo=D(`ZodISOTime`,(e,t)=>{Pr.init(e,t),fs.init(e,t)});function Go(e){return ca(Wo,e)}const Ko=D(`ZodISODuration`,(e,t)=>{Fr.init(e,t),fs.init(e,t)});function qo(e){return la(Ko,e)}const Jo=(e,t)=>{en.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rn(e,t)},flatten:{value:t=>nn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,yt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,yt,2)}},isEmpty:{get(){return e.issues.length===0}}})};D(`ZodError`,Jo);const Yo=D(`ZodError`,Jo,{Parent:Error}),Xo=sn(Yo),Zo=ln(Yo),Qo=dn(Yo),$o=pn(Yo),es=hn(Yo),ts=gn(Yo),ns=_n(Yo),rs=vn(Yo),is=yn(Yo),as=bn(Yo),ss=xn(Yo),cs=Sn(Yo),ls=D(`ZodType`,(e,t)=>(vr.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Za(e,`input`),output:Za(e,`output`)}}),e.toJSONSchema=Xa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Dt(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Lt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Xo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Qo(e,t,n),e.parseAsync=async(t,n)=>Zo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>$o(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>es(e,t,n),e.decode=(t,n)=>ts(e,t,n),e.encodeAsync=async(t,n)=>ns(e,t,n),e.decodeAsync=async(t,n)=>rs(e,t,n),e.safeEncode=(t,n)=>is(e,t,n),e.safeDecode=(t,n)=>as(e,t,n),e.safeEncodeAsync=async(t,n)=>ss(e,t,n),e.safeDecodeAsync=async(t,n)=>cs(e,t,n),e.refine=(t,n)=>e.check(Ec(t,n)),e.superRefine=t=>e.check(Dc(t)),e.overwrite=t=>e.check(Ma(t)),e.optional=()=>sc(e),e.exactOptional=()=>lc(e),e.nullable=()=>dc(e),e.nullish=()=>sc(dc(e)),e.nonoptional=t=>_c(e,t),e.array=()=>M(e),e.or=t=>Ys([e,t]),e.and=t=>$s(e,t),e.transform=t=>xc(e,ac(t)),e.default=t=>pc(e,t),e.prefault=t=>hc(e,t),e.catch=t=>yc(e,t),e.pipe=t=>xc(e,t),e.readonly=()=>Cc(e),e.describe=t=>{let n=e.clone();return Ii.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Ii.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Ii.get(e);let n=e.clone();return Ii.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),us=D(`_ZodString`,(e,t)=>{yr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ea(...t)),e.includes=(...t)=>e.check(ka(...t)),e.startsWith=(...t)=>e.check(Aa(...t)),e.endsWith=(...t)=>e.check(ja(...t)),e.min=(...t)=>e.check(wa(...t)),e.max=(...t)=>e.check(Ca(...t)),e.length=(...t)=>e.check(Ta(...t)),e.nonempty=(...t)=>e.check(wa(1,...t)),e.lowercase=t=>e.check(Da(t)),e.uppercase=t=>e.check(Oa(t)),e.trim=()=>e.check(Pa()),e.normalize=(...t)=>e.check(Na(...t)),e.toLowerCase=()=>e.check(Fa()),e.toUpperCase=()=>e.check(Ia()),e.slugify=()=>e.check(La())}),ds=D(`ZodString`,(e,t)=>{yr.init(e,t),us.init(e,t),e.email=t=>e.check(Ri(ps,t)),e.url=t=>e.check(Wi(gs,t)),e.jwt=t=>e.check(aa(Ms,t)),e.emoji=t=>e.check(Gi(vs,t)),e.guid=t=>e.check(zi(ms,t)),e.uuid=t=>e.check(Bi(hs,t)),e.uuidv4=t=>e.check(Vi(hs,t)),e.uuidv6=t=>e.check(Hi(hs,t)),e.uuidv7=t=>e.check(Ui(hs,t)),e.nanoid=t=>e.check(Ki(ys,t)),e.guid=t=>e.check(zi(ms,t)),e.cuid=t=>e.check(qi(bs,t)),e.cuid2=t=>e.check(Ji(xs,t)),e.ulid=t=>e.check(Yi(Ss,t)),e.base64=t=>e.check(na(ks,t)),e.base64url=t=>e.check(ra(As,t)),e.xid=t=>e.check(Xi(Cs,t)),e.ksuid=t=>e.check(Zi(ws,t)),e.ipv4=t=>e.check(Qi(Ts,t)),e.ipv6=t=>e.check($i(Es,t)),e.cidrv4=t=>e.check(ea(Ds,t)),e.cidrv6=t=>e.check(ta(Os,t)),e.e164=t=>e.check(ia(js,t)),e.datetime=t=>e.check(Vo(t)),e.date=t=>e.check(Uo(t)),e.time=t=>e.check(Go(t)),e.duration=t=>e.check(qo(t))});function k(e){return Li(ds,e)}const fs=D(`ZodStringFormat`,(e,t)=>{br.init(e,t),us.init(e,t)}),ps=D(`ZodEmail`,(e,t)=>{Cr.init(e,t),fs.init(e,t)}),ms=D(`ZodGUID`,(e,t)=>{xr.init(e,t),fs.init(e,t)}),hs=D(`ZodUUID`,(e,t)=>{Sr.init(e,t),fs.init(e,t)}),gs=D(`ZodURL`,(e,t)=>{wr.init(e,t),fs.init(e,t)});function _s(e){return Wi(gs,e)}const vs=D(`ZodEmoji`,(e,t)=>{Tr.init(e,t),fs.init(e,t)}),ys=D(`ZodNanoID`,(e,t)=>{Er.init(e,t),fs.init(e,t)}),bs=D(`ZodCUID`,(e,t)=>{Dr.init(e,t),fs.init(e,t)}),xs=D(`ZodCUID2`,(e,t)=>{Or.init(e,t),fs.init(e,t)}),Ss=D(`ZodULID`,(e,t)=>{kr.init(e,t),fs.init(e,t)}),Cs=D(`ZodXID`,(e,t)=>{Ar.init(e,t),fs.init(e,t)}),ws=D(`ZodKSUID`,(e,t)=>{jr.init(e,t),fs.init(e,t)}),Ts=D(`ZodIPv4`,(e,t)=>{Ir.init(e,t),fs.init(e,t)}),Es=D(`ZodIPv6`,(e,t)=>{Lr.init(e,t),fs.init(e,t)}),Ds=D(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),fs.init(e,t)}),Os=D(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),fs.init(e,t)}),ks=D(`ZodBase64`,(e,t)=>{Vr.init(e,t),fs.init(e,t)}),As=D(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),fs.init(e,t)}),js=D(`ZodE164`,(e,t)=>{Wr.init(e,t),fs.init(e,t)}),Ms=D(`ZodJWT`,(e,t)=>{Kr.init(e,t),fs.init(e,t)}),Ns=D(`ZodNumber`,(e,t)=>{qr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.gt=(t,n)=>e.check(ba(t,n)),e.gte=(t,n)=>e.check(xa(t,n)),e.min=(t,n)=>e.check(xa(t,n)),e.lt=(t,n)=>e.check(va(t,n)),e.lte=(t,n)=>e.check(ya(t,n)),e.max=(t,n)=>e.check(ya(t,n)),e.int=t=>e.check(Fs(t)),e.safe=t=>e.check(Fs(t)),e.positive=t=>e.check(ba(0,t)),e.nonnegative=t=>e.check(xa(0,t)),e.negative=t=>e.check(va(0,t)),e.nonpositive=t=>e.check(ya(0,t)),e.multipleOf=(t,n)=>e.check(Sa(t,n)),e.step=(t,n)=>e.check(Sa(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function A(e){return ua(Ns,e)}const Ps=D(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Ns.init(e,t)});function Fs(e){return fa(Ps,e)}const Is=D(`ZodBoolean`,(e,t)=>{Yr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r)});function j(e){return pa(Is,e)}const Ls=D(`ZodNull`,(e,t)=>{Xr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r)});function Rs(e){return ma(Ls,e)}const zs=D(`ZodAny`,(e,t)=>{Zr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bs(){return ha(zs)}const Vs=D(`ZodUnknown`,(e,t)=>{Qr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Hs(){return ga(Vs)}const Us=D(`ZodNever`,(e,t)=>{$r.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r)});function Ws(e){return _a(Us,e)}const Gs=D(`ZodArray`,(e,t)=>{ti.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(wa(t,n)),e.nonempty=t=>e.check(wa(1,t)),e.max=(t,n)=>e.check(Ca(t,n)),e.length=(t,n)=>e.check(Ta(t,n)),e.unwrap=()=>e.element});function M(e,t){return Ra(Gs,e,t)}const Ks=D(`ZodObject`,(e,t)=>{oi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),Tt(e,`shape`,()=>t.shape),e.keyof=()=>P(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Hs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Hs()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ws()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ht(e,t),e.safeExtend=t=>Ut(e,t),e.merge=t=>Wt(e,t),e.pick=t=>Bt(e,t),e.omit=t=>Vt(e,t),e.partial=(...t)=>Gt(oc,e,t[0]),e.required=(...t)=>Kt(gc,e,t[0])});function N(e,t){return new Ks({type:`object`,shape:e??{},...O(t)})}function qs(e,t){return new Ks({type:`object`,shape:e,catchall:Hs(),...O(t)})}const Js=D(`ZodUnion`,(e,t)=>{ci.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.options=t.options});function Ys(e,t){return new Js({type:`union`,options:e,...O(t)})}const Xs=D(`ZodDiscriminatedUnion`,(e,t)=>{Js.init(e,t),li.init(e,t)});function Zs(e,t,n){return new Xs({type:`union`,options:t,discriminator:e,...O(n)})}const Qs=D(`ZodIntersection`,(e,t)=>{ui.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r)});function $s(e,t){return new Qs({type:`intersection`,left:e,right:t})}const ec=D(`ZodRecord`,(e,t)=>{pi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function tc(e,t,n){return new ec({type:`record`,keyType:e,valueType:t,...O(n)})}const nc=D(`ZodEnum`,(e,t)=>{mi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new nc({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new nc({...t,checks:[],...O(r),entries:i})}});function P(e,t){return new nc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...O(t)})}const rc=D(`ZodLiteral`,(e,t)=>{hi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function F(e,t){return new rc({type:`literal`,values:Array.isArray(e)?e:[e],...O(t)})}const ic=D(`ZodTransform`,(e,t)=>{gi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Qt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Qt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ac(e){return new ic({type:`transform`,transform:e})}const oc=D(`ZodOptional`,(e,t)=>{vi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sc(e){return new oc({type:`optional`,innerType:e})}const cc=D(`ZodExactOptional`,(e,t)=>{yi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new cc({type:`optional`,innerType:e})}const uc=D(`ZodNullable`,(e,t)=>{bi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`nullable`,innerType:e})}const fc=D(`ZodDefault`,(e,t)=>{xi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pc(e,t){return new fc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const mc=D(`ZodPrefault`,(e,t)=>{Ci.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e,t){return new mc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const gc=D(`ZodNonOptional`,(e,t)=>{wi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _c(e,t){return new gc({type:`nonoptional`,innerType:e,...O(t)})}const vc=D(`ZodCatch`,(e,t)=>{Ei.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yc(e,t){return new vc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const bc=D(`ZodPipe`,(e,t)=>{Di.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.in=t.in,e.out=t.out});function xc(e,t){return new bc({type:`pipe`,in:e,out:t})}const Sc=D(`ZodReadonly`,(e,t)=>{ki.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cc(e){return new Sc({type:`readonly`,innerType:e})}const wc=D(`ZodCustom`,(e,t)=>{ji.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Tc(e,t){return za(wc,e??(()=>!0),t)}function Ec(e,t={}){return Ba(wc,e,t)}function Dc(e){return Va(e)}function Oc(e,t){return xc(ac(e),t)}var kc=ft();a();const Ac=Symbol.for(`@inkeep/open-knowledge/field-registry`),jc=globalThis;jc[Ac]===void 0&&(jc[Ac]=Fi());const Mc=jc[Ac];function Nc(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Pc(t)?Mc.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Pc(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const Fc=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Ic=52428800,Lc=26214400,Rc=`https://api.openai.com/v1`,zc=`text-embedding-3-small`,Bc=qs({content:qs({dir:k().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Folder Open Knowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore.`}).default(`.`)}).default({dir:`.`}),appearance:qs({theme:P([`light`,`dark`,`system`]).register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),preview:qs({autoOpen:j().register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:qs({showHiddenFiles:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showAllFiles:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show every file, including those excluded by .gitignore / .okignore. Per-machine (project-local) — not shared.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:qs({wordWrap:j().register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0}),autoSync:qs({enabled:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Whether this machine auto-pulls and auto-pushes git commits for this project. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared.`}).nullable().default(null)}).default({enabled:null}),telemetry:qs({localSink:qs({enabled:j().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:qs({maxBytes:A().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(Ic)}).default({maxBytes:Ic}),logs:qs({maxBytes:A().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Lc)}).default({maxBytes:Lc}),attributeDenylist:M(k()).register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...Fc])}).default({enabled:!0,spans:{maxBytes:Ic},logs:{maxBytes:Lc},attributeDenylist:[...Fc]})}).default({localSink:{enabled:!0,spans:{maxBytes:Ic},logs:{maxBytes:Lc},attributeDenylist:[...Fc]}}),search:qs({semantic:qs({enabled:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:k().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override for Azure / self-hosted / other providers. The API key is NOT stored here — set it with `ok embeddings set-key` (OS keyring)."}).default(Rc),model:k().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(zc),dimensions:A().int().positive().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit to use the model's native size (1536 for text-embedding-3-small). Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality. Changing it re-embeds the corpus.`}).optional()}).default({enabled:!1,baseUrl:Rc,model:zc})}).default({semantic:{enabled:!1,baseUrl:Rc,model:zc}})}),Vc=`open-knowledge-config`;async function Hc(e,t,n){let r=o.getTracer(Vc),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,async e=>{try{return await n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Uc(e,t,n){let r=o.getTracer(Vc),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Wc(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Gc(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Kc(e,t){let n=e;for(let e of t){n=Gc(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function qc(e,t){let n=Kc(e,t);if(n!==void 0)return Nc(n)}function Jc(e,t){return e===`either`?!0:e===t}function Yc(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=qc(Bc,i);a?.scope!==void 0&&(Jc(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Xc(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,kc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function Zc(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Xc(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Xc(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function Qc(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const $c=N({file:k(),line:A().int().min(1),column:A().int().min(1),snippet:k().optional()}),el=N({path:M(Ys([k(),A()])),message:k(),issueCode:k(),params:tc(k(),Hs()).optional(),source:$c.optional()}),tl=P([`user`,`project`,`project-local`,`either`]),nl=P([`user`,`project`,`project-local`]),rl=Zs(`code`,[N({code:F(`YAML_PARSE`),detail:k()}),N({code:F(`SCHEMA_INVALID`),issues:M(el)}),N({code:F(`SCOPE_VIOLATION`),path:M(k()),expectedScope:tl,actualScope:nl}),N({code:F(`NOT_AGENT_SETTABLE`),path:M(k())}),N({code:F(`MIXED_SCOPE`),paths:M(N({path:M(k()),scope:nl}))}),N({code:F(`REMOVED_KEY`),path:M(k()),redirect:k(),source:$c.optional()}),N({code:F(`WRITE_ERROR`),detail:k()}),N({code:F(`OKIGNORE_INVALID`),detail:k(),lineNumber:A().int().min(1).optional()}),N({code:F(`UNKNOWN`),message:k().optional()})]),il=new Set(rl.options.map(e=>e.shape.code.value)),al=Ys([rl,qs({code:k(),message:k().optional()})]);function ol(e){return il.has(e.code)}function sl(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function cl(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function ll(e){if(!ol(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
|
|
154
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ja(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Za(t,`input`,e.processors),output:Za(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ya(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ya(r.element,n);if(r.type===`set`)return Ya(r.valueType,n);if(r.type===`lazy`)return Ya(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return Ya(r.innerType,n);if(r.type===`intersection`)return Ya(r.left,n)||Ya(r.right,n);if(r.type===`record`||r.type===`map`)return Ya(r.keyType,n)||Ya(r.valueType,n);if(r.type===`pipe`)return Ya(r.in,n)||Ya(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ya(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ya(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ya(e,n))return!0;return!!(r.rest&&Ya(r.rest,n))}return!1}const Xa=(e,t={})=>n=>{let r=Ga({...n,processors:t});return Ka(e,r),qa(r,e),Ja(r,e)},Za=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ga({...i??{},target:a,io:t,processors:n});return Ka(e,o),qa(o,e),Ja(o,e)},Qa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$a=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qa[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},eo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},to=(e,t,n,r)=>{n.type=`boolean`},no=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},io=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ao=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{n.not={}},co=(e,t,n,r)=>{},lo=(e,t,n,r)=>{},uo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},fo=(e,t,n,r)=>{let i=e._zod.def,a=vt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},po=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},go=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},_o=(e,t,n,r)=>{n.type=`boolean`},vo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},bo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ka(a.element,t,{...r,path:[...r.path,`items`]})},wo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ka(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ka(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},To=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ka(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Eo=(e,t,n,r)=>{let i=e._zod.def,a=Ka(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ka(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Do=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Ka(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ka(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Oo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ka(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ka(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ka(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ko=(e,t,n,r)=>{let i=e._zod.def,a=Ka(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ao=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Mo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},No=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Po=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;Ka(a,t,r);let o=t.seen.get(e);o.ref=a},Fo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Io=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Lo=(e,t,n,r)=>{let i=e._zod.def;Ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ro={string:$a,number:eo,boolean:to,bigint:no,symbol:ro,null:io,undefined:ao,void:oo,never:so,any:co,unknown:lo,date:uo,enum:fo,literal:po,nan:mo,template_literal:ho,file:go,success:_o,custom:vo,function:yo,transform:bo,map:xo,set:So,array:Co,object:wo,union:To,intersection:Eo,tuple:Do,record:Oo,nullable:ko,nonoptional:Ao,default:jo,prefault:Mo,catch:No,pipe:Po,readonly:Fo,promise:Io,optional:Lo,lazy:(e,t,n,r)=>{let i=e._zod.innerType;Ka(i,t,r);let a=t.seen.get(e);a.ref=i}};function zo(e,t){if(`_idmap`in e){let n=e,r=Ga({...t,processors:Ro}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Ka(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;qa(r,n),a[t]=Ja(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ga({...t,processors:Ro});return Ka(e,n),qa(n,e),Ja(n,e)}const Bo=D(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),fs.init(e,t)});function Vo(e){return oa(Bo,e)}const Ho=D(`ZodISODate`,(e,t)=>{Nr.init(e,t),fs.init(e,t)});function Uo(e){return sa(Ho,e)}const Wo=D(`ZodISOTime`,(e,t)=>{Pr.init(e,t),fs.init(e,t)});function Go(e){return ca(Wo,e)}const Ko=D(`ZodISODuration`,(e,t)=>{Fr.init(e,t),fs.init(e,t)});function qo(e){return la(Ko,e)}const Jo=(e,t)=>{en.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>rn(e,t)},flatten:{value:t=>nn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,yt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,yt,2)}},isEmpty:{get(){return e.issues.length===0}}})};D(`ZodError`,Jo);const Yo=D(`ZodError`,Jo,{Parent:Error}),Xo=sn(Yo),Zo=ln(Yo),Qo=dn(Yo),$o=pn(Yo),es=hn(Yo),ts=gn(Yo),ns=_n(Yo),rs=vn(Yo),is=yn(Yo),as=bn(Yo),ss=xn(Yo),cs=Sn(Yo),ls=D(`ZodType`,(e,t)=>(vr.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Za(e,`input`),output:Za(e,`output`)}}),e.toJSONSchema=Xa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Dt(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Lt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Xo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Qo(e,t,n),e.parseAsync=async(t,n)=>Zo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>$o(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>es(e,t,n),e.decode=(t,n)=>ts(e,t,n),e.encodeAsync=async(t,n)=>ns(e,t,n),e.decodeAsync=async(t,n)=>rs(e,t,n),e.safeEncode=(t,n)=>is(e,t,n),e.safeDecode=(t,n)=>as(e,t,n),e.safeEncodeAsync=async(t,n)=>ss(e,t,n),e.safeDecodeAsync=async(t,n)=>cs(e,t,n),e.refine=(t,n)=>e.check(Ec(t,n)),e.superRefine=t=>e.check(Dc(t)),e.overwrite=t=>e.check(Ma(t)),e.optional=()=>sc(e),e.exactOptional=()=>lc(e),e.nullable=()=>dc(e),e.nullish=()=>sc(dc(e)),e.nonoptional=t=>_c(e,t),e.array=()=>M(e),e.or=t=>Ys([e,t]),e.and=t=>$s(e,t),e.transform=t=>xc(e,ac(t)),e.default=t=>pc(e,t),e.prefault=t=>hc(e,t),e.catch=t=>yc(e,t),e.pipe=t=>xc(e,t),e.readonly=()=>Cc(e),e.describe=t=>{let n=e.clone();return Ii.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Ii.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Ii.get(e);let n=e.clone();return Ii.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),us=D(`_ZodString`,(e,t)=>{yr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ea(...t)),e.includes=(...t)=>e.check(ka(...t)),e.startsWith=(...t)=>e.check(Aa(...t)),e.endsWith=(...t)=>e.check(ja(...t)),e.min=(...t)=>e.check(wa(...t)),e.max=(...t)=>e.check(Ca(...t)),e.length=(...t)=>e.check(Ta(...t)),e.nonempty=(...t)=>e.check(wa(1,...t)),e.lowercase=t=>e.check(Da(t)),e.uppercase=t=>e.check(Oa(t)),e.trim=()=>e.check(Pa()),e.normalize=(...t)=>e.check(Na(...t)),e.toLowerCase=()=>e.check(Fa()),e.toUpperCase=()=>e.check(Ia()),e.slugify=()=>e.check(La())}),ds=D(`ZodString`,(e,t)=>{yr.init(e,t),us.init(e,t),e.email=t=>e.check(Ri(ps,t)),e.url=t=>e.check(Wi(gs,t)),e.jwt=t=>e.check(aa(Ms,t)),e.emoji=t=>e.check(Gi(vs,t)),e.guid=t=>e.check(zi(ms,t)),e.uuid=t=>e.check(Bi(hs,t)),e.uuidv4=t=>e.check(Vi(hs,t)),e.uuidv6=t=>e.check(Hi(hs,t)),e.uuidv7=t=>e.check(Ui(hs,t)),e.nanoid=t=>e.check(Ki(ys,t)),e.guid=t=>e.check(zi(ms,t)),e.cuid=t=>e.check(qi(bs,t)),e.cuid2=t=>e.check(Ji(xs,t)),e.ulid=t=>e.check(Yi(Ss,t)),e.base64=t=>e.check(na(ks,t)),e.base64url=t=>e.check(ra(As,t)),e.xid=t=>e.check(Xi(Cs,t)),e.ksuid=t=>e.check(Zi(ws,t)),e.ipv4=t=>e.check(Qi(Ts,t)),e.ipv6=t=>e.check($i(Es,t)),e.cidrv4=t=>e.check(ea(Ds,t)),e.cidrv6=t=>e.check(ta(Os,t)),e.e164=t=>e.check(ia(js,t)),e.datetime=t=>e.check(Vo(t)),e.date=t=>e.check(Uo(t)),e.time=t=>e.check(Go(t)),e.duration=t=>e.check(qo(t))});function k(e){return Li(ds,e)}const fs=D(`ZodStringFormat`,(e,t)=>{br.init(e,t),us.init(e,t)}),ps=D(`ZodEmail`,(e,t)=>{Cr.init(e,t),fs.init(e,t)}),ms=D(`ZodGUID`,(e,t)=>{xr.init(e,t),fs.init(e,t)}),hs=D(`ZodUUID`,(e,t)=>{Sr.init(e,t),fs.init(e,t)}),gs=D(`ZodURL`,(e,t)=>{wr.init(e,t),fs.init(e,t)});function _s(e){return Wi(gs,e)}const vs=D(`ZodEmoji`,(e,t)=>{Tr.init(e,t),fs.init(e,t)}),ys=D(`ZodNanoID`,(e,t)=>{Er.init(e,t),fs.init(e,t)}),bs=D(`ZodCUID`,(e,t)=>{Dr.init(e,t),fs.init(e,t)}),xs=D(`ZodCUID2`,(e,t)=>{Or.init(e,t),fs.init(e,t)}),Ss=D(`ZodULID`,(e,t)=>{kr.init(e,t),fs.init(e,t)}),Cs=D(`ZodXID`,(e,t)=>{Ar.init(e,t),fs.init(e,t)}),ws=D(`ZodKSUID`,(e,t)=>{jr.init(e,t),fs.init(e,t)}),Ts=D(`ZodIPv4`,(e,t)=>{Ir.init(e,t),fs.init(e,t)}),Es=D(`ZodIPv6`,(e,t)=>{Lr.init(e,t),fs.init(e,t)}),Ds=D(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),fs.init(e,t)}),Os=D(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),fs.init(e,t)}),ks=D(`ZodBase64`,(e,t)=>{Vr.init(e,t),fs.init(e,t)}),As=D(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),fs.init(e,t)}),js=D(`ZodE164`,(e,t)=>{Wr.init(e,t),fs.init(e,t)}),Ms=D(`ZodJWT`,(e,t)=>{Kr.init(e,t),fs.init(e,t)}),Ns=D(`ZodNumber`,(e,t)=>{qr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.gt=(t,n)=>e.check(ba(t,n)),e.gte=(t,n)=>e.check(xa(t,n)),e.min=(t,n)=>e.check(xa(t,n)),e.lt=(t,n)=>e.check(va(t,n)),e.lte=(t,n)=>e.check(ya(t,n)),e.max=(t,n)=>e.check(ya(t,n)),e.int=t=>e.check(Fs(t)),e.safe=t=>e.check(Fs(t)),e.positive=t=>e.check(ba(0,t)),e.nonnegative=t=>e.check(xa(0,t)),e.negative=t=>e.check(va(0,t)),e.nonpositive=t=>e.check(ya(0,t)),e.multipleOf=(t,n)=>e.check(Sa(t,n)),e.step=(t,n)=>e.check(Sa(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function A(e){return ua(Ns,e)}const Ps=D(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Ns.init(e,t)});function Fs(e){return fa(Ps,e)}const Is=D(`ZodBoolean`,(e,t)=>{Yr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r)});function j(e){return pa(Is,e)}const Ls=D(`ZodNull`,(e,t)=>{Xr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r)});function Rs(e){return ma(Ls,e)}const zs=D(`ZodAny`,(e,t)=>{Zr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Bs(){return ha(zs)}const Vs=D(`ZodUnknown`,(e,t)=>{Qr.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Hs(){return ga(Vs)}const Us=D(`ZodNever`,(e,t)=>{$r.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r)});function Ws(e){return _a(Us,e)}const Gs=D(`ZodArray`,(e,t)=>{ti.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(wa(t,n)),e.nonempty=t=>e.check(wa(1,t)),e.max=(t,n)=>e.check(Ca(t,n)),e.length=(t,n)=>e.check(Ta(t,n)),e.unwrap=()=>e.element});function M(e,t){return Ra(Gs,e,t)}const Ks=D(`ZodObject`,(e,t)=>{oi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),Tt(e,`shape`,()=>t.shape),e.keyof=()=>P(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Hs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Hs()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ws()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ht(e,t),e.safeExtend=t=>Ut(e,t),e.merge=t=>Wt(e,t),e.pick=t=>Bt(e,t),e.omit=t=>Vt(e,t),e.partial=(...t)=>Gt(oc,e,t[0]),e.required=(...t)=>Kt(gc,e,t[0])});function N(e,t){return new Ks({type:`object`,shape:e??{},...O(t)})}function qs(e,t){return new Ks({type:`object`,shape:e,catchall:Hs(),...O(t)})}const Js=D(`ZodUnion`,(e,t)=>{ci.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.options=t.options});function Ys(e,t){return new Js({type:`union`,options:e,...O(t)})}const Xs=D(`ZodDiscriminatedUnion`,(e,t)=>{Js.init(e,t),li.init(e,t)});function Zs(e,t,n){return new Xs({type:`union`,options:t,discriminator:e,...O(n)})}const Qs=D(`ZodIntersection`,(e,t)=>{ui.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r)});function $s(e,t){return new Qs({type:`intersection`,left:e,right:t})}const ec=D(`ZodRecord`,(e,t)=>{pi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function tc(e,t,n){return new ec({type:`record`,keyType:e,valueType:t,...O(n)})}const nc=D(`ZodEnum`,(e,t)=>{mi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new nc({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new nc({...t,checks:[],...O(r),entries:i})}});function P(e,t){return new nc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...O(t)})}const rc=D(`ZodLiteral`,(e,t)=>{hi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function F(e,t){return new rc({type:`literal`,values:Array.isArray(e)?e:[e],...O(t)})}const ic=D(`ZodTransform`,(e,t)=>{gi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Qt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Qt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ac(e){return new ic({type:`transform`,transform:e})}const oc=D(`ZodOptional`,(e,t)=>{vi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sc(e){return new oc({type:`optional`,innerType:e})}const cc=D(`ZodExactOptional`,(e,t)=>{yi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new cc({type:`optional`,innerType:e})}const uc=D(`ZodNullable`,(e,t)=>{bi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`nullable`,innerType:e})}const fc=D(`ZodDefault`,(e,t)=>{xi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function pc(e,t){return new fc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const mc=D(`ZodPrefault`,(e,t)=>{Ci.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hc(e,t){return new mc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const gc=D(`ZodNonOptional`,(e,t)=>{wi.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _c(e,t){return new gc({type:`nonoptional`,innerType:e,...O(t)})}const vc=D(`ZodCatch`,(e,t)=>{Ei.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yc(e,t){return new vc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const bc=D(`ZodPipe`,(e,t)=>{Di.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.in=t.in,e.out=t.out});function xc(e,t){return new bc({type:`pipe`,in:e,out:t})}const Sc=D(`ZodReadonly`,(e,t)=>{ki.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cc(e){return new Sc({type:`readonly`,innerType:e})}const wc=D(`ZodCustom`,(e,t)=>{ji.init(e,t),ls.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Tc(e,t){return za(wc,e??(()=>!0),t)}function Ec(e,t={}){return Ba(wc,e,t)}function Dc(e){return Va(e)}function Oc(e,t){return xc(ac(e),t)}var kc=ft();a();const Ac=Symbol.for(`@inkeep/open-knowledge/field-registry`),jc=globalThis;jc[Ac]===void 0&&(jc[Ac]=Fi());const Mc=jc[Ac];function Nc(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Pc(t)?Mc.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Pc(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const Fc=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Ic=52428800,Lc=26214400,Rc=`https://api.openai.com/v1`,zc=`text-embedding-3-small`,Bc=qs({content:qs({dir:k().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Folder Open Knowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore.`}).default(`.`)}).default({dir:`.`}),appearance:qs({theme:P([`light`,`dark`,`system`]).register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),preview:qs({autoOpen:j().register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:qs({showHiddenFiles:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showAllFiles:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show every file, including those excluded by .gitignore / .okignore. Per-machine (project-local) — not shared.`}).default(!1)}).optional()}).default({preview:{autoOpen:!0}}),editor:qs({wordWrap:j().register(Mc,{scope:`user`,agentSettable:!1,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0}),autoSync:qs({enabled:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Whether this machine auto-pulls and auto-pushes git commits for this project. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared.`}).nullable().default(null)}).default({enabled:null}),telemetry:qs({localSink:qs({enabled:j().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:"Write local diagnostic spans + logs under .ok/local/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:qs({maxBytes:A().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(Ic)}).default({maxBytes:Ic}),logs:qs({maxBytes:A().register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Lc)}).default({maxBytes:Lc}),attributeDenylist:M(k()).register(Mc,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...Fc])}).default({enabled:!0,spans:{maxBytes:Ic},logs:{maxBytes:Lc},attributeDenylist:[...Fc]})}).default({localSink:{enabled:!0,spans:{maxBytes:Ic},logs:{maxBytes:Lc},attributeDenylist:[...Fc]}}),search:qs({semantic:qs({enabled:j().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:k().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override for Azure / self-hosted / other providers. The API key is NOT stored here — set it with `ok embeddings set-key` (OS keyring)."}).default(Rc),model:k().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(zc),dimensions:A().int().positive().register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit to use the model's native size (1536 for text-embedding-3-small). Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality. Changing it re-embeds the corpus.`}).optional(),similarityFloor:A().min(0).max(1).register(Mc,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional()}).default({enabled:!1,baseUrl:Rc,model:zc})}).default({semantic:{enabled:!1,baseUrl:Rc,model:zc}})}),Vc=`open-knowledge-config`;async function Hc(e,t,n){let r=o.getTracer(Vc),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,async e=>{try{return await n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Uc(e,t,n){let r=o.getTracer(Vc),a=t?{attributes:t}:{};return r.startActiveSpan(e,a,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:i.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function Wc(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Gc(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Kc(e,t){let n=e;for(let e of t){n=Gc(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function qc(e,t){let n=Kc(e,t);if(n!==void 0)return Nc(n)}function Jc(e,t){return e===`either`?!0:e===t}function Yc(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}let a=qc(Bc,i);a?.scope!==void 0&&(Jc(a.scope,t)||(n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t}))}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}function Xc(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,kc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function Zc(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){Xc(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}Xc(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function Qc(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const $c=N({file:k(),line:A().int().min(1),column:A().int().min(1),snippet:k().optional()}),el=N({path:M(Ys([k(),A()])),message:k(),issueCode:k(),params:tc(k(),Hs()).optional(),source:$c.optional()}),tl=P([`user`,`project`,`project-local`,`either`]),nl=P([`user`,`project`,`project-local`]),rl=Zs(`code`,[N({code:F(`YAML_PARSE`),detail:k()}),N({code:F(`SCHEMA_INVALID`),issues:M(el)}),N({code:F(`SCOPE_VIOLATION`),path:M(k()),expectedScope:tl,actualScope:nl}),N({code:F(`NOT_AGENT_SETTABLE`),path:M(k())}),N({code:F(`MIXED_SCOPE`),paths:M(N({path:M(k()),scope:nl}))}),N({code:F(`REMOVED_KEY`),path:M(k()),redirect:k(),source:$c.optional()}),N({code:F(`WRITE_ERROR`),detail:k()}),N({code:F(`OKIGNORE_INVALID`),detail:k(),lineNumber:A().int().min(1).optional()}),N({code:F(`UNKNOWN`),message:k().optional()})]),il=new Set(rl.options.map(e=>e.shape.code.value)),al=Ys([rl,qs({code:k(),message:k().optional()})]);function ol(e){return il.has(e.code)}function sl(e){switch(e){case`user`:return`~/.ok/global.yml`;case`project`:return`.ok/config.yml`;case`project-local`:return`.ok/local/config.yml`;case`either`:return`.ok/config.yml or ~/.ok/global.yml`}}function cl(e){switch(e){case`user`:return`personal to you, across all projects`;case`project`:return`shared with your team via git`;case`project-local`:return`this machine only, not shared`;case`either`:return`user or project`}}function ll(e){if(!ol(e))return e.message??`Unknown error (${e.code}).`;switch(e.code){case`YAML_PARSE`:return`Failed to parse YAML: ${e.detail}`;case`SCHEMA_INVALID`:{if(e.issues.length===0)return`Invalid configuration.`;let t=new Map;for(let n of e.issues){let e=n.source?.file??`<no source>`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];for(let[e,r]of t){e===`<no source>`?n.push(`Invalid configuration:`):n.push(`Invalid configuration at ${e}:`);for(let t of r){let r=t.path.length===0?`<root>`:t.path.join(`.`);if(t.source){if(n.push(` ${e}:${t.source.line}:${t.source.column}`),n.push(` ${r}: ${t.message}`),t.source.snippet&&t.source.snippet.length>0)for(let e of t.source.snippet.split(`
|
|
155
155
|
`))n.push(` ${e}`)}else n.push(` ${r}: ${t.message}`)}}return n.join(`
|
|
156
156
|
`)}case`SCOPE_VIOLATION`:return[`Setting ${e.path.join(`.`)} belongs in your ${e.expectedScope} config`,`(${sl(e.expectedScope)} — ${cl(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${sl(e.actualScope)}).`,`Move it to ${sl(e.expectedScope)}.`].join(` `);case`NOT_AGENT_SETTABLE`:return[`Setting ${e.path.join(`.`)} is human-only and can't be changed by an agent.`,`Change it in the Settings pane, or edit the config.yml by hand.`].join(` `);case`MIXED_SCOPE`:return[`This change touches settings that live in different config files. Apply them one file at a time:`,e.paths.map(({path:e,scope:t})=>` ${e.join(`.`)} → ${sl(t)} (${t})`).join(`
|
|
157
157
|
`)].join(`
|
|
@@ -426,5 +426,5 @@ $2`).split(`
|
|
|
426
426
|
`;return l.join(f)},table(e,t,n,r){let i=n.enter(`table`),a=[],o=[],s=e.children??[];for(let e of s){let t=e.children??[],i=[],s=[];for(let e of t){let t=n.enter(`tableCell`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,{...r,before:` `,after:` `});a(),t(),i.push(o);let c=e.data?.sourcePadding;s.push(c&&typeof c.left==`number`&&typeof c.right==`number`?{left:c.left,right:c.right}:null)}a.push(i),o.push(s)}i();let c=e.align??[],l=e.data?.sourceDashCounts,u=a[0]?.length??0,d=a.slice(1).reduce((e,t)=>Math.max(e,t.length),0),f=Math.max(u,d,c.length),p=[];for(let e=0;e<f;e++){let t=c[e],n=``,r=``;t===`center`?(n=`:`,r=`:`):t===`left`?n=`:`:t===`right`&&(r=`:`);let i=l?.[e],a=typeof i==`number`&&i>=1?i:1;p.push(n+`-`.repeat(a)+r)}let m=(e,t)=>{let n=[];for(let r=0;r<f;r++){let i=e[r]??``,a=t[r]??{left:1,right:1};n.push(` `.repeat(a.left)+i+` `.repeat(a.right))}return`|${n.join(`|`)}|`},h=Array.from({length:f},()=>null);if(a.length===0)return m(p,h);let g=[];g.push(m(a[0],o[0]??[])),g.push(m(p,h));for(let e=1;e<a.length;e++)g.push(m(a[e],o[e]??[]));return g.join(`
|
|
427
427
|
`)},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=zZ(i.attributes??[]);if(!i.children||i.children.length===0)return s?c?`<${s} ${c} />`:`<${s} />`:``;let l=c?`<${s} ${c}>`:`<${s}>`,u=`</${s}>`;return`${l}\n\n${n.containerFlow({type:`root`,children:i.children},r)}\n\n${u}`},mark(e,t,n,r){let i=n.createTracker(r),a=n.enter(`mark`),o=i.move(`==`);return o+=n.containerPhrasing(e,{before:o,after:`==`,...i.current()}),o+=i.move(`==`),a(),o},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=zZ(e.attributes??[]);return 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)=>n?`>`:s?.[c++]===`none`?`>${e}`:`> ${e}`)}};function zZ(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`){if(n.value.includes(`"`)){let r=n.value.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t.push(`${e}={"${r}"}`)}else t.push(`${e}="${n.value}"`);continue}t.push(`${e}={${n.value.value}}`)}return t.join(` `)}function BZ(e,t,n=` `){return t===`single`?`${n}'${e.replace(/'/g,`\\'`)}'`:t===`paren`?`${n}(${e.replace(/[()]/g,`\\$&`)})`:`${n}"${e.replace(/"/g,`\\"`)}"`}function VZ(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 HZ(e){return e.replace(/(?<!\\)&(?=(#[0-9]+|#[xX][0-9A-Fa-f]+|[A-Za-z][A-Za-z0-9]*);)/g,(e,t)=>UZ(t)?e:`\\${e}`)}function UZ(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}function WZ(e,t,n){let r=e.unsafe;e.unsafe=r.filter(e=>!(e.character===`&`&&e.after===`[#A-Za-z]`||e.character===`<`||e.character===`[`||e.character===`(`||e.character==="`"));let i;try{i=e.safe(t,n)}finally{e.unsafe=r}return HZ(i)}function GZ(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KiB`,`MiB`,`GiB`,`TiB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(1).replace(/\.0$/,``)} ${t[r]}`}var KZ=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};constructor(e){this.schema=Ny(e.extensions),this.handlers=nQ(this.schema,this.parseCtx);let{nodeHandlers:t,markHandlers:n}=rQ(this.schema);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=kZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=AZ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers,toMarkdownHandlers:RZ})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return jZ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?MZ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?eY(e,{parse:e=>this.parse(e,t)}):{type:`doc`,content:[{type:`paragraph`,content:[]}]}}serialize(e){let t;try{t=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})}return NZ(t,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}};const qZ=UJ();function JZ(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 i?.type===`boolean`?r[e]=t.value===`true`:r[e]=t.value;continue}let a=t.value.value;try{r[e]=JSON.parse(a)}catch{r[e]=a}}return r}function YZ(e){let t=!1;return e.descendants(e=>t||e.type.name===`jsxInline`?!1:e.type.name===`jsxComponent`&&e.attrs.sourceDirty?(t=!0,!1):!0),t}function XZ(e){return e.attrs.sourceDirty||YZ(e)}function ZZ(e){if(e.type!==`paragraph`)return!1;let t=e.children??[];return t.length===0?!0:t.every(e=>e.type===`text`&&e.value===``)}function QZ(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),Object.keys(n).length===0?e:{...e,data:n}}function $Z(e,t){if(e.length===0)return QZ({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return QZ({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:[$Z(n.children,t)]}}return QZ({type:`inlineCode`,value:eQ(e)},t)}function eQ(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=eQ(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const tQ=UG;function nQ(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=GL(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=GL(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;return n.table.createAndFill({sourceDashCounts:s},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=LZ(r,t.current.sourcePath);return n.image.createAndFill({src:i,alt:e.alt??null,title:e.title??null,sourceUrl:i===r?null:r})},n.imageReference?i.imageReference=e=>n.imageReference.createAndFill({alt:e.alt??``,label:e.label??e.identifier??``,identifier:e.identifier??``,referenceType:e.referenceType??`shortcut`}):i.imageReference=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){let t=n.replaceAll(`\xA0`,` `);return r.sourceLiteral?e.text(t,[r.sourceLiteral.create({sourceRaw:i})]):e.text(t)}let a=t.data?.escapedChars,o=t.data?.entityRefSpans;if(!a?.length&&!o?.length)return e.text(n.replaceAll(`\xA0`,` `));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=[],l=0;for(let t of s){if(t.offset>l){let r=n.slice(l,t.offset).replaceAll(`\xA0`,` `);r&&c.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);i&&(t.kind===`escape`?c.push(e.text(i,[r.escapeMark.create()])):r.sourceLiteral?c.push(e.text(i,[r.sourceLiteral.create({sourceRaw:t.raw})])):c.push(e.text(i))),l=t.offset+t.length}}if(l<n.length){let t=n.slice(l).replaceAll(`\xA0`,` `);t&&c.push(e.text(t))}return c.length===1?c[0]:c}),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})]));let a=r.strike??r.delete;if(a&&(i.delete=KL(a)),r.highlight&&(i.mark=KL(r.highlight)),r.comment&&(i.comment=KL(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=GL(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=KL(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=KL(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=GL(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}))),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`},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`})),n.list&&(i.list=GL(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=GL(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread}))),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:``,title: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;i.definition=i=>{let s={title:i.title??null};return n&&(s.identifier=i.identifier??``),s.label=i.label??i.identifier??``,e?s.url=i.url??``:t&&(s.href=i.url??``),r&&(s.sourceLayout=i.data?.sourceLayout??null),a&&(s.sourceTitleMarker=i.data?.sourceTitleMarker??null),o.createAndFill(s)}}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=qZ.getOrWildcard(o),c=JZ(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=LZ(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})}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})),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=lq(o),{resolveEmbed:u,sourcePath:d}=t.current,f=u&&d?u(o,d)??null:null,p=f?`/${f}`:o,m=a?.type===`paragraph`&&Array.isArray(a.children)&&a.children.length===1;if(m&&tQ.has(l)&&n.jsxComponent&&qZ.has(`WikiEmbedImage`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedImage`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,alt:s??o,target:o,anchor:c,alias:s}});if(m&&WG.has(l)&&n.jsxComponent&&qZ.has(`WikiEmbedVideo`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedVideo`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&KG.has(l)&&n.jsxComponent&&qZ.has(`WikiEmbedAudio`))return n.jsxComponent.createAndFill({componentName:`WikiEmbedAudio`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,title:s??o,target:o,anchor:c,alias:s}});if(m&&qG.has(l)&&n.jsxComponent&&qZ.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:GZ(r);return n.jsxComponent.createAndFill({componentName:`WikiEmbedFile`,kind:`element`,attributes:[],sourceRaw:``,sourceDirty:!1,props:{src:p,target:o,anchor:c,alias:s,size:i}})}let h=s||(c?`${o}#${c}`:o);if(eK.has(l)&&r.link){let t=r.link.create({href:p,title:null,linkStyle:`inline`,refLabel:null,sourceForm:`wikiembed`,target:o,anchor:c,alias:s});return e.text(h,[t])}if(r.link){let t=r.link.create({href:o,title:null,linkStyle:`inline`,refLabel:null});return e.text(h,[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??``})),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=GL(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 rQ(e){let t={},n={},r=e.nodes,i=e.marks;r.paragraph&&(t.paragraph=ZL(`paragraph`)),r.blockquote&&(t.blockquote=ZL(`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}:{}})),r.heading&&(t.heading=ZL(`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?!0:void 0}}))),r.codeBlock&&(t.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}}}),r.thematicBreak&&(t.thematicBreak=e=>({type:`thematicBreak`,data:{sourceRaw:e.attrs.sourceRaw}})),r.hardBreak&&(t.hardBreak=e=>({type:`break`,data:{sourceStyle:e.attrs.hardBreakStyle}})),r.list&&(t.list=ZL(`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}}))),r.listItem&&(t.listItem=(e,t,n)=>{let r=n.all(e),i=r.length>1&&ZZ(r[0])?r.slice(1):r;return{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,children:i}}),r.table&&(t.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?{sourceDashCounts:s}:void 0,l={type:`table`,align:i,children:o};return c&&(l.data=c),l}),r.tableRow&&(t.tableRow=ZL(`tableRow`));let a=e=>{let t=e.attrs.sourcePadding,n={};return typeof t==`object`&&t&&typeof t.left==`number`&&typeof t.right==`number`&&(n.sourcePadding=t),Object.keys(n).length>0?{data:n}:{}};if(r.tableCell&&(t.tableCell=ZL(`tableCell`,a)),r.tableHeader&&(t.tableHeader=ZL(`tableCell`,a)),r.image&&(t.image=e=>({type:`image`,url:e.attrs.sourceUrl??e.attrs.src,alt:e.attrs.alt,title:e.attrs.title})),r.imageReference&&(t.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`}}),r.htmlBlock&&(t.htmlBlock=e=>({type:`html`,value:e.attrs.content})),r.linkDefinition??r.linkRefDef){let e=r.linkDefinition?`linkDefinition`:`linkRefDef`;t[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);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(r.jsxComponent&&(t.jsxComponent=(e,t,n)=>{if(e.attrs.kind===`expression`)return{type:`html`,value:e.attrs.sourceRaw??``};let r=e.attrs.componentName||null,i=Array.isArray(e.attrs.attributes)?e.attrs.attributes:[];return!XZ(e)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:r,attributes:i,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:qZ.getOrWildcard(r??`*`).serialize(e,{all:e=>n.all(e),registry:qZ,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.`)}})}),r.rawMdxFallback&&(t.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}}}}),r.jsxInline&&(t.jsxInline=e=>{let t=e.attrs.sourceRaw||e.textContent||``;return{type:`mdxJsxTextElement`,name:null,attributes:[],children:[],data:{sourceRaw:String(t)}}}),r.mathInline&&(t.mathInline=e=>{let t=e.attrs.formula??``,n=e.attrs.id;return typeof n==`string`&&n.length>0?{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]}:{type:`inlineMath`,value:t}}),r.wikiLink&&(t.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},children:[{type:`text`,value:i}]}}),r.tag&&(t.tag=e=>({type:`tag`,value:String(e.attrs.value??``)})),r.wikiLinkEmbed&&(t.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}]}}),i.emphasis&&(n.emphasis=QL(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.strong&&(n.strong=QL(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.code&&(n.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return $Z(n,{sourceFenceChar:r,sourceFenceLength:i})}),i.strike??i.delete){let e=i.strike?`strike`:`delete`;n[e]=QL(`delete`)}return i.highlight&&(n.highlight=QL(`mark`)),i.comment&&(n.comment=QL(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),r.commentBlock&&(t.commentBlock=ZL(`commentBlock`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`,sourceLayout:e.attrs.sourceLayout===`inline`?`inline`:`block`}}))),r.footnoteReference&&(t.footnoteReference=e=>{let t=String(e.attrs.identifier??``);return{type:`footnoteReference`,identifier:t,label:e.attrs.label?String(e.attrs.label):t}}),r.footnoteDefinition&&(t.footnoteDefinition=ZL(`footnoteDefinition`,e=>({identifier:String(e.attrs.identifier??``),label:e.attrs.label?String(e.attrs.label):String(e.attrs.identifier??``)}))),i.link&&(n.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??``,n=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,r=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?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}]}}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}}),i.escapeMark&&(n.escapeMark=(e,t,n)=>{for(let e of n)if(e.type===`text`&&e.value){let t=e;t.data=t.data??{},t.data.escapedChars=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}),i.sourceLiteral&&(n.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 ZK(t,e.value)&&(e.data=e.data??{},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:t,markHandlers:n}}const iQ=/\p{M}+/gu,aQ=/[^\p{L}\p{N}]+/gu,oQ=/^-+|-+$/g;function sQ(e){return e.trim().normalize(`NFKD`).replace(iQ,``).toLowerCase().replace(aQ,`-`).replace(oQ,``)}function cQ(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function lQ(e,t){let n=sQ(e);return n?cQ(n,t):``}const uQ=VB(),dQ=aB(),fQ=oB();function pQ(){return VJ.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function mQ(){return pQ().filter(e=>hQ(e)!==`fence`)}function hQ(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function gQ(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:hQ(e)}}function _Q(e){if(e.hidden!==!0&&e.type!==`reactnode`){if(`defaultValue`in e&&e.defaultValue!==void 0)return e.defaultValue;if(e.type===`enum`)return e.enumValues[0];if(e.type===`string`)return``;if(e.type===`number`)return 0;if(e.type===`boolean`)return!1}}function vQ(e,t){return!(e.omitOnDefault===!0&&`defaultValue`in e&&Object.is(e.defaultValue,t)||e.type===`string`&&e.required===!1&&e.defaultValue===void 0&&t===``)}function yQ(e){let t=[];for(let n of e.props){let e=_Q(n);e!==void 0&&vQ(n,e)&&t.push(eJ(n.name,e))}return t}function bQ(e){return pz(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[uQ],mdastExtensions:[dQ]}).children}function xQ(e){let t=hQ(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
428
428
|
A --> B`};else{let r=yQ(e),i=t===`jsx-block`?bQ(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return oP({type:`root`,children:[n]},{extensions:[fQ]}).trimEnd()}function SQ(e){let t=[];for(let n of e.props){if(n.hidden===!0)continue;let e={name:n.name,type:n.type,required:n.required};n.description!==void 0&&(e.description=n.description),n.advanced===!0&&(e.advanced=!0),n.omitOnDefault===!0&&(e.omitOnDefault=!0),n.type===`enum`&&(e.values=n.enumValues,n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue)),n.type===`string`&&(n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.language!==void 0&&(e.language=n.language),n.accept!==void 0&&(e.accept=n.accept)),n.type===`boolean`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),n.type===`number`&&n.defaultValue!==void 0&&(e.defaultValue=n.defaultValue),t.push(e)}return t}function CQ(e){return{...gQ(e),example:xQ(e),params:SQ(e)}}function wQ(){return[``,"**Custom canonical components.** OK `.md` / `.mdx` supports the JSX components below — use whichever is semantically useful in any part of the doc. For full source syntax + parameter schemas, call `palette({ components: [ids] })` with the ids you want to use. Fenced code blocks render naturally and don't need a fetch — including ` ```mermaid ` for diagrams and ` ```html preview ` for interactive HTML/JS/CSS pages (the fence info-string `preview` token renders the block as a live iframe; works for `html` / `htm` / `xml`; optional `h=` / `w=` tokens set size, e.g. ` ```html preview h=400px `). Use ` ```html preview ` whenever you want anything interactive or JS-powered (charts, demos, calculators, animations) — just author the standalone HTML page in the fence. Call `palette` for the markdown-native component forms (write `> [!NOTE]`, not `<Callout>`), copy-ready themed `html preview` starters, and the theme tokens (`var(--chart-1)`, `var(--foreground)`, …) an embed should reference so it tracks the reader's light/dark theme. Arbitrary `<TagName>` JSX falls through as raw MDX when no canonical fits.",``,...mQ().map(gQ).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
429
|
-
`)}const TQ=N({docName:yq,summary:xq,content:k().optional(),...bq}).loose(),EQ=N({docName:yq,summary:xq,markdown:k(),position:P([`append`,`prepend`,`replace`]).optional(),extension:P([`.md`,`.mdx`]).optional(),...bq}).loose(),DQ=N({docName:yq,summary:xq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...bq}).loose(),OQ=N({docName:yq,connectionId:k().min(1),scope:P([`last`,`session`,`file`]).optional(),...bq}).loose(),kQ=N({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),AQ=Zs(`kind`,[N({kind:F(`inline`),content:k()}),N({kind:F(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),jQ=N({kind:F(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:AQ.optional(),hint:k().optional()}).loose(),MQ=N({type:F(`orphan`),parentCandidates:M(k()),message:k()}).loose(),NQ=Zs(`kind`,[jQ,N({kind:F(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),hint:k().optional()}).loose()]),PQ=N({timestamp:k().min(1),summary:kQ.optional(),warning:NQ.optional()}).loose(),FQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:M(MQ).optional(),summary:kQ.optional(),warning:NQ.optional()}).loose(),IQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:kQ.optional(),warning:NQ.optional()}).loose(),LQ=N({docName:k().min(1),scope:P([`last`,`session`]),undone:j()}).loose(),RQ=N({docName:yq,patch:tc(k(),Ys([jW,Rs()])),types:tc(k(),P(AW)).optional(),summary:xq,...bq}).loose(),zQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:M(k()),summary:kQ.optional(),warning:NQ.optional()}).loose(),BQ=N({entries:M(N({level:P([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:tc(k(),Hs()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),VQ=N({accepted:A().int().min(0)}).loose(),HQ=N({status:k().min(1),reason:k()}).loose(),UQ=N({docName:k().min(1),content:k(),lifecycle:HQ.nullable()}).loose(),WQ=N({documents:M(N({kind:P([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:j().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:P([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:M(k().min(1)).optional(),hasChildren:j().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.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:j().optional()}).loose(),GQ=N({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),KQ=N({docName:k().min(1),backlinks:M(GQ)}).loose(),qQ=N({counts:tc(k().min(1),A().int().nonnegative())}).loose(),JQ=Zs(`kind`,[N({kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),N({kind:F(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),YQ=N({docName:k().min(1),forwardLinks:M(JQ)}).loose(),XQ=Zs(`kind`,[N({id:k().min(1),kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:M(k()).nullable()}).loose(),N({id:k().min(1),kind:F(`external`),url:k().min(1),label:k()}).loose()]),ZQ=N({source:k().min(1),target:k().min(1)}).loose(),QQ=N({nodes:M(XQ),links:M(ZQ)}).loose(),$Q=N({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),e$=N({app:Ys([F(`cursor`),F(`codex`),F(`claude`),Rs()]),signals_fired:M(k())}).loose(),t$=N({entries:M($Q),count:A().int().min(0),detection:e$}).loose(),n$=N({writers:M(N({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),summary:xq,...bq}).loose(),r$=N({checkpointRef:k().min(1)}).loose(),i$=N({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:M(k()),summaries:M(k()).optional()}).loose(),a$=N({entries:M(N({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:P([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:M(i$),checkpoint:Hs().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:j().optional()}).loose(),o$=N({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),s$=N({contentDir:k().min(1),pathSeparator:P([`/`,`\\`]),symlinkResolved:j()}).loose(),c$=M(Zs(`source`,[N({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:F(`flat`)}).loose(),N({docName:k().min(1),timestamp:k().min(1),source:F(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),l$=N({orphans:M(N({docName:k().min(1),title:k()}).loose())}).loose(),u$=N({hubs:M(N({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),d$=N({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),f$=N({deadLinks:M(N({target:k().min(1),sources:M(d$)}).loose())}).loose(),p$=N({target:N({docName:k().min(1),title:k(),aliases:M(k())}).loose(),mentions:M(N({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:j()}).loose(),m$=N({projectPath:k().min(1)}).loose(),h$=P([`not-a-git-worktree`,`init-failed`]),g$=Zs(`ok`,[N({ok:F(!0),projectPath:k().min(1)}).loose(),N({ok:F(!1),reason:h$,message:k().min(1)}).loose()]),_$=N({host:k().min(1).optional()}).loose(),v$=N({key:k().min(1)}).loose(),y$=N({keyPresent:j()}).loose(),b$=N({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),x$=N({authenticated:j()}).loose(),S$=N({}).loose(),C$=N({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),w$=N({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:M(C$)}).loose(),T$=N({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),E$=N({sessionAlive:j(),agent:T$.nullable(),files:M(w$)}).loose(),D$=N({diff:k(),generatedAt:A().int().min(0)}).loose(),O$=N({}).loose(),k$=N({}).loose(),A$=N({}).loose(),j$=N({}).loose(),M$=N({}).loose(),N$=N({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:P([`idle`,`writing`]),ts:A().int().min(0)}).loose(),P$=N({presence:tc(k().min(1),N$)}).loose(),F$=tc(k().min(1),j()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});N({path:k().min(1,`path must be non-empty`)}).loose();const I$=N({}).loose(),L$=N({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),R$=N({fromPath:k().min(1),toPath:k().min(1)}).loose(),z$=N({}).loose(),B$=N({path:k().min(1),...bq,summary:xq}).loose(),V$=N({docName:k().min(1)}).loose(),H$=N({path:k().min(1),...bq,summary:xq}).loose(),U$=N({path:k().min(1)}).loose(),W$=N({kind:P([`file`,`folder`]),path:k().min(1),...bq,summary:xq}).loose(),G$=N({kind:P([`file`,`folder`]),path:k().min(1),duplicatedDocNames:M(k().min(1))}).loose(),K$=N({pages:M(N({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),q$=N({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),J$=N({docName:k().min(1),headings:M(q$)}).loose(),Y$=N({docName:k().min(1),rewrites:A().int().nonnegative()}).loose(),X$=N({kind:P([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...bq,summary:xq}).loose(),Z$=N({renamed:M(L$),renamedAssets:M(R$),rewrittenDocs:M(Y$).optional(),summary:kQ.optional()}).loose(),Q$=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...bq}).loose(),$$=N({deletedDocNames:M(k().min(1))}).loose(),e1=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...bq,summary:xq}).loose(),t1=N({deletedDocNames:M(k().min(1))}).loose(),n1=N({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:xq,...bq}).loose(),r1=N({restoredFrom:k().min(1),timestamp:k().min(1),summary:kQ.optional(),warning:jQ.optional()}).loose(),i1=P([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),a1=N({label:k().min(1),webUrl:_s().nullable()}).loose(),o1=Zs(`checkStatus`,[N({checkStatus:F(`allowed`)}).loose(),N({checkStatus:F(`denied`),deniedReason:P([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),N({checkStatus:F(`unknown`),unknownError:P([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),s1=P([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),c1=N({state:i1,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:j(),syncEnabled:j(),identityUnresolved:j(),remote:a1.nullable().optional(),pushError:k().optional(),pushErrorCode:s1.optional(),pullError:k().optional(),pullErrorCode:s1.optional(),pausedReason:k().optional(),pushPermission:o1.optional()}).loose(),l1=N({op:P([`sync`,`push`,`pull`]).optional()}).loose(),u1=N({op:P([`sync`,`push`,`pull`])}).loose(),d1=N({conflicts:M(N({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose())}).loose(),f1=N({file:k().min(1),strategy:P([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),p1=N({}).loose(),m1=N({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:P([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),h1=N({plan:Tc(e=>e!==void 0,{message:`plan is required`})}).loose(),g1=N({plan:Tc(e=>e!==void 0,{message:`plan is required`})}).loose(),_1=N({result:Tc(e=>e!==void 0,{message:`result is required`})}).loose(),v1=N({path:k().min(1),summary:k().min(1)}).loose(),y1=N({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),b1=N({packs:M(N({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:M(v1),entryCounts:y1}).loose())}).loose(),x1=N({noOpen:j().optional(),out:k().min(1).optional()}).loose(),S1=N({reason:P([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),C1=Zs(`status`,[N({status:F(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),N({status:F(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:S1.optional()}).loose(),N({status:F(`failed`),buildError:k()}).loose(),N({status:F(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),w1=N({tags:M(N({name:k().min(1),count:A().int().nonnegative(),isLeaf:j()}).loose())}).loose(),T1=N({docName:k().min(1),title:k(),matchingTags:M(k().min(1)),snippet:k().nullable()}).loose(),E1=N({name:k().min(1),docs:M(T1)}).loose(),D1=N({folder:Hs(),frontmatter_local:tc(k(),Hs()).nullable()}).loose(),O1=N({path:k(),frontmatter:tc(k(),Hs()).optional()}).loose(),k1=N({applied:Hs()}).loose(),A1=tc(k(),Hs()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),j1=N({template:N({name:k().min(1),folder:k(),scope:P([`local`,`inherited`]),path:k().min(1),frontmatter:A1,body:k()}).strict()}).strict(),M1=N({templates:M(N({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:j()}).strict(),N1=N({folder:k(),name:k(),body:k().optional(),frontmatter:A1.optional(),...bq,summary:xq}).strict(),P1=N({path:k().min(1),created:j(),warnings:M(k())}).strict(),F1=N({existed:j(),path:k().min(1)}).strict(),I1=N({fromFolder:k(),fromName:k(),toFolder:k(),toName:k(),body:k().optional(),frontmatter:A1.optional(),...bq,summary:xq}).strict(),L1=N({from:k().min(1),to:k().min(1),committed:j()}).strict(),R1=N({query:k().optional(),intent:P([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:M(P([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional(),semantic:j().optional()}).loose(),z1=N({kind:P([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:tc(k(),Hs()),snippet:k().optional()}).loose(),B1=N({capable:j(),applied:j(),coverage:N({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),V1=N({enabled:j(),keyPresent:j(),keySource:P([`file`,`env`]).nullable(),ready:j(),capable:j(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),H1=N({query:k(),intent:P([`autocomplete`,`full_text`,`omnibar`]),results:M(z1),elapsedMs:A().nonnegative(),semantic:B1.optional()}).loose(),U1=N({version:k().min(1),recordedAt:k().min(1)}).loose(),W1=N({currentVersion:k().min(1),targets:tc(k(),U1.nullable())}).loose(),G1=`server-info`,K1=`branch-switched`,q1=`disk-ack`,J1=`config-validation-rejected`,Y1=`config-ignore-nested-error`,X1=P([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),Z1=N({v:F(1),ch:F(G1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),Q1=N({v:F(1),ch:F(K1),seq:A(),branch:k().min(1)}).loose(),$1=N({v:F(1),ch:X1,seq:A()}).loose(),e0=N({v:F(1),ch:F(q1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),t0=N({v:F(1),ch:F(J1),seq:A(),docName:k().min(1),error:al}).loose(),n0=N({v:F(1),ch:F(Y1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),r0={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},i0=new WeakMap;function a0(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function o0(e){return e.trim().toLowerCase()}function s0(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function c0(e){return e.split(`/`).filter(Boolean).join(` `)}function l0(e){let t=s0(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:c0(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function u0(e){let t=jU({schema:r0});return e.length>0&&HU(t,e),t}function d0(e){let t={documents:e};return i0.set(t,u0(e)),t}function f0(e){let t=i0.get(e);if(t)return t;let n=u0(e.documents);return i0.set(e,n),n}function p0(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function m0(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function h0(e,t){let n=o0(t);if(!n)return 0;let r=o0(e.title),i=o0(e.name),a=o0(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function g0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function _0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function v0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function y0(e,t){return o0(t).length<4?0:e===`full_text`?1:0}function b0(e,t,n={}){let r=n.intent??`omnibar`,i=a0(n.limit),a=new Set(n.scopes??p0(r)),o=e.documents.filter(e=>m0(e,a)),s=o0(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=vW(f0(e),{term:s,properties:_0(r),boost:v0(r),tolerance:y0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>m0(e.document,a)).map(e=>[e.document.id,e.score])),u=g0(o),d=new Map;for(let e of o)h0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)m0(e.document,a)&&d.set(e.document.id,e.document);return n.semantic?S0({scopedDocuments:o,candidates:d,fullTextScores:l,recency:u,normalizedQuery:s,semantic:n.semantic,limit:i}):[...d.values()].map(e=>{let t=Math.max(0,h0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function x0(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function S0(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,semantic:o,limit:s}=e,c=o.rrfK??60,l=o.candidateLimit??64,u=o.similarityFloor??.35,d=o.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=[...n.values()].map(e=>{let t=Math.max(0,h0(e,a)),n=r.get(e.id)??0,o=i.get(e.id)??0,s=d.get(e.id),c=s!==void 0&&s>=u;return{document:e,score:t+n*20+o,signals:c?{lexical:t,fullText:n,recency:o,vector:s}:{lexical:t,fullText:n,recency:o},lexical:t,fullText:n,recency:o,cosine:s}}),h=x0(m.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),g=x0(m.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=e=>{let t=0,n=h.get(e);n!==void 0&&(t+=1/(c+n));let r=g.get(e);return r!==void 0&&(t+=1/(c+r)),t};return m.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=_(e.document.id),a=_(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n})).slice(0,s)}function C0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),w0(n)}function w0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const T0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),E0=globalThis;E0[T0]===void 0&&(E0[T0]=Fi());const D0=E0[T0],O0=[`.ok`,`skill-state.yml`],k0=[`claude-cowork`,`cli-hosts`],A0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],j0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,M0=qs({version:k().regex(j0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(D0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(D0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(A0).register(D0,{description:`Install-source surface that recorded this entry.`}).optional()}),N0=qs({schema:F(1).register(D0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:qs({"claude-cowork":M0.optional(),"cli-hosts":M0.optional()}).register(D0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function P0(){return{schema:1,targets:{}}}function F0(){let e=!1,t=``,n=0;return r=>{let i=I0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function I0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const L0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],R0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function z0(e,t=L0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const B0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function V0(e){return e?B0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const H0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function U0(e){let t=e?.trim();return t?H0[V0(t)]??t:`Agent`}function W0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const G0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function K0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function q0(e){let t=e.trim();return G0.test(t)||t.startsWith(`//`)}function J0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(q0(n))return{kind:`external`,url:n};let r=W0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=K0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Y0(e,t){let n=e.trim();if(!n)return null;if(q0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=K0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function X0(e,t){let n=e.trim();if(!n||G0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function Z0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Q0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function $0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function e2(e){return e.split(`/`).filter(e=>e!==``)}function t2(e,t){let n=$0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function n2(e,t){let n=$0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:e2(r).length}function r2(e,t){let n=e2(e),r=e2(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function i2(){let e=new Map;function t(t){let n=Z0(t);if(n===``)return;let r=Q0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=Z0(t),r=Q0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=$0(Z0(n)),o=[],s=[];for(let e of i)t2(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=n2(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=n2(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=r2(a,$0(t));for(let r=1;r<e.length;r++){let i=e[r],o=r2(a,$0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function a2(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function o2(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function s2(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function c2(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function l2(){try{let e=_(g(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(d(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const u2=l2(),d2=1;var f2=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function p2(e,t){return _(e,`${t}.lock`)}const m2=new Map;function h2(e){m2.set(e,(m2.get(e)??0)+1)}function g2(e){let t=m2.get(e);return t===void 0||t<=1?(m2.delete(e),!0):(m2.set(e,t-1),!1)}function _2(e,t){try{let n=JSON.parse(d(e,`utf-8`));return n&&typeof n==`object`&&c2(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function v2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;l(n,{recursive:!0});let a=p2(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??u2},d=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!c(a))try{let e=u(a,`wx`,384);try{m(e,d)}finally{s(e)}return h2(a),y2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return p(a,d,{encoding:`utf-8`,mode:384}),h2(a),y2({lockName:t,lockDir:n,lockPath:a});if(r&&s2(e.pid))throw new f2(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{f(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function y2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>C2({lockName:t,lockDir:n}),updatePort:e=>b2({lockName:t,lockDir:n,port:e})}}function b2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=p2(n,t);if(!c(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(d(a,`utf-8`));if(!e||typeof e!=`object`||!c2(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{p(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function x2(e){let{lockName:t,lockDir:n}=e,r=p2(n,t);if(!c(r))return null;let i;try{let e=JSON.parse(d(r,`utf-8`));if(!e||typeof e!=`object`||!c2(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!s2(i.pid)){try{f(r)}catch{}return null}return i}function S2(e){let{lockName:t,lockDir:n}=e,r=p2(n,t);if(!c(r))return{status:`absent`};let i;try{i=JSON.parse(d(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!c2(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!s2(o.pid)){try{f(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function C2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=p2(n,t);if(g2(i)&&c(i))try{let e=JSON.parse(d(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;f(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var w2=class extends f2{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T2(e,t){try{return v2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f2&&e.lockName===`server`?new w2(e.existing,e.lockPath):e}}function E2(e,t){b2({lockName:`server`,lockDir:e,port:t})}function D2(e){return x2({lockName:`server`,lockDir:e})}function O2(e){C2({lockName:`server`,lockDir:e})}export{xG as $,Ys as $i,I1 as $n,CQ as $r,j$ as $t,Gq as A,pl as Ai,Uq as An,U0 as Ar,jW as At,e0 as B,M as Bi,Qq as Bn,sq as Br,QQ as Bt,IQ as C,bl as Ci,R1 as Cn,F0 as Cr,z$ as Ct,FQ as D,vl as Di,b1 as Dn,mG as Dr,YQ as Dt,EQ as E,Zc as Ei,_1 as En,l0 as Er,k1 as Et,rG as F,Ns as Fi,Mq as Fn,XW as Fr,x1 as Ft,q1 as G,F as Gi,p1 as Gn,MG as Gr,Zq as Gt,K1 as H,Tc as Hi,m1 as Hn,Lq as Hr,_$ as Ht,Q1 as I,oc as Ii,Pq as In,GZ as Ir,C1 as It,gG as J,N as Ji,u1 as Jn,eG as Jr,m$ as Jt,G1 as K,qs as Ki,c1 as Kn,Fq as Kr,y$ as Kt,n0 as L,P as Li,W1 as Ln,mQ as Lr,F$ as Lt,KQ as M,Yc as Mi,Tq as Mn,C0 as Mr,o$ as Mt,zq as N,Hc as Ni,Aq as Nn,a2 as Nr,u$ as Nt,TQ as O,ll as Oi,h1 as On,pG as Or,RQ as Ot,QW as P,Uc as Pi,kq as Pn,hq as Pr,QG as Pt,SG as Q,k as Qi,j1 as Qn,IG as Qr,M$ as Qt,t0 as R,Rs as Ri,N0 as Rn,lQ as Rr,TG as Rt,DQ as S,xl as Si,r$ as Sn,i2 as Sr,t$ as St,LQ as T,Wc as Ti,g1 as Tn,d0 as Tr,O1 as Tt,Y1 as U,Zs as Ui,d1 as Un,NW as Ur,b$ as Ut,Z1 as V,j as Vi,p$ as Vn,V0 as Vr,S$ as Vt,J1 as W,$s as Wi,f1 as Wn,_q as Wr,x$ as Wt,CG as X,Oc as Xi,w1 as Xn,zW as Xr,KZ as Xt,wG as Y,sc as Yi,E1 as Yn,fG as Yr,g$ as Yt,bG as Z,tc as Zi,F1 as Zn,IW as Zr,P$ as Zt,R0 as _,D as _a,Rc as _i,k0 as _n,qq as _r,UQ as _t,v2 as a,Ua as aa,dq as ai,J$ as an,A$ as ar,U$ as at,E$ as b,Ic as bi,vG as bn,_G as br,OG as bt,c2 as c,vr as ca,ZW as ci,Jq as cn,t1 as cr,$G as ct,S2 as d,fn as da,gq as di,c$ as dn,Yq as dr,NG as dt,Hs as ea,WW as ei,jG as en,L1 as er,Bq as et,D2 as f,mn as fa,Ny as fi,n1 as fn,s$ as fr,EG as ft,E2 as g,O as ga,Bc as gi,O0 as gn,YW as gr,WQ as gt,b2 as h,Tt as ha,yl as hi,XG as hn,EW as hr,$$ as ht,w2 as i,da as ia,b0 as ii,hG as in,k$ as ir,H$ as it,qQ as j,Qc as ji,Cq as jn,P0 as jr,a$ as jt,PQ as k,ol as ki,V1 as kn,VW as kr,zQ as kt,p2 as l,cn as la,sQ as li,X$ as ln,kG as lr,AG as lt,O2 as m,Lt as ma,I as mi,ZG as mn,DW as mr,Q$ as mt,u2 as n,Vo as na,X0 as ni,FG as nn,P1 as nr,BQ as nt,T2 as o,Wa as oa,FW as oi,K$ as on,O$ as or,B$ as ot,C2 as p,on as pa,Cf as pi,r1 as pn,NQ as pr,f$ as pt,yG as q,A as qi,l1 as qn,mK as qr,v$ as qt,d2 as r,zo as ra,W0 as ri,LG as rn,M1 as rr,VQ as rt,s2 as s,ai as sa,o2 as si,Wq as sn,e1 as sr,V$ as st,f2 as t,_s as ta,wQ as ti,l$ as tn,N1 as tr,Hq as tt,x2 as u,un as ua,LW as ui,Z$ as un,Xq as ur,RG as ut,DG as v,pt as va,zc as vi,j0 as vn,J0 as vr,W$ as vt,OQ as w,hl as wi,H1 as wn,WX as wr,D1 as wt,D$ as x,Fc as xi,n$ as xn,z0 as xr,JG as xt,YG as y,ft as ya,Lc as yi,PG as yn,Y0 as yr,G$ as yt,$1 as z,Bs as zi,I$ as zn,JJ as zr,pK as zt};
|
|
430
|
-
//# sourceMappingURL=server-lock-BpjJj3OD-
|
|
429
|
+
`)}const TQ=N({docName:yq,summary:xq,content:k().optional(),...bq}).loose(),EQ=N({docName:yq,summary:xq,markdown:k(),position:P([`append`,`prepend`,`replace`]).optional(),extension:P([`.md`,`.mdx`]).optional(),...bq}).loose(),DQ=N({docName:yq,summary:xq,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...bq}).loose(),OQ=N({docName:yq,connectionId:k().min(1),scope:P([`last`,`session`,`file`]).optional(),...bq}).loose(),kQ=N({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),AQ=Zs(`kind`,[N({kind:F(`inline`),content:k()}),N({kind:F(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),jQ=N({kind:F(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:AQ.optional(),hint:k().optional()}).loose(),MQ=N({type:F(`orphan`),parentCandidates:M(k()),message:k()}).loose(),NQ=Zs(`kind`,[jQ,N({kind:F(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),hint:k().optional()}).loose()]),PQ=N({timestamp:k().min(1),summary:kQ.optional(),warning:NQ.optional()}).loose(),FQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:M(MQ).optional(),summary:kQ.optional(),warning:NQ.optional()}).loose(),IQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:kQ.optional(),warning:NQ.optional()}).loose(),LQ=N({docName:k().min(1),scope:P([`last`,`session`]),undone:j()}).loose(),RQ=N({docName:yq,patch:tc(k(),Ys([jW,Rs()])),types:tc(k(),P(AW)).optional(),summary:xq,...bq}).loose(),zQ=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:M(k()),summary:kQ.optional(),warning:NQ.optional()}).loose(),BQ=N({entries:M(N({level:P([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:tc(k(),Hs()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),VQ=N({accepted:A().int().min(0)}).loose(),HQ=N({status:k().min(1),reason:k()}).loose(),UQ=N({docName:k().min(1),content:k(),lifecycle:HQ.nullable()}).loose(),WQ=N({documents:M(N({kind:P([`document`,`asset`,`folder`]).default(`document`),docName:k().min(1).optional(),docExt:k().min(1).default(`.md`),size:A().int().nonnegative(),modified:k().min(1),isSymlink:j().default(!1),canonicalDocName:k().nullable().default(null),targetPath:k().nullable().default(null),path:k().min(1).optional(),assetExt:k().min(1).optional(),mediaKind:P([`image`,`video`,`audio`,`pdf`,`text`]).nullable().optional(),referencedBy:M(k().min(1)).optional(),hasChildren:j().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.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName)`})),truncated:j().optional()}).loose(),GQ=N({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),KQ=N({docName:k().min(1),backlinks:M(GQ)}).loose(),qQ=N({counts:tc(k().min(1),A().int().nonnegative())}).loose(),JQ=Zs(`kind`,[N({kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),N({kind:F(`external`),url:k().min(1),title:k(),snippet:k().nullable()}).loose()]),YQ=N({docName:k().min(1),forwardLinks:M(JQ)}).loose(),XQ=Zs(`kind`,[N({id:k().min(1),kind:F(`doc`),docName:k().min(1),anchor:k().nullable(),label:k(),cluster:k().nullable(),category:k().nullable(),tags:M(k()).nullable()}).loose(),N({id:k().min(1),kind:F(`external`),url:k().min(1),label:k()}).loose()]),ZQ=N({source:k().min(1),target:k().min(1)}).loose(),QQ=N({nodes:M(XQ),links:M(ZQ)}).loose(),$Q=N({ts:A().int().min(0),url:k(),method:k(),ua:k().optional(),origin:k().optional(),referer:k().optional(),host:k().optional(),remote:k().optional(),secChUa:k().optional(),secChUaMobile:k().optional(),secChUaPlatform:k().optional(),secFetchSite:k().optional(),secFetchDest:k().optional(),secFetchMode:k().optional(),secFetchUser:k().optional()}).loose(),e$=N({app:Ys([F(`cursor`),F(`codex`),F(`claude`),Rs()]),signals_fired:M(k())}).loose(),t$=N({entries:M($Q),count:A().int().min(0),detection:e$}).loose(),n$=N({writers:M(N({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),summary:xq,...bq}).loose(),r$=N({checkpointRef:k().min(1)}).loose(),i$=N({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:M(k()),summaries:M(k()).optional()}).loose(),a$=N({entries:M(N({sha:k().min(1),timestamp:k().min(1),author:k(),authorEmail:k(),type:P([`checkpoint`,`wip`,`upstream`,`park`]),message:k(),contributors:M(i$),checkpoint:Hs().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:j().optional()}).loose(),o$=N({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),s$=N({contentDir:k().min(1),pathSeparator:P([`/`,`\\`]),symlinkResolved:j()}).loose(),c$=M(Zs(`source`,[N({docName:k().min(1),timestamp:k().min(1),size:A().int().nonnegative(),source:F(`flat`)}).loose(),N({docName:k().min(1),timestamp:k().min(1),source:F(`timeline`),sha:k().min(1)}).loose()])).meta({description:"Flat array of rescue buffer entries; discriminated via `source`."}),l$=N({orphans:M(N({docName:k().min(1),title:k()}).loose())}).loose(),u$=N({hubs:M(N({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),d$=N({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),f$=N({deadLinks:M(N({target:k().min(1),sources:M(d$)}).loose())}).loose(),p$=N({target:N({docName:k().min(1),title:k(),aliases:M(k())}).loose(),mentions:M(N({source:k().min(1),excerpt:k(),offset:A().int().nonnegative()}).loose()),truncated:j()}).loose(),m$=N({projectPath:k().min(1)}).loose(),h$=P([`not-a-git-worktree`,`init-failed`]),g$=Zs(`ok`,[N({ok:F(!0),projectPath:k().min(1)}).loose(),N({ok:F(!1),reason:h$,message:k().min(1)}).loose()]),_$=N({host:k().min(1).optional()}).loose(),v$=N({key:k().min(1)}).loose(),y$=N({keyPresent:j()}).loose(),b$=N({name:k().refine(e=>e.trim().length>0,{message:`name must be non-empty`}),email:k().refine(e=>e.trim().length>0,{message:`email must be non-empty`})}).loose(),x$=N({authenticated:j()}).loose(),S$=N({}).loose(),C$=N({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),w$=N({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:M(C$)}).loose(),T$=N({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),E$=N({sessionAlive:j(),agent:T$.nullable(),files:M(w$)}).loose(),D$=N({diff:k(),generatedAt:A().int().min(0)}).loose(),O$=N({}).loose(),k$=N({}).loose(),A$=N({}).loose(),j$=N({}).loose(),M$=N({}).loose(),N$=N({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:P([`idle`,`writing`]),ts:A().int().min(0)}).loose(),P$=N({presence:tc(k().min(1),N$)}).loose(),F$=tc(k().min(1),j()).meta({description:`Flat boolean record keyed by agent-scheme name (claude / codex / cursor). True = installed.`});N({path:k().min(1,`path must be non-empty`)}).loose();const I$=N({}).loose(),L$=N({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),R$=N({fromPath:k().min(1),toPath:k().min(1)}).loose(),z$=N({}).loose(),B$=N({path:k().min(1),...bq,summary:xq}).loose(),V$=N({docName:k().min(1)}).loose(),H$=N({path:k().min(1),...bq,summary:xq}).loose(),U$=N({path:k().min(1)}).loose(),W$=N({kind:P([`file`,`folder`]),path:k().min(1),...bq,summary:xq}).loose(),G$=N({kind:P([`file`,`folder`]),path:k().min(1),duplicatedDocNames:M(k().min(1))}).loose(),K$=N({pages:M(N({docName:k().min(1),title:k(),docExt:k().min(1),size:A().int().nonnegative(),modified:k().min(1),icon:k().min(1).max(2048).optional()}).loose())}).loose(),q$=N({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),J$=N({docName:k().min(1),headings:M(q$)}).loose(),Y$=N({docName:k().min(1),rewrites:A().int().nonnegative()}).loose(),X$=N({kind:P([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...bq,summary:xq}).loose(),Z$=N({renamed:M(L$),renamedAssets:M(R$),rewrittenDocs:M(Y$).optional(),summary:kQ.optional()}).loose(),Q$=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...bq}).loose(),$$=N({deletedDocNames:M(k().min(1))}).loose(),e1=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...bq,summary:xq}).loose(),t1=N({deletedDocNames:M(k().min(1))}).loose(),n1=N({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:xq,...bq}).loose(),r1=N({restoredFrom:k().min(1),timestamp:k().min(1),summary:kQ.optional(),warning:jQ.optional()}).loose(),i1=P([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),a1=N({label:k().min(1),webUrl:_s().nullable()}).loose(),o1=Zs(`checkStatus`,[N({checkStatus:F(`allowed`)}).loose(),N({checkStatus:F(`denied`),deniedReason:P([`no-collaborator`,`private-no-access`,`repo-not-found`])}).loose(),N({checkStatus:F(`unknown`),unknownError:P([`network`,`timeout`,`rate-limit`,`token-invalid`,`malformed-response`]).optional()}).loose()]),s1=P([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),c1=N({state:i1,lastSyncUtc:k().nullable(),lastFetchUtc:k().nullable(),lastPushedSha:k().nullable(),ahead:A().int().min(0),behind:A().int().min(0),consecutiveFailures:A().int().min(0),conflictCount:A().int().min(0),hasRemote:j(),syncEnabled:j(),identityUnresolved:j(),remote:a1.nullable().optional(),pushError:k().optional(),pushErrorCode:s1.optional(),pullError:k().optional(),pullErrorCode:s1.optional(),pausedReason:k().optional(),pushPermission:o1.optional()}).loose(),l1=N({op:P([`sync`,`push`,`pull`]).optional()}).loose(),u1=N({op:P([`sync`,`push`,`pull`])}).loose(),d1=N({conflicts:M(N({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose())}).loose(),f1=N({file:k().min(1),strategy:P([`mine`,`theirs`,`content`,`delete`]),content:k().optional()}).loose().refine(e=>e.strategy!==`content`||e.content!==void 0&&e.content!==``,{message:`content must be a non-empty string when strategy is 'content'`,path:[`content`]}),p1=N({}).loose(),m1=N({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:P([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),h1=N({plan:Tc(e=>e!==void 0,{message:`plan is required`})}).loose(),g1=N({plan:Tc(e=>e!==void 0,{message:`plan is required`})}).loose(),_1=N({result:Tc(e=>e!==void 0,{message:`result is required`})}).loose(),v1=N({path:k().min(1),summary:k().min(1)}).loose(),y1=N({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),b1=N({packs:M(N({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:M(v1),entryCounts:y1}).loose())}).loose(),x1=N({noOpen:j().optional(),out:k().min(1).optional()}).loose(),S1=N({reason:P([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),C1=Zs(`status`,[N({status:F(`installed`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k()}).loose(),N({status:F(`built`),outputPath:k(),size:A().int().nonnegative(),sha256:k(),skillVersion:k(),handoffError:S1.optional()}).loose(),N({status:F(`failed`),buildError:k()}).loose(),N({status:F(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),w1=N({tags:M(N({name:k().min(1),count:A().int().nonnegative(),isLeaf:j()}).loose())}).loose(),T1=N({docName:k().min(1),title:k(),matchingTags:M(k().min(1)),snippet:k().nullable()}).loose(),E1=N({name:k().min(1),docs:M(T1)}).loose(),D1=N({folder:Hs(),frontmatter_local:tc(k(),Hs()).nullable()}).loose(),O1=N({path:k(),frontmatter:tc(k(),Hs()).optional()}).loose(),k1=N({applied:Hs()}).loose(),A1=tc(k(),Hs()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),j1=N({template:N({name:k().min(1),folder:k(),scope:P([`local`,`inherited`]),path:k().min(1),frontmatter:A1,body:k()}).strict()}).strict(),M1=N({templates:M(N({name:k().min(1),title:k().optional(),description:k().optional(),path:k().min(1),source_folder:k()}).strict()),truncated:j()}).strict(),N1=N({folder:k(),name:k(),body:k().optional(),frontmatter:A1.optional(),...bq,summary:xq}).strict(),P1=N({path:k().min(1),created:j(),warnings:M(k())}).strict(),F1=N({existed:j(),path:k().min(1)}).strict(),I1=N({fromFolder:k(),fromName:k(),toFolder:k(),toName:k(),body:k().optional(),frontmatter:A1.optional(),...bq,summary:xq}).strict(),L1=N({from:k().min(1),to:k().min(1),committed:j()}).strict(),R1=N({query:k().optional(),intent:P([`autocomplete`,`full_text`,`omnibar`]).optional(),scopes:M(P([`page`,`folder`,`content`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional(),semantic:j().optional(),source:P([`omnibar`,`mcp`,`http`]).optional()}).loose(),z1=N({kind:P([`page`,`folder`,`content`]),path:k().min(1),title:k(),score:A(),signals:tc(k(),Hs()),snippet:k().optional()}).loose(),B1=N({capable:j(),applied:j(),coverage:N({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),V1=N({enabled:j(),keyPresent:j(),keySource:P([`file`,`env`]).nullable(),keyHint:k().nullable(),ready:j(),capable:j(),embedded:A().int().nonnegative(),total:A().int().nonnegative()}).loose(),H1=N({query:k(),intent:P([`autocomplete`,`full_text`,`omnibar`]),results:M(z1),elapsedMs:A().nonnegative(),semantic:B1.optional()}).loose(),U1=N({version:k().min(1),recordedAt:k().min(1)}).loose(),W1=N({currentVersion:k().min(1),targets:tc(k(),U1.nullable())}).loose(),G1=`server-info`,K1=`branch-switched`,q1=`disk-ack`,J1=`config-validation-rejected`,Y1=`config-ignore-nested-error`,X1=P([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),Z1=N({v:F(1),ch:F(G1),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),Q1=N({v:F(1),ch:F(K1),seq:A(),branch:k().min(1)}).loose(),$1=N({v:F(1),ch:X1,seq:A()}).loose(),e0=N({v:F(1),ch:F(q1),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),t0=N({v:F(1),ch:F(J1),seq:A(),docName:k().min(1),error:al}).loose(),n0=N({v:F(1),ch:F(Y1),seq:A(),path:k().min(1),error:k().min(1)}).loose(),r0={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},i0=new WeakMap;function a0(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function o0(e){return e.trim().toLowerCase()}function s0(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function c0(e){return e.split(`/`).filter(Boolean).join(` `)}function l0(e){let t=s0(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0;return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:c0(e.path),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function u0(e){let t=jU({schema:r0});return e.length>0&&HU(t,e),t}function d0(e){let t={documents:e};return i0.set(t,u0(e)),t}function f0(e){let t=i0.get(e);if(t)return t;let n=u0(e.documents);return i0.set(e,n),n}function p0(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`]:[`page`,`folder`]}function m0(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function h0(e,t){let n=o0(t);if(!n)return 0;let r=o0(e.title),i=o0(e.name),a=o0(e.path),o=a.split(`/`);return r===n||i===n?700:a===n?650:r.startsWith(n)||i.startsWith(n)?600:o.some(e=>e.startsWith(n))?550:r.includes(n)||i.includes(n)?500:a.includes(n)?450:-1}function g0(e){let t=e.map(e=>e.modifiedTs).filter(e=>Number.isFinite(e)&&e>0);if(t.length===0)return new Map;let n=1/0,r=-1/0;for(let e of t)e<n&&(n=e),e>r&&(r=e);let i=Math.max(1,r-n);return new Map(e.map(e=>[e.id,e.modifiedTs>0?(e.modifiedTs-n)/i*50:0]))}function _0(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function v0(e){return e===`full_text`?{title:8,name:7,path:5,pathSegments:4,content:1}:e===`autocomplete`?{title:10,name:9,path:5,pathSegments:4}:{title:8,name:7,path:5,pathSegments:4}}function y0(e,t){return o0(t).length<4?0:e===`full_text`?1:0}function b0(e,t,n={}){let r=n.intent??`omnibar`,i=a0(n.limit),a=new Set(n.scopes??p0(r)),o=e.documents.filter(e=>m0(e,a)),s=o0(t);if(!s)return o.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,i).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let c=vW(f0(e),{term:s,properties:_0(r),boost:v0(r),tolerance:y0(r,s),limit:Math.max(i*4,40)}),l=new Map(c.hits.filter(e=>m0(e.document,a)).map(e=>[e.document.id,e.score])),u=g0(o),d=new Map;for(let e of o)h0(e,s)>=0&&d.set(e.id,e);for(let e of c.hits)m0(e.document,a)&&d.set(e.document.id,e.document);return n.semantic?S0({scopedDocuments:o,candidates:d,fullTextScores:l,recency:u,normalizedQuery:s,semantic:n.semantic,limit:i}):[...d.values()].map(e=>{let t=Math.max(0,h0(e,s)),n=l.get(e.id)??0,r=u.get(e.id)??0;return{document:e,score:t+n*20+r,signals:{lexical:t,fullText:n,recency:r}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score).slice(0,i)}function x0(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function S0(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,semantic:o,limit:s}=e,c=o.rrfK??60,l=o.candidateLimit??64,u=o.similarityFloor??0,d=o.scores,f=new Map(t.map(e=>[e.id,e])),p=[...d.entries()].filter(([e,t])=>t>=u&&f.has(e)).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,l);for(let[e]of p)if(!n.has(e)){let t=f.get(e);t&&n.set(e,t)}let m=[...n.values()].map(e=>{let t=Math.max(0,h0(e,a)),n=r.get(e.id)??0,o=i.get(e.id)??0,s=d.get(e.id),c=s!==void 0&&s>=u;return{document:e,score:t+n*20+o,signals:c?{lexical:t,fullText:n,recency:o,vector:s}:{lexical:t,fullText:n,recency:o},lexical:t,fullText:n,recency:o,cosine:s}}),h=x0(m.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),g=x0(m.filter(e=>e.cosine!==void 0&&e.cosine>=u).sort((e,t)=>t.cosine-e.cosine||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=e=>{let t=0,n=h.get(e);n!==void 0&&(t+=1/(c+n));let r=g.get(e);return r!==void 0&&(t+=1/(c+r)),t};return m.sort((e,t)=>{let n=e.lexical>0?1:0,r=t.lexical>0?1:0;if(n!==r)return r-n;if(n===1)return e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score;let i=_(e.document.id),a=_(t.document.id);return i===a?e.recency===t.recency?e.document.path.localeCompare(t.document.path):t.recency-e.recency:a-i}).map(({document:e,score:t,signals:n})=>({document:e,score:t,signals:n})).slice(0,s)}function C0(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),w0(n)}function w0(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}const T0=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),E0=globalThis;E0[T0]===void 0&&(E0[T0]=Fi());const D0=E0[T0],O0=[`.ok`,`skill-state.yml`],k0=[`claude-cowork`,`cli-hosts`],A0=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],j0=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,M0=qs({version:k().regex(j0,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(D0,{description:`Recorded skill version for this target.`}),recordedAt:Vo().register(D0,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(A0).register(D0,{description:`Install-source surface that recorded this entry.`}).optional()}),N0=qs({schema:F(1).register(D0,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:qs({"claude-cowork":M0.optional(),"cli-hosts":M0.optional()}).register(D0,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function P0(){return{schema:1,targets:{}}}function F0(){let e=!1,t=``,n=0;return r=>{let i=I0(r);return e?(i&&i.char===t&&i.len>=n&&!i.hasInfo&&(e=!1,t=``,n=0),!0):i?(e=!0,t=i.char,n=i.len,!0):!1}}function I0(e){let t=(e.endsWith(`\r`)?e.slice(0,-1):e).match(/^ {0,3}([`~])(\1{2,})(.*)$/);return t?{char:t[1],len:1+t[2].length,hasInfo:t[3].trim()!==``}:null}const L0=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],R0={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function z0(e,t=L0){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const B0={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function V0(e){return e?B0[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const H0={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function U0(e){let t=e?.trim();return t?H0[V0(t)]??t:`Agent`}function W0(e,t){let n=e.trim();if(!n||/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=r>=0?n.slice(0,r):n,a=r>=0?n.slice(r+1):null,o=(i.split(`?`)[0]??``).trim();if(!o)return null;let s=(o.split(`/`).pop()??``).match(/\.([a-z0-9]+)$/i);if(s){let e=(s[1]??``).toLowerCase();if(e!==`md`&&e!==`mdx`)return null}let c=o.toLowerCase(),l=c.endsWith(`.mdx`)?o.slice(0,-4):c.endsWith(`.md`)?o.slice(0,-3):o,u=l.startsWith(`/`),d=u?l.slice(1):l,f=u?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of d.split(`/`))if(e===`..`){if(f.length===0)return null;f.pop()}else e!==`.`&&e!==``&&f.push(e);return f.length===0?null:{docName:f.join(`/`),anchor:a||null}}const G0=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function K0(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function q0(e){let t=e.trim();return G0.test(t)||t.startsWith(`//`)}function J0(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`#`)){let e=n.slice(1).trim();return e?{kind:`anchor`,anchor:e}:null}if(q0(n))return{kind:`external`,url:n};let r=W0(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=K0(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function Y0(e,t){let n=e.trim();if(!n)return null;if(q0(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=K0(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function X0(e,t){let n=e.trim();if(!n||G0.test(n)||n.startsWith(`//`)||n.startsWith(`#`))return null;let r=n.indexOf(`#`),i=((r>=0?n.slice(0,r):n).split(`?`)[0]??``).trim();if(!i)return null;let a=i.startsWith(`/`),o=a?i.slice(1):i,s=a?[]:t.includes(`/`)?t.split(`/`).slice(0,-1):[];for(let e of o.split(`/`))if(e===`..`){if(s.length===0)return null;s.pop()}else e!==`.`&&e!==``&&s.push(e);return s.length===0?null:s.join(`/`)}function Z0(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function Q0(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function $0(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function e2(e){return e.split(`/`).filter(e=>e!==``)}function t2(e,t){let n=$0(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function n2(e,t){let n=$0(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:e2(r).length}function r2(e,t){let n=e2(e),r=e2(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function i2(){let e=new Map;function t(t){let n=Z0(t);if(n===``)return;let r=Q0(n);if(r===``)return;let i=r.toLowerCase(),a=e.get(i);if(!a){e.set(i,[n]);return}a.includes(n)||a.push(n)}function n(t){let n=Z0(t),r=Q0(n).toLowerCase(),i=e.get(r);if(!i)return;let a=i.indexOf(n);a!==-1&&(i.splice(a,1),i.length===0&&e.delete(r))}function r(e,r){n(e),t(r)}function i(t,n){let r=t.toLowerCase(),i=e.get(r);if(!i||i.length===0)return null;if(i.length===1)return i[0];let a=$0(Z0(n)),o=[],s=[];for(let e of i)t2(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=n2(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=n2(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=r2(a,$0(t));for(let r=1;r<e.length;r++){let i=e[r],o=r2(a,$0(i));(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(s)}function a(){let t=new Map;for(let[n,r]of e)t.set(n,[...r]);return t}function o(){e.clear()}return{add:t,remove:n,rename:r,resolveEmbed:i,clear:o,snapshot:a,size:()=>e.size}}function a2(e){if(!e)return[];let t=e.split(`/`),n=[],r=``;for(let e of t)r=r?`${r}/${e}`:e,n.push(r);return n}function o2(e,t){if(e.size===0)return new Set;if(t===``)return new Set(e);let n=new Set,r=`${t}/`;for(let i of e)(i===t||i.startsWith(r))&&n.add(i);return n}function s2(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function c2(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function l2(){try{let e=_(g(b(import.meta.url)),`..`,`package.json`),t=JSON.parse(d(e,`utf-8`));if(typeof t.version==`string`&&t.version.length>0)return t.version}catch{}return`0.0.0-unknown`}const u2=l2(),d2=1;var f2=class extends Error{existing;lockPath;lockName;constructor(e,t,n){super(`Open Knowledge ${n} already running on port ${e.port} (pid ${e.pid}, started ${e.startedAt}). Stop it first or use a different directory. Lock: ${t}`),this.name=`ProcessLockCollisionError`,this.existing=e,this.lockPath=t,this.lockName=n}};function p2(e,t){return _(e,`${t}.lock`)}const m2=new Map;function h2(e){m2.set(e,(m2.get(e)??0)+1)}function g2(e){let t=m2.get(e);return t===void 0||t<=1?(m2.delete(e),!0):(m2.set(e,t-1),!1)}function _2(e,t){try{let n=JSON.parse(d(e,`utf-8`));return n&&typeof n==`object`&&c2(n.pid)?n:(console.warn(`${t} Corrupt lock file at ${e} — replacing`),null)}catch{return console.warn(`${t} Corrupt lock file at ${e} — replacing`),null}}function v2(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;l(n,{recursive:!0});let a=p2(n,t),o={pid:process.pid,hostname:y(),port:r.port,startedAt:new Date().toISOString(),worktreeRoot:r.worktreeRoot,...r.kind!==void 0&&{kind:r.kind},...r.parentPid!==void 0&&{parentPid:r.parentPid},...r.capabilities!==void 0&&{capabilities:r.capabilities},protocolVersion:r.protocolVersion??1,runtimeVersion:r.runtimeVersion??u2},d=JSON.stringify(o,null,2);for(let e=0;e<3;e++){if(!c(a))try{let e=u(a,`wx`,384);try{m(e,d)}finally{s(e)}return h2(a),y2({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=_2(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return p(a,d,{encoding:`utf-8`,mode:384}),h2(a),y2({lockName:t,lockDir:n,lockPath:a});if(r&&s2(e.pid))throw new f2(e,a,t);console.warn(`${i} Stale lock detected (pid=${e.pid}, host=${e.hostname}) — replacing`)}try{f(a)}catch{}}throw Error(`${i} Failed to acquire ${a} after 3 attempts (concurrent acquire contention).`)}function y2(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>C2({lockName:t,lockDir:n}),updatePort:e=>b2({lockName:t,lockDir:n,port:e})}}function b2(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=p2(n,t);if(!c(a)){console.warn(`${i} Lock file missing at ${a} during port update — skipping`);return}let o;try{let e=JSON.parse(d(a,`utf-8`));if(!e||typeof e!=`object`||!c2(e.pid)){console.warn(`${i} Corrupt lock at ${a} during port update — skipping`);return}o=e}catch{console.warn(`${i} Unreadable lock at ${a} during port update — skipping`);return}if(o.pid===process.pid&&!(typeof o.hostname==`string`&&o.hostname!==y())){o.port=r;try{p(a,JSON.stringify(o,null,2),{encoding:`utf-8`,mode:384})}catch(e){console.warn(`${i} Failed to update port in ${a}: ${e instanceof Error?e.message:String(e)}`)}}}function x2(e){let{lockName:t,lockDir:n}=e,r=p2(n,t);if(!c(r))return null;let i;try{let e=JSON.parse(d(r,`utf-8`));if(!e||typeof e!=`object`||!c2(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!s2(i.pid)){try{f(r)}catch{}return null}return i}function S2(e){let{lockName:t,lockDir:n}=e,r=p2(n,t);if(!c(r))return{status:`absent`};let i;try{i=JSON.parse(d(r,`utf-8`))}catch{return{status:`incompatible`,reason:`corrupt`,raw:void 0}}if(!i||typeof i!=`object`)return{status:`incompatible`,reason:`corrupt`,raw:i};let a=i;if(!c2(a.pid)||typeof a.hostname!=`string`||typeof a.port!=`number`||typeof a.startedAt!=`string`||typeof a.worktreeRoot!=`string`)return{status:`incompatible`,reason:`corrupt`,raw:i};let o={pid:a.pid,hostname:a.hostname,port:a.port,startedAt:a.startedAt,worktreeRoot:a.worktreeRoot,protocolVersion:typeof a.protocolVersion==`number`?a.protocolVersion:void 0,runtimeVersion:typeof a.runtimeVersion==`string`?a.runtimeVersion:void 0};if(o.hostname!==y())return{status:`stale`,lock:o};if(!s2(o.pid)){try{f(r)}catch{}return{status:`stale`,lock:o}}return o.protocolVersion===void 0||o.runtimeVersion===void 0?{status:`incompatible`,reason:`missing-fields`,raw:i}:{status:`live`,lock:o}}function C2(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=p2(n,t);if(g2(i)&&c(i))try{let e=JSON.parse(d(i,`utf-8`));if(!e||typeof e!=`object`||typeof e.pid!=`number`||e.pid!==process.pid||typeof e.hostname==`string`&&e.hostname!==y())return;f(i)}catch(e){console.warn(`${r} Failed to release ${i}: ${e instanceof Error?e.message:String(e)}`)}}var w2=class extends f2{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function T2(e,t){try{return v2({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof f2&&e.lockName===`server`?new w2(e.existing,e.lockPath):e}}function E2(e,t){b2({lockName:`server`,lockDir:e,port:t})}function D2(e){return x2({lockName:`server`,lockDir:e})}function O2(e){C2({lockName:`server`,lockDir:e})}export{xG as $,Ys as $i,I1 as $n,CQ as $r,j$ as $t,Gq as A,pl as Ai,Uq as An,U0 as Ar,jW as At,e0 as B,M as Bi,Qq as Bn,sq as Br,QQ as Bt,IQ as C,bl as Ci,R1 as Cn,F0 as Cr,z$ as Ct,FQ as D,vl as Di,b1 as Dn,mG as Dr,YQ as Dt,EQ as E,Zc as Ei,_1 as En,l0 as Er,k1 as Et,rG as F,Ns as Fi,Mq as Fn,XW as Fr,x1 as Ft,q1 as G,F as Gi,p1 as Gn,MG as Gr,Zq as Gt,K1 as H,Tc as Hi,m1 as Hn,Lq as Hr,_$ as Ht,Q1 as I,oc as Ii,Pq as In,GZ as Ir,C1 as It,gG as J,N as Ji,u1 as Jn,eG as Jr,m$ as Jt,G1 as K,qs as Ki,c1 as Kn,Fq as Kr,y$ as Kt,n0 as L,P as Li,W1 as Ln,mQ as Lr,F$ as Lt,KQ as M,Yc as Mi,Tq as Mn,C0 as Mr,o$ as Mt,zq as N,Hc as Ni,Aq as Nn,a2 as Nr,u$ as Nt,TQ as O,ll as Oi,h1 as On,pG as Or,RQ as Ot,QW as P,Uc as Pi,kq as Pn,hq as Pr,QG as Pt,SG as Q,k as Qi,j1 as Qn,IG as Qr,M$ as Qt,t0 as R,Rs as Ri,N0 as Rn,lQ as Rr,TG as Rt,DQ as S,xl as Si,r$ as Sn,i2 as Sr,t$ as St,LQ as T,Wc as Ti,g1 as Tn,d0 as Tr,O1 as Tt,Y1 as U,Zs as Ui,d1 as Un,NW as Ur,b$ as Ut,Z1 as V,j as Vi,p$ as Vn,V0 as Vr,S$ as Vt,J1 as W,$s as Wi,f1 as Wn,_q as Wr,x$ as Wt,CG as X,Oc as Xi,w1 as Xn,zW as Xr,KZ as Xt,wG as Y,sc as Yi,E1 as Yn,fG as Yr,g$ as Yt,bG as Z,tc as Zi,F1 as Zn,IW as Zr,P$ as Zt,R0 as _,D as _a,Rc as _i,k0 as _n,qq as _r,UQ as _t,v2 as a,Ua as aa,dq as ai,J$ as an,A$ as ar,U$ as at,E$ as b,Ic as bi,vG as bn,_G as br,OG as bt,c2 as c,vr as ca,ZW as ci,Jq as cn,t1 as cr,$G as ct,S2 as d,fn as da,gq as di,c$ as dn,Yq as dr,NG as dt,Hs as ea,WW as ei,jG as en,L1 as er,Bq as et,D2 as f,mn as fa,Ny as fi,n1 as fn,s$ as fr,EG as ft,E2 as g,O as ga,Bc as gi,O0 as gn,YW as gr,WQ as gt,b2 as h,Tt as ha,yl as hi,XG as hn,EW as hr,$$ as ht,w2 as i,da as ia,b0 as ii,hG as in,k$ as ir,H$ as it,qQ as j,Qc as ji,Cq as jn,P0 as jr,a$ as jt,PQ as k,ol as ki,V1 as kn,VW as kr,zQ as kt,p2 as l,cn as la,sQ as li,X$ as ln,kG as lr,AG as lt,O2 as m,Lt as ma,I as mi,ZG as mn,DW as mr,Q$ as mt,u2 as n,Vo as na,X0 as ni,FG as nn,P1 as nr,BQ as nt,T2 as o,Wa as oa,FW as oi,K$ as on,O$ as or,B$ as ot,C2 as p,on as pa,Cf as pi,r1 as pn,NQ as pr,f$ as pt,yG as q,A as qi,l1 as qn,mK as qr,v$ as qt,d2 as r,zo as ra,W0 as ri,LG as rn,M1 as rr,VQ as rt,s2 as s,ai as sa,o2 as si,Wq as sn,e1 as sr,V$ as st,f2 as t,_s as ta,wQ as ti,l$ as tn,N1 as tr,Hq as tt,x2 as u,un as ua,LW as ui,Z$ as un,Xq as ur,RG as ut,DG as v,pt as va,zc as vi,j0 as vn,J0 as vr,W$ as vt,OQ as w,hl as wi,H1 as wn,WX as wr,D1 as wt,D$ as x,Fc as xi,n$ as xn,z0 as xr,JG as xt,YG as y,ft as ya,Lc as yi,PG as yn,Y0 as yr,G$ as yt,$1 as z,Bs as zi,I$ as zn,JJ as zr,pK as zt};
|
|
430
|
+
//# sourceMappingURL=server-lock-BpjJj3OD-CfUjMF3O.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./server-lock-BpjJj3OD-CfUjMF3O.mjs";export{e as updateServerLockPort};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-
|
|
1
|
+
import{o as e}from"./chunk-FK9Q3tQk.mjs";import{t}from"./esm-CEs3LWY3.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-CfUjMF3O.mjs";import"./gh-detect-TiuAfW0N.mjs";import{Ir as a,hn as o}from"./dist-Bms63Kbz.mjs";import{g as s,h as c,k as l}from"./init-ClLEt0k7.mjs";import"./loader-x4Hpo3YH.mjs";import{c as u}from"./colors-BtKMHmBX.mjs";import"./preview-slpAYVBO.mjs";import{n as d}from"./write-project-skill-CoFl-uBP.mjs";import{spawnSync as f}from"node:child_process";import{existsSync as p,lstatSync as m,readFileSync as h,readdirSync as g,statSync as ee}from"node:fs";import{basename as te,dirname as _,isAbsolute as v,join as y,relative as b,resolve as x}from"node:path";import{hostname as ne}from"node:os";import{readFile as S,realpath as C}from"node:fs/promises";function w(e,t,a={}){let o=r(e,t);if(!p(o))return{status:`missing`,lockPath:o};let s;try{s=JSON.parse(h(o,`utf-8`))}catch{return{status:`corrupt`,lockPath:o}}if(!s||typeof s!=`object`||!n(s.pid))return{status:`corrupt`,lockPath:o};let c=s;if(!(a.isAlive??i)(c.pid))return{status:`dead-pid`,lockPath:o,lock:c};let l=a.host??ne();return c.hostname===l?{status:`alive`,lockPath:o,lock:c}:{status:`foreign-host`,lockPath:o,lock:c}}function T(e){return e.replace(/:\d+$/,``)}function E(e){let t=e.trim();if(!t)return null;{let e=/^https?:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`https`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^ssh:\/\/(?:[\w.-]+@)?([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`ssh`,hostname:T(e[1]),owner:e[2],name:e[3]}}{let e=/^git:\/\/([^/?#]+)\/([\w.\-~%]+)\/([\w.\-~%]+?)(?:\.git)?\/?$/.exec(t);if(e)return{protocol:`git`,hostname:T(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 D(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`).filter(e=>e.length>0);if(n.length<5||n[2]!==`blob`)return null;let r,i,a,o;try{r=decodeURIComponent(n[0]),i=decodeURIComponent(n[1]),a=decodeURIComponent(n[3]),o=n.slice(4).map(e=>decodeURIComponent(e))}catch{return null}return!r||!i||!a||o.length===0||o.some(e=>e.length===0)?null:{owner:r,repo:i,branch:a,path:o.join(`/`)}}function O(e){let t;try{t=new URL(e)}catch{return null}if(t.hostname!==`github.com`&&t.hostname!==`www.github.com`)return null;let n=t.pathname.split(`/`);if(n.length<5||n[0]!==``||n[3]!==`tree`)return null;let r=n.slice(5);r.length===1&&r[0]===``&&r.pop();let i,a,o,s;try{i=decodeURIComponent(n[1]),a=decodeURIComponent(n[2]),o=decodeURIComponent(n[4]),s=r.map(e=>decodeURIComponent(e))}catch{return null}return!i||!a||!o||s.some(e=>e.length===0)?null:{owner:i,repo:a,branch:o,path:s.join(`/`)}}function k(e){let t=D(e);if(t)return{kind:`doc`,...t};let n=O(e);return n?{kind:`folder`,...n}:null}const A=2e3,j=2e3,re=[/cli\.mjs/,/(^|[\s/])(open-knowledge|ok)\s+(start|mcp|ui)(\s|$)/,/Open Knowledge(?:\.app| Helper)/,/(^|[\s/])bun([\s/]).*?(run dev|packages\/app|vite|hocuspocus)/,/(^|[\s/])node([\s/]).*?(packages\/(cli|app)|vite|hocuspocus)/,/(^|\s)--ok-lock-dir-b64=/,/(^|\s)--ok-project-path=/];function M(e){return re.some(t=>t.test(e))}function ie(e){let t=e.trim().split(/\s+/).find(e=>e.startsWith(`--ok-lock-dir-b64=`));if(t==null)return null;let n=t.slice(18);if(!n)return null;try{let e=Buffer.from(n,`base64url`).toString(`utf8`);return v(e)?e:null}catch{return null}}function ae(e){let t=e.indexOf(`--ok-project-path=`);if(t===-1)return null;let n=t+18,r=e.slice(n),i=r.search(/\s--/),a=(i===-1?r:r.slice(0,i)).trim();return a&&v(a)?a:null}function oe(e){let t=[];for(let n of e.split(`
|
|
2
2
|
`)){let e=n.trim();if(!e)continue;let r=e.indexOf(` `);if(r===-1)continue;let i=e.slice(0,r),a=e.slice(r+1),o=Number.parseInt(i,10);!Number.isNaN(o)&&M(a)&&t.push({pid:o,command:a})}return t}function se(e){let t=[],n=e.split(`
|
|
3
3
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.indexOf(` `);if(i===-1)continue;let a=r.slice(0,i),o=r.slice(i+1).trim(),s=Number.parseInt(a,10);!Number.isNaN(s)&&M(o)&&t.push({pid:s,command:o})}return t}async function ce(){let e=f(`pgrep`,[`-a`,`-f`,`cli\\.mjs|open-knowledge|Open Knowledge(\\.app| Helper)|--ok-lock-dir-b64=|--ok-project-path=|(^|[ /])ok[ ]+(start|mcp|ui)([ ]|$)|packages/(cli|app)|hocuspocus|vite`],{encoding:`utf-8`,timeout:A});if(!(e.error!=null&&e.error.code===`ENOENT`)){let t=e.stdout??``,n=oe(t);if(n.length>0||t.trim()===``)return n}let t=f(`ps`,[`-axo`,`pid,command`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?[]:se(t.stdout)}function le(e){let t=e.trim().split(/\s+/).filter(Boolean);for(let e of t){if(e.startsWith(`@`))continue;let t=te(e);if(t===`open-knowledge`||t===`ok`||e.endsWith(`/packages/cli/src/cli.ts`)||e.endsWith(`/packages/cli/dist/cli.mjs`)||t===`cli.mjs`||t===`cli.ts`)return e}return null}function N(e){let t=f(`ps`,[`-p`,String(e),`-o`,`command=`],{encoding:`utf-8`,timeout:A});return t.error!=null||!t.stdout?null:t.stdout.trim()||null}function P(e){let t=f(`ps`,[`-p`,String(e),`-o`,`%cpu=,%mem=`],{encoding:`utf-8`,timeout:A});if(t.error!=null||!t.stdout)return null;let[n,r]=t.stdout.trim().split(/\s+/),i=Number.parseFloat(n??``),a=Number.parseFloat(r??``);return Number.isNaN(i)||Number.isNaN(a)?null:{cpuPercent:i,memPercent:a}}async function F(e){let t=f(`lsof`,[`-p`,String(e),`-a`,`-d`,`cwd`,`-Fn`],{encoding:`utf-8`,timeout:A});if(t.error!=null)return null;let n=t.stdout??``;for(let e of n.split(`
|
|
4
4
|
`))if(e.startsWith(`n`)&&e.length>1)return e.slice(1);return null}function I(e){let t=[],n=e.split(`
|
|
5
5
|
`);for(let e=1;e<n.length;e++){let r=n[e]?.trim();if(!r)continue;let i=r.split(/\s+/);if(i.length<2)continue;let a=Number.parseInt(i[1]??``,10);Number.isNaN(a)||t.push(a)}return[...new Set(t)]}function L(e){return p(y(e,`server.lock`))||p(y(e,`ui.lock`))}function R(e,t){for(let n of[y(t,`.ok`,`local`),y(t,`.ok`)])p(n)&&L(n)&&e.add(n)}function z(e,t){let n=0,r=(t,i)=>{if(n>=j||(n++,R(e,t),i>=3))return;let a;try{a=g(t)}catch{return}for(let e of a){if(n>=j)return;if(e===`node_modules`||e===`.git`||e===`Library`||e.startsWith(`.`)&&e!==`.ok`)continue;let a=y(t,e),o=!1;try{o=m(a).isDirectory()}catch{continue}o&&r(a,i+1)}};r(t,0)}async function B(){let e=new Set,t=await ce(),n=t.map(e=>F(e.pid)),r=await Promise.all(n);for(let n of t){let t=ie(n.command);t!=null&&p(t)&&e.add(t);let r=ae(n.command);r!=null&&R(e,r)}for(let t of r)t!=null&&R(e,t);let i=f(`lsof`,[`-iTCP`,`-sTCP:LISTEN`,`-nP`],{encoding:`utf-8`,timeout:A});if(i.error==null&&i.stdout){let n=I(i.stdout),r=new Set(t.map(e=>e.pid)),a=n.filter(e=>!r.has(e)).map(e=>F(e)),o=await Promise.all(a);for(let t of o)t!=null&&R(e,t)}(e.size===0||r.some(e=>e===`/`))&&z(e,process.cwd());let a=new Map;for(let t of e)try{let e=await C(t);a.set(e,e)}catch{a.set(t,t)}return[...a.values()]}var V=e(u(),1);function H(e){return e==null?!1:e.includes(`--type=utility`)&&e.includes(`--utility-sub-type=node.mojom.NodeService`)}function U(e,t=Date.now()){let n=new Date(e).getTime();if(Number.isNaN(n))return`—`;let r=t-n,i=Math.floor(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function W(e,t,n,r,i,a){if(t.status===`missing`||t.status===`corrupt`)return null;let o=t.lock,s=null;if(n.status!==`missing`&&n.status!==`corrupt`){let e=n.lock;s={port:e.port,status:n.status,pid:e.pid,startedAt:e.startedAt,usage:a}}return{directory:o.worktreeRoot,server:{port:o.port,status:t.status,pid:o.pid,startedAt:o.startedAt,usage:i},ui:s,hostname:o.hostname,lockPath:t.lockPath,binary:r==null?null:le(r),command:r,isDesktop:H(r)}}function ue(e){return e.ui==null?!1:e.ui.status===`alive`||e.ui.status===`foreign-host`}function G(e){let t=e.server.status;return t===`alive`||t===`foreign-host`?e.isDesktop?`desktop`:t===`alive`?`running`:`foreign`:t===`dead-pid`&&ue(e)?`ui-orphan`:`stale`}const de=new Set([`running`,`desktop`,`foreign`,`ui-orphan`]);function fe(e){switch(e){case`running`:return V.default.green(e);case`desktop`:return V.default.blue(e);case`foreign`:return V.default.cyan(e);case`ui-orphan`:return V.default.magenta(e);case`stale`:return V.default.yellow(e)}}function K(e){return e==null?`—`:`${e.cpuPercent.toFixed(1)}% / ${e.memPercent.toFixed(1)}%`}function pe(e){return`${K(e.server.usage)} | ${K(e.ui?.usage??null)}`}function me(e){return`${e.server.port===0?`(starting)`:String(e.server.port)} / ${e.ui==null||e.ui.status===`dead-pid`?`—`:String(e.ui.port)}`}function he(e){if(e.length===0)return`No open-knowledge servers found.`;let t=[`DIRECTORY`,`PORTS (API/UI)`,`CPU/MEM (API | UI)`,`STATUS`,`PID`,`STARTED`,`BINARY`],n=e.map(e=>{let t=G(e),n=t===`ui-orphan`&&e.ui!=null?e.ui.pid:e.server.pid;return[e.directory,me(e),pe(e),t,String(n),U(e.server.startedAt),e.binary??`—`]}),r=t.length,i=t.map(e=>e.length);for(let e of n)for(let t=0;t<r;t++)i[t]=Math.max(i[t]??0,(e[t]??``).length);let a=t.map((e,t)=>e.padEnd(i[t]??0)).join(` `).trimEnd(),o=e.map((e,t)=>{let a=n[t]??[],o=[];for(let t=0;t<r;t++){let n=(a[t]??``).padEnd(i[t]??0);if(t===3){let r=a[t]??``;n=fe(G(e))+` `.repeat(Math.max(0,(i[t]??0)-r.length))}o.push(n)}return o.join(` `).trimEnd()}),s=V.default.dim(`To stop a server: ok stop <port|pid|directory|all>`);return[a,...o,``,s].join(`
|
|
6
6
|
`)}async function q(e={}){let t=e.discover??B,n=e.inspect??w,r=e.log??(e=>console.log(e)),i=e.resolveCommand??N,a=e.resolveUsage??P,o=await t(),s=[];for(let e of o){let t=n(e,`server`),r=n(e,`ui`),o=W(e,t,r,t.status===`missing`||t.status===`corrupt`?null:i(t.lock.pid),t.status===`missing`||t.status===`corrupt`?null:a(t.lock.pid),r.status===`missing`||r.status===`corrupt`?null:a(r.lock.pid));o!=null&&s.push(o)}if(e.json){let e=s.map(e=>({...e,displayStatus:G(e)}));r(JSON.stringify(e,null,2));return}r(he(e.all?s:s.filter(e=>de.has(G(e)))))}function ge(){return new t(`ps`).description(`List all running open-knowledge servers`).argument(`[modifier]`,`"all" to include stale (dead-pid) entries`).option(`--all`,`Include stale (dead-pid) entries (foreign-host shows by default)`).option(`--json`,`Emit structured JSON (always includes all statuses)`).action(async(e,t)=>{await q({all:t.all===!0||e===`all`,json:t.json===!0})})}const _e=new Set([`start`,`stop`,`status`,`clean`,`ui`,`mcp`,`preview`]);function ve(e,t,n=o){if(e!==void 0&&!_e.has(e))return null;let r=n(t);return r===null||r.distance===0?null:r.rootPath}let J=null;function ye(e){J=e}function be(){return J??process.cwd()}function xe(e,t,n={}){let r=n.isAlive??i,a=[];for(let[n,i]of[[`server`,e],[`ui`,t]])(i.status===`alive`||i.status===`foreign-host`&&r(i.lock.pid))&&a.push({name:n,pid:i.lock.pid,port:i.lock.port});return{targets:a}}function Y(e){let t=e.inspect??(t=>w(e.lockDir,t)),n=e.kill??((e,t)=>process.kill(e,t)),r=e.log??(e=>console.log(e)),i=e.error??(e=>console.error(e)),a=xe(t(`server`),t(`ui`),{isAlive:e.isAlive});if(a.targets.length===0)return r(`No running open-knowledge processes.`),{stopped:[],failed:[],hadTargets:!1};let o=[],s=[];for(let e of a.targets)try{n(e.pid,`SIGTERM`),o.push(e)}catch(t){s.push({target:e,error:t instanceof Error?t.message:String(t)})}return o.length>0&&r(`Stopped: ${o.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `)}`),s.length>0&&i(`Failed to stop: ${s.map(({target:e,error:t})=>`${e.name} (pid=${e.pid}): ${t}`).join(`; `)}`),{stopped:o,failed:s,hadTargets:!0}}function X(e,t){return e.status===`alive`?!0:e.status===`foreign-host`?t(e.lock.pid):!1}async function Se(e,t=i){let n=await B(),r=null;for(let i of n){let n=w(i,`server`),a=w(i,`ui`);if(X(n,t)&&n.lock.port===e||X(a,t)&&a.lock.port===e)return i;r===null&&(X(n,t)&&n.lock.pid===e||X(a,t)&&a.lock.pid===e)&&(r=i)}return r}function Z(e){let t=Y({lockDir:e});return t.failed.length>0&&(process.exitCode=1),t}function Ce(e){return new t(`stop`).description(`Stop open-knowledge server(s). With no argument: stops the server for the current directory. Pass a port number, a directory path, or "all" to target globally.`).argument(`[target...]`,`port number, directory path (spaces OK), or "all"`).action(async t=>{let n=t.length===0?void 0:t.join(` `);if(n===void 0){e();let t=Y({lockDir:a(process.cwd()),log:()=>{}});if(t.hadTargets){if(t.stopped.length>0){let e=t.stopped.map(e=>`${e.name} (pid=${e.pid}, port=${e.port})`).join(`, `);console.log(`Stopped: ${e}`)}t.failed.length>0&&(process.exitCode=1)}else await q({});return}if(n===`all`){let e=await B();if(e.length===0){console.log(`No running open-knowledge servers found.`);return}let t=0;for(let n of e){let e=w(n,`server`),r=w(n,`ui`);!X(e,i)&&!X(r,i)||(Z(n),t++)}t===0&&console.log(`No running open-knowledge servers found.`);return}if(/^\d+$/.test(n)){let e=Number.parseInt(n,10),t=await Se(e);if(t===null){console.log(`No running open-knowledge server found with port or PID ${e}.`);return}Z(t);return}Z(a(x(be(),n)))})}async function we(e,t){let n,r;try{n=await C(x(e)),r=await C(x(_(e)))}catch{return{kind:`not-git`}}if(!$(n,r))return{kind:`symlink-escape`};let i=y(n,`.git`),a;try{a=ee(i)}catch{return{kind:`not-git`}}let o;if(a.isDirectory()){let e;try{e=await C(i)}catch{return{kind:`not-git`}}if(!$(e,n))return{kind:`symlink-escape`};o=e}else if(a.isFile()){let e;try{e=await S(i,`utf-8`)}catch{return{kind:`not-git`}}let t=/^gitdir:\s*(.+)$/m.exec(e.trim());if(!t)return{kind:`not-git`};let r=t[1].trim(),a=v(r)?r:x(n,r);try{o=await C(a)}catch{return{kind:`not-git`}}}else return{kind:`not-git`};let s=y(await Q(o),`config`),c;try{c=await S(s,`utf-8`)}catch{return{kind:`not-git`}}let l=Ee(c);if(l===null)return{kind:`no-origin`};let u=E(l);if(u===null||u.hostname!==`github.com`)return{kind:`non-github`};let d=u.owner.toLowerCase()===t.owner.toLowerCase(),f=u.name.toLowerCase()===t.repo.toLowerCase();return!d||!f?{kind:`wrong-repo`,actualOwner:u.owner,actualRepo:u.name}:{kind:`ok`,gitRemoteUrl:`https://github.com/${u.owner}/${u.name}.git`}}async function Q(e){let t;try{t=(await S(y(e,`commondir`),`utf-8`)).trim()}catch{return e}if(t.length===0)return e;let n=v(t)?t:x(e,t);try{return await C(n)}catch{return n}}function $(e,t){if(e===t)return!0;let n=b(t,e);return n.length>0&&!n.startsWith(`..`)&&!v(n)}function Te(e){let t=e.indexOf(`#`),n=e.indexOf(`;`),r=-1;return t>=0&&n>=0?r=Math.min(t,n):t>=0?r=t:n>=0&&(r=n),(r===-1?e:e.slice(0,r)).trim()}function Ee(e){let t=!1;for(let n of e.split(/\r?\n/)){let e=Te(n);if(e.length===0)continue;if(e.startsWith(`[`)){t=/^\[\s*remote\s+["']origin["']\s*\]$/.test(e);continue}if(!t)continue;let r=/^url\s*=\s*(.+)$/.exec(e);if(r)return De(r[1])}return null}function De(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}const Oe=[{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=s(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`}:{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 n=d(e,t);return{integration:`project-skill`,editorId:e.id,action:n.action,...n.path?{path:n.path}:{},...n.error?{error:n.error}:{}}}catch(t){return{integration:`project-skill`,editorId:e.id,action:`failed`,error:t instanceof Error?t.message:String(t)}}}}];function ke(e,t,n={},r=Oe){let i=[];for(let a of t){let t=l[a];for(let a of r)i.push(a.write(t,e,n))}return i}function Ae(e,t,n={}){return{integrations:ke(e,t,n),claudeLaunchJson:t.includes(`claude`)?c(e,n):void 0}}export{ye as a,B as c,D as d,k as f,w as h,Ce as i,N as l,E as m,we as n,ve as o,O as p,Y as r,ge as s,Ae as t,P as u};
|
|
7
|
-
//# sourceMappingURL=src-
|
|
7
|
+
//# sourceMappingURL=src-Lw06Pp2P.mjs.map
|