@inkeep/open-knowledge 0.16.1-beta.1 → 0.16.1-beta.10
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 +6 -6
- package/dist/config-schema.json +17 -9
- package/dist/config.project-local.schema.json +17 -9
- package/dist/config.project.schema.json +17 -1
- package/dist/config.user.schema.json +17 -1
- package/dist/constants-B0QLOhFl.mjs +2 -0
- package/dist/{dist-DK6nQomd.mjs → dist-DrTAfRJI.mjs} +6 -6
- package/dist/{dist-DI00wise.mjs → dist-LsppKGkv.mjs} +1 -1
- package/dist/{gh-detect-Dfl-0bCl.mjs → gh-detect-CEob6rSE.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/init-DawgWPKe.mjs +1 -0
- package/dist/{init-BuVVoeqs.mjs → init-qn36c3HB.mjs} +4 -4
- package/dist/{loader-Cdaa6CrF.mjs → loader-An2Ns2eZ.mjs} +2 -2
- package/dist/loader-C0BxOlRv.mjs +1 -0
- package/dist/{preview-CmvbuLFx.mjs → preview-DKNJ3xmp.mjs} +2 -2
- package/dist/preview-DX_y9F6z.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-BZfDggRe.js → ActivityModeContent-DKpBhLuw.js} +1 -1
- package/dist/public/assets/{DocumentContext-D8INk7jT.js → DocumentContext-BR6HKC4G.js} +3 -3
- package/dist/public/assets/{GraphPanel-Ch6asGi2.js → GraphPanel-5UhSd8l0.js} +1 -1
- package/dist/public/assets/{OpenInAgentMenuRequestContext-MdDQqW0P.js → OpenInAgentMenuRequestContext-B3Gxr9nv.js} +1 -1
- package/dist/public/assets/SettingsDialogBody-CBC8_9q_.js +7 -0
- package/dist/public/assets/SourceEditor-Dv-b05s_.js +2 -0
- package/dist/public/assets/{TerminalPanel-Cjyt7ADc.js → TerminalPanel-Bj2Zsd7g.js} +1 -1
- package/dist/public/assets/config-validation-events-BKFQM-aH.js +12 -0
- package/dist/public/assets/{dist-BIbxx2ds.js → dist-CSrq-tfq.js} +2 -2
- package/dist/public/assets/index-BQ8I_aNc.css +1 -0
- package/dist/public/assets/index-nqDxLuXJ.js +2002 -0
- package/dist/public/assets/{keyboard-shortcuts-DhU9JBBP.js → keyboard-shortcuts-DQSB-PIq.js} +1 -1
- package/dist/public/assets/{prop-types-JdxpK0Ba.js → prop-types-BegaE8MN.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-h5JrxhMT.js → target-navigation-intent-DK2ymubU.js} +1 -1
- package/dist/public/index.html +9 -9
- package/dist/{repair-launch-json-3Z4fXvrz.mjs → repair-launch-json-o2Jm1MZZ.mjs} +2 -2
- package/dist/{repair-mcp-configs-CfMHuE87.mjs → repair-mcp-configs-BfhtrKPO.mjs} +2 -2
- package/dist/{repair-skills-fEOpZb8J.mjs → repair-skills-BgFasQ-j.mjs} +2 -2
- package/dist/repair-skills-D4KInMdR.mjs +1 -0
- package/dist/schemas/v0/config.project-local.schema.json +17 -9
- package/dist/schemas/v0/config.project.schema.json +17 -1
- package/dist/schemas/v0/config.user.schema.json +17 -1
- package/dist/{server-lock-BpjJj3OD-7KPAM7xJ.mjs → server-lock-BpjJj3OD-lsTSrbso.mjs} +3 -3
- package/dist/server-lock-CyhBidkz-B2MlIotv.mjs +1 -0
- package/dist/{src-CSi1jwK-.mjs → src-mVEjFVvA.mjs} +2 -2
- package/dist/{start-B6t-aE3I.mjs → start-BjxTNWMJ.mjs} +2 -2
- package/dist/start-D2GVyIP5.mjs +1 -0
- package/dist/{write-project-skill-tUkoCT_R.mjs → write-project-skill-Dj8OKpHt.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-CAj2OG6r.mjs +0 -2
- package/dist/init-ElfEbTWy.mjs +0 -1
- package/dist/loader-bbAwSl3z.mjs +0 -1
- package/dist/preview-6aJgEhTw.mjs +0 -1
- package/dist/public/assets/SettingsDialogBody-B_p9wl5R.js +0 -7
- package/dist/public/assets/SourceEditor-D5__UsME.js +0 -2
- package/dist/public/assets/config-validation-events-B31yU1ex.js +0 -12
- package/dist/public/assets/index-CQsSvQMF.js +0 -2002
- package/dist/public/assets/index-GNAYzOUb.css +0 -1
- package/dist/repair-skills-BRbSYbWT.mjs +0 -1
- package/dist/server-lock-CyhBidkz-Cn1wgQoO.mjs +0 -1
- package/dist/start-CTh6vTLm.mjs +0 -1
|
@@ -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(`$ZodLazy`,(e,t)=>{vr.init(e,t),Tt(e._zod,`innerType`,()=>t.getter()),Tt(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),Tt(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),Tt(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),Tt(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Mi=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=>Ni(t,n,r,e));Ni(i,n,r,e)}});function Ni(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 Pi,Fi=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 Ii(){return new Fi}(Pi=globalThis).__zod_globalRegistry??(Pi.__zod_globalRegistry=Ii());const Li=globalThis.__zod_globalRegistry;function Ri(e,t){return new e({type:`string`,...O(t)})}function zi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...O(t)})}function Bi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...O(t)})}function Vi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...O(t)})}function Hi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...O(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...O(t)})}function Wi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...O(t)})}function Gi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...O(t)})}function Ki(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...O(t)})}function qi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...O(t)})}function Ji(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...O(t)})}function Yi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...O(t)})}function Xi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...O(t)})}function Zi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...O(t)})}function Qi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...O(t)})}function $i(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...O(t)})}function ea(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...O(t)})}function ta(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...O(t)})}function na(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...O(t)})}function ra(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...O(t)})}function ia(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...O(t)})}function aa(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...O(t)})}function oa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...O(t)})}function sa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...O(t)})}function ca(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...O(t)})}function la(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...O(t)})}function ua(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...O(t)})}function da(e,t){return new e({type:`number`,checks:[],...O(t)})}function fa(e,t){return new e({type:`number`,coerce:!0,checks:[],...O(t)})}function pa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...O(t)})}function ma(e,t){return new e({type:`boolean`,...O(t)})}function ha(e,t){return new e({type:`null`,...O(t)})}function ga(e){return new e({type:`any`})}function _a(e){return new e({type:`unknown`})}function va(e,t){return new e({type:`never`,...O(t)})}function ya(e,t){return new tr({check:`less_than`,...O(t),value:e,inclusive:!1})}function ba(e,t){return new tr({check:`less_than`,...O(t),value:e,inclusive:!0})}function xa(e,t){return new nr({check:`greater_than`,...O(t),value:e,inclusive:!1})}function Sa(e,t){return new nr({check:`greater_than`,...O(t),value:e,inclusive:!0})}function Ca(e,t){return new rr({check:`multiple_of`,...O(t),value:e})}function wa(e,t){return new ar({check:`max_length`,...O(t),maximum:e})}function Ta(e,t){return new or({check:`min_length`,...O(t),minimum:e})}function Ea(e,t){return new sr({check:`length_equals`,...O(t),length:e})}function Da(e,t){return new lr({check:`string_format`,format:`regex`,...O(t),pattern:e})}function Oa(e){return new ur({check:`string_format`,format:`lowercase`,...O(e)})}function ka(e){return new dr({check:`string_format`,format:`uppercase`,...O(e)})}function Aa(e,t){return new fr({check:`string_format`,format:`includes`,...O(t),includes:e})}function ja(e,t){return new pr({check:`string_format`,format:`starts_with`,...O(t),prefix:e})}function Ma(e,t){return new mr({check:`string_format`,format:`ends_with`,...O(t),suffix:e})}function Na(e){return new hr({check:`overwrite`,tx:e})}function Pa(e){return Na(t=>t.normalize(e))}function Fa(){return Na(e=>e.trim())}function Ia(){return Na(e=>e.toLowerCase())}function La(){return Na(e=>e.toUpperCase())}function Ra(){return Na(e=>kt(e))}function za(e,t,n){return new e({type:`array`,element:t,...O(n)})}function Ba(e,t,n){let r=O(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Va(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...O(n)})}function Ha(e){let t=Ua(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 Ua(e,t){let n=new $n({check:`custom`,...O(t)});return n._zod.check=e,n}function Wa(e){let t=new $n({check:`describe`});return t._zod.onattach=[t=>{let n=Li.get(t)??{};Li.add(t,{...n,description:e})}],t._zod.check=()=>{},t}function Ga(e){let t=new $n({check:`meta`});return t._zod.onattach=[t=>{let n=Li.get(t)??{};Li.add(t,{...n,...e})}],t._zod.check=()=>{},t}function Ka(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??Li,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 qa(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,qa(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`&&Xa(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 Ja(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 Ya(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:Qa(t,`input`,e.processors),output:Qa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Xa(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 Xa(r.element,n);if(r.type===`set`)return Xa(r.valueType,n);if(r.type===`lazy`)return Xa(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 Xa(r.innerType,n);if(r.type===`intersection`)return Xa(r.left,n)||Xa(r.right,n);if(r.type===`record`||r.type===`map`)return Xa(r.keyType,n)||Xa(r.valueType,n);if(r.type===`pipe`)return Xa(r.in,n)||Xa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Xa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Xa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Xa(e,n))return!0;return!!(r.rest&&Xa(r.rest,n))}return!1}const Za=(e,t={})=>n=>{let r=Ka({...n,processors:t});return qa(e,r),Ja(r,e),Ya(r,e)},Qa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ka({...i??{},target:a,io:t,processors:n});return qa(e,o),Ja(o,e),Ya(o,e)},$a={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},eo=(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=$a[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}))])}},to=(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)},no=(e,t,n,r)=>{n.type=`boolean`},ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},io=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ao=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},co=(e,t,n,r)=>{n.not={}},lo=(e,t,n,r)=>{},uo=(e,t,n,r)=>{},fo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},po=(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},mo=(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},ho=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},go=(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},_o=(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)},vo=(e,t,n,r)=>{n.type=`boolean`},yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},bo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},wo=(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=qa(a.element,t,{...r,path:[...r.path,`items`]})},To=(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]=qa(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=qa(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Eo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>qa(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Do=(e,t,n,r)=>{let i=e._zod.def,a=qa(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=qa(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]]},Oo=(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)=>qa(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?qa(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)},ko=(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=qa(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=qa(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=qa(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)}},Ao=(e,t,n,r)=>{let i=e._zod.def,a=qa(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`}]},jo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},No=(e,t,n,r)=>{let i=e._zod.def;qa(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)))},Po=(e,t,n,r)=>{let i=e._zod.def;qa(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},Fo=(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;qa(a,t,r);let o=t.seen.get(e);o.ref=a},Io=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Lo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ro=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zo=(e,t,n,r)=>{let i=e._zod.innerType;qa(i,t,r);let a=t.seen.get(e);a.ref=i},Bo={string:eo,number:to,boolean:no,bigint:ro,symbol:io,null:ao,undefined:oo,void:so,never:co,any:lo,unknown:uo,date:fo,enum:po,literal:mo,nan:ho,template_literal:go,file:_o,success:vo,custom:yo,function:bo,transform:xo,map:So,set:Co,array:wo,object:To,union:Eo,intersection:Do,tuple:Oo,record:ko,nullable:Ao,nonoptional:jo,default:Mo,prefault:No,catch:Po,pipe:Fo,readonly:Io,promise:Lo,optional:Ro,lazy:zo};function Vo(e,t){if(`_idmap`in e){let n=e,r=Ka({...t,processors:Bo}),i={};for(let e of n._idmap.entries()){let[t,n]=e;qa(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Ja(r,n),a[t]=Ya(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ka({...t,processors:Bo});return qa(e,n),Ja(n,e),Ya(n,e)}const Ho=D(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),ms.init(e,t)});function Uo(e){return sa(Ho,e)}const Wo=D(`ZodISODate`,(e,t)=>{Nr.init(e,t),ms.init(e,t)});function Go(e){return ca(Wo,e)}const Ko=D(`ZodISOTime`,(e,t)=>{Pr.init(e,t),ms.init(e,t)});function qo(e){return la(Ko,e)}const Jo=D(`ZodISODuration`,(e,t)=>{Fr.init(e,t),ms.init(e,t)});function Yo(e){return ua(Jo,e)}const Xo=(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`,Xo);const Zo=D(`ZodError`,Xo,{Parent:Error}),Qo=sn(Zo),$o=ln(Zo),es=dn(Zo),ts=pn(Zo),ns=hn(Zo),rs=gn(Zo),is=_n(Zo),as=vn(Zo),ss=yn(Zo),cs=bn(Zo),ls=xn(Zo),us=Sn(Zo),ds=D(`ZodType`,(e,t)=>(vr.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Qa(e,`input`),output:Qa(e,`output`)}}),e.toJSONSchema=Za(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)=>Qo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>es(e,t,n),e.parseAsync=async(t,n)=>$o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ts(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ns(e,t,n),e.decode=(t,n)=>rs(e,t,n),e.encodeAsync=async(t,n)=>is(e,t,n),e.decodeAsync=async(t,n)=>as(e,t,n),e.safeEncode=(t,n)=>ss(e,t,n),e.safeDecode=(t,n)=>cs(e,t,n),e.safeEncodeAsync=async(t,n)=>ls(e,t,n),e.safeDecodeAsync=async(t,n)=>us(e,t,n),e.refine=(t,n)=>e.check(Ac(t,n)),e.superRefine=t=>e.check(jc(t)),e.overwrite=t=>e.check(Na(t)),e.optional=()=>lc(e),e.exactOptional=()=>dc(e),e.nullable=()=>pc(e),e.nullish=()=>lc(pc(e)),e.nonoptional=t=>yc(e,t),e.array=()=>M(e),e.or=t=>Zs([e,t]),e.and=t=>tc(e,t),e.transform=t=>Cc(e,sc(t)),e.default=t=>hc(e,t),e.prefault=t=>_c(e,t),e.catch=t=>xc(e,t),e.pipe=t=>Cc(e,t),e.readonly=()=>Tc(e),e.describe=t=>{let n=e.clone();return Li.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Li.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Li.get(e);let n=e.clone();return Li.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),fs=D(`_ZodString`,(e,t)=>{yr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(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(Da(...t)),e.includes=(...t)=>e.check(Aa(...t)),e.startsWith=(...t)=>e.check(ja(...t)),e.endsWith=(...t)=>e.check(Ma(...t)),e.min=(...t)=>e.check(Ta(...t)),e.max=(...t)=>e.check(wa(...t)),e.length=(...t)=>e.check(Ea(...t)),e.nonempty=(...t)=>e.check(Ta(1,...t)),e.lowercase=t=>e.check(Oa(t)),e.uppercase=t=>e.check(ka(t)),e.trim=()=>e.check(Fa()),e.normalize=(...t)=>e.check(Pa(...t)),e.toLowerCase=()=>e.check(Ia()),e.toUpperCase=()=>e.check(La()),e.slugify=()=>e.check(Ra())}),ps=D(`ZodString`,(e,t)=>{yr.init(e,t),fs.init(e,t),e.email=t=>e.check(zi(hs,t)),e.url=t=>e.check(Gi(vs,t)),e.jwt=t=>e.check(oa(Ps,t)),e.emoji=t=>e.check(Ki(bs,t)),e.guid=t=>e.check(Bi(gs,t)),e.uuid=t=>e.check(Vi(_s,t)),e.uuidv4=t=>e.check(Hi(_s,t)),e.uuidv6=t=>e.check(Ui(_s,t)),e.uuidv7=t=>e.check(Wi(_s,t)),e.nanoid=t=>e.check(qi(xs,t)),e.guid=t=>e.check(Bi(gs,t)),e.cuid=t=>e.check(Ji(Ss,t)),e.cuid2=t=>e.check(Yi(Cs,t)),e.ulid=t=>e.check(Xi(ws,t)),e.base64=t=>e.check(ra(js,t)),e.base64url=t=>e.check(ia(Ms,t)),e.xid=t=>e.check(Zi(Ts,t)),e.ksuid=t=>e.check(Qi(Es,t)),e.ipv4=t=>e.check($i(Ds,t)),e.ipv6=t=>e.check(ea(Os,t)),e.cidrv4=t=>e.check(ta(ks,t)),e.cidrv6=t=>e.check(na(As,t)),e.e164=t=>e.check(aa(Ns,t)),e.datetime=t=>e.check(Uo(t)),e.date=t=>e.check(Go(t)),e.time=t=>e.check(qo(t)),e.duration=t=>e.check(Yo(t))});function k(e){return Ri(ps,e)}const ms=D(`ZodStringFormat`,(e,t)=>{br.init(e,t),fs.init(e,t)}),hs=D(`ZodEmail`,(e,t)=>{Cr.init(e,t),ms.init(e,t)}),gs=D(`ZodGUID`,(e,t)=>{xr.init(e,t),ms.init(e,t)}),_s=D(`ZodUUID`,(e,t)=>{Sr.init(e,t),ms.init(e,t)}),vs=D(`ZodURL`,(e,t)=>{wr.init(e,t),ms.init(e,t)});function ys(e){return Gi(vs,e)}const bs=D(`ZodEmoji`,(e,t)=>{Tr.init(e,t),ms.init(e,t)}),xs=D(`ZodNanoID`,(e,t)=>{Er.init(e,t),ms.init(e,t)}),Ss=D(`ZodCUID`,(e,t)=>{Dr.init(e,t),ms.init(e,t)}),Cs=D(`ZodCUID2`,(e,t)=>{Or.init(e,t),ms.init(e,t)}),ws=D(`ZodULID`,(e,t)=>{kr.init(e,t),ms.init(e,t)}),Ts=D(`ZodXID`,(e,t)=>{Ar.init(e,t),ms.init(e,t)}),Es=D(`ZodKSUID`,(e,t)=>{jr.init(e,t),ms.init(e,t)}),Ds=D(`ZodIPv4`,(e,t)=>{Ir.init(e,t),ms.init(e,t)}),Os=D(`ZodIPv6`,(e,t)=>{Lr.init(e,t),ms.init(e,t)}),ks=D(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),ms.init(e,t)}),As=D(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),ms.init(e,t)}),js=D(`ZodBase64`,(e,t)=>{Vr.init(e,t),ms.init(e,t)}),Ms=D(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),ms.init(e,t)}),Ns=D(`ZodE164`,(e,t)=>{Wr.init(e,t),ms.init(e,t)}),Ps=D(`ZodJWT`,(e,t)=>{Kr.init(e,t),ms.init(e,t)}),Fs=D(`ZodNumber`,(e,t)=>{qr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.gt=(t,n)=>e.check(xa(t,n)),e.gte=(t,n)=>e.check(Sa(t,n)),e.min=(t,n)=>e.check(Sa(t,n)),e.lt=(t,n)=>e.check(ya(t,n)),e.lte=(t,n)=>e.check(ba(t,n)),e.max=(t,n)=>e.check(ba(t,n)),e.int=t=>e.check(Ls(t)),e.safe=t=>e.check(Ls(t)),e.positive=t=>e.check(xa(0,t)),e.nonnegative=t=>e.check(Sa(0,t)),e.negative=t=>e.check(ya(0,t)),e.nonpositive=t=>e.check(ba(0,t)),e.multipleOf=(t,n)=>e.check(Ca(t,n)),e.step=(t,n)=>e.check(Ca(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 da(Fs,e)}const Is=D(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Fs.init(e,t)});function Ls(e){return pa(Is,e)}const Rs=D(`ZodBoolean`,(e,t)=>{Yr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r)});function j(e){return ma(Rs,e)}const zs=D(`ZodNull`,(e,t)=>{Xr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r)});function Bs(e){return ha(zs,e)}const Vs=D(`ZodAny`,(e,t)=>{Zr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Hs(){return ga(Vs)}const Us=D(`ZodUnknown`,(e,t)=>{Qr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ws(){return _a(Us)}const Gs=D(`ZodNever`,(e,t)=>{$r.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function Ks(e){return va(Gs,e)}const qs=D(`ZodArray`,(e,t)=>{ti.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Ta(t,n)),e.nonempty=t=>e.check(Ta(1,t)),e.max=(t,n)=>e.check(wa(t,n)),e.length=(t,n)=>e.check(Ea(t,n)),e.unwrap=()=>e.element});function M(e,t){return za(qs,e,t)}const Js=D(`ZodObject`,(e,t)=>{oi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(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:Ws()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ws()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ks()}),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(cc,e,t[0]),e.required=(...t)=>Kt(vc,e,t[0])});function N(e,t){return new Js({type:`object`,shape:e??{},...O(t)})}function Ys(e,t){return new Js({type:`object`,shape:e,catchall:Ws(),...O(t)})}const Xs=D(`ZodUnion`,(e,t)=>{ci.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.options=t.options});function Zs(e,t){return new Xs({type:`union`,options:e,...O(t)})}const Qs=D(`ZodDiscriminatedUnion`,(e,t)=>{Xs.init(e,t),li.init(e,t)});function $s(e,t,n){return new Qs({type:`union`,options:t,discriminator:e,...O(n)})}const ec=D(`ZodIntersection`,(e,t)=>{ui.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r)});function tc(e,t){return new ec({type:`intersection`,left:e,right:t})}const nc=D(`ZodRecord`,(e,t)=>{pi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function rc(e,t,n){return new nc({type:`record`,keyType:e,valueType:t,...O(n)})}const ic=D(`ZodEnum`,(e,t)=>{mi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(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 ic({...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 ic({...t,checks:[],...O(r),entries:i})}});function P(e,t){return new ic({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...O(t)})}const ac=D(`ZodLiteral`,(e,t)=>{hi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(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 ac({type:`literal`,values:Array.isArray(e)?e:[e],...O(t)})}const oc=D(`ZodTransform`,(e,t)=>{gi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(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 sc(e){return new oc({type:`transform`,transform:e})}const cc=D(`ZodOptional`,(e,t)=>{vi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new cc({type:`optional`,innerType:e})}const uc=D(`ZodExactOptional`,(e,t)=>{yi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}const fc=D(`ZodNullable`,(e,t)=>{bi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`nullable`,innerType:e})}const mc=D(`ZodDefault`,(e,t)=>{xi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function hc(e,t){return new mc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const gc=D(`ZodPrefault`,(e,t)=>{Ci.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _c(e,t){return new gc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const vc=D(`ZodNonOptional`,(e,t)=>{wi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`nonoptional`,innerType:e,...O(t)})}const bc=D(`ZodCatch`,(e,t)=>{Ei.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xc(e,t){return new bc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Sc=D(`ZodPipe`,(e,t)=>{Di.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.in=t.in,e.out=t.out});function Cc(e,t){return new Sc({type:`pipe`,in:e,out:t})}const wc=D(`ZodReadonly`,(e,t)=>{ki.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new wc({type:`readonly`,innerType:e})}const Ec=D(`ZodLazy`,(e,t)=>{ji.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Dc(e){return new Ec({type:`lazy`,getter:e})}const Oc=D(`ZodCustom`,(e,t)=>{Mi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function kc(e,t){return Ba(Oc,e??(()=>!0),t)}function Ac(e,t={}){return Va(Oc,e,t)}function jc(e){return Ha(e)}function Mc(e,t){return Cc(sc(e),t)}var Nc=ft();a();const Pc=Symbol.for(`@inkeep/open-knowledge/field-registry`),Fc=globalThis;Fc[Pc]===void 0&&(Fc[Pc]=Ii());const Ic=Fc[Pc];function Lc(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Rc(t)?Ic.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Rc(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const zc=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Bc=52428800,Vc=26214400,Hc=`https://api.openai.com/v1`,Uc=`text-embedding-3-small`,Wc=Ys({content:Ys({dir:k().register(Ic,{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:Ys({theme:P([`light`,`dark`,`system`]).register(Ic,{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:Ys({autoOpen:j().register(Ic,{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:Ys({showHiddenFiles:j().register(Ic,{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(Ic,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Show every file, including those excluded by .gitignore / .okignore. On by default; turn off to scope the tree to indexed/linked content. Per-machine (project-local) — not shared.`}).default(!0)}).optional()}).default({preview:{autoOpen:!0}}),editor:Ys({wordWrap:j().register(Ic,{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:Ys({enabled:j().register(Ic,{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}),terminal:Ys({enabled:j().register(Ic,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),telemetry:Ys({localSink:Ys({enabled:j().register(Ic,{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:Ys({maxBytes:A().register(Ic,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(Bc)}).default({maxBytes:Bc}),logs:Ys({maxBytes:A().register(Ic,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Vc)}).default({maxBytes:Vc}),attributeDenylist:M(k()).register(Ic,{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([...zc])}).default({enabled:!0,spans:{maxBytes:Bc},logs:{maxBytes:Vc},attributeDenylist:[...zc]})}).default({localSink:{enabled:!0,spans:{maxBytes:Bc},logs:{maxBytes:Vc},attributeDenylist:[...zc]}}),search:Ys({semantic:Ys({enabled:j().register(Ic,{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(Ic,{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(Hc),model:k().register(Ic,{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(Uc),dimensions:A().int().positive().register(Ic,{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(Ic,{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:Hc,model:Uc})}).default({semantic:{enabled:!1,baseUrl:Hc,model:Uc}})}),Gc=`open-knowledge-config`;async function Kc(e,t,n){let r=o.getTracer(Gc),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 qc(e,t,n){let r=o.getTracer(Gc),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 Jc(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Yc(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 Xc(e,t){let n=e;for(let e of t){n=Yc(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Zc(e,t){let n=Xc(e,t);if(n!==void 0)return Lc(n)}function Qc(e,t){return e===`either`?!0:e===t}function $c(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=Zc(Wc,i);a?.scope!==void 0&&(Qc(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 el(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,Nc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function tl(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)){el(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}el(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function nl(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const rl=N({file:k(),line:A().int().min(1),column:A().int().min(1),snippet:k().optional()}),il=N({path:M(Zs([k(),A()])),message:k(),issueCode:k(),params:rc(k(),Ws()).optional(),source:rl.optional()}),al=P([`user`,`project`,`project-local`,`either`]),ol=P([`user`,`project`,`project-local`]),sl=$s(`code`,[N({code:F(`YAML_PARSE`),detail:k()}),N({code:F(`SCHEMA_INVALID`),issues:M(il)}),N({code:F(`SCOPE_VIOLATION`),path:M(k()),expectedScope:al,actualScope:ol}),N({code:F(`NOT_AGENT_SETTABLE`),path:M(k())}),N({code:F(`MIXED_SCOPE`),paths:M(N({path:M(k()),scope:ol}))}),N({code:F(`REMOVED_KEY`),path:M(k()),redirect:k(),source:rl.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()})]),cl=new Set(sl.options.map(e=>e.shape.code.value)),ll=Zs([sl,Ys({code:k(),message:k().optional()})]);function ul(e){return cl.has(e.code)}function dl(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 fl(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 pl(e){if(!ul(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 Ya(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:Qa(t,`input`,e.processors),output:Qa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Xa(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 Xa(r.element,n);if(r.type===`set`)return Xa(r.valueType,n);if(r.type===`lazy`)return Xa(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 Xa(r.innerType,n);if(r.type===`intersection`)return Xa(r.left,n)||Xa(r.right,n);if(r.type===`record`||r.type===`map`)return Xa(r.keyType,n)||Xa(r.valueType,n);if(r.type===`pipe`)return Xa(r.in,n)||Xa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Xa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Xa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Xa(e,n))return!0;return!!(r.rest&&Xa(r.rest,n))}return!1}const Za=(e,t={})=>n=>{let r=Ka({...n,processors:t});return qa(e,r),Ja(r,e),Ya(r,e)},Qa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ka({...i??{},target:a,io:t,processors:n});return qa(e,o),Ja(o,e),Ya(o,e)},$a={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},eo=(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=$a[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}))])}},to=(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)},no=(e,t,n,r)=>{n.type=`boolean`},ro=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},io=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},ao=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},co=(e,t,n,r)=>{n.not={}},lo=(e,t,n,r)=>{},uo=(e,t,n,r)=>{},fo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},po=(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},mo=(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},ho=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},go=(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},_o=(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)},vo=(e,t,n,r)=>{n.type=`boolean`},yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},bo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},xo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},So=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},wo=(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=qa(a.element,t,{...r,path:[...r.path,`items`]})},To=(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]=qa(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=qa(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Eo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>qa(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Do=(e,t,n,r)=>{let i=e._zod.def,a=qa(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=qa(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]]},Oo=(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)=>qa(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?qa(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)},ko=(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=qa(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=qa(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=qa(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)}},Ao=(e,t,n,r)=>{let i=e._zod.def,a=qa(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`}]},jo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},No=(e,t,n,r)=>{let i=e._zod.def;qa(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)))},Po=(e,t,n,r)=>{let i=e._zod.def;qa(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},Fo=(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;qa(a,t,r);let o=t.seen.get(e);o.ref=a},Io=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Lo=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ro=(e,t,n,r)=>{let i=e._zod.def;qa(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zo=(e,t,n,r)=>{let i=e._zod.innerType;qa(i,t,r);let a=t.seen.get(e);a.ref=i},Bo={string:eo,number:to,boolean:no,bigint:ro,symbol:io,null:ao,undefined:oo,void:so,never:co,any:lo,unknown:uo,date:fo,enum:po,literal:mo,nan:ho,template_literal:go,file:_o,success:vo,custom:yo,function:bo,transform:xo,map:So,set:Co,array:wo,object:To,union:Eo,intersection:Do,tuple:Oo,record:ko,nullable:Ao,nonoptional:jo,default:Mo,prefault:No,catch:Po,pipe:Fo,readonly:Io,promise:Lo,optional:Ro,lazy:zo};function Vo(e,t){if(`_idmap`in e){let n=e,r=Ka({...t,processors:Bo}),i={};for(let e of n._idmap.entries()){let[t,n]=e;qa(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Ja(r,n),a[t]=Ya(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ka({...t,processors:Bo});return qa(e,n),Ja(n,e),Ya(n,e)}const Ho=D(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),ms.init(e,t)});function Uo(e){return sa(Ho,e)}const Wo=D(`ZodISODate`,(e,t)=>{Nr.init(e,t),ms.init(e,t)});function Go(e){return ca(Wo,e)}const Ko=D(`ZodISOTime`,(e,t)=>{Pr.init(e,t),ms.init(e,t)});function qo(e){return la(Ko,e)}const Jo=D(`ZodISODuration`,(e,t)=>{Fr.init(e,t),ms.init(e,t)});function Yo(e){return ua(Jo,e)}const Xo=(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`,Xo);const Zo=D(`ZodError`,Xo,{Parent:Error}),Qo=sn(Zo),$o=ln(Zo),es=dn(Zo),ts=pn(Zo),ns=hn(Zo),rs=gn(Zo),is=_n(Zo),as=vn(Zo),ss=yn(Zo),cs=bn(Zo),ls=xn(Zo),us=Sn(Zo),ds=D(`ZodType`,(e,t)=>(vr.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Qa(e,`input`),output:Qa(e,`output`)}}),e.toJSONSchema=Za(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)=>Qo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>es(e,t,n),e.parseAsync=async(t,n)=>$o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ts(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ns(e,t,n),e.decode=(t,n)=>rs(e,t,n),e.encodeAsync=async(t,n)=>is(e,t,n),e.decodeAsync=async(t,n)=>as(e,t,n),e.safeEncode=(t,n)=>ss(e,t,n),e.safeDecode=(t,n)=>cs(e,t,n),e.safeEncodeAsync=async(t,n)=>ls(e,t,n),e.safeDecodeAsync=async(t,n)=>us(e,t,n),e.refine=(t,n)=>e.check(Ac(t,n)),e.superRefine=t=>e.check(jc(t)),e.overwrite=t=>e.check(Na(t)),e.optional=()=>lc(e),e.exactOptional=()=>dc(e),e.nullable=()=>pc(e),e.nullish=()=>lc(pc(e)),e.nonoptional=t=>yc(e,t),e.array=()=>M(e),e.or=t=>Zs([e,t]),e.and=t=>tc(e,t),e.transform=t=>Cc(e,sc(t)),e.default=t=>hc(e,t),e.prefault=t=>_c(e,t),e.catch=t=>xc(e,t),e.pipe=t=>Cc(e,t),e.readonly=()=>Tc(e),e.describe=t=>{let n=e.clone();return Li.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return Li.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Li.get(e);let n=e.clone();return Li.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),fs=D(`_ZodString`,(e,t)=>{yr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(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(Da(...t)),e.includes=(...t)=>e.check(Aa(...t)),e.startsWith=(...t)=>e.check(ja(...t)),e.endsWith=(...t)=>e.check(Ma(...t)),e.min=(...t)=>e.check(Ta(...t)),e.max=(...t)=>e.check(wa(...t)),e.length=(...t)=>e.check(Ea(...t)),e.nonempty=(...t)=>e.check(Ta(1,...t)),e.lowercase=t=>e.check(Oa(t)),e.uppercase=t=>e.check(ka(t)),e.trim=()=>e.check(Fa()),e.normalize=(...t)=>e.check(Pa(...t)),e.toLowerCase=()=>e.check(Ia()),e.toUpperCase=()=>e.check(La()),e.slugify=()=>e.check(Ra())}),ps=D(`ZodString`,(e,t)=>{yr.init(e,t),fs.init(e,t),e.email=t=>e.check(zi(hs,t)),e.url=t=>e.check(Gi(vs,t)),e.jwt=t=>e.check(oa(Ps,t)),e.emoji=t=>e.check(Ki(bs,t)),e.guid=t=>e.check(Bi(gs,t)),e.uuid=t=>e.check(Vi(_s,t)),e.uuidv4=t=>e.check(Hi(_s,t)),e.uuidv6=t=>e.check(Ui(_s,t)),e.uuidv7=t=>e.check(Wi(_s,t)),e.nanoid=t=>e.check(qi(xs,t)),e.guid=t=>e.check(Bi(gs,t)),e.cuid=t=>e.check(Ji(Ss,t)),e.cuid2=t=>e.check(Yi(Cs,t)),e.ulid=t=>e.check(Xi(ws,t)),e.base64=t=>e.check(ra(js,t)),e.base64url=t=>e.check(ia(Ms,t)),e.xid=t=>e.check(Zi(Ts,t)),e.ksuid=t=>e.check(Qi(Es,t)),e.ipv4=t=>e.check($i(Ds,t)),e.ipv6=t=>e.check(ea(Os,t)),e.cidrv4=t=>e.check(ta(ks,t)),e.cidrv6=t=>e.check(na(As,t)),e.e164=t=>e.check(aa(Ns,t)),e.datetime=t=>e.check(Uo(t)),e.date=t=>e.check(Go(t)),e.time=t=>e.check(qo(t)),e.duration=t=>e.check(Yo(t))});function k(e){return Ri(ps,e)}const ms=D(`ZodStringFormat`,(e,t)=>{br.init(e,t),fs.init(e,t)}),hs=D(`ZodEmail`,(e,t)=>{Cr.init(e,t),ms.init(e,t)}),gs=D(`ZodGUID`,(e,t)=>{xr.init(e,t),ms.init(e,t)}),_s=D(`ZodUUID`,(e,t)=>{Sr.init(e,t),ms.init(e,t)}),vs=D(`ZodURL`,(e,t)=>{wr.init(e,t),ms.init(e,t)});function ys(e){return Gi(vs,e)}const bs=D(`ZodEmoji`,(e,t)=>{Tr.init(e,t),ms.init(e,t)}),xs=D(`ZodNanoID`,(e,t)=>{Er.init(e,t),ms.init(e,t)}),Ss=D(`ZodCUID`,(e,t)=>{Dr.init(e,t),ms.init(e,t)}),Cs=D(`ZodCUID2`,(e,t)=>{Or.init(e,t),ms.init(e,t)}),ws=D(`ZodULID`,(e,t)=>{kr.init(e,t),ms.init(e,t)}),Ts=D(`ZodXID`,(e,t)=>{Ar.init(e,t),ms.init(e,t)}),Es=D(`ZodKSUID`,(e,t)=>{jr.init(e,t),ms.init(e,t)}),Ds=D(`ZodIPv4`,(e,t)=>{Ir.init(e,t),ms.init(e,t)}),Os=D(`ZodIPv6`,(e,t)=>{Lr.init(e,t),ms.init(e,t)}),ks=D(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),ms.init(e,t)}),As=D(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),ms.init(e,t)}),js=D(`ZodBase64`,(e,t)=>{Vr.init(e,t),ms.init(e,t)}),Ms=D(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),ms.init(e,t)}),Ns=D(`ZodE164`,(e,t)=>{Wr.init(e,t),ms.init(e,t)}),Ps=D(`ZodJWT`,(e,t)=>{Kr.init(e,t),ms.init(e,t)}),Fs=D(`ZodNumber`,(e,t)=>{qr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.gt=(t,n)=>e.check(xa(t,n)),e.gte=(t,n)=>e.check(Sa(t,n)),e.min=(t,n)=>e.check(Sa(t,n)),e.lt=(t,n)=>e.check(ya(t,n)),e.lte=(t,n)=>e.check(ba(t,n)),e.max=(t,n)=>e.check(ba(t,n)),e.int=t=>e.check(Ls(t)),e.safe=t=>e.check(Ls(t)),e.positive=t=>e.check(xa(0,t)),e.nonnegative=t=>e.check(Sa(0,t)),e.negative=t=>e.check(ya(0,t)),e.nonpositive=t=>e.check(ba(0,t)),e.multipleOf=(t,n)=>e.check(Ca(t,n)),e.step=(t,n)=>e.check(Ca(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 da(Fs,e)}const Is=D(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Fs.init(e,t)});function Ls(e){return pa(Is,e)}const Rs=D(`ZodBoolean`,(e,t)=>{Yr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r)});function j(e){return ma(Rs,e)}const zs=D(`ZodNull`,(e,t)=>{Xr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r)});function Bs(e){return ha(zs,e)}const Vs=D(`ZodAny`,(e,t)=>{Zr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Hs(){return ga(Vs)}const Us=D(`ZodUnknown`,(e,t)=>{Qr.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ws(){return _a(Us)}const Gs=D(`ZodNever`,(e,t)=>{$r.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function Ks(e){return va(Gs,e)}const qs=D(`ZodArray`,(e,t)=>{ti.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Ta(t,n)),e.nonempty=t=>e.check(Ta(1,t)),e.max=(t,n)=>e.check(wa(t,n)),e.length=(t,n)=>e.check(Ea(t,n)),e.unwrap=()=>e.element});function M(e,t){return za(qs,e,t)}const Js=D(`ZodObject`,(e,t)=>{oi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(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:Ws()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ws()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ks()}),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(cc,e,t[0]),e.required=(...t)=>Kt(vc,e,t[0])});function N(e,t){return new Js({type:`object`,shape:e??{},...O(t)})}function Ys(e,t){return new Js({type:`object`,shape:e,catchall:Ws(),...O(t)})}const Xs=D(`ZodUnion`,(e,t)=>{ci.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.options=t.options});function Zs(e,t){return new Xs({type:`union`,options:e,...O(t)})}const Qs=D(`ZodDiscriminatedUnion`,(e,t)=>{Xs.init(e,t),li.init(e,t)});function $s(e,t,n){return new Qs({type:`union`,options:t,discriminator:e,...O(n)})}const ec=D(`ZodIntersection`,(e,t)=>{ui.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r)});function tc(e,t){return new ec({type:`intersection`,left:e,right:t})}const nc=D(`ZodRecord`,(e,t)=>{pi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function rc(e,t,n){return new nc({type:`record`,keyType:e,valueType:t,...O(n)})}const ic=D(`ZodEnum`,(e,t)=>{mi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(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 ic({...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 ic({...t,checks:[],...O(r),entries:i})}});function P(e,t){return new ic({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...O(t)})}const ac=D(`ZodLiteral`,(e,t)=>{hi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(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 ac({type:`literal`,values:Array.isArray(e)?e:[e],...O(t)})}const oc=D(`ZodTransform`,(e,t)=>{gi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(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 sc(e){return new oc({type:`transform`,transform:e})}const cc=D(`ZodOptional`,(e,t)=>{vi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lc(e){return new cc({type:`optional`,innerType:e})}const uc=D(`ZodExactOptional`,(e,t)=>{yi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new uc({type:`optional`,innerType:e})}const fc=D(`ZodNullable`,(e,t)=>{bi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`nullable`,innerType:e})}const mc=D(`ZodDefault`,(e,t)=>{xi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function hc(e,t){return new mc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const gc=D(`ZodPrefault`,(e,t)=>{Ci.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>No(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _c(e,t){return new gc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Pt(t)}})}const vc=D(`ZodNonOptional`,(e,t)=>{wi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new vc({type:`nonoptional`,innerType:e,...O(t)})}const bc=D(`ZodCatch`,(e,t)=>{Ei.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Po(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xc(e,t){return new bc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Sc=D(`ZodPipe`,(e,t)=>{Di.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fo(e,t,n,r),e.in=t.in,e.out=t.out});function Cc(e,t){return new Sc({type:`pipe`,in:e,out:t})}const wc=D(`ZodReadonly`,(e,t)=>{ki.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tc(e){return new wc({type:`readonly`,innerType:e})}const Ec=D(`ZodLazy`,(e,t)=>{ji.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Dc(e){return new Ec({type:`lazy`,getter:e})}const Oc=D(`ZodCustom`,(e,t)=>{Mi.init(e,t),ds.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r)});function kc(e,t){return Ba(Oc,e??(()=>!0),t)}function Ac(e,t={}){return Va(Oc,e,t)}function jc(e){return Ha(e)}function Mc(e,t){return Cc(sc(e),t)}var Nc=ft();a();const Pc=Symbol.for(`@inkeep/open-knowledge/field-registry`),Fc=globalThis;Fc[Pc]===void 0&&(Fc[Pc]=Ii());const Ic=Fc[Pc];function Lc(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=Rc(t)?Ic.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function Rc(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}const zc=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),Bc=52428800,Vc=26214400,Hc=`https://api.openai.com/v1`,Uc=`text-embedding-3-small`,Wc=Ys({content:Ys({dir:k().register(Ic,{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:Ys({theme:P([`light`,`dark`,`system`]).register(Ic,{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:Ys({autoOpen:j().register(Ic,{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:Ys({showHiddenFiles:j().register(Ic,{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)}).optional()}).default({preview:{autoOpen:!0}}),editor:Ys({wordWrap:j().register(Ic,{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:Ys({enabled:j().register(Ic,{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:j().register(Ic,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Committed project default for a machine's autoSync.enabled on first open: true = auto-sync on, false = off, null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.enabled choice overrides it.`}).nullable().default(null)}).default({enabled:null,default:null}),terminal:Ys({enabled:j().register(Ic,{scope:`project-local`,agentSettable:!1,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null)}).default({enabled:null}),telemetry:Ys({localSink:Ys({enabled:j().register(Ic,{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:Ys({maxBytes:A().register(Ic,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(Bc)}).default({maxBytes:Bc}),logs:Ys({maxBytes:A().register(Ic,{scope:`project`,agentSettable:!1,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(Vc)}).default({maxBytes:Vc}),attributeDenylist:M(k()).register(Ic,{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([...zc])}).default({enabled:!0,spans:{maxBytes:Bc},logs:{maxBytes:Vc},attributeDenylist:[...zc]})}).default({localSink:{enabled:!0,spans:{maxBytes:Bc},logs:{maxBytes:Vc},attributeDenylist:[...zc]}}),search:Ys({semantic:Ys({enabled:j().register(Ic,{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(Ic,{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(Hc),model:k().register(Ic,{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(Uc),dimensions:A().int().positive().register(Ic,{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(Ic,{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:Hc,model:Uc})}).default({semantic:{enabled:!1,baseUrl:Hc,model:Uc}})}),Gc=`open-knowledge-config`;async function Kc(e,t,n){let r=o.getTracer(Gc),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 qc(e,t,n){let r=o.getTracer(Gc),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 Jc(e,t){let n=o.getActiveSpan();n&&n.addEvent(e,t)}function Yc(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 Xc(e,t){let n=e;for(let e of t){n=Yc(n);let t=n?._zod?.def?.shape;if(!t||(n=t[String(e)],n===void 0))return}return n}function Zc(e,t){let n=Xc(e,t);if(n!==void 0)return Lc(n)}function Qc(e,t){return e===`either`?!0:e===t}function $c(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=Zc(Wc,i);a?.scope!==void 0&&(Qc(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 el(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&((0,Nc.isCollection)(e.getIn(r,!0))||e.deleteIn(r))}}function tl(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)){el(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}el(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function nl(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}const rl=N({file:k(),line:A().int().min(1),column:A().int().min(1),snippet:k().optional()}),il=N({path:M(Zs([k(),A()])),message:k(),issueCode:k(),params:rc(k(),Ws()).optional(),source:rl.optional()}),al=P([`user`,`project`,`project-local`,`either`]),ol=P([`user`,`project`,`project-local`]),sl=$s(`code`,[N({code:F(`YAML_PARSE`),detail:k()}),N({code:F(`SCHEMA_INVALID`),issues:M(il)}),N({code:F(`SCOPE_VIOLATION`),path:M(k()),expectedScope:al,actualScope:ol}),N({code:F(`NOT_AGENT_SETTABLE`),path:M(k())}),N({code:F(`MIXED_SCOPE`),paths:M(N({path:M(k()),scope:ol}))}),N({code:F(`REMOVED_KEY`),path:M(k()),redirect:k(),source:rl.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()})]),cl=new Set(sl.options.map(e=>e.shape.code.value)),ll=Zs([sl,Ys({code:k(),message:k().optional()})]);function ul(e){return cl.has(e.code)}function dl(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 fl(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 pl(e){if(!ul(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`,`(${dl(e.expectedScope)} — ${fl(e.expectedScope)}),`,`but it was set in the ${e.actualScope} config (${dl(e.actualScope)}).`,`Move it to ${dl(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(`.`)} → ${dl(t)} (${t})`).join(`
|
|
157
157
|
`)].join(`
|
|
@@ -159,7 +159,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
159
159
|
`))n.push(` ${t}`);return n.join(`
|
|
160
160
|
`)}case`WRITE_ERROR`:return`Failed to write config file: ${e.detail}`;case`OKIGNORE_INVALID`:return e.lineNumber===void 0?`.okignore: ${e.detail}`:`.okignore line ${e.lineNumber}: ${e.detail}`;case`UNKNOWN`:return e.message??`Unknown error.`}}function ml(e,t){if(t.length===0)return e.contents??null;let n=e.getIn(t,!0);if((0,Nc.isNode)(n))return n;for(let n=t.length-1;n>=0;n--){let r=e.getIn(t.slice(0,n),!0);if((0,Nc.isNode)(r))return r}return e.contents??null}function hl(e,t){let n=1,r=1,i=Math.min(t,e.length);for(let t=0;t<i;t++)e.charCodeAt(t)===10?(n++,r=1):r++;return{line:n,column:r}}function gl(e,t,n,r,i){let a=e.split(`
|
|
161
161
|
`),o=r-1;if(o<0||o>=a.length)return``;let s=a[o]??``,c=t-(i-1)+s.length,l=Math.max(1,Math.min(n,c)-t),u=[],d=String(o+2).length;for(let e=Math.max(0,o-1);e<=Math.min(a.length-1,o+1);e++){let t=e===o,n=t?`>`:` `,r=String(e+1).padStart(d,` `);if(u.push(`${n} ${r} | ${a[e]??``}`),t){let e=` `.repeat(2+d+3+i-1);u.push(`${e}${`^`.repeat(l)}`)}}return u.join(`
|
|
162
|
-
`)}function _l(e){let t=ml(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=hl(e.source,r),s=(0,Nc.isCollection)(t)?gl(e.source,r,r+1,a,o):gl(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const vl="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.",yl=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,vl].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,vl].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",vl].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,vl].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,vl].join(` `)},{path:[`server`,`host`],redirect:[`Use the --host CLI flag or the HOST environment variable instead.`,vl].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,vl].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,vl].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,vl].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running UI process — start one with `ok ui`.",vl].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,vl].join(` `)}];function bl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xl(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!bl(n))return!1;n=n[t[e]]}return bl(n)?t[t.length-1]in n:!1}function Sl(e){let{value:t,file:n,source:r,doc:i}=e;if(!bl(t))return[];let a=[];for(let e of yl){if(!xl(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=_l({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}const Cl=`v0`,wl=`.ok/config.yml`,Tl=`local`;function El(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Ol(e.position):`start`in e||`end`in e?Ol(e):`line`in e||`column`in e?Dl(e):``}function Dl(e){return kl(e&&e.line)+`:`+kl(e&&e.column)}function Ol(e){return Dl(e&&e.start)+`-`+Dl(e&&e.end)}function kl(e){return e&&typeof e==`number`?e:1}var Al=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=El(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Al.prototype.file=``,Al.prototype.name=``,Al.prototype.reason=``,Al.prototype.message=``,Al.prototype.stack=``,Al.prototype.column=void 0,Al.prototype.line=void 0,Al.prototype.ancestors=void 0,Al.prototype.cause=void 0,Al.prototype.fatal=void 0,Al.prototype.place=void 0,Al.prototype.ruleId=void 0,Al.prototype.source=void 0;var jl=r(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var ee=-b+v;ee<=b-y;ee+=2){for(var T=l+ee,E=ee==-b||ee!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,te=E-ee;E<o&&te<s&&e.charAt(o-E-1)==t.charAt(s-te-1);)E++,te++;if(f[T]=E,E>o)y+=2;else if(te>s)v+=2;else if(!h){var S=l+m-ee;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
|
|
162
|
+
`)}function _l(e){let t=ml(e.doc,e.path);if(!t)return;let n=t.range;if(!n)return;let[r,,i=r]=n,{line:a,column:o}=hl(e.source,r),s=(0,Nc.isCollection)(t)?gl(e.source,r,r+1,a,o):gl(e.source,r,i,a,o);return{file:e.file,line:a,column:o,snippet:s.length>0?s:void 0}}const vl="Run `ok config migrate` to strip the obsolete key from config.yml automatically, or remove it by hand.",yl=[{path:[`content`,`include`],redirect:[`content.include has been removed.`,`For subdirectory scoping, set content.dir in .ok/config.yml instead.`,`For pattern-based filtering, use .okignore (gitignore syntax — exclude-only; do not copy include patterns directly).`,vl].join(` `)},{path:[`content`,`exclude`],redirect:[`Move these patterns to .okignore at the project root (gitignore syntax, 1:1 migration).`,vl].join(` `)},{path:[`folders`],redirect:[`folders is no longer a top-level config field.`,"A folder's own frontmatter (open-shape, like a doc's) lives in nested `<folder>/.ok/frontmatter.yml`; new-doc starting properties come from templates in `<folder>/.ok/templates/`.","Edit via the folder overview in the editor sidebar, or `edit({ folder: { path, frontmatter } })` via the MCP.",vl].join(` `)},{path:[`appearance`,`editorModeDefault`],redirect:[`appearance.editorModeDefault was removed and is never read — new docs always open in WYSIWYG; toggle mode via the editor mode button.`,vl].join(` `)},{path:[`upload`,`maxBytes`],redirect:[`streaming uploads have no user-facing cap; the value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`github`,`oauthAppClientId`],redirect:[`Use the OPEN_KNOWLEDGE_GITHUB_CLIENT_ID environment variable instead.`,vl].join(` `)},{path:[`server`,`host`],redirect:[`Use the --host CLI flag or the HOST environment variable instead.`,vl].join(` `)},{path:[`server`,`openOnAgentEdit`],redirect:[`This behavior was removed; the value is hardcoded.`,vl].join(` `)},{path:[`mcp`,`autoStart`],redirect:[`To disable MCP auto-start, set OK_MCP_AUTOSTART=0.`,vl].join(` `)},{path:[`mcp`,`tools`,`read_document`,`historyDepth`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`mcp`,`tools`,`grep`,`maxResults`],redirect:[`This value is hardcoded in @inkeep/open-knowledge-core.`,vl].join(` `)},{path:[`mcp`,`tools`,`search`,`maxResults`],redirect:[`The search result cap is hardcoded in @inkeep/open-knowledge-core; this config key was removed.`,vl].join(` `)},{path:[`preview`,`baseUrl`],redirect:["preview URLs now resolve only to the running UI process — start one with `ok ui`.",vl].join(` `)},{path:[`preview`,`scriptSrc`],redirect:[`preview.scriptSrc has been removed.`,`The code-block preview iframe now runs a fixed open network policy (it is no longer configurable).`,vl].join(` `)},{path:[`appearance`,`sidebar`,`showAllFiles`],redirect:[`appearance.sidebar.showAllFiles has been removed.`,`The sidebar now always lists every file on disk; dot-prefixed entries are still gated by appearance.sidebar.showHiddenFiles. There is no longer a way to scope the tree to indexed/linked content.`,vl].join(` `)}];function bl(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xl(e,t){let n=e;for(let e=0;e<t.length-1;e++){if(!bl(n))return!1;n=n[t[e]]}return bl(n)?t[t.length-1]in n:!1}function Sl(e){let{value:t,file:n,source:r,doc:i}=e;if(!bl(t))return[];let a=[];for(let e of yl){if(!xl(t,e.path))continue;let o;i!=null&&r!=null&&n!=null&&(o=_l({file:n,source:r,doc:i,path:e.path})),a.push({code:`REMOVED_KEY`,path:e.path,redirect:e.redirect,...o===void 0?{}:{source:o}})}return a}const Cl=`v0`,wl=`.ok/config.yml`,Tl=`local`;function El(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Ol(e.position):`start`in e||`end`in e?Ol(e):`line`in e||`column`in e?Dl(e):``}function Dl(e){return kl(e&&e.line)+`:`+kl(e&&e.column)}function Ol(e){return Dl(e&&e.start)+`-`+Dl(e&&e.end)}function kl(e){return e&&typeof e==`number`?e:1}var Al=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=El(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Al.prototype.file=``,Al.prototype.name=``,Al.prototype.reason=``,Al.prototype.message=``,Al.prototype.stack=``,Al.prototype.column=void 0,Al.prototype.line=void 0,Al.prototype.ancestors=void 0,Al.prototype.cause=void 0,Al.prototype.fatal=void 0,Al.prototype.place=void 0,Al.prototype.ruleId=void 0,Al.prototype.source=void 0;var jl=r(((e,t)=>{var n=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},r=-1,i=1,a=0;n.Diff=function(e,t){return[e,t]},n.prototype.diff_main=function(e,t,r,i){i===void 0&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:new Date().getTime()+this.Diff_Timeout*1e3);var o=i;if(e==null||t==null)throw Error(`Null input. (diff_main)`);if(e==t)return e?[new n.Diff(a,e)]:[];r===void 0&&(r=!0);var s=r,c=this.diff_commonPrefix(e,t),l=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=this.diff_commonSuffix(e,t);var u=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var d=this.diff_compute_(e,t,s,o);return l&&d.unshift(new n.Diff(a,l)),u&&d.push(new n.Diff(a,u)),this.diff_cleanupMerge(d),d},n.prototype.diff_compute_=function(e,t,o,s){var c;if(!e)return[new n.Diff(i,t)];if(!t)return[new n.Diff(r,e)];var l=e.length>t.length?e:t,u=e.length>t.length?t:e,d=l.indexOf(u);if(d!=-1)return c=[new n.Diff(i,l.substring(0,d)),new n.Diff(a,u),new n.Diff(i,l.substring(d+u.length))],e.length>t.length&&(c[0][0]=c[2][0]=r),c;if(u.length==1)return[new n.Diff(r,e),new n.Diff(i,t)];var f=this.diff_halfMatch_(e,t);if(f){var p=f[0],m=f[1],h=f[2],g=f[3],_=f[4],v=this.diff_main(p,h,o,s),y=this.diff_main(m,g,o,s);return v.concat([new n.Diff(a,_)],y)}return o&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,s):this.diff_bisect_(e,t,s)},n.prototype.diff_lineMode_=function(e,t,o){var s=this.diff_linesToChars_(e,t);e=s.chars1,t=s.chars2;var c=s.lineArray,l=this.diff_main(e,t,!1,o);this.diff_charsToLines_(l,c),this.diff_cleanupSemantic(l),l.push(new n.Diff(a,``));for(var u=0,d=0,f=0,p=``,m=``;u<l.length;){switch(l[u][0]){case i:f++,m+=l[u][1];break;case r:d++,p+=l[u][1];break;case a:if(d>=1&&f>=1){l.splice(u-d-f,d+f),u=u-d-f;for(var h=this.diff_main(p,m,!1,o),g=h.length-1;g>=0;g--)l.splice(u,0,h[g]);u+=h.length}f=0,d=0,p=``,m=``;break}u++}return l.pop(),l},n.prototype.diff_bisect_=function(e,t,a){for(var o=e.length,s=t.length,c=Math.ceil((o+s)/2),l=c,u=2*c,d=Array(u),f=Array(u),p=0;p<u;p++)d[p]=-1,f[p]=-1;d[l+1]=0,f[l+1]=0;for(var m=o-s,h=m%2!=0,g=0,_=0,v=0,y=0,b=0;b<c&&!(new Date().getTime()>a);b++){for(var x=-b+g;x<=b-_;x+=2){for(var S=l+x,C=x==-b||x!=b&&d[S-1]<d[S+1]?d[S+1]:d[S-1]+1,w=C-x;C<o&&w<s&&e.charAt(C)==t.charAt(w);)C++,w++;if(d[S]=C,C>o)_+=2;else if(w>s)g+=2;else if(h){var T=l+m-x;if(T>=0&&T<u&&f[T]!=-1){var E=o-f[T];if(C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}for(var ee=-b+v;ee<=b-y;ee+=2){for(var T=l+ee,E=ee==-b||ee!=b&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1,te=E-ee;E<o&&te<s&&e.charAt(o-E-1)==t.charAt(s-te-1);)E++,te++;if(f[T]=E,E>o)y+=2;else if(te>s)v+=2;else if(!h){var S=l+m-ee;if(S>=0&&S<u&&d[S]!=-1){var C=d[S],w=l+C-S;if(E=o-E,C>=E)return this.diff_bisectSplit_(e,t,C,w,a)}}}}return[new n.Diff(r,e),new n.Diff(i,t)]},n.prototype.diff_bisectSplit_=function(e,t,n,r,i){var a=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=this.diff_main(a,o,!1,i),u=this.diff_main(s,c,!1,i);return l.concat(u)},n.prototype.diff_linesToChars_=function(e,t){var n=[],r={};n[0]=``;function i(e){for(var t=``,i=0,o=-1,s=n.length;o<e.length-1;){o=e.indexOf(`
|
|
163
163
|
`,i),o==-1&&(o=e.length-1);var c=e.substring(i,o+1);(r.hasOwnProperty?r.hasOwnProperty(c):r[c]!==void 0)?t+=String.fromCharCode(r[c]):(s==a&&(c=e.substring(i),o=e.length),t+=String.fromCharCode(s),r[c]=s,n[s++]=c),i=o+1}return t}var a=4e4,o=i(e);return a=65535,{chars1:o,chars2:i(t),lineArray:n}},n.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],a=0;a<r.length;a++)i[a]=t[r.charCodeAt(a)];e[n][1]=i.join(``)}},n.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return i},n.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}},n.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;var i=this;function a(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),a=-1,o=``,s,c,l,u;(a=t.indexOf(r,a+1))!=-1;){var d=i.diff_commonPrefix(e.substring(n),t.substring(a)),f=i.diff_commonSuffix(e.substring(0,n),t.substring(0,a));o.length<f+d&&(o=t.substring(a-f,a)+t.substring(a,a+d),s=e.substring(0,n-f),c=e.substring(n+d),l=t.substring(0,a-f),u=t.substring(a+d))}return o.length*2>=e.length?[s,c,l,u,o]:null}var o=a(n,r,Math.ceil(n.length/4)),s=a(n,r,Math.ceil(n.length/2)),c;if(!o&&!s)return null;c=s?o&&o[4].length>s[4].length?o:s:o;var l,u,d,f;e.length>t.length?(l=c[0],u=c[1],d=c[2],f=c[3]):(d=c[0],f=c[1],l=c[2],u=c[3]);var p=c[4];return[l,u,d,f,p]},n.prototype.diff_cleanupSemantic=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=0,d=0,f=0,p=0;l<e.length;)e[l][0]==a?(o[s++]=l,u=f,d=p,f=0,p=0,c=e[l][1]):(e[l][0]==i?f+=e[l][1].length:p+=e[l][1].length,c&&c.length<=Math.max(u,d)&&c.length<=Math.max(f,p)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,s--,l=s>0?o[s-1]:-1,u=0,d=0,f=0,p=0,c=null,t=!0)),l++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),l=1;l<e.length;){if(e[l-1][0]==r&&e[l][0]==i){var m=e[l-1][1],h=e[l][1],g=this.diff_commonOverlap_(m,h),_=this.diff_commonOverlap_(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(l,0,new n.Diff(a,h.substring(0,g))),e[l-1][1]=m.substring(0,m.length-g),e[l+1][1]=h.substring(g),l++):(_>=m.length/2||_>=h.length/2)&&(e.splice(l,0,new n.Diff(a,m.substring(0,_))),e[l-1][0]=i,e[l-1][1]=h.substring(0,h.length-_),e[l+1][0]=r,e[l+1][1]=m.substring(_),l++),l++}l++}},n.prototype.diff_cleanupSemanticLossless=function(e){function t(e,t){if(!e||!t)return 6;var r=e.charAt(e.length-1),i=t.charAt(0),a=r.match(n.nonAlphaNumericRegex_),o=i.match(n.nonAlphaNumericRegex_),s=a&&r.match(n.whitespaceRegex_),c=o&&i.match(n.whitespaceRegex_),l=s&&r.match(n.linebreakRegex_),u=c&&i.match(n.linebreakRegex_),d=l&&e.match(n.blanklineEndRegex_),f=u&&t.match(n.blanklineStartRegex_);return d||f?5:l||u?4:a&&!s&&c?3:s||c?2:a||o?1:0}for(var r=1;r<e.length-1;){if(e[r-1][0]==a&&e[r+1][0]==a){var i=e[r-1][1],o=e[r][1],s=e[r+1][1],c=this.diff_commonSuffix(i,o);if(c){var l=o.substring(o.length-c);i=i.substring(0,i.length-c),o=l+o.substring(0,o.length-c),s=l+s}for(var u=i,d=o,f=s,p=t(i,o)+t(o,s);o.charAt(0)===s.charAt(0);){i+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var m=t(i,o)+t(o,s);m>=p&&(p=m,u=i,d=o,f=s)}e[r-1][1]!=u&&(u?e[r-1][1]=u:(e.splice(r-1,1),r--),e[r][1]=d,f?e[r+1][1]=f:(e.splice(r+1,1),r--))}r++}},n.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,n.whitespaceRegex_=/\s/,n.linebreakRegex_=/[\r\n]/,n.blanklineEndRegex_=/\n\r?\n$/,n.blanklineStartRegex_=/^\r?\n\r?\n/,n.prototype.diff_cleanupEfficiency=function(e){for(var t=!1,o=[],s=0,c=null,l=0,u=!1,d=!1,f=!1,p=!1;l<e.length;)e[l][0]==a?(e[l][1].length<this.Diff_EditCost&&(f||p)?(o[s++]=l,u=f,d=p,c=e[l][1]):(s=0,c=null),f=p=!1):(e[l][0]==r?p=!0:f=!0,c&&(u&&d&&f&&p||c.length<this.Diff_EditCost/2&&u+d+f+p==3)&&(e.splice(o[s-1],0,new n.Diff(r,c)),e[o[s-1]+1][0]=i,s--,c=null,u&&d?(f=p=!0,s=0):(s--,l=s>0?o[s-1]:-1,f=p=!1),t=!0)),l++;t&&this.diff_cleanupMerge(e)},n.prototype.diff_cleanupMerge=function(e){e.push(new n.Diff(a,``));for(var t=0,o=0,s=0,c=``,l=``,u;t<e.length;)switch(e[t][0]){case i:s++,l+=e[t][1],t++;break;case r:o++,c+=e[t][1],t++;break;case a:o+s>1?(o!==0&&s!==0&&(u=this.diff_commonPrefix(l,c),u!==0&&(t-o-s>0&&e[t-o-s-1][0]==a?e[t-o-s-1][1]+=l.substring(0,u):(e.splice(0,0,new n.Diff(a,l.substring(0,u))),t++),l=l.substring(u),c=c.substring(u)),u=this.diff_commonSuffix(l,c),u!==0&&(e[t][1]=l.substring(l.length-u)+e[t][1],l=l.substring(0,l.length-u),c=c.substring(0,c.length-u))),t-=o+s,e.splice(t,o+s),c.length&&(e.splice(t,0,new n.Diff(r,c)),t++),l.length&&(e.splice(t,0,new n.Diff(i,l)),t++),t++):t!==0&&e[t-1][0]==a?(e[t-1][1]+=e[t][1],e.splice(t,1)):t++,s=0,o=0,c=``,l=``;break}e[e.length-1][1]===``&&e.pop();var d=!1;for(t=1;t<e.length-1;)e[t-1][0]==a&&e[t+1][0]==a&&(e[t][1].substring(e[t][1].length-e[t-1][1].length)==e[t-1][1]?(e[t][1]=e[t-1][1]+e[t][1].substring(0,e[t][1].length-e[t-1][1].length),e[t+1][1]=e[t-1][1]+e[t+1][1],e.splice(t-1,1),d=!0):e[t][1].substring(0,e[t+1][1].length)==e[t+1][1]&&(e[t-1][1]+=e[t+1][1],e[t][1]=e[t][1].substring(e[t+1][1].length)+e[t+1][1],e.splice(t+1,1),d=!0)),t++;d&&this.diff_cleanupMerge(e)},n.prototype.diff_xIndex=function(e,t){var n=0,a=0,o=0,s=0,c;for(c=0;c<e.length&&(e[c][0]!==i&&(n+=e[c][1].length),e[c][0]!==r&&(a+=e[c][1].length),!(n>t));c++)o=n,s=a;return e.length!=c&&e[c][0]===r?s:s+(t-o)},n.prototype.diff_prettyHtml=function(e){for(var t=[],n=/&/g,o=/</g,s=/>/g,c=/\n/g,l=0;l<e.length;l++){var u=e[l][0],d=e[l][1].replace(n,`&`).replace(o,`<`).replace(s,`>`).replace(c,`¶<br>`);switch(u){case i:t[l]=`<ins style="background:#e6ffe6;">`+d+`</ins>`;break;case r:t[l]=`<del style="background:#ffe6e6;">`+d+`</del>`;break;case a:t[l]=`<span>`+d+`</span>`;break}}return t.join(``)},n.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==i&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_text2=function(e){for(var t=[],n=0;n<e.length;n++)e[n][0]!==r&&(t[n]=e[n][1]);return t.join(``)},n.prototype.diff_levenshtein=function(e){for(var t=0,n=0,o=0,s=0;s<e.length;s++){var c=e[s][0],l=e[s][1];switch(c){case i:n+=l.length;break;case r:o+=l.length;break;case a:t+=Math.max(n,o),n=0,o=0;break}}return t+=Math.max(n,o),t},n.prototype.diff_toDelta=function(e){for(var t=[],n=0;n<e.length;n++)switch(e[n][0]){case i:t[n]=`+`+encodeURI(e[n][1]);break;case r:t[n]=`-`+e[n][1].length;break;case a:t[n]=`=`+e[n][1].length;break}return t.join(` `).replace(/%20/g,` `)},n.prototype.diff_fromDelta=function(e,t){for(var o=[],s=0,c=0,l=t.split(/\t/g),u=0;u<l.length;u++){var d=l[u].substring(1);switch(l[u].charAt(0)){case`+`:try{o[s++]=new n.Diff(i,decodeURI(d))}catch{throw Error(`Illegal escape in diff_fromDelta: `+d)}break;case`-`:case`=`:var f=parseInt(d,10);if(isNaN(f)||f<0)throw Error(`Invalid number in diff_fromDelta: `+d);var p=e.substring(c,c+=f);l[u].charAt(0)==`=`?o[s++]=new n.Diff(a,p):o[s++]=new n.Diff(r,p);break;default:if(l[u])throw Error(`Invalid diff operation in diff_fromDelta: `+l[u])}}if(c!=e.length)throw Error(`Delta length (`+c+`) does not equal source text length (`+e.length+`).`);return o},n.prototype.match_main=function(e,t,n){if(e==null||t==null||n==null)throw Error(`Null input. (match_main)`);return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},n.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw Error(`Pattern too long for this browser.`);var r=this.match_alphabet_(t),i=this;function a(e,r){var a=e/t.length,o=Math.abs(n-r);return i.Match_Distance?a+o/i.Match_Distance:o?1:a}var o=this.Match_Threshold,s=e.indexOf(t,n);s!=-1&&(o=Math.min(a(0,s),o),s=e.lastIndexOf(t,n+t.length),s!=-1&&(o=Math.min(a(0,s),o)));var c=1<<t.length-1;s=-1;for(var l,u,d=t.length+e.length,f,p=0;p<t.length;p++){for(l=0,u=d;l<u;)a(p,n+u)<=o?l=u:d=u,u=Math.floor((d-l)/2+l);d=u;var m=Math.max(1,n-u+1),h=Math.min(n+u,e.length)+t.length,g=Array(h+2);g[h+1]=(1<<p)-1;for(var _=h;_>=m;_--){var v=r[e.charAt(_-1)];if(p===0?g[_]=(g[_+1]<<1|1)&v:g[_]=(g[_+1]<<1|1)&v|(f[_+1]|f[_])<<1|1|f[_+1],g[_]&c){var y=a(p,_-1);if(y<=o)if(o=y,s=_-1,s>n)m=Math.max(1,2*n-s);else break}}if(a(p+1,n)>o)break;f=g}return s},n.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(var n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},n.prototype.patch_addContext_=function(e,t){if(t.length!=0){if(e.start2===null)throw Error(`patch not initialized`);for(var r=t.substring(e.start2,e.start2+e.length1),i=0;t.indexOf(r)!=t.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=t.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var o=t.substring(e.start2-i,e.start2);o&&e.diffs.unshift(new n.Diff(a,o));var s=t.substring(e.start2+e.length1,e.start2+e.length1+i);s&&e.diffs.push(new n.Diff(a,s)),e.start1-=o.length,e.start2-=o.length,e.length1+=o.length+s.length,e.length2+=o.length+s.length}},n.prototype.patch_make=function(e,t,o){var s,c;if(typeof e==`string`&&typeof t==`string`&&o===void 0)s=e,c=this.diff_main(s,t,!0),c.length>2&&(this.diff_cleanupSemantic(c),this.diff_cleanupEfficiency(c));else if(e&&typeof e==`object`&&t===void 0&&o===void 0)c=e,s=this.diff_text1(c);else if(typeof e==`string`&&t&&typeof t==`object`&&o===void 0)s=e,c=t;else if(typeof e==`string`&&typeof t==`string`&&o&&typeof o==`object`)s=e,c=o;else throw Error(`Unknown call format to patch_make.`);if(c.length===0)return[];for(var l=[],u=new n.patch_obj,d=0,f=0,p=0,m=s,h=s,g=0;g<c.length;g++){var _=c[g][0],v=c[g][1];switch(!d&&_!==a&&(u.start1=f,u.start2=p),_){case i:u.diffs[d++]=c[g],u.length2+=v.length,h=h.substring(0,p)+v+h.substring(p);break;case r:u.length1+=v.length,u.diffs[d++]=c[g],h=h.substring(0,p)+h.substring(p+v.length);break;case a:v.length<=2*this.Patch_Margin&&d&&c.length!=g+1?(u.diffs[d++]=c[g],u.length1+=v.length,u.length2+=v.length):v.length>=2*this.Patch_Margin&&d&&(this.patch_addContext_(u,m),l.push(u),u=new n.patch_obj,d=0,m=h,f=p);break}_!==i&&(f+=v.length),_!==r&&(p+=v.length)}return d&&(this.patch_addContext_(u,m),l.push(u)),l},n.prototype.patch_deepCopy=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=new n.patch_obj;a.diffs=[];for(var o=0;o<i.diffs.length;o++)a.diffs[o]=new n.Diff(i.diffs[o][0],i.diffs[o][1]);a.start1=i.start1,a.start2=i.start2,a.length1=i.length1,a.length2=i.length2,t[r]=a}return t},n.prototype.patch_apply=function(e,t){if(e.length==0)return[t,[]];e=this.patch_deepCopy(e);var n=this.patch_addPadding(e);t=n+t+n,this.patch_splitMax(e);for(var o=0,s=[],c=0;c<e.length;c++){var l=e[c].start2+o,u=this.diff_text1(e[c].diffs),d,f=-1;if(u.length>this.Match_MaxBits?(d=this.match_main(t,u.substring(0,this.Match_MaxBits),l),d!=-1&&(f=this.match_main(t,u.substring(u.length-this.Match_MaxBits),l+u.length-this.Match_MaxBits),(f==-1||d>=f)&&(d=-1))):d=this.match_main(t,u,l),d==-1)s[c]=!1,o-=e[c].length2-e[c].length1;else{s[c]=!0,o=d-l;var p=f==-1?t.substring(d,d+u.length):t.substring(d,f+this.Match_MaxBits);if(u==p)t=t.substring(0,d)+this.diff_text2(e[c].diffs)+t.substring(d+u.length);else{var m=this.diff_main(u,p,!1);if(u.length>this.Match_MaxBits&&this.diff_levenshtein(m)/u.length>this.Patch_DeleteThreshold)s[c]=!1;else{this.diff_cleanupSemanticLossless(m);for(var h=0,g,_=0;_<e[c].diffs.length;_++){var v=e[c].diffs[_];v[0]!==a&&(g=this.diff_xIndex(m,h)),v[0]===i?t=t.substring(0,d+g)+v[1]+t.substring(d+g):v[0]===r&&(t=t.substring(0,d+g)+t.substring(d+this.diff_xIndex(m,h+v[1].length))),v[0]!==r&&(h+=v[1].length)}}}}}return t=t.substring(n.length,t.length-n.length),[t,s]},n.prototype.patch_addPadding=function(e){for(var t=this.Patch_Margin,r=``,i=1;i<=t;i++)r+=String.fromCharCode(i);for(var i=0;i<e.length;i++)e[i].start1+=t,e[i].start2+=t;var o=e[0],s=o.diffs;if(s.length==0||s[0][0]!=a)s.unshift(new n.Diff(a,r)),o.start1-=t,o.start2-=t,o.length1+=t,o.length2+=t;else if(t>s[0][1].length){var c=t-s[0][1].length;s[0][1]=r.substring(s[0][1].length)+s[0][1],o.start1-=c,o.start2-=c,o.length1+=c,o.length2+=c}if(o=e[e.length-1],s=o.diffs,s.length==0||s[s.length-1][0]!=a)s.push(new n.Diff(a,r)),o.length1+=t,o.length2+=t;else if(t>s[s.length-1][1].length){var c=t-s[s.length-1][1].length;s[s.length-1][1]+=r.substring(0,c),o.length1+=c,o.length2+=c}return r},n.prototype.patch_splitMax=function(e){for(var t=this.Match_MaxBits,o=0;o<e.length;o++)if(!(e[o].length1<=t)){var s=e[o];e.splice(o--,1);for(var c=s.start1,l=s.start2,u=``;s.diffs.length!==0;){var d=new n.patch_obj,f=!0;for(d.start1=c-u.length,d.start2=l-u.length,u!==``&&(d.length1=d.length2=u.length,d.diffs.push(new n.Diff(a,u)));s.diffs.length!==0&&d.length1<t-this.Patch_Margin;){var p=s.diffs[0][0],m=s.diffs[0][1];p===i?(d.length2+=m.length,l+=m.length,d.diffs.push(s.diffs.shift()),f=!1):p===r&&d.diffs.length==1&&d.diffs[0][0]==a&&m.length>2*t?(d.length1+=m.length,c+=m.length,f=!1,d.diffs.push(new n.Diff(p,m)),s.diffs.shift()):(m=m.substring(0,t-d.length1-this.Patch_Margin),d.length1+=m.length,c+=m.length,p===a?(d.length2+=m.length,l+=m.length):f=!1,d.diffs.push(new n.Diff(p,m)),m==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(m.length))}u=this.diff_text2(d.diffs),u=u.substring(u.length-this.Patch_Margin);var h=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);h!==``&&(d.length1+=h.length,d.length2+=h.length,d.diffs.length!==0&&d.diffs[d.diffs.length-1][0]===a?d.diffs[d.diffs.length-1][1]+=h:d.diffs.push(new n.Diff(a,h))),f||e.splice(++o,0,d)}}},n.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join(``)},n.prototype.patch_fromText=function(e){var t=[];if(!e)return t;for(var o=e.split(`
|
|
164
164
|
`),s=0,c=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;s<o.length;){var l=o[s].match(c);if(!l)throw Error(`Invalid patch string: `+o[s]);var u=new n.patch_obj;for(t.push(u),u.start1=parseInt(l[1],10),l[2]===``?(u.start1--,u.length1=1):l[2]==`0`?u.length1=0:(u.start1--,u.length1=parseInt(l[2],10)),u.start2=parseInt(l[3],10),l[4]===``?(u.start2--,u.length2=1):l[4]==`0`?u.length2=0:(u.start2--,u.length2=parseInt(l[4],10)),s++;s<o.length;){var d=o[s].charAt(0);try{var f=decodeURI(o[s].substring(1))}catch{throw Error(`Illegal escape in patch_fromText: `+f)}if(d==`-`)u.diffs.push(new n.Diff(r,f));else if(d==`+`)u.diffs.push(new n.Diff(i,f));else if(d==` `)u.diffs.push(new n.Diff(a,f));else if(d==`@`)break;else if(d!==``)throw Error(`Invalid patch mode "`+d+`" in: `+f);s++}}return t},n.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0},n.patch_obj.prototype.toString=function(){for(var e=this.length1===0?this.start1+`,0`:this.length1==1?this.start1+1:this.start1+1+`,`+this.length1,t=this.length2===0?this.start2+`,0`:this.length2==1?this.start2+1:this.start2+1+`,`+this.length2,n=[`@@ -`+e+` +`+t+` @@
|
|
165
165
|
`],o,s=0;s<this.diffs.length;s++){switch(this.diffs[s][0]){case i:o=`+`;break;case r:o=`-`;break;case a:o=` `;break}n[s+1]=o+encodeURI(this.diffs[s][1])+`
|
|
@@ -444,4 +444,4 @@ $2`).split(`
|
|
|
444
444
|
`||e[r]===`\r`;let i=n.after.charCodeAt(0);return Number.isNaN(i)||i===10||i===13}function f$(e,t){let n=``,r=0;for(;r<e.length;){let i=e.charAt(r);if(i===`\\`){n+=e.slice(r,r+2),r+=2;continue}if(i===`*`||i===`_`||i===`~`||i===`=`){let a=r+1;for(;a<e.length&&e.charAt(a)===i;)a++;let o=r===0?t.before.charCodeAt(t.before.length-1):e.charCodeAt(r-1);if(i===`=`)n+=(Number.isNaN(o)||o===10||o===13)&&d$(e,a,t)?`\\${e.slice(r,a)}`:e.slice(r,a);else{let s=a<e.length?e.charCodeAt(a):t.after.charCodeAt(0);n+=u$(i,o,s)?`\\${i}`.repeat(a-r):e.slice(r,a)}r=a;continue}n+=i,r+=1}return n}function p$(e,t,n){let r=n.startsWith(`_`)?`_`:`*`,i=e,a=i.charCodeAt(0);m$(t.before.charCodeAt(t.before.length-1),a,r)&&(i=h$(a)+i.slice(1));let o=i.charCodeAt(i.length-1);return m$(t.after.charCodeAt(0),o,r)&&(i=i.slice(0,-1)+h$(o)),i}function m$(e,t,n){return!(lN(t)!==1||n===`_`&&lN(e)===void 0)}function h$(e){return`&#x${e.toString(16).toUpperCase()};`}function g$(e,t,n,r){let i=e.value??``,a=e.data?.sourceDelimiter,o=typeof a==`string`&&/^\$+$/.test(a)?a.length:2;for(o===1&&!v$(i,r)&&(o=2);RegExp(`(^|[^$])${`\\$`.repeat(o)}([^$]|$)`).test(i);)o++;let s=`$`.repeat(o);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=` ${i} `);let c=-1;for(;++c<n.unsafe.length;){let e=n.unsafe[c];if(!e.atBreak)continue;let t=n.compilePattern(e),r;for(;(r=t.exec(i))!==null;){let e=r.index;i.codePointAt(e)===10&&i.codePointAt(e-1)===13&&e--,i=`${i.slice(0,e)} ${i.slice(r.index+1)}`}}return s+i+s}function _$(e,t,n,r){let i=e.data?.sourceDelimiter===`~`?`~`:`~~`,a=n.createTracker(r),o=n.enter(`strikethrough`),s=a.move(i);return s+=n.containerPhrasing(e,{...a.current(),before:s,after:`~`}),s+=a.move(i),o(),s}function v$(e,t){return!(e.length===0||!/^\S/.test(e)||!/\S$/.test(e)||/[$\r\n]/.test(e)||e.endsWith(`\\`)||/\\[!-/:-@[-`{-~]/.test(e)||/^\d/.test(t.after)||t.before.endsWith(`\\`))}function y$(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 b$=class{schema;handlers;pmNodeHandlers;pmMarkHandlers;parseProcessor;serializeProcessor;parseCtx={current:{}};constructor(e){this.schema=Ly(e.extensions),this.handlers=A$(this.schema,this.parseCtx);let{nodeHandlers:t,markHandlers:n}=j$(this.schema);this.pmNodeHandlers=t,this.pmMarkHandlers=n,this.parseProcessor=LQ({schema:this.schema,handlers:this.handlers,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers}),this.serializeProcessor=RQ({toMarkdownHandlers:e$})}parse(e,t){if(!e.trim())return{type:`doc`,content:[{type:`paragraph`,content:[]}]};this.parseCtx.current=t??{};try{return WQ(e,this.parseProcessor).toJSON()}finally{this.parseCtx.current={}}}parseToMdast(e){return e.trim()?GQ(e,this.parseProcessor):{type:`root`,children:[]}}parseWithFallback(e,t){return e.trim()?$Y(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 KQ(t,this.serializeProcessor,{schema:this.schema,pmNodeHandlers:this.pmNodeHandlers,pmMarkHandlers:this.pmMarkHandlers})}};const x$=VY();function S$(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 C$(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 w$(e){return e.attrs.sourceDirty||C$(e)}function T$(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 E$(e,t){if(!t)return e;let n={};return t.sourceFenceChar&&(n.sourceFenceChar=t.sourceFenceChar),typeof t.sourceFenceLength==`number`&&(n.sourceFenceLength=t.sourceFenceLength),t.sourcePadded===!0&&(n.sourcePadded=!0),Object.keys(n).length===0?e:{...e,data:n}}function D$(e,t){if(e.length===0)return E$({type:`inlineCode`,value:``},t);if(e.every(e=>e.type===`text`))return E$({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:[D$(n.children,t)]}}return E$({type:`inlineCode`,value:O$(e)},t)}function O$(e){let t=``;for(let n of e)n.type===`text`?t+=n.value:`children`in n&&Array.isArray(n.children)?t+=O$(n.children):`value`in n&&typeof n.value==`string`&&(t+=n.value);return t}const k$=CK;function A$(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=QL(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=QL(n.tableRow)),n.table&&n.tableRow&&n.tableCell&&(i.table=(e,t,r)=>{let i=e.align??[],a=e.children??[],o=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type!==`tableRow`)continue;let s=t.children??[],c=[];for(let t=0;t<s.length;t++){let a=s[t];if(a.type!==`tableCell`)continue;let o=r.all(a).flat(),l=o.length>0&&n.paragraph?[n.paragraph.create(null,o)]:null,u=i[t]??null,d=e===0&&n.tableHeader?n.tableHeader:n.tableCell,f=a.data?.sourcePadding??null,p=d.createAndFill({align:u,sourcePadding:f},l);p&&c.push(p)}let l=n.tableRow.createAndFill(null,c.length>0?c:null);l&&o.push(l)}let s=e.data?.sourceDashCounts??null,c=e.data?.sourceOuterPipes??null,l=e.data?.sourceAlignmentPadding??null;return n.table.createAndFill({sourceDashCounts:s,sourceOuterPipes:c,sourceAlignmentPadding:l},o.length>0?o:null)}),n.image&&(i.image=e=>{let r=e.url??``,i=XQ(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=[];for(let e of s){let t=c[c.length-1];e.kind===`entity`&&t?.kind===`entity`&&t.offset+t.length===e.offset&&Iq(t.raw)!==null&&Nq(e.raw)?c[c.length-1]={kind:`entity`,offset:t.offset,length:t.length+e.length,raw:t.raw+e.raw}:c.push(e)}let l=[],u=0;for(let t of c){if(t.offset>u){let r=n.slice(u,t.offset).replaceAll(`\xA0`,` `);r&&l.push(e.text(r))}if(t.offset<n.length){let i=n.slice(t.offset,t.offset+t.length).replaceAll(`\xA0`,` `);if(i)if(t.kind===`escape`)l.push(e.text(i,[r.escapeMark.create()]));else if(r.sourceLiteral){let n=Iq(t.raw);l.push(e.text(n??i,[r.sourceLiteral.create({sourceRaw:t.raw})]))}else l.push(e.text(i));u=t.offset+t.length}}if(u<n.length){let t=n.slice(u).replaceAll(`\xA0`,` `);t&&l.push(e.text(t))}return l.length===1?l[0]:l}),r.code&&(i.inlineCode=t=>e.text(t.value,[r.code.create({sourceFenceChar:t.data?.sourceFenceChar??"`",sourceFenceLength:typeof t.data?.sourceFenceLength==`number`?t.data.sourceFenceLength:1,sourcePadded:t.data?.sourcePadded===!0})]));let a=r.strike??r.delete;if(a&&(i.delete=$L(a,e=>({sourceDelimiter:e.data?.sourceDelimiter===`~`?`~`:`~~`}))),r.highlight&&(i.mark=$L(r.highlight)),r.comment&&(i.comment=$L(r.comment,e=>({sourceForm:e.data?.sourceForm??`percent`}))),n.commentBlock&&(i.commentBlock=QL(n.commentBlock,e=>({sourceForm:e.data?.sourceForm??`percent`,sourceLayout:e.data?.sourceLayout??`block`}))),r.emphasis&&(i.emphasis=$L(r.emphasis,e=>({sourceDelimiter:e.data?.sourceDelimiter??`*`}))),r.strong&&(i.strong=$L(r.strong,e=>({sourceDelimiter:e.data?.sourceDelimiter??`**`}))),n.heading&&(i.heading=QL(n.heading,e=>({level:e.depth,headingStyle:e.data?.sourceStyle??`atx`,sourceTrailingHashes:e.data?.sourceTrailingHashes??null,sourceUnderlineLength:e.data?.sourceUnderlineLength??null,sourceContiguousNext:e.data?.sourceContiguousNext??!1,sourceLeadingIndent:e.data?.sourceLeadingIndent??null,sourceInteriorSpacing:e.data?.sourceInteriorSpacing??null}))),n.codeBlock&&(i.code=t=>{let r=t.value?[e.text(t.value)]:[];return n.codeBlock.createAndFill({language:t.lang??null,meta:t.meta??null,fenceDelimiter:t.data?.sourceFenceChar??"`",fenceLength:t.data?.sourceFenceLength??3,sourceStyle:t.data?.sourceStyle??`fenced`,sourceClosingFenceLength:t.data?.sourceClosingFenceLength??null,sourceFenceIndent:t.data?.sourceFenceIndent??null,sourceInfoPadding:t.data?.sourceInfoPadding??null,sourceIndents:t.data?.sourceIndents??null},r)}),n.thematicBreak&&(i.thematicBreak=e=>n.thematicBreak.createAndFill({sourceRaw:e.data?.sourceRaw??`---`})),n.hardBreak&&(i.break=e=>n.hardBreak.createAndFill({hardBreakStyle:e.data?.sourceStyle??`spaces`})),n.list&&(i.list=QL(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=QL(n.listItem,e=>({checked:e.checked??null,spread:!!e.spread,sourceMarkerSpacing:e.data?.sourceMarkerSpacing??null,sourceOrdinal:e.data?.sourceOrdinal??null,sourceCheckboxChar:e.data?.sourceCheckboxChar??null,sourceContinuationIndent:e.data?.sourceContinuationIndent??null}))),r.link){let t=r.sourceLiteral;i.link=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[](${n.url??``})`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:n.url??``,title:n.title??null,linkStyle:n.data?.sourceStyle??`inline`,refLabel:null,sourceUrlForm:n.data?.sourceUrlForm??null,sourceTitleMarker:n.data?.sourceTitleMarker??null});return o.map(e=>e.mark(s.addToSet(e.marks)))},i.linkReference=(n,i,a)=>{if((n.children??[]).length===0){let r=typeof n.data?.sourceRaw==`string`?n.data.sourceRaw:`[${n.label??``}][${n.identifier??``}]`;return r?t?e.text(r,[t.create({sourceRaw:r})]):e.text(r):null}let o=a.all(n).flat(),s=r.link.create({href:``,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=x$.getOrWildcard(o),c=S$(e.attributes,s.props);if(o===`CommonMarkImage`&&typeof c.src==`string`){let e=c.src,n=XQ(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,sourceTarget:e.data?.sourceTarget??null,sourceAnchor:e.data?.sourceAnchor??null,sourceAlias:e.data?.sourceAlias??null})),n.tag&&(i.tag=e=>n.tag.createAndFill({value:e.value})),n.wikiLinkEmbed&&(i.wikiLinkEmbed=(i,a)=>{let o=i.data?.target??``,s=i.data?.alias??null,c=i.data?.anchor??null,l=Zq(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&&k$.has(l)&&n.jsxComponent&&x$.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&&wK.has(l)&&n.jsxComponent&&x$.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&&EK.has(l)&&n.jsxComponent&&x$.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&&DK.has(l)&&n.jsxComponent&&x$.has(`WikiEmbedFile`)){let{resolveSize:e}=t.current,r=e&&d?e(o,d)??null:null,i=r===null?null:y$(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(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])}throw Error("[wikiLinkEmbed handler] schema lacks `link` mark — cannot dispatch without violating the STOP rule against emitting PM wikiLinkEmbed server-side")}),n.mathInline&&(i.inlineMath=e=>n.mathInline.create({formula:e.value??``,sourceDelimiter:e.data?.sourceDelimiter??null})),i.math||=t=>{let r=t.value==null?`«unknown:${t.type}»`:t.value;return n.rawMdxFallback?(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled block mdast: ${t.type}`})),n.rawMdxFallback.createAndFill({reason:`Unhandled block mdast: ${t.type}`},r?[e.text(r)]:null)):null},i.inlineMath||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:t.type,reason:`Unhandled inline mdast: ${t.type}`})),t.value==null?e.text(`«unknown:${t.type}»`):e.text(t.value)),n.footnoteReference?i.footnoteReference=e=>n.footnoteReference.create({identifier:e.identifier,label:e.label??e.identifier}):i.footnoteReference||=t=>(console.warn(JSON.stringify({event:`unknown-mdast-type`,type:`footnoteReference`,reason:`FootnoteReference extension missing — recovering [^id] source`})),e.text(`[^${t.label??t.identifier}]`)),n.footnoteDefinition?i.footnoteDefinition=QL(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 j$(e){let t={},n={},r=e.nodes,i=e.marks;r.paragraph&&(t.paragraph=iR(`paragraph`)),r.blockquote&&(t.blockquote=iR(`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=iR(`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,sourceLeadingIndent:e.attrs.sourceLeadingIndent??void 0,sourceInteriorSpacing:e.attrs.sourceInteriorSpacing??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,sourceClosingFenceLength:e.attrs.sourceClosingFenceLength??void 0,sourceFenceIndent:e.attrs.sourceFenceIndent??void 0,sourceInfoPadding:e.attrs.sourceInfoPadding??void 0,sourceIndents:e.attrs.sourceIndents??void 0}}}),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=iR(`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&&T$(r[0])?r.slice(1):r,a={};return typeof e.attrs.sourceMarkerSpacing==`number`&&(a.sourceMarkerSpacing=e.attrs.sourceMarkerSpacing),typeof e.attrs.sourceOrdinal==`number`&&(a.sourceOrdinal=e.attrs.sourceOrdinal),e.attrs.sourceCheckboxChar===`X`&&(a.sourceCheckboxChar=`X`),typeof e.attrs.sourceContinuationIndent==`number`&&(a.sourceContinuationIndent=e.attrs.sourceContinuationIndent),{type:`listItem`,checked:e.attrs.checked??null,spread:e.attrs.spread??!1,...Object.keys(a).length>0?{data:a}:{},children:i}}),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&&(c.sourceDashCounts=s);let l=e.attrs.sourceOuterPipes;typeof l==`object`&&l&&typeof l.leading==`boolean`&&typeof l.trailing==`boolean`&&(c.sourceOuterPipes=l);let u=e.attrs.sourceAlignmentPadding;Array.isArray(u)&&u.length>0&&(c.sourceAlignmentPadding=u);let d=Object.keys(c).length>0?c:void 0,f={type:`table`,align:i,children:o};return d&&(f.data=d),f}),r.tableRow&&(t.tableRow=iR(`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=iR(`tableCell`,a)),r.tableHeader&&(t.tableHeader=iR(`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!w$(e)&&e.attrs.sourceRaw?{type:`mdxJsxFlowElement`,name:r,attributes:i,children:[],data:{sourceRaw:String(e.attrs.sourceRaw)}}:x$.getOrWildcard(r??`*`).serialize(e,{all:e=>n.all(e),registry:x$,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;if(typeof n==`string`&&n.length>0)return{type:`mdxJsxTextElement`,name:`InlineMath`,attributes:[{type:`mdxJsxAttribute`,name:`formula`,value:t},{type:`mdxJsxAttribute`,name:`id`,value:n}],children:[]};let r=e.attrs.sourceDelimiter;return{type:`inlineMath`,value:t,...typeof r==`string`&&r.length>0?{data:{sourceDelimiter:r}}:{}}}),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,sourceTarget:typeof e.attrs.sourceTarget==`string`?e.attrs.sourceTarget:null,sourceAnchor:typeof e.attrs.sourceAnchor==`string`?e.attrs.sourceAnchor:null,sourceAlias:typeof e.attrs.sourceAlias==`string`?e.attrs.sourceAlias:null},children:[{type:`text`,value:i}]}}),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=aR(`emphasis`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.strong&&(n.strong=aR(`strong`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter}}))),i.code&&(n.code=(e,t,n)=>{let r=e.attrs.sourceFenceChar,i=e.attrs.sourceFenceLength;return D$(n,{sourceFenceChar:r,sourceFenceLength:i,sourcePadded:e.attrs.sourcePadded===!0?!0:void 0})}),i.strike??i.delete){let e=i.strike?`strike`:`delete`;n[e]=aR(`delete`,e=>({data:{sourceDelimiter:e.attrs.sourceDelimiter===`~`?`~`:`~~`}}))}return i.highlight&&(n.highlight=aR(`mark`)),i.comment&&(n.comment=aR(`comment`,e=>({data:{sourceForm:e.attrs.sourceForm===`html`?`html`:`percent`}}))),r.commentBlock&&(t.commentBlock=iR(`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=iR(`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??``,r=typeof e.attrs.anchor==`string`&&e.attrs.anchor.length>0?e.attrs.anchor:null,i=typeof e.attrs.alias==`string`&&e.attrs.alias.length>0?e.attrs.alias:null,a=i||(r?`${t}#${r}`:t),o=n.map(e=>`value`in e&&typeof e.value==`string`?e.value:``).join(``);return o!==a&&o.trim().length>0&&!o.includes(`]]`)&&(i=o,a=o),{type:`wikiLinkEmbed`,value:a,data:{target:t,anchor:r,alias:i},children:[{type:`text`,value:a}]}}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.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 Rq(t,e.value)&&(e.data??={},e.data.sourceRaw=t),e}return{type:`text`,value:n.filter(e=>e.type===`text`).map(e=>e.value??``).join(``)||r}}),{nodeHandlers:t,markHandlers:n}}const M$=/\p{M}+/gu,N$=/[^\p{L}\p{N}]+/gu,P$=/^-+|-+$/g;function F$(e){return e.trim().normalize(`NFKD`).replace(M$,``).toLowerCase().replace(N$,`-`).replace(P$,``)}function I$(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n}`}function L$(e,t){let n=F$(e);return n?I$(n,t):``}const R$=new Set([`img`,`video`,`audio`,`mark`]);new Map(zY.flatMap(e=>e.surface===`compat`&&R$.has(e.rendersAs)?[[e.name,e]]:[])),dF(`<>`);const z$=JB(),B$=fB(),V$=pB();function H$(){return zY.filter(e=>e.surface===`canonical`&&e.name!==`*`)}function U$(){return H$().filter(e=>W$(e)!==`fence`)}function W$(e){return e.name===`MermaidFence`?`fence`:e.hasChildren?`jsx-block`:`jsx-void`}function G$(e){return{id:e.name,displayName:e.displayName??e.name,description:e.description??``,kind:W$(e)}}function K$(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 q$(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 J$(e){let t=[];for(let n of e.props){let e=K$(n);e!==void 0&&q$(n,e)&&t.push(QJ(n.name,e))}return t}function Y$(e){return bz(e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`Body content here.`,{extensions:[z$],mdastExtensions:[B$]}).children}function X$(e){let t=W$(e),n;if(t===`fence`)n={type:`code`,lang:`mermaid`,meta:null,value:e.exampleBody&&e.exampleBody.trim().length>0?e.exampleBody:`graph LR
|
|
445
445
|
A --> B`};else{let r=J$(e),i=t===`jsx-block`?Y$(e):[];n={type:`mdxJsxFlowElement`,name:e.name,attributes:r,children:i}}return fP({type:`root`,children:[n]},{extensions:[V$]}).trimEnd()}function Z$(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 Q$(e){return{...G$(e),example:X$(e),params:Z$(e)}}function $$(){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 (mermaid label text has sharp edges — `palette({ components: [\"Mermaid\"] })` lists them; parse failures come back as `warnings` entries on write/edit) 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.",``,...U$().map(G$).map(e=>`- \`${e.id}\` (${e.kind}) — ${e.description}`)].join(`
|
|
446
446
|
`)}const e1=N({docName:lJ,summary:dJ,content:k().optional(),...uJ}).loose(),t1=N({docName:lJ,summary:dJ,markdown:k(),position:P([`append`,`prepend`,`replace`]).optional(),extension:P(iK).optional(),...uJ}).loose(),n1=N({docName:lJ,summary:dJ,find:k().min(1),replace:k(),offset:A().int().nonnegative().optional(),...uJ}).loose(),r1=N({docName:lJ,connectionId:k().min(1),scope:P([`last`,`session`,`file`]).optional(),...uJ}).loose(),i1=N({value:k(),truncatedFrom:A().int().nonnegative().optional(),hint:k().optional()}).loose(),a1=$s(`kind`,[N({kind:F(`inline`),content:k()}),N({kind:F(`truncated`),byteLength:A().int().nonnegative(),hint:k()})]),o1=N({kind:F(`content-divergence`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),divergenceType:k().optional(),currentState:a1.optional(),hint:k().optional()}).loose(),s1=N({type:F(`orphan`),parentCandidates:M(k()),message:k()}).loose(),c1=N({kind:F(`disk-edit-reconciled`),intendedBytes:A().int().nonnegative(),actualBytes:A().int().nonnegative(),byteDelta:A().int(),mergeOutcome:k().optional(),hint:k().optional()}).loose(),l1=$s(`kind`,[o1,c1]),u1=$s(`kind`,[o1,c1,N({kind:F(`mermaid-parse-error`),fenceIndex:A().int().positive(),fenceFirstLine:k(),message:k(),line:A().int().positive().optional()}).loose()]),d1=M(u1).min(1),f1=N({timestamp:k().min(1),summary:i1.optional(),warning:l1.optional(),warnings:d1.optional()}).loose(),p1=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),hints:M(s1).optional(),summary:i1.optional(),warning:l1.optional(),warnings:d1.optional()}).loose(),m1=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),summary:i1.optional(),warning:l1.optional(),warnings:d1.optional()}).loose(),h1=N({docName:k().min(1),scope:P([`last`,`session`]),undone:j()}).loose(),g1=N({docName:lJ,patch:rc(k(),Zs([zW,Bs()])),types:rc(k(),P(IW)).optional(),summary:dJ,...uJ}).loose(),_1=N({timestamp:k().min(1),subscriberCount:A().int().nonnegative(),systemSubscriberCount:A().int().nonnegative(),appliedKeys:M(k()),summary:i1.optional(),warning:l1.optional(),warnings:d1.optional()}).loose(),v1=N({entries:M(N({level:P([`info`,`warn`,`error`]),message:k().max(8192),event:k().optional(),fields:rc(k(),Ws()).optional(),ts:A().optional(),sourceId:k().optional(),lineNumber:A().optional()}).loose()).max(100)}).loose(),y1=N({accepted:A().int().min(0)}).loose(),b1=N({status:k().min(1),reason:k()}).loose(),x1=N({docName:k().min(1),content:k(),lifecycle:b1.nullable()}).loose(),S1=N({documents:M(N({kind:P([`document`,`asset`,`folder`,`file`]).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.kind===`file`?e.path!==void 0&&e.mediaKind===void 0&&e.referencedBy===void 0&&e.hasChildren===void 0:e.path!==void 0&&e.assetExt!==void 0&&e.referencedBy!==void 0&&e.hasChildren===void 0,{message:`document/asset/folder/file kind must match its required fields (document → docName; asset → path+assetExt+referencedBy; folder → path only, no docName; file → path, no mediaKind/referencedBy/hasChildren)`})),truncated:j().optional()}).loose(),C1=N({source:k().min(1),anchor:k().nullable(),title:k(),snippet:k().nullable()}).loose(),w1=N({docName:k().min(1),backlinks:M(C1)}).loose(),T1=N({counts:rc(k().min(1),A().int().nonnegative())}).loose(),E1=$s(`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()]),D1=N({docName:k().min(1),forwardLinks:M(E1)}).loose(),O1=$s(`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()]),k1=N({source:k().min(1),target:k().min(1)}).loose(),A1=N({nodes:M(O1),links:M(k1)}).loose(),j1=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(),M1=N({app:Zs([F(`cursor`),F(`codex`),F(`claude`),Bs()]),signals_fired:M(k())}).loose(),N1=N({entries:M(j1),count:A().int().min(0),detection:M1}).loose(),P1=N({writers:M(N({id:k().min(1),name:k().optional(),email:k().optional()}).loose()).optional(),summary:dJ,...uJ}).loose(),F1=N({checkpointRef:k().min(1)}).loose(),I1=N({v:A().int().optional(),id:k().min(1),name:k().min(1),colorSeed:k().optional(),docs:M(k()),summaries:M(k()).optional()}).loose(),L1=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(I1),checkpoint:Ws().nullable()}).loose()),total:A().int().nonnegative().optional(),truncated:j().optional(),hasMore:j().optional()}).loose(),R1=N({sha:k().regex(/^[0-9a-f]{40}$/i),content:k(),timestamp:k(),author:k()}).loose(),z1=N({contentDir:k().min(1),pathSeparator:P([`/`,`\\`]),symlinkResolved:j()}).loose(),B1=M($s(`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`."}),V1=N({orphans:M(N({docName:k().min(1),title:k()}).loose())}).loose(),H1=N({hubs:M(N({docName:k().min(1),title:k(),count:A().int().nonnegative()}).loose())}).loose(),U1=N({source:k().min(1),title:k(),snippet:k().nullable()}).loose(),W1=N({deadLinks:M(N({target:k().min(1),sources:M(U1)}).loose())}).loose(),G1=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(),K1=N({projectPath:k().min(1)}).loose(),q1=P([`not-a-git-worktree`,`init-failed`]),J1=$s(`ok`,[N({ok:F(!0),projectPath:k().min(1)}).loose(),N({ok:F(!1),reason:q1,message:k().min(1)}).loose()]),Y1=N({host:k().min(1).optional()}).loose(),X1=N({key:k().min(1)}).loose(),Z1=N({keyPresent:j()}).loose(),Q1=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(),$1=N({authenticated:j()}).loose(),e0=N({}).loose(),t0=N({stackIndex:A().int().min(0),ts:A().int().min(0),additions:A().int().min(0),deletions:A().int().min(0)}).loose(),n0=N({docName:k().min(1),additionsTotal:A().int().min(0),deletionsTotal:A().int().min(0),lastTs:A().int().min(0),bursts:M(t0)}).loose(),r0=N({displayName:k().min(1),color:k().min(1),icon:k().optional(),connectionId:k().min(1)}).loose(),i0=N({sessionAlive:j(),agent:r0.nullable(),files:M(n0)}).loose(),a0=N({diff:k(),generatedAt:A().int().min(0)}).loose(),o0=N({}).loose(),s0=N({}).loose(),c0=N({}).loose(),l0=N({}).loose(),u0=N({}).loose(),d0=N({}).loose(),f0=N({displayName:k().min(1),icon:k(),color:k().min(1),currentDoc:k().nullable(),mode:P([`idle`,`writing`]),ts:A().int().min(0)}).loose(),p0=N({presence:rc(k().min(1),f0)}).loose(),m0=rc(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 h0=N({}).loose(),g0=N({fromDocName:k().min(1),toDocName:k().min(1)}).loose(),_0=N({fromPath:k().min(1),toPath:k().min(1)}).loose(),v0=N({}).loose(),y0=N({path:k().min(1),...uJ,summary:dJ}).loose(),b0=N({docName:k().min(1)}).loose(),x0=N({path:k().min(1),...uJ,summary:dJ}).loose(),S0=N({path:k().min(1)}).loose(),C0=N({kind:P([`file`,`folder`]),path:k().min(1),...uJ,summary:dJ}).loose(),w0=N({kind:P([`file`,`folder`]),path:k().min(1),duplicatedDocNames:M(k().min(1))}).loose(),T0=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(),E0=N({level:A().int().min(1).max(6),text:k(),slug:k()}).loose(),D0=N({docName:k().min(1),headings:M(E0)}).loose(),O0=N({docName:k().min(1),rewrites:A().int().nonnegative()}).loose(),k0=N({kind:P([`file`,`folder`,`asset`]),fromPath:k().min(1),toPath:k().min(1),...uJ,summary:dJ}).loose(),A0=N({renamed:M(g0),renamedAssets:M(_0),rewrittenDocs:M(O0).optional(),summary:i1.optional()}).loose(),j0=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...uJ}).loose(),M0=N({deletedDocNames:M(k().min(1))}).loose(),N0=N({kind:P([`file`,`folder`,`asset`]),path:k().min(1),...uJ,summary:dJ}).loose(),P0=N({deletedDocNames:M(k().min(1))}).loose(),F0=N({docName:k().min(1),commitSha:k().regex(/^[0-9a-f]{40}$/i,{message:`commitSha must be a 40-char git SHA`}),summary:dJ,...uJ}).loose(),I0=N({restoredFrom:k().min(1),timestamp:k().min(1),summary:i1.optional(),warning:o1.optional(),warnings:d1.optional()}).loose(),L0=P([`dormant`,`idle`,`fetching`,`pulling`,`pushing`,`conflict`,`offline`,`auth-error`,`disabled`]),R0=N({label:k().min(1),webUrl:ys().nullable()}).loose(),z0=$s(`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()]),B0=P([`auth-403`,`auth-401`,`auth-scope-mismatch`,`auth-no-credential`,`semantic-protected-branch`]),V0=N({state:L0,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:R0.nullable().optional(),pushError:k().optional(),pushErrorCode:B0.optional(),pullError:k().optional(),pullErrorCode:B0.optional(),pausedReason:k().optional(),pushPermission:z0.optional()}).loose(),H0=N({op:P([`sync`,`push`,`pull`]).optional()}).loose(),U0=N({op:P([`sync`,`push`,`pull`])}).loose(),W0=N({conflicts:M(N({file:k().min(1),detectedAt:k().min(1),oursSha:k().optional(),theirsSha:k().optional(),baseSha:k().optional()}).loose())}).loose(),G0=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`]}),K0=N({}).loose(),q0=N({file:k().min(1),base:k(),ours:k(),theirs:k(),kind:P([`both-modified`,`delete-modify`,`modify-delete`]),lifecycleStatus:k().nullable()}).loose(),J0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),Y0=N({plan:kc(e=>e!==void 0,{message:`plan is required`})}).loose(),X0=N({result:kc(e=>e!==void 0,{message:`result is required`})}).loose(),Z0=N({path:k().min(1),summary:k().min(1)}).loose(),Q0=N({files:A().int().nonnegative(),folders:A().int().nonnegative()}).loose(),$0=N({packs:M(N({id:k().min(1),name:k().min(1),description:k().min(1),defaultSubfolder:k().optional(),folders:M(Z0),entryCounts:Q0}).loose())}).loose(),e2=N({noOpen:j().optional(),out:k().min(1).optional()}).loose(),t2=N({reason:P([`unsupported-platform`,`spawn-error`]),message:k()}).loose(),n2=$s(`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:t2.optional()}).loose(),N({status:F(`failed`),buildError:k()}).loose(),N({status:F(`skip-current`),skillVersion:k(),recordedAt:k().optional()}).loose()]),r2=N({tags:M(N({name:k().min(1),count:A().int().nonnegative(),isLeaf:j()}).loose())}).loose(),i2=N({docName:k().min(1),title:k(),matchingTags:M(k().min(1)),snippet:k().nullable()}).loose(),a2=N({name:k().min(1),docs:M(i2)}).loose(),o2=N({folder:Ws(),frontmatter_local:rc(k(),Ws()).nullable()}).loose(),s2=N({path:k(),frontmatter:rc(k(),Ws()).optional()}).loose(),c2=N({applied:Ws()}).loose(),l2=rc(k(),Ws()).meta({description:`Free-form frontmatter map embedded in template payloads.`}),u2=N({template:N({name:k().min(1),folder:k(),scope:P([`local`,`inherited`]),path:k().min(1),frontmatter:l2,body:k()}).strict()}).strict(),d2=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(),f2=N({folder:k(),name:k(),body:k().optional(),frontmatter:l2.optional(),...uJ,summary:dJ}).strict(),p2=N({path:k().min(1),created:j(),warnings:M(k())}).strict(),m2=N({existed:j(),path:k().min(1)}).strict(),h2=N({fromFolder:k(),fromName:k(),toFolder:k(),toName:k(),body:k().optional(),frontmatter:l2.optional(),...uJ,summary:dJ}).strict(),g2=N({from:k().min(1),to:k().min(1),committed:j()}).strict(),_2=N({query:k().optional(),intent:P([`autocomplete`,`full_text`,`omnibar`]).optional(),ranking:P([`navigation`,`relevance`]).optional(),scopes:M(P([`page`,`folder`,`content`,`file`])).optional(),scope:k().optional(),limit:A().int().nonnegative().optional(),semantic:j().optional(),source:P([`omnibar`,`mcp`,`http`]).optional()}).loose(),v2=N({kind:P([`page`,`folder`,`content`,`file`]),path:k().min(1),title:k(),score:A(),signals:rc(k(),Ws()),snippet:k().optional()}).loose(),y2=N({capable:j(),applied:j(),coverage:N({embedded:A().int().nonnegative(),total:A().int().nonnegative()})}).loose(),b2=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(),x2=N({query:k(),intent:P([`autocomplete`,`full_text`,`omnibar`]),results:M(v2),elapsedMs:A().nonnegative(),semantic:y2.optional(),truncated:j().optional(),ready:j().optional()}).loose(),S2=N({version:k().min(1),recordedAt:k().min(1)}).loose(),C2=N({currentVersion:k().min(1),targets:rc(k(),S2.nullable())}).loose(),w2=`server-info`,T2=`branch-switched`,E2=`disk-ack`,D2=`config-validation-rejected`,O2=`config-ignore-nested-error`,k2=P([`files`,`backlinks`,`graph`,`sync-status`,`session-activity`,`tags`]),A2=N({v:F(1),ch:F(w2),seq:A(),serverInstanceId:k().min(1),currentBranch:k().min(1).optional()}).loose(),j2=N({v:F(1),ch:F(T2),seq:A(),branch:k().min(1)}).loose(),M2=N({v:F(1),ch:k2,seq:A()}).loose(),N2=N({v:F(1),ch:F(E2),seq:A(),docName:k().min(1),sv:k().min(1)}).loose(),P2=N({v:F(1),ch:F(D2),seq:A(),docName:k().min(1),error:ll}).loose(),F2=N({v:F(1),ch:F(O2),seq:A(),path:k().min(1),error:k().min(1)}).loose(),I2={id:`string`,kind:`enum`,path:`string`,title:`string`,name:`string`,pathSegments:`string`,content:`string`,modifiedTs:`number`},L2=new WeakMap;function R2(e){return e===void 0||!Number.isFinite(e)?20:Math.max(1,Math.min(100,Math.trunc(e)))}function z2(e){return e.trim().toLowerCase()}const B2=/\.(?:md|mdx)$/;function V2(e,t){if(t!==`page`)return e;let n=e.replace(B2,``);return n.length>0?n:e}function H2(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function U2(e){let t=H2(e.path),n=e.title?.trim()||t,r=e.modifiedTs??0,i=e.path.split(`/`).filter(Boolean),a=new Set(i),o=[...new Set((e.aliases??[]).flatMap(e=>e.split(`/`).filter(Boolean)).filter(e=>!a.has(e)))];return{id:`${e.kind}:${e.path}`,kind:e.kind,path:e.path,title:n,name:t,pathSegments:[...i,...o].join(` `),content:e.content??``,modifiedTs:Number.isFinite(r)?r:0}}function W2(e){let t=LU({schema:I2});return e.length>0&&JU(t,e),t}function G2(e){let t={documents:e};return L2.set(t,W2(e)),t}function K2(e){let t=L2.get(e);if(t)return t;let n=W2(e.documents);return L2.set(e,n),n}function q2(e){return e===`autocomplete`?[`page`]:e===`full_text`?[`page`,`content`,`file`]:[`page`,`folder`,`file`]}function J2(e,t){return t.has(e.kind)?!0:e.kind===`page`&&t.has(`content`)}function Y2(e,t){let n=z2(t);if(!n)return 0;let r=V2(n,e.kind),i=z2(e.title),a=z2(e.name),o=z2(e.path),s=o.split(`/`);return i===r||a===r?700:o===r?650:i.startsWith(r)||a.startsWith(r)?600:s.some(e=>e.startsWith(r))?550:i.includes(r)||a.includes(r)?500:o.includes(r)?450:-1}function X2(e,t){let n=Y2(e,t);return n<=0?n:sJ(e.path)?n*.5:n}function Z2(e){return e===`file`?-60:0}function Q2(e,t,n,r,i){let a=i>0?t/i:0,o=n/50,s=r===`file`?-.001:0,c=1*a+1*o+s;return e*1e3+c}function $2(e,t,n,r){return e+t*20+n+Z2(r)}function e4(e,t,n,r,i,a){return e===`relevance`?$2(t,n,r,i):Q2(t,n,r,i,a)}function t4(e,t){return t||(e===`full_text`?`relevance`:`navigation`)}function n4(e,t){let n=0;for(let r of e){let e=t.get(r.id)??0;e>n&&(n=e)}return n}function r4(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 i4(e){return e===`full_text`?[`title`,`name`,`path`,`pathSegments`,`content`]:[`title`,`name`,`path`,`pathSegments`]}function a4(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 o4(e,t){return z2(t).length<4?0:e===`full_text`?1:0}function s4(e,t,n){if(t===`relevance`)return e.slice(0,n);let r=[],i=0,a=0;for(let t of e){if(t.document.kind===`folder`){if(i>=3)continue;i+=1}else if(t.document.kind===`file`){if(a>=3)continue;a+=1}if(r.push(t),r.length>=n)break}return r}function c4(e,t,n={}){let r=n.intent??`omnibar`,i=t4(r,n.ranking),a=R2(n.limit),o=new Set(n.scopes??q2(r)),s=e.documents.filter(e=>J2(e,o)),c=z2(t);if(!c)return s.slice().sort((e,t)=>e.path.localeCompare(t.path)).slice(0,a).map(e=>({document:e,score:0,signals:{lexical:0,fullText:0,recency:0}}));let l=wW(K2(e),{term:c,properties:i4(r),boost:a4(r),tolerance:o4(r,c),limit:Math.max(a*4,40)}),u=new Map(l.hits.filter(e=>J2(e.document,o)).map(e=>[e.document.id,e.score])),d=r4(s),f=new Map;for(let e of s)X2(e,c)>=0&&f.set(e.id,e);for(let e of l.hits)J2(e.document,o)&&f.set(e.document.id,e.document);if(!n.semantic){let e=n4(f.values(),u);return s4([...f.values()].map(t=>{let n=Math.max(0,X2(t,c)),r=u.get(t.id)??0,a=d.get(t.id)??0;return{document:t,score:e4(i,n,r,a,t.kind,e),signals:{lexical:n,fullText:r,recency:a}}}).sort((e,t)=>e.score===t.score?e.document.path.localeCompare(t.document.path):t.score-e.score),i,a)}return s4(u4({scopedDocuments:s,candidates:f,fullTextScores:u,recency:d,normalizedQuery:c,ranking:i,semantic:n.semantic}),i,a)}function l4(e){let t=new Map;return e.forEach((e,n)=>{t.set(e,n+1)}),t}function u4(e){let{scopedDocuments:t,candidates:n,fullTextScores:r,recency:i,normalizedQuery:a,ranking:o,semantic:s}=e,c=s.rrfK??60,l=s.candidateLimit??64,u=s.similarityFloor??0,d=s.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=n4(n.values(),r),h=[...n.values()].map(e=>{let t=Math.max(0,X2(e,a)),n=r.get(e.id)??0,s=i.get(e.id)??0,c=d.get(e.id),l=c!==void 0&&c>=u;return{document:e,score:t>0?e4(o,t,n,s,e.kind,m):$2(t,n,s,e.kind),signals:l?{lexical:t,fullText:n,recency:s,vector:c}:{lexical:t,fullText:n,recency:s},lexical:t,fullText:n,recency:s,cosine:c}}),g=l4(h.filter(e=>e.fullText>0).sort((e,t)=>t.fullText-e.fullText||e.document.path.localeCompare(t.document.path)).map(e=>e.document.id)),_=l4(h.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)),v=e=>{let t=0,n=g.get(e);n!==void 0&&(t+=1/(c+n));let r=_.get(e);return r!==void 0&&(t+=1/(c+r)),t};return h.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=v(e.document.id),a=v(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}))}function d4(e){let t=new TextEncoder().encode(e),n=new Uint8Array(1+t.length);return n[0]=1,n.set(t,1),f4(n)}function f4(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 p4=Symbol.for(`@inkeep/open-knowledge/skill-state-field-registry`),m4=globalThis;m4[p4]===void 0&&(m4[p4]=Ii());const h4=m4[p4],g4=[`.ok`,`skill-state.yml`],_4=[`claude-cowork`,`cli-hosts`],v4=[`server-build-and-open`,`electron-build-and-open`,`cli-npx-skills-add`,`desktop-direct`,`cli-start`],y4=/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/,b4=Ys({version:k().regex(y4,`version must match /^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$/`).register(h4,{description:`Recorded skill version for this target.`}),recordedAt:Uo().register(h4,{description:`ISO 8601 timestamp of the most recent successful write. Updated on every write, including reinstalls of the same version.`}),surface:P(v4).register(h4,{description:`Install-source surface that recorded this entry.`}).optional()}),x4=Ys({schema:F(1).register(h4,{description:`Schema major version. Bumped only on breaking shape changes.`}),targets:Ys({"claude-cowork":b4.optional(),"cli-hosts":b4.optional()}).register(h4,{description:`Per-target install-state entries. Absent target = no recorded install.`}).default({})});function S4(){return{schema:1,targets:{}}}function C4(){let e=!1,t=``,n=0;return r=>{let i=w4(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 w4(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 T4=[`#D97757`,`#1B1912`,`#F9F3E9`,`#7A9DFF`,`#8534F3`,`#9663F0`,`#727CF3`],E4={claude:`#D97757`,cursor:`#1B1912`,windsurf:`#0B100F`,openai:`#7A9DFF`,github:`#8534F3`,cline:`#9663F0`,bot:`#727CF3`};function D4(e,t=T4){let n=0;for(let t of e)n=(n<<5)-n+t.charCodeAt(0)|0;return t[Math.abs(n)%t.length]}const O4={"claude-code":`claude`,"claude-ai":`claude`,cursor:`cursor`,"cursor-vscode":`cursor`,cascade:`windsurf`,codex:`openai`,"codex-mcp-client":`openai`,copilot:`github`,cline:`cline`};function k4(e){return e?O4[e]||(e.startsWith(`local-agent-mode-`)?`claude`:`bot`):`bot`}const A4={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`};function j4(e){let t=e?.trim();return t?A4[k4(t)]??t:`Agent`}function M4(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 N4=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function P4(e){let t=(e.split(/[?#]/)[0]??e).match(/\.([a-z0-9]+)$/i);return t?(t[1]??``).toLowerCase():null}function F4(e){let t=e.trim();return N4.test(t)||t.startsWith(`//`)}function I4(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(F4(n))return{kind:`external`,url:n};let r=M4(n,t);if(r)return{kind:`doc`,docName:r.docName,anchor:r.anchor};let i=P4(n);return i&&i!==`md`&&i!==`mdx`?{kind:`asset`,url:n,ext:i}:null}function L4(e,t){let n=e.trim();if(!n)return null;if(F4(n))return{kind:`external`,url:t?`${n}#${t}`:n};let r=P4(n);return r&&r!==`md`&&r!==`mdx`?{kind:`asset`,url:n,ext:r}:{kind:`doc`,docName:n,anchor:t?.trim()||null}}function R4(e,t){let n=e.trim();if(!n||N4.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 z4(e){let t=e;return t.startsWith(`./`)&&(t=t.slice(2)),t.startsWith(`/`)&&(t=t.slice(1)),t}function B4(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function V4(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function H4(e){return e.split(`/`).filter(e=>e!==``)}function U4(e,t){let n=V4(t);return e===``||n===e?!0:n.startsWith(`${e}/`)}function W4(e,t){let n=V4(t);if(e===n)return 0;let r=e===``?n:n.slice(e.length+1);return r===``?0:H4(r).length}function G4(e,t){let n=H4(e),r=H4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return n.length-i+(r.length-i)}function K4(){let e=new Map;function t(t){let n=z4(t);if(n===``)return;let r=B4(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=z4(t),r=B4(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=V4(z4(n)),o=[],s=[];for(let e of i)U4(a,e)?o.push(e):s.push(e);return o.length>0?(e=>{let t=e[0],n=W4(a,t);for(let r=1;r<e.length;r++){let i=e[r],o=W4(a,i);(o<n||o===n&&i<t)&&(t=i,n=o)}return t})(o):(e=>{let t=e[0],n=G4(a,V4(t));for(let r=1;r<e.length;r++){let i=e[r],o=G4(a,V4(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 q4(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 J4(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 Y4(e){try{return process.kill(e,0),!0}catch(e){return!!(e&&typeof e==`object`&&`code`in e&&e.code===`EPERM`)}}function X4(e){return!(typeof e!=`number`||!Number.isInteger(e)||e<2||e>2147483647)}function Z4(){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 Q4=Z4(),$4=1;var e3=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 t3(e,t){return _(e,`${t}.lock`)}const n3=new Map;function r3(e){n3.set(e,(n3.get(e)??0)+1)}function i3(e){let t=n3.get(e);return t===void 0||t<=1?(n3.delete(e),!0):(n3.set(e,t-1),!1)}function a3(e,t){try{let n=JSON.parse(d(e,`utf-8`));return n&&typeof n==`object`&&X4(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 o3(e){let{lockName:t,lockDir:n,metadata:r}=e,i=`[${t}-lock]`;l(n,{recursive:!0});let a=t3(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??Q4},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 r3(a),s3({lockName:t,lockDir:n,lockPath:a})}catch(e){if(e.code!==`EEXIST`)throw e}let e=a3(a,i);if(e){let r=e.hostname===y();if(r&&e.pid===process.pid)return p(a,d,{encoding:`utf-8`,mode:384}),r3(a),s3({lockName:t,lockDir:n,lockPath:a});if(r&&Y4(e.pid))throw new e3(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 s3(e){let{lockName:t,lockDir:n,lockPath:r}=e;return{lockPath:r,release:()=>d3({lockName:t,lockDir:n}),updatePort:e=>c3({lockName:t,lockDir:n,port:e})}}function c3(e){let{lockName:t,lockDir:n,port:r}=e,i=`[${t}-lock]`,a=t3(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`||!X4(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 l3(e){let{lockName:t,lockDir:n}=e,r=t3(n,t);if(!c(r))return null;let i;try{let e=JSON.parse(d(r,`utf-8`));if(!e||typeof e!=`object`||!X4(e.pid))return null;i=e}catch{return null}if(i.hostname!==y())return null;if(!Y4(i.pid)){try{f(r)}catch{}return null}return i}function u3(e){let{lockName:t,lockDir:n}=e,r=t3(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(!X4(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(!Y4(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 d3(e){let{lockName:t,lockDir:n}=e,r=`[${t}-lock]`,i=t3(n,t);if(i3(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 f3=class extends e3{constructor(e,t){super(e,t,`server`),this.name=`ServerLockCollisionError`}};function p3(e,t){try{return o3({lockName:`server`,lockDir:e,metadata:t}).lockPath}catch(e){throw e instanceof e3&&e.lockName===`server`?new f3(e.existing,e.lockPath):e}}function m3(e,t){c3({lockName:`server`,lockDir:e,port:t})}function h3(e){return l3({lockName:`server`,lockDir:e})}function g3(e){d3({lockName:`server`,lockDir:e})}export{eK as $,j as $i,m2 as $n,hG as $r,d0 as $t,f1 as A,pt as Aa,Uc as Ai,J0 as An,BG as Ar,_1 as At,M2 as B,pl as Bi,x4 as Bn,y$ as Br,qK as Bt,n1 as C,fn as Ca,ZW as Ci,P1 as Cn,YG as Cr,N1 as Ct,t1 as D,Tt as Da,Cl as Di,Y0 as Dn,ZZ as Dr,c2 as Dt,h1 as E,Lt as Ea,I as Ei,x2 as En,C4 as Er,s2 as Et,lG as F,wl as Fi,bJ as Fn,S4 as Fr,MK as Ft,D2 as G,Kc as Gi,W0 as Gn,k4 as Gr,$1 as Gt,A2 as H,_l as Hi,YJ as Hn,L$ as Hr,e0 as Ht,vG as I,yl as Ii,yJ as In,d4 as Ir,e2 as It,ZG as J,cc as Ji,V0 as Jn,sJ as Jr,X1 as Jt,E2 as K,qc as Ki,G0 as Kn,DJ as Kr,JJ as Kt,j2 as L,Jc as Li,SJ as Ln,q4 as Lr,n2 as Lt,T1 as M,Bc as Mi,BJ as Mn,QW as Mr,L1 as Mt,w1 as N,zc as Ni,pJ as Nn,j4 as Nr,R1 as Nt,p1 as O,O as Oa,Wc as Oi,X0 as On,G2 as Or,D1 as Ot,IJ as P,Tl as Pi,hJ as Pn,KG as Pr,H1 as Pt,QG as Q,M as Qi,r2 as Qn,JK as Qr,p0 as Qt,F2 as R,tl as Ri,wJ as Rn,rJ as Rr,m0 as Rt,a0 as S,un as Sa,oJ as Si,XG as Sn,L4 as Sr,OK as St,r1 as T,on as Ta,Df as Ti,_2 as Tn,K4 as Tr,o2 as Tt,T2 as U,nl as Ui,G1 as Un,qY as Ur,Y1 as Ut,N2 as V,ul as Vi,h0 as Vn,U$ as Vr,A1 as Vt,O2 as W,$c as Wi,q0 as Wn,Yq as Wr,Q1 as Wt,nK as X,Bs as Xi,U0 as Xn,fK as Xr,J1 as Xt,JG as Y,P as Yi,H0 as Yn,PJ as Yr,K1 as Yt,tK as Z,Hs as Zi,a2 as Zn,TJ as Zr,b$ as Zt,E4 as _,Wa as _a,UW as _i,g4 as _n,MW as _r,S1 as _t,o3 as a,A as aa,pG as ai,qG as an,d2 as ar,x0 as at,u1 as b,vr as ba,F$ as bi,mK as bn,NJ as br,w0 as bt,X4 as c,Mc as ca,$$ as ci,VJ as cn,c0 as cr,b0 as ct,u3 as d,Zs as da,c4 as di,A0 as dn,P0 as dr,vK as dt,kc as ea,RG as ei,u0 as en,u2 as er,$G as et,h3 as f,Ws as fa,JW as fi,B1 as fn,lK as fr,pK as ft,m3 as g,fa as ga,dG as gi,AK as gn,NW as gr,M0 as gt,c3 as h,Vo as ha,aJ as hi,jK as hn,z1 as hr,j0 as ht,f3 as i,Ys as ia,Q$ as ii,_K as in,p2 as ir,y1 as it,HJ as j,ft as ja,Vc as ji,b2 as jn,zG as jr,zW as jt,e1 as k,D as ka,Hc as ki,$0 as kn,U2 as kr,g1 as kt,t3 as l,rc as la,R4 as li,GJ as ln,o0 as lr,NK as lt,g3 as m,Uo as ma,$q as mi,I0 as mn,KJ as mr,W1 as mt,Q4 as n,tc as na,WW as ni,V1 as nn,g2 as nr,zJ as nt,p3 as o,N as oa,tG as oi,D0 as on,l0 as or,S0 as ot,d3 as p,ys as pa,GG as pi,F0 as pn,qJ as pr,oK as pt,w2 as q,Fs as qi,K0 as qn,VW as qr,Z1 as qt,$4 as r,F as ra,gK as ri,hK as rn,f2 as rr,v1 as rt,Y4 as s,lc as sa,fG as si,T0 as sn,s0 as sr,y0 as st,e3 as t,$s as ta,qW as ti,dK as tn,h2 as tr,LJ as tt,l3 as u,k as ua,M4 as ui,k0 as un,N0 as ur,uK as ut,sK as v,Ga as va,J4 as vi,_4 as vn,oG as vr,x1 as vt,m1 as w,mn as wa,Ly as wi,F1 as wn,D4 as wr,v0 as wt,i0 as x,cn as xa,GW as xi,iK as xn,I4 as xr,cK as xt,kK as y,ai as ya,cG as yi,y4 as yn,WJ as yr,C0 as yt,P2 as z,Sl as zi,C2 as zn,sG as zr,aK as zt};
|
|
447
|
-
//# sourceMappingURL=server-lock-BpjJj3OD-
|
|
447
|
+
//# sourceMappingURL=server-lock-BpjJj3OD-lsTSrbso.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./server-lock-BpjJj3OD-lsTSrbso.mjs";export{e as updateServerLockPort};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-
|
|
1
|
+
import{s as e}from"./chunk-C94x7I9S.mjs";import{t}from"./esm-BLMtE3s6.mjs";import{c as n,l as r,s as i}from"./server-lock-BpjJj3OD-lsTSrbso.mjs";import"./gh-detect-CEob6rSE.mjs";import{Ur as a,vn as o}from"./dist-DrTAfRJI.mjs";import{g as s,h as c}from"./init-qn36c3HB.mjs";import{n as l,o as u}from"./write-project-skill-Dj8OKpHt.mjs";import"./loader-An2Ns2eZ.mjs";import{c as d}from"./colors-CBY1ibtz.mjs";import"./preview-DKNJ3xmp.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(d(),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=l(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=u[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-mVEjFVvA.mjs.map
|