flavor-code 1.2.14 → 1.2.15
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/README.md +8 -3
- package/README.zh-CN.md +8 -3
- package/dist/agent/planner.d.ts +2 -0
- package/dist/{app-UJAGMKD5.js → app-3KW2FTVJ.js} +1 -1
- package/dist/{chunk-4YXDGGIC.js → chunk-5TG3E2EJ.js} +561 -74
- package/dist/{chunk-KL6TR2KG.js → chunk-BKARQJQZ.js} +1 -1
- package/dist/cli.js +78 -16
- package/dist/desktop/main.js +875 -328
- package/dist/desktop-renderer/assets/{index-CcD0D6x0.js → index-BCJjMvbX.js} +1 -1
- package/dist/desktop-renderer/index.html +1 -1
- package/dist/evolve/store.d.ts +26 -0
- package/dist/git/insights.d.ts +52 -0
- package/dist/git/service.d.ts +43 -0
- package/dist/git/tools.d.ts +9 -0
- package/dist/sdk/index.js +2 -2
- package/dist/session/store.d.ts +1 -0
- package/dist/ui/commands.d.ts +8 -2
- package/dist/ui/session.d.ts +2 -0
- package/package.json +1 -1
|
@@ -132,7 +132,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
132
132
|
|
|
133
133
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Bn,s=!En.jitless,c=s&&Vn.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?aa([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ca(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=>!nr(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=>or(e,r,Dn())))}),t)}var la=F(`$ZodUnion`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),I(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),I(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),I(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=>Mn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ca(t,r,e,i)):ca(o,r,e,i)}}),ua=F(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,la.init(e,t);let n=e._zod.parse;I(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=An(()=>{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(!Bn(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||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),da=F(`$ZodIntersection`,(e,t)=>{R.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])=>pa(e,t,n)):pa(e,i,a)}});function fa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Hn(e)&&Hn(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=fa(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=fa(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 pa(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}),nr(e))return e;let o=fa(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ma=F(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Hn(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 c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>or(e,r,Dn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...ir(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...ir(c,u.issues)),n.value[l]=u.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__`||!Object.prototype.propertyIsEnumerable.call(i,o))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`&&ti.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=>or(e,r,Dn())),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(...ir(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ir(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ha=F(`$ZodEnum`,(e,t)=>{R.init(e,t);let n=On(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Wn.has(typeof e)).map(e=>typeof e==`string`?Gn(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}}),ga=F(`$ZodLiteral`,(e,t)=>{if(R.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`?Gn(e):e?Gn(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}}),_a=F(`$ZodTransform`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(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.fallback=!0,n));if(i instanceof Promise)throw new wn;return n.value=i,n.fallback=!0,n}});function va(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ya=F(`$ZodOptional`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,I(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>va(e,r)):va(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ba=F(`$ZodExactOptional`,(e,t)=>{ya.init(e,t),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xa=F(`$ZodNullable`,(e,t)=>{R.init(e,t),I(e._zod,`optin`,()=>t.innerType._zod.optin),I(e._zod,`optout`,()=>t.innerType._zod.optout),I(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mn(e.source)}|null)$`):void 0}),I(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)}),Sa=F(`$ZodDefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(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=>Ca(e,t)):Ca(r,t)}});function Ca(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wa=F(`$ZodPrefault`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(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))}),Ta=F(`$ZodNonOptional`,(e,t)=>{R.init(e,t),I(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=>Ea(t,e)):Ea(i,e)}});function Ea(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Da=F(`$ZodCatch`,(e,t)=>{R.init(e,t),e._zod.optin=`optional`,I(e._zod,`optout`,()=>t.innerType._zod.optout),I(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=>or(e,n,Dn()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>or(e,n,Dn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Oa=F(`$ZodPipe`,(e,t)=>{R.init(e,t),I(e._zod,`values`,()=>t.in._zod.values),I(e._zod,`optin`,()=>t.in._zod.optin),I(e._zod,`optout`,()=>t.out._zod.optout),I(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=>ka(e,t.in,n)):ka(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ka(e,t.out,n)):ka(r,t.out,n)}});function ka(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Aa=F(`$ZodPreprocess`,(e,t)=>{Oa.init(e,t)}),ja=F(`$ZodReadonly`,(e,t)=>{R.init(e,t),I(e._zod,`propValues`,()=>t.innerType._zod.propValues),I(e._zod,`values`,()=>t.innerType._zod.values),I(e._zod,`optin`,()=>t.innerType?._zod?.optin),I(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(Ma):Ma(r)}});function Ma(e){return e.value=Object.freeze(e.value),e}var Na=F(`$ZodCustom`,(e,t)=>{ai.init(e,t),R.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=>Pa(t,n,r,e));Pa(i,n,r,e)}});function Pa(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(cr(e))}}var Fa,Ia=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 La(){return new Ia}(Fa=globalThis).__zod_globalRegistry??(Fa.__zod_globalRegistry=La());var Ra=globalThis.__zod_globalRegistry;function za(e,t){return new e({type:`string`,...L(t)})}function Ba(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function Va(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function Ua(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function Wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function Ga(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function Ka(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function qa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Ja(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Ya(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function Xa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Za(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Qa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function $a(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function eo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function to(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function no(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function ro(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function io(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function ao(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function oo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function so(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function co(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function lo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function uo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function fo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function V(e,t){return new e({type:`number`,checks:[],...L(t)})}function po(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function mo(e,t){return new e({type:`boolean`,...L(t)})}function ho(e){return new e({type:`unknown`})}function go(e,t){return new e({type:`never`,...L(t)})}function _o(e,t){return new si({check:`less_than`,...L(t),value:e,inclusive:!1})}function vo(e,t){return new si({check:`less_than`,...L(t),value:e,inclusive:!0})}function yo(e,t){return new ci({check:`greater_than`,...L(t),value:e,inclusive:!1})}function bo(e,t){return new ci({check:`greater_than`,...L(t),value:e,inclusive:!0})}function xo(e,t){return new li({check:`multiple_of`,...L(t),value:e})}function So(e,t){return new di({check:`max_length`,...L(t),maximum:e})}function Co(e,t){return new fi({check:`min_length`,...L(t),minimum:e})}function wo(e,t){return new pi({check:`length_equals`,...L(t),length:e})}function To(e,t){return new hi({check:`string_format`,format:`regex`,...L(t),pattern:e})}function Eo(e){return new gi({check:`string_format`,format:`lowercase`,...L(e)})}function Do(e){return new _i({check:`string_format`,format:`uppercase`,...L(e)})}function Oo(e,t){return new vi({check:`string_format`,format:`includes`,...L(t),includes:e})}function ko(e,t){return new yi({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function Ao(e,t){return new bi({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function jo(e){return new xi({check:`overwrite`,tx:e})}function Mo(e){return jo(t=>t.normalize(e))}function No(){return jo(e=>e.trim())}function Po(){return jo(e=>e.toLowerCase())}function Fo(){return jo(e=>e.toUpperCase())}function Io(){return jo(e=>Rn(e))}function Lo(e,t,n){return new e({type:`array`,element:t,...L(n)})}function Ro(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function zo(e,t){let n=Bo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(cr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(cr(r))}},e(t.value,t)),t);return n}function Bo(e,t){let n=new ai({check:`custom`,...L(t)});return n._zod.check=e,n}function Vo(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??Ra,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 Ho(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,Ho(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`&&Go(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Uo(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>
|
|
134
134
|
|
|
135
|
-
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 Wo(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Go(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 Go(r.element,n);if(r.type===`set`)return Go(r.valueType,n);if(r.type===`lazy`)return Go(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 Go(r.innerType,n);if(r.type===`intersection`)return Go(r.left,n)||Go(r.right,n);if(r.type===`record`||r.type===`map`)return Go(r.keyType,n)||Go(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Go(r.in,n)||Go(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Go(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Go(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Go(e,n))return!0;return!!(r.rest&&Go(r.rest,n))}return!1}var Ko=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Ho(e,r),Uo(r,e),Wo(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Ho(e,o),Uo(o,e),Wo(o,e)},Jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yo=(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=Jo[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}))])}},Xo=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zo=(e,t,n,r)=>{n.type=`boolean`},Qo=(e,t,n,r)=>{n.not={}},$o=(e,t,n,r)=>{let i=e._zod.def,a=On(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},es=(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},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rs=(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=Ho(a.element,t,{...r,path:[...r.path,`items`]})},is=(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]=Ho(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=Ho(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},as=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ho(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},os=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ho(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]]},ss=(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=Ho(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=Ho(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ho(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)}},cs=(e,t,n,r)=>{let i=e._zod.def,a=Ho(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`}]},ls=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},us=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ds=(e,t,n,r)=>{let i=e._zod.def;Ho(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)))},fs=(e,t,n,r)=>{let i=e._zod.def;Ho(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},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ho(o,t,r);let s=t.seen.get(e);s.ref=o},ms=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gs=F(`ZodISODateTime`,(e,t)=>{Fi.init(e,t),Hs.init(e,t)});function _s(e){return co(gs,e)}var vs=F(`ZodISODate`,(e,t)=>{Ii.init(e,t),Hs.init(e,t)});function ys(e){return lo(vs,e)}var bs=F(`ZodISOTime`,(e,t)=>{Li.init(e,t),Hs.init(e,t)});function xs(e){return uo(bs,e)}var Ss=F(`ZodISODuration`,(e,t)=>{Ri.init(e,t),Hs.init(e,t)});function Cs(e){return fo(Ss,e)}var ws=F(`ZodError`,(e,t)=>{ur.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pr(e,t)},flatten:{value:t=>fr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ts=mr(ws),Es=hr(ws),Ds=gr(ws),Os=vr(ws),ks=br(ws),As=xr(ws),js=Sr(ws),Ms=Cr(ws),Ns=wr(ws),Ps=Tr(ws),Fs=Er(ws),Is=Dr(ws),Ls=new WeakMap;function Rs(e,t,n){let r=Object.getPrototypeOf(e),i=Ls.get(r);if(i||(i=new Set,Ls.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zs=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qo(e,`input`),output:qo(e,`output`)}}),e.toJSONSchema=Ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ts(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ds(e,t,n),e.parseAsync=async(t,n)=>Es(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ks(e,t,n),e.decode=(t,n)=>As(e,t,n),e.encodeAsync=async(t,n)=>js(e,t,n),e.decodeAsync=async(t,n)=>Ms(e,t,n),e.safeEncode=(t,n)=>Ns(e,t,n),e.safeDecode=(t,n)=>Ps(e,t,n),e.safeEncodeAsync=async(t,n)=>Fs(e,t,n),e.safeDecodeAsync=async(t,n)=>Is(e,t,n),Rs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(In(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Kn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(jo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return yc(this)},or(e){return Sc([this,e])},and(e){return Ec(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return Ra.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ra.get(this);let t=this.clone();return Ra.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ra.get(e)?.description},configurable:!0}),e)),Bs=F(`_ZodString`,(e,t)=>{wi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rs(e,`_ZodString`,{regex(...e){return this.check(To(...e))},includes(...e){return this.check(Oo(...e))},startsWith(...e){return this.check(ko(...e))},endsWith(...e){return this.check(Ao(...e))},min(...e){return this.check(Co(...e))},max(...e){return this.check(So(...e))},length(...e){return this.check(wo(...e))},nonempty(...e){return this.check(Co(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Do(e))},trim(){return this.check(No())},normalize(...e){return this.check(Mo(...e))},toLowerCase(){return this.check(Po())},toUpperCase(){return this.check(Fo())},slugify(){return this.check(Io())}})}),Vs=F(`ZodString`,(e,t)=>{wi.init(e,t),Bs.init(e,t),e.email=t=>e.check(Ba(Us,t)),e.url=t=>e.check(Ka(qs,t)),e.jwt=t=>e.check(so(cc,t)),e.emoji=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Va(Ws,t)),e.uuid=t=>e.check(Ha(Gs,t)),e.uuidv4=t=>e.check(Ua(Gs,t)),e.uuidv6=t=>e.check(Wa(Gs,t)),e.uuidv7=t=>e.check(Ga(Gs,t)),e.nanoid=t=>e.check(Ja(Ys,t)),e.guid=t=>e.check(Va(Ws,t)),e.cuid=t=>e.check(Ya(Xs,t)),e.cuid2=t=>e.check(Xa(Zs,t)),e.ulid=t=>e.check(Za(Qs,t)),e.base64=t=>e.check(io(ac,t)),e.base64url=t=>e.check(ao(oc,t)),e.xid=t=>e.check(Qa($s,t)),e.ksuid=t=>e.check($a(ec,t)),e.ipv4=t=>e.check(eo(tc,t)),e.ipv6=t=>e.check(to(nc,t)),e.cidrv4=t=>e.check(no(rc,t)),e.cidrv6=t=>e.check(ro(ic,t)),e.e164=t=>e.check(oo(sc,t)),e.datetime=t=>e.check(_s(t)),e.date=t=>e.check(ys(t)),e.time=t=>e.check(xs(t)),e.duration=t=>e.check(Cs(t))});function H(e){return za(Vs,e)}var Hs=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Bs.init(e,t)}),Us=F(`ZodEmail`,(e,t)=>{Di.init(e,t),Hs.init(e,t)}),Ws=F(`ZodGUID`,(e,t)=>{Ti.init(e,t),Hs.init(e,t)}),Gs=F(`ZodUUID`,(e,t)=>{Ei.init(e,t),Hs.init(e,t)});function Ks(e){return Ha(Gs,e)}var qs=F(`ZodURL`,(e,t)=>{Oi.init(e,t),Hs.init(e,t)}),Js=F(`ZodEmoji`,(e,t)=>{ki.init(e,t),Hs.init(e,t)}),Ys=F(`ZodNanoID`,(e,t)=>{Ai.init(e,t),Hs.init(e,t)}),Xs=F(`ZodCUID`,(e,t)=>{ji.init(e,t),Hs.init(e,t)}),Zs=F(`ZodCUID2`,(e,t)=>{Mi.init(e,t),Hs.init(e,t)}),Qs=F(`ZodULID`,(e,t)=>{Ni.init(e,t),Hs.init(e,t)}),$s=F(`ZodXID`,(e,t)=>{B.init(e,t),Hs.init(e,t)}),ec=F(`ZodKSUID`,(e,t)=>{Pi.init(e,t),Hs.init(e,t)}),tc=F(`ZodIPv4`,(e,t)=>{zi.init(e,t),Hs.init(e,t)}),nc=F(`ZodIPv6`,(e,t)=>{Bi.init(e,t),Hs.init(e,t)}),rc=F(`ZodCIDRv4`,(e,t)=>{Vi.init(e,t),Hs.init(e,t)}),ic=F(`ZodCIDRv6`,(e,t)=>{Hi.init(e,t),Hs.init(e,t)}),ac=F(`ZodBase64`,(e,t)=>{Wi.init(e,t),Hs.init(e,t)}),oc=F(`ZodBase64URL`,(e,t)=>{Ki.init(e,t),Hs.init(e,t)}),sc=F(`ZodE164`,(e,t)=>{qi.init(e,t),Hs.init(e,t)}),cc=F(`ZodJWT`,(e,t)=>{Yi.init(e,t),Hs.init(e,t)}),lc=F(`ZodNumber`,(e,t)=>{Xi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),Rs(e,`ZodNumber`,{gt(e,t){return this.check(yo(e,t))},gte(e,t){return this.check(bo(e,t))},min(e,t){return this.check(bo(e,t))},lt(e,t){return this.check(_o(e,t))},lte(e,t){return this.check(vo(e,t))},max(e,t){return this.check(vo(e,t))},int(e){return this.check(dc(e))},safe(e){return this.check(dc(e))},positive(e){return this.check(yo(0,e))},nonnegative(e){return this.check(bo(0,e))},negative(e){return this.check(_o(0,e))},nonpositive(e){return this.check(vo(0,e))},multipleOf(e,t){return this.check(xo(e,t))},step(e,t){return this.check(xo(e,t))},finite(){return this}});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 U(e){return V(lc,e)}var uc=F(`ZodNumberFormat`,(e,t)=>{Zi.init(e,t),lc.init(e,t)});function dc(e){return po(uc,e)}var fc=F(`ZodBoolean`,(e,t)=>{Qi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function pc(e){return mo(fc,e)}var mc=F(`ZodUnknown`,(e,t)=>{$i.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hc(){return ho(mc)}var gc=F(`ZodNever`,(e,t)=>{ea.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r)});function _c(e){return go(gc,e)}var vc=F(`ZodArray`,(e,t)=>{na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.element=t.element,Rs(e,`ZodArray`,{min(e,t){return this.check(Co(e,t))},nonempty(e){return this.check(Co(1,e))},max(e,t){return this.check(So(e,t))},length(e,t){return this.check(wo(e,t))},unwrap(){return this.element}})});function yc(e,t){return Lo(vc,e,t)}var bc=F(`ZodObject`,(e,t)=>{sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),I(e,`shape`,()=>t.shape),Rs(e,`ZodObject`,{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:_c()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Zn(this,e)},safeExtend(e){return Qn(this,e)},merge(e){return $n(this,e)},pick(e){return Yn(this,e)},omit(e){return Xn(this,e)},partial(...e){return er(Pc,this,e[0])},required(...e){return tr(Wc,this,e[0])}})});function W(e,t){return new bc({type:`object`,shape:e??{},...L(t)})}var xc=F(`ZodUnion`,(e,t)=>{la.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...L(t)})}var Cc=F(`ZodDiscriminatedUnion`,(e,t)=>{xc.init(e,t),ua.init(e,t)});function wc(e,t,n){return new Cc({type:`union`,options:t,discriminator:e,...L(n)})}var Tc=F(`ZodIntersection`,(e,t)=>{da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Ec(e,t){return new Tc({type:`intersection`,left:e,right:t})}var Dc=F(`ZodRecord`,(e,t)=>{ma.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oc(e,t,n){return!t||!t._zod?new Dc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Dc({type:`record`,keyType:e,valueType:t,...L(n)})}var kc=F(`ZodEnum`,(e,t)=>{ha.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(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 kc({...t,checks:[],...L(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 kc({...t,checks:[],...L(r),entries:i})}});function Ac(e,t){return new kc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var jc=F(`ZodLiteral`,(e,t)=>{ga.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(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 G(e,t){return new jc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Mc=F(`ZodTransform`,(e,t)=>{_a.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cr(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(cr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=F(`ZodOptional`,(e,t)=>{ya.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=F(`ZodExactOptional`,(e,t)=>{ba.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=F(`ZodNullable`,(e,t)=>{xa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=F(`ZodDefault`,(e,t)=>{Sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Hc=F(`ZodPrefault`,(e,t)=>{wa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Wc=F(`ZodNonOptional`,(e,t)=>{Ta.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...L(t)})}var Kc=F(`ZodCatch`,(e,t)=>{Da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=F(`ZodPipe`,(e,t)=>{Oa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=F(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),Aa.init(e,t)}),Zc=F(`ZodReadonly`,(e,t)=>{ja.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=F(`ZodCustom`,(e,t)=>{Na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)});function el(e,t={}){return Ro($c,e,t)}function tl(e,t){return zo(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,Ac(rl).default(`default`)),ol=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:yc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),claudeClient:pc().optional(),apiType:Ac([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),sl={disabled:pc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},cl=Sc([W({command:H().min(1),args:yc(H()).default([]),env:Oc(H(),H()).default({}),cwd:H().min(1).optional(),...sl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Oc(H(),H()).default({}),...sl}).strict()]),ll=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:pc().default(!1),providers:Oc(H(),ol).default({}),mcpServers:Oc(ll,cl).default({}),skills:W({disabled:yc(ul).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:pc().default(!0),autoExtract:pc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:U().int().min(1).max(10).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:W({mode:Ac([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:pc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:pc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(80),subagent:U().int().min(10).max(200).default(40),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(20)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(20),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(13e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:pc().default(!1),webhookUrl:H().url().optional()}).prefault({}),evolve:W({promptTop:U().int().min(1).max(10).default(3),minRepeats:U().int().min(2).max(100).default(2),testCommand:H().trim().min(1).default(`npm test`),testTimeoutMs:U().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=G(1),K=Ks(),bl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=H().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=W({version:yl,id:K,alias:xl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:_s(),lastSeenAt:_s()}).strict();yc(El).max(16),W({version:yl,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict();var Dl=W({version:yl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Ac([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=W({version:yl,type:G(`delivery-receipt`),messageId:K,status:Ac([`delivered`,`duplicate`,`rejected`]),recipientIds:yc(K).max(16),error:Cl.optional()}).strict(),kl=W({palId:K,required:pc()}).strict(),Al=yc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=W({id:H().min(1).max(128),assigneeId:K,description:wl,dependsOn:yc(H().min(1).max(128)).max(32)}).strict(),Ml=W({version:yl,coWorkId:K,epoch:U().int().positive(),goal:wl,participants:yc(kl).min(1).max(16),tasks:yc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=Ac([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=W({passed:pc(),evidence:Tl}).strict(),Fl=W({participantId:K,passed:pc(),detail:Tl.optional()}).strict(),Il=W({version:yl,coWorkId:K,epoch:U().int().positive(),phase:Nl,goal:wl,participants:yc(kl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:yc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:yc(K).max(16),readyParticipantIds:yc(K).max(16),completedParticipantIds:yc(K).max(16),completionAssertions:yc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),Ll={version:yl,requestId:K};wc(`type`,[W({...Ll,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),W({...Ll,type:G(`heartbeat`)}).strict(),W({...Ll,type:G(`list`)}).strict(),W({...Ll,type:G(`disconnect`)}).strict(),W({...Ll,type:G(`chat`),messageId:K,target:Sl,message:wl}).strict(),W({...Ll,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict(),W({...Ll,type:G(`cowork-propose`),coWorkId:K,goal:wl,participants:Al}).strict(),W({...Ll,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Ll,type:G(`cowork-plan`),plan:Ml}).strict(),W({...Ll,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),detail:Tl.optional()}).strict(),W({...Ll,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),evidence:Tl}).strict(),W({...Ll,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Ll,type:G(`cowork-cancel`),coWorkId:K,reason:wl}).strict()]);var q=W({version:yl,type:G(`ok`),requestId:K,data:hc()}).strict(),Rl=W({version:yl,type:G(`error`),requestId:K,code:Ac([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),J=Sc([W({version:yl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:wl}).strict(),Dl,Ol,W({version:yl,type:G(`cowork-event`),action:Ac([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);wc(`type`,[q,Rl,W({version:yl,type:G(`event`),event:J}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Y=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.evolve.mcp.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work`.split(`.`),X={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`},zl={name:``,description:``,body:`# Instructions
|
|
135
|
+
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 Wo(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.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Go(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 Go(r.element,n);if(r.type===`set`)return Go(r.valueType,n);if(r.type===`lazy`)return Go(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 Go(r.innerType,n);if(r.type===`intersection`)return Go(r.left,n)||Go(r.right,n);if(r.type===`record`||r.type===`map`)return Go(r.keyType,n)||Go(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Go(r.in,n)||Go(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Go(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Go(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Go(e,n))return!0;return!!(r.rest&&Go(r.rest,n))}return!1}var Ko=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Ho(e,r),Uo(r,e),Wo(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Ho(e,o),Uo(o,e),Wo(o,e)},Jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yo=(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=Jo[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}))])}},Xo=(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`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zo=(e,t,n,r)=>{n.type=`boolean`},Qo=(e,t,n,r)=>{n.not={}},$o=(e,t,n,r)=>{let i=e._zod.def,a=On(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},es=(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},ts=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},rs=(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=Ho(a.element,t,{...r,path:[...r.path,`items`]})},is=(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]=Ho(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=Ho(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},as=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ho(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},os=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ho(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]]},ss=(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=Ho(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=Ho(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ho(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)}},cs=(e,t,n,r)=>{let i=e._zod.def,a=Ho(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`}]},ls=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},us=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ds=(e,t,n,r)=>{let i=e._zod.def;Ho(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)))},fs=(e,t,n,r)=>{let i=e._zod.def;Ho(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},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ho(o,t,r);let s=t.seen.get(e);s.ref=o},ms=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gs=F(`ZodISODateTime`,(e,t)=>{Fi.init(e,t),Hs.init(e,t)});function _s(e){return co(gs,e)}var vs=F(`ZodISODate`,(e,t)=>{Ii.init(e,t),Hs.init(e,t)});function ys(e){return lo(vs,e)}var bs=F(`ZodISOTime`,(e,t)=>{Li.init(e,t),Hs.init(e,t)});function xs(e){return uo(bs,e)}var Ss=F(`ZodISODuration`,(e,t)=>{Ri.init(e,t),Hs.init(e,t)});function Cs(e){return fo(Ss,e)}var ws=F(`ZodError`,(e,t)=>{ur.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pr(e,t)},flatten:{value:t=>fr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ts=mr(ws),Es=hr(ws),Ds=gr(ws),Os=vr(ws),ks=br(ws),As=xr(ws),js=Sr(ws),Ms=Cr(ws),Ns=wr(ws),Ps=Tr(ws),Fs=Er(ws),Is=Dr(ws),Ls=new WeakMap;function Rs(e,t,n){let r=Object.getPrototypeOf(e),i=Ls.get(r);if(i||(i=new Set,Ls.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zs=F(`ZodType`,(e,t)=>(R.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qo(e,`input`),output:qo(e,`output`)}}),e.toJSONSchema=Ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ts(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ds(e,t,n),e.parseAsync=async(t,n)=>Es(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Os(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ks(e,t,n),e.decode=(t,n)=>As(e,t,n),e.encodeAsync=async(t,n)=>js(e,t,n),e.decodeAsync=async(t,n)=>Ms(e,t,n),e.safeEncode=(t,n)=>Ns(e,t,n),e.safeDecode=(t,n)=>Ps(e,t,n),e.safeEncodeAsync=async(t,n)=>Fs(e,t,n),e.safeDecodeAsync=async(t,n)=>Is(e,t,n),Rs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(In(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Kn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(el(e,t))},superRefine(e,t){return this.check(tl(e,t))},overwrite(e){return this.check(jo(e))},optional(){return Fc(this)},exactOptional(){return Lc(this)},nullable(){return zc(this)},nullish(){return Fc(zc(this))},nonoptional(e){return Gc(this,e)},array(){return yc(this)},or(e){return Sc([this,e])},and(e){return Ec(this,e)},transform(e){return Yc(this,Nc(e))},default(e){return Vc(this,e)},prefault(e){return Uc(this,e)},catch(e){return qc(this,e)},pipe(e){return Yc(this,e)},readonly(){return Qc(this)},describe(e){let t=this.clone();return Ra.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ra.get(this);let t=this.clone();return Ra.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Ra.get(e)?.description},configurable:!0}),e)),Bs=F(`_ZodString`,(e,t)=>{wi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rs(e,`_ZodString`,{regex(...e){return this.check(To(...e))},includes(...e){return this.check(Oo(...e))},startsWith(...e){return this.check(ko(...e))},endsWith(...e){return this.check(Ao(...e))},min(...e){return this.check(Co(...e))},max(...e){return this.check(So(...e))},length(...e){return this.check(wo(...e))},nonempty(...e){return this.check(Co(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Do(e))},trim(){return this.check(No())},normalize(...e){return this.check(Mo(...e))},toLowerCase(){return this.check(Po())},toUpperCase(){return this.check(Fo())},slugify(){return this.check(Io())}})}),Vs=F(`ZodString`,(e,t)=>{wi.init(e,t),Bs.init(e,t),e.email=t=>e.check(Ba(Us,t)),e.url=t=>e.check(Ka(qs,t)),e.jwt=t=>e.check(so(cc,t)),e.emoji=t=>e.check(qa(Js,t)),e.guid=t=>e.check(Va(Ws,t)),e.uuid=t=>e.check(Ha(Gs,t)),e.uuidv4=t=>e.check(Ua(Gs,t)),e.uuidv6=t=>e.check(Wa(Gs,t)),e.uuidv7=t=>e.check(Ga(Gs,t)),e.nanoid=t=>e.check(Ja(Ys,t)),e.guid=t=>e.check(Va(Ws,t)),e.cuid=t=>e.check(Ya(Xs,t)),e.cuid2=t=>e.check(Xa(Zs,t)),e.ulid=t=>e.check(Za(Qs,t)),e.base64=t=>e.check(io(ac,t)),e.base64url=t=>e.check(ao(oc,t)),e.xid=t=>e.check(Qa($s,t)),e.ksuid=t=>e.check($a(ec,t)),e.ipv4=t=>e.check(eo(tc,t)),e.ipv6=t=>e.check(to(nc,t)),e.cidrv4=t=>e.check(no(rc,t)),e.cidrv6=t=>e.check(ro(ic,t)),e.e164=t=>e.check(oo(sc,t)),e.datetime=t=>e.check(_s(t)),e.date=t=>e.check(ys(t)),e.time=t=>e.check(xs(t)),e.duration=t=>e.check(Cs(t))});function H(e){return za(Vs,e)}var Hs=F(`ZodStringFormat`,(e,t)=>{z.init(e,t),Bs.init(e,t)}),Us=F(`ZodEmail`,(e,t)=>{Di.init(e,t),Hs.init(e,t)}),Ws=F(`ZodGUID`,(e,t)=>{Ti.init(e,t),Hs.init(e,t)}),Gs=F(`ZodUUID`,(e,t)=>{Ei.init(e,t),Hs.init(e,t)});function Ks(e){return Ha(Gs,e)}var qs=F(`ZodURL`,(e,t)=>{Oi.init(e,t),Hs.init(e,t)}),Js=F(`ZodEmoji`,(e,t)=>{ki.init(e,t),Hs.init(e,t)}),Ys=F(`ZodNanoID`,(e,t)=>{Ai.init(e,t),Hs.init(e,t)}),Xs=F(`ZodCUID`,(e,t)=>{ji.init(e,t),Hs.init(e,t)}),Zs=F(`ZodCUID2`,(e,t)=>{Mi.init(e,t),Hs.init(e,t)}),Qs=F(`ZodULID`,(e,t)=>{Ni.init(e,t),Hs.init(e,t)}),$s=F(`ZodXID`,(e,t)=>{B.init(e,t),Hs.init(e,t)}),ec=F(`ZodKSUID`,(e,t)=>{Pi.init(e,t),Hs.init(e,t)}),tc=F(`ZodIPv4`,(e,t)=>{zi.init(e,t),Hs.init(e,t)}),nc=F(`ZodIPv6`,(e,t)=>{Bi.init(e,t),Hs.init(e,t)}),rc=F(`ZodCIDRv4`,(e,t)=>{Vi.init(e,t),Hs.init(e,t)}),ic=F(`ZodCIDRv6`,(e,t)=>{Hi.init(e,t),Hs.init(e,t)}),ac=F(`ZodBase64`,(e,t)=>{Wi.init(e,t),Hs.init(e,t)}),oc=F(`ZodBase64URL`,(e,t)=>{Ki.init(e,t),Hs.init(e,t)}),sc=F(`ZodE164`,(e,t)=>{qi.init(e,t),Hs.init(e,t)}),cc=F(`ZodJWT`,(e,t)=>{Yi.init(e,t),Hs.init(e,t)}),lc=F(`ZodNumber`,(e,t)=>{Xi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),Rs(e,`ZodNumber`,{gt(e,t){return this.check(yo(e,t))},gte(e,t){return this.check(bo(e,t))},min(e,t){return this.check(bo(e,t))},lt(e,t){return this.check(_o(e,t))},lte(e,t){return this.check(vo(e,t))},max(e,t){return this.check(vo(e,t))},int(e){return this.check(dc(e))},safe(e){return this.check(dc(e))},positive(e){return this.check(yo(0,e))},nonnegative(e){return this.check(bo(0,e))},negative(e){return this.check(_o(0,e))},nonpositive(e){return this.check(vo(0,e))},multipleOf(e,t){return this.check(xo(e,t))},step(e,t){return this.check(xo(e,t))},finite(){return this}});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 U(e){return V(lc,e)}var uc=F(`ZodNumberFormat`,(e,t)=>{Zi.init(e,t),lc.init(e,t)});function dc(e){return po(uc,e)}var fc=F(`ZodBoolean`,(e,t)=>{Qi.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function pc(e){return mo(fc,e)}var mc=F(`ZodUnknown`,(e,t)=>{$i.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function hc(){return ho(mc)}var gc=F(`ZodNever`,(e,t)=>{ea.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r)});function _c(e){return go(gc,e)}var vc=F(`ZodArray`,(e,t)=>{na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.element=t.element,Rs(e,`ZodArray`,{min(e,t){return this.check(Co(e,t))},nonempty(e){return this.check(Co(1,e))},max(e,t){return this.check(So(e,t))},length(e,t){return this.check(wo(e,t))},unwrap(){return this.element}})});function yc(e,t){return Lo(vc,e,t)}var bc=F(`ZodObject`,(e,t)=>{sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),I(e,`shape`,()=>t.shape),Rs(e,`ZodObject`,{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:_c()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Zn(this,e)},safeExtend(e){return Qn(this,e)},merge(e){return $n(this,e)},pick(e){return Yn(this,e)},omit(e){return Xn(this,e)},partial(...e){return er(Pc,this,e[0])},required(...e){return tr(Wc,this,e[0])}})});function W(e,t){return new bc({type:`object`,shape:e??{},...L(t)})}var xc=F(`ZodUnion`,(e,t)=>{la.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.options=t.options});function Sc(e,t){return new xc({type:`union`,options:e,...L(t)})}var Cc=F(`ZodDiscriminatedUnion`,(e,t)=>{xc.init(e,t),ua.init(e,t)});function wc(e,t,n){return new Cc({type:`union`,options:t,discriminator:e,...L(n)})}var Tc=F(`ZodIntersection`,(e,t)=>{da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r)});function Ec(e,t){return new Tc({type:`intersection`,left:e,right:t})}var Dc=F(`ZodRecord`,(e,t)=>{ma.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Oc(e,t,n){return!t||!t._zod?new Dc({type:`record`,keyType:H(),valueType:e,...L(t)}):new Dc({type:`record`,keyType:e,valueType:t,...L(n)})}var kc=F(`ZodEnum`,(e,t)=>{ha.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(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 kc({...t,checks:[],...L(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 kc({...t,checks:[],...L(r),entries:i})}});function Ac(e,t){return new kc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var jc=F(`ZodLiteral`,(e,t)=>{ga.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(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 G(e,t){return new jc({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var Mc=F(`ZodTransform`,(e,t)=>{_a.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cr(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(cr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Nc(e){return new Mc({type:`transform`,transform:e})}var Pc=F(`ZodOptional`,(e,t)=>{ya.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Pc({type:`optional`,innerType:e})}var Ic=F(`ZodExactOptional`,(e,t)=>{ba.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Ic({type:`optional`,innerType:e})}var Rc=F(`ZodNullable`,(e,t)=>{xa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`nullable`,innerType:e})}var Bc=F(`ZodDefault`,(e,t)=>{Sa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vc(e,t){return new Bc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Hc=F(`ZodPrefault`,(e,t)=>{wa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uc(e,t){return new Hc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Un(t)}})}var Wc=F(`ZodNonOptional`,(e,t)=>{Ta.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`nonoptional`,innerType:e,...L(t)})}var Kc=F(`ZodCatch`,(e,t)=>{Da.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qc(e,t){return new Kc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Jc=F(`ZodPipe`,(e,t)=>{Oa.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.in=t.in,e.out=t.out});function Yc(e,t){return new Jc({type:`pipe`,in:e,out:t})}var Xc=F(`ZodPreprocess`,(e,t)=>{Jc.init(e,t),Aa.init(e,t)}),Zc=F(`ZodReadonly`,(e,t)=>{ja.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`readonly`,innerType:e})}var $c=F(`ZodCustom`,(e,t)=>{Na.init(e,t),zs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)});function el(e,t={}){return Ro($c,e,t)}function tl(e,t){return zo(e,t)}function nl(e,t){return new Xc({type:`pipe`,in:Nc(e),out:t})}var rl=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function il(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var al=nl(il,Ac(rl).default(`default`)),ol=W({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:yc(H().min(1)).max(100).optional(),maxOutputTokens:U().int().positive().optional(),claudeClient:pc().optional(),apiType:Ac([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),sl={disabled:pc().default(!1),timeoutMs:U().int().min(100).max(30*6e4).default(6e4)},cl=Sc([W({command:H().min(1),args:yc(H()).default([]),env:Oc(H(),H()).default({}),cwd:H().min(1).optional(),...sl}).strict(),W({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:Oc(H(),H()).default({}),...sl}).strict()]),ll=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),ul=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);W({sleep:pc().default(!1),providers:Oc(H(),ol).default({}),mcpServers:Oc(ll,cl).default({}),skills:W({disabled:yc(ul).max(1e3).default([])}).prefault({}),agents:W({main:W({model:H()}).optional(),subagent:W({model:H()}).optional()}).optional(),maxSubagents:U().int().min(1).max(16).default(3),maxSessions:U().int().min(1).max(1e3).default(50),memory:W({enabled:pc().default(!0),autoExtract:pc().default(!0),autoExtractMinChars:U().int().min(200).max(1e5).default(200),scoreThreshold:U().int().min(0).max(12).default(9),autoStoreThreshold:U().int().min(0).max(12).default(11),ignoreStreakLimit:U().int().min(2).max(100).default(5),reviewAutoDismissSeconds:U().int().min(0).max(300).default(5),maxCandidatesPerTask:U().int().min(1).max(10).default(1),retrievalTopK:U().int().min(1).max(20).default(5),maxEntries:U().int().min(1).max(1e4).default(200),maxEntryChars:U().int().min(32).max(2e4).default(1e3),maxPromptChars:U().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:al,execution:W({mode:Ac([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:pc().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:U().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:W({showWarnings:pc().default(!1),evaluationTimeoutMs:U().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:W({main:U().int().min(10).max(500).default(80),subagent:U().int().min(10).max(200).default(40),softLimitFactor:U().min(.5).max(1).default(.8),extendBy:U().int().min(5).max(100).default(20)}).prefault({}),loop:W({maxCycles:U().int().positive().max(1e4).default(20),maxTokens:U().int().positive().max(2**53-1).default(5e5),isolation:G(`auto`).default(`auto`)}).prefault({}),context:W({windowTokens:U().int().positive().default(2e5),reservedOutputTokens:U().int().nonnegative().default(2e4),autoCompactBufferTokens:U().int().nonnegative().default(13e3),warningBufferTokens:U().int().nonnegative().default(2e4),blockingBufferTokens:U().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:U().int().nonnegative().default(5),recentTokens:U().int().nonnegative().default(1e4),recentTextMessages:U().int().nonnegative().default(5),maxRecentTokens:U().int().nonnegative().default(4e4),compactAtChars:U().int().positive().optional(),toolOutputChars:U().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:W({enabled:pc().default(!1),webhookUrl:H().url().optional()}).prefault({}),evolve:W({promptTop:U().int().min(1).max(10).default(3),minRepeats:U().int().min(2).max(100).default(2),testCommand:H().trim().min(1).default(`npm test`),testTimeoutMs:U().int().min(1e3).max(6e5).default(12e4)}).prefault({})});var dl=[`user`,`feedback`,`project`,`reference`],fl=32*1024,pl=64*1024,ml=1024,hl=24*1024,gl=56*1024,_l=4*1024,vl=12*1024,yl=G(1),K=Ks(),bl=H().trim().min(1).max(64).refine(e=>!/[\p{Cc}\uD800-\uDFFF]/u.test(e),`Identity must contain only printable non-control Unicode`),xl=bl,Sl=bl,Cl=H().refine(e=>Buffer.byteLength(e,`utf8`)<=fl,`Text must not exceed ${fl} UTF-8 bytes`),wl=Cl.refine(e=>e.length>0,`Text must not be empty`),Tl=H().trim().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=_l,`Completion evidence must not exceed ${_l} UTF-8 bytes`),El=W({version:yl,id:K,alias:xl,projectPath:H().min(1).refine(e=>Buffer.byteLength(e,`utf8`)<=ml,`Project path must not exceed ${ml} UTF-8 bytes`),connectedAt:_s(),lastSeenAt:_s()}).strict();yc(El).max(16),W({version:yl,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict();var Dl=W({version:yl,type:G(`task-event`),messageId:K,taskId:K,senderId:K,recipientId:K,status:Ac([`accepted`,`started`,`progress`,`completed`,`failed`,`cancelled`]),detail:Cl.optional()}).strict(),Ol=W({version:yl,type:G(`delivery-receipt`),messageId:K,status:Ac([`delivered`,`duplicate`,`rejected`]),recipientIds:yc(K).max(16),error:Cl.optional()}).strict(),kl=W({palId:K,required:pc()}).strict(),Al=yc(kl).min(2).max(16).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.entries()){let e=i.palId.toLowerCase();n.has(e)&&t.addIssue({code:`custom`,path:[r,`palId`],message:`Duplicate participant`}),n.add(e)}}),jl=W({id:H().min(1).max(128),assigneeId:K,description:wl,dependsOn:yc(H().min(1).max(128)).max(32)}).strict(),Ml=W({version:yl,coWorkId:K,epoch:U().int().positive(),goal:wl,participants:yc(kl).min(1).max(16),tasks:yc(jl).min(1).max(32)}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>24576&&t.addIssue({code:`custom`,message:`Encoded plan must not exceed ${hl} UTF-8 bytes`});let n=new Set;for(let[r,i]of e.participants.entries())n.has(i.palId)&&t.addIssue({code:`custom`,path:[`participants`,r,`palId`],message:`Duplicate participant`}),n.add(i.palId);let r=new Set;for(let[i,a]of e.tasks.entries())r.has(a.id)&&t.addIssue({code:`custom`,path:[`tasks`,i,`id`],message:`Duplicate task id`}),r.add(a.id),n.has(a.assigneeId)||t.addIssue({code:`custom`,path:[`tasks`,i,`assigneeId`],message:`Assignee is not a participant`});for(let[n,i]of e.tasks.entries())for(let e of i.dependsOn)(!r.has(e)||e===i.id)&&t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Invalid task dependency`});let i=new Map(e.tasks.map(e=>[e.id,e.dependsOn])),a=new Set,o=new Set,s=e=>{if(a.has(e))return!0;if(o.has(e))return!1;a.add(e);for(let t of i.get(e)??[])if(i.has(t)&&s(t))return!0;return a.delete(e),o.add(e),!1};for(let[n,r]of e.tasks.entries())if(s(r.id)){t.addIssue({code:`custom`,path:[`tasks`,n,`dependsOn`],message:`Task dependencies must be acyclic`});break}}),Nl=Ac([`proposed`,`planning`,`prepared`,`running`,`verifying`,`completed`,`failed`,`cancelled`]),Pl=W({passed:pc(),evidence:Tl}).strict(),Fl=W({participantId:K,passed:pc(),detail:Tl.optional()}).strict(),Il=W({version:yl,coWorkId:K,epoch:U().int().positive(),phase:Nl,goal:wl,participants:yc(kl).min(1).max(16),integrationOwnerId:K,acceptedParticipantIds:yc(K).max(16),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),plan:Ml.nullable(),planAcceptedParticipantIds:yc(K).max(16),readyParticipantIds:yc(K).max(16),completedParticipantIds:yc(K).max(16),completionAssertions:yc(Fl).max(16),integration:Pl.nullable()}).strict().superRefine((e,t)=>{Buffer.byteLength(JSON.stringify(e),`utf8`)>57344&&t.addIssue({code:`custom`,message:`Encoded snapshot must not exceed ${gl} UTF-8 bytes`});let n=new Set(e.participants.map(({palId:e})=>e));new Set(e.participants.filter(({required:e})=>e).map(({palId:e})=>e)).has(e.integrationOwnerId)||t.addIssue({code:`custom`,path:[`integrationOwnerId`],message:`Integration owner must be a required participant`});let r=new Set,i=0;for(let[a,o]of e.completionAssertions.entries())n.has(o.participantId)||t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Assertion owner must be a participant`}),r.has(o.participantId)&&t.addIssue({code:`custom`,path:[`completionAssertions`,a,`participantId`],message:`Duplicate completion assertion`}),r.add(o.participantId),i+=Buffer.byteLength(o.detail??``,`utf8`);i>12288&&t.addIssue({code:`custom`,path:[`completionAssertions`],message:`Completion assertions must not exceed ${vl} UTF-8 bytes in aggregate`})}),Ll={version:yl,requestId:K};wc(`type`,[W({...Ll,type:G(`register`),authToken:H().regex(/^[a-f0-9]{64}$/).optional(),presence:El}).strict(),W({...Ll,type:G(`heartbeat`)}).strict(),W({...Ll,type:G(`list`)}).strict(),W({...Ll,type:G(`disconnect`)}).strict(),W({...Ll,type:G(`chat`),messageId:K,target:Sl,message:wl}).strict(),W({...Ll,type:G(`task`),messageId:K,target:Sl,goal:wl}).strict(),W({...Ll,type:G(`cowork-propose`),coWorkId:K,goal:wl,participants:Al}).strict(),W({...Ll,type:G(`cowork-accept`),coWorkId:K,epoch:U().int().positive()}).strict(),W({...Ll,type:G(`cowork-plan`),plan:Ml}).strict(),W({...Ll,type:G(`cowork-plan-accept`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-ready`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/)}).strict(),W({...Ll,type:G(`cowork-complete`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),detail:Tl.optional()}).strict(),W({...Ll,type:G(`cowork-integration`),coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/),passed:pc(),evidence:Tl}).strict(),W({...Ll,type:G(`cowork-get`),coWorkId:K}).strict(),W({...Ll,type:G(`cowork-cancel`),coWorkId:K,reason:wl}).strict()]);var q=W({version:yl,type:G(`ok`),requestId:K,data:hc()}).strict(),Rl=W({version:yl,type:G(`error`),requestId:K,code:Ac([`invalid-request`,`authentication-failed`,`not-found`,`ambiguous-target`,`alias-conflict`,`invalid-transition`,`stale-epoch`,`duplicate`]),message:Cl}).strict(),J=Sc([W({version:yl,type:G(`chat-event`),messageId:K,senderId:K,recipientId:K,message:wl}).strict(),Dl,Ol,W({version:yl,type:G(`cowork-event`),action:Ac([`PROPOSE`,`PLAN`,`START`,`END`,`FAIL`,`CANCEL`]),actorId:K,coWorkId:K,epoch:U().int().positive(),planHash:H().regex(/^[a-f0-9]{64}$/).nullable(),snapshot:Il}).strict()]);wc(`type`,[q,Rl,W({version:yl,type:G(`event`),event:J}).strict()]),H().refine(e=>Buffer.byteLength(e,`utf8`)<=pl,`Control frame must not exceed ${pl} UTF-8 bytes`);var Y=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.evolve.mcp.commit.review.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork.pals.chat.co-work`.split(`.`),X={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,evolve:`Self-improvement loop: capture failures, suggest fixes, verify with tests`,commit:`Generate a commit message for staged changes and commit after confirmation`,review:`Review uncommitted changes for bugs and risks before committing`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`,pals:`List, rename, or inspect active Flavor pals`,chat:`Send a task to another Flavor pal`,"co-work":`Coordinate a shared goal with another Flavor pal`},zl={name:``,description:``,body:`# Instructions
|
|
136
136
|
|
|
137
137
|
Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function Bl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(zl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e.length===0?n:n.filter(t=>t.name.includes(e)||t.description.toLowerCase().includes(e))},[m,n]),b=n.filter(e=>e.enabled).length,x=c?o.name.trim().length>0||o.description.trim().length>0||o.body!==zl.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),ee=e=>t(e instanceof Error?e.message:String(e)),S=async e=>{let t=await window.flavorDesktop.listSkills();r(t);let n=e??i?.name??t[0]?.name;n!==void 0&&t.some(e=>e.name===n)?await C(n):c||(a(void 0),s(zl))},C=async e=>{try{let t=await window.flavorDesktop.getSkill(e);a(t),s({name:t.name,description:t.description,body:t.body,disableModelInvocation:t.disableModelInvocation}),l(!1),v(!1)}catch(e){ee(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await C(t[0].name))}).catch(ee).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let te=()=>{l(!0),a(void 0),s(zl),v(!1)},ne=async()=>{if(!f){p(!0);try{let e=c?await window.flavorDesktop.createSkill(o):await window.flavorDesktop.updateSkill(i.name,o);l(!1),a(e),s({name:e.name,description:e.description,body:e.body,disableModelInvocation:e.disableModelInvocation}),await S(e.name)}catch(e){ee(e)}finally{p(!1)}}},re=async(e,t)=>{r(n=>n.map(n=>n.name===e.name?{...n,enabled:t}:n)),i?.name===e.name&&a({...i,enabled:t});try{await window.flavorDesktop.setSkillEnabled(e.name,t)}catch(n){r(n=>n.map(n=>n.name===e.name?{...n,enabled:!t}:n)),i?.name===e.name&&a({...i,enabled:!t}),ee(n)}},ie=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(zl);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await C(e[0].name)}catch(e){ee(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,P.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目能力`}),(0,P.jsx)(`h1`,{children:`技能管理`})]})]}),(0,P.jsxs)(`div`,{className:`skill-health`,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,P.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,P.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,P.jsxs)(`button`,{className:`skill-create`,onClick:te,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,P.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,P.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,P.jsx)(`strong`,{children:`没有匹配的技能`}),(0,P.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,P.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`skill-select`,onClick:()=>void C(e.name),children:[(0,P.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.description})]})]}),(0,P.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void re(e,t.target.checked)}),(0,P.jsx)(`span`,{})]})]},e.name))]}),(0,P.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,P.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,P.jsx)(`span`,{children:`◇`}),(0,P.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,P.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,P.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,P.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,P.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,P.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,P.jsxs)(`div`,{className:`skill-form`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`名称 `,(0,P.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,P.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`描述 `,(0,P.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,P.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,P.jsxs)(`label`,{className:`skill-instructions`,children:[(0,P.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,P.jsx)(`small`,{children:`支持 Markdown`})]}),(0,P.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,P.jsxs)(`label`,{className:`manual-invocation`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:`仅允许手动调用`}),(0,P.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,P.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,P.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),S()},children:`取消`}),(c||i?.editable)&&(0,P.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void ne(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,P.jsx)(`div`,{className:`skill-delete-layer`,children:(0,P.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除项目技能`}),(0,P.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,P.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ie(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var Vl={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},Hl={enabled:!0,path:``,entries:[]},Ul={type:`project`,content:``};function Wl({onClose:e,onError:t}){let[n,r]=(0,_.useState)(Hl),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Ul),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`all`),[y,b]=(0,_.useState)(!1),x=e=>t(e instanceof Error?e.message:String(e)),ee=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,m,n.entries]),S=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),C=(e,t)=>{let n=e.entries.find(e=>e.id===t)??e.entries.find(e=>e.id===i?.id)??e.entries[0];a(n),s(n===void 0?Ul:{type:n.type,content:n.content})},te=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),C(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),C(t))}).catch(x).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ne=()=>{l(!0),a(void 0),s(Ul),b(!1)},re=e=>{l(!1),a(e),s({type:e.type,content:e.content}),b(!1)},ie=async()=>{if(!(f||o.content.trim().length===0)){p(!0);try{let e=c?await window.flavorDesktop.createMemory(o):await window.flavorDesktop.updateMemory(i.id,o);l(!1),await te(e.id)}catch(e){x(e)}finally{p(!1)}}},ae=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);b(!1),a(void 0),s(Ul),await te()}catch(e){x(e)}finally{p(!1)}}};return(0,P.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,P.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`memory-heading`,children:[(0,P.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`项目上下文`}),(0,P.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,P.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,P.jsx)(`i`,{}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:n.entries.length}),` 条已保存`]})]})]}),(0,P.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,P.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,P.jsxs)(`button`,{className:`memory-create`,onClick:ne,disabled:!n.enabled,children:[(0,P.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,P.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,P.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,P.jsx)(`span`,{children:`全部`}),(0,P.jsx)(`b`,{children:n.entries.length})]}),dl.map(e=>(0,P.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,P.jsx)(`span`,{children:Vl[e].label}),(0,P.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,P.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,P.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,P.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&ee.length===0&&(0,P.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,P.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,P.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),ee.map(e=>(0,P.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>re(e),children:[(0,P.jsx)(`span`,{className:`memory-card-tab`,children:Vl[e.type].label}),(0,P.jsx)(`strong`,{children:e.content}),(0,P.jsx)(`code`,{children:e.id})]},e.id))]}),(0,P.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,P.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,P.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⌁`}),(0,P.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,P.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,P.jsx)(`button`,{onClick:ne,children:`新建第一条记忆`})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,P.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:Vl[o.type].label})]}),(0,P.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,P.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,P.jsx)(`span`,{children:`i`}),(0,P.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,P.jsxs)(`div`,{className:`memory-form`,children:[(0,P.jsxs)(`fieldset`,{children:[(0,P.jsx)(`legend`,{children:`记忆类型`}),(0,P.jsx)(`div`,{className:`memory-type-options`,children:dl.map(e=>(0,P.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,P.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:Vl[e].label}),(0,P.jsx)(`small`,{children:Vl[e].hint})]})]},e))})]}),(0,P.jsxs)(`label`,{className:`memory-content-field`,children:[(0,P.jsxs)(`span`,{children:[`内容 `,(0,P.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,P.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,P.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,P.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,P.jsx)(`button`,{className:`memory-delete`,onClick:()=>b(!0),children:`删除记忆`}),c&&(0,P.jsx)(`button`,{onClick:()=>{l(!1),te()},children:`取消`}),(0,P.jsx)(`button`,{className:`memory-save`,disabled:!S||f||o.content.trim().length===0,onClick:()=>void ie(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,P.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,P.jsx)(`span`,{children:`⊘`}),(0,P.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,P.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),y&&i!==void 0&&(0,P.jsx)(`div`,{className:`memory-delete-layer`,children:(0,P.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,P.jsx)(`span`,{children:`!`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`删除长期记忆`}),(0,P.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,Vl[i.type].label,`?`]}),(0,P.jsx)(`small`,{children:i.content}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`button`,{onClick:()=>b(!1),children:`取消`}),(0,P.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ae(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var Gl={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function Kl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(Gl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``?n:n.filter(t=>t.name.toLowerCase().includes(e)||t.transport.includes(e))},[m,n]),b=async e=>{let t=await window.flavorDesktop.listMcpServers();r(t);let n=t.find(t=>t.name===e)??t.find(e=>e.name===i)??t[0];n===void 0?t.length===0&&a(void 0):(a(n.name),s(ql(n)))};(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listMcpServers().then(t=>{if(e)return;r(t);let n=t[0];n!==void 0&&(a(n.name),s(ql(n)))}).catch(n=>{e||t(eu(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(ql(e))},ee=()=>{l(!0),a(void 0),s(Gl)},S=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,Jl(o));l(!1),a(e.name),await b(e.name)}catch(e){t(eu(e))}finally{p(!1)}},C=async(e,n)=>{try{let t=await window.flavorDesktop.setMcpServerEnabled(e.name,n);r(e=>e.map(e=>e.name===t.name?t:e)),i===t.name&&s(ql(t))}catch(e){t(eu(e))}},te=async()=>{let e=g;if(e!==void 0){p(!0);try{await window.flavorDesktop.deleteMcpServer(e.name),v(void 0),l(!1),a(void 0),s(Gl),await b()}catch(e){t(eu(e))}finally{p(!1)}}},ne=n.find(e=>e.name===i);return(0,P.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,P.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,P.jsxs)(`div`,{className:`mcp-heading`,children:[(0,P.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,P.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,P.jsxs)(`div`,{className:`mcp-health`,children:[(0,P.jsx)(`i`,{}),`项目配置 `,(0,P.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,P.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,P.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,P.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`⌕`}),(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,P.jsxs)(`button`,{className:`mcp-create`,onClick:ee,children:[(0,P.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,P.jsx)(`div`,{className:`mcp-list`,children:u?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:`正在读取项目配置`}),(0,P.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,P.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,P.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,P.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,P.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,P.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,P.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{children:e.name}),(0,P.jsx)(`small`,{children:e.transport===`stdio`?Ql(e.config):$l(e.config)})]})]}),(0,P.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void C(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,P.jsx)(`span`,{})]})]},e.name))}),(0,P.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,P.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,P.jsx)(`article`,{className:`mcp-editor`,children:c||ne!==void 0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,P.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,P.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,P.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,P.jsx)(`span`,{children:`↻`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,P.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,P.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,P.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`服务名称 `,(0,P.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,P.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`传输方式`}),(0,P.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,P.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,P.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`span`,{children:`启动命令`}),(0,P.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsxs)(`span`,{children:[`参数 `,(0,P.jsx)(`small`,{children:`每行一个参数`})]}),(0,P.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
|
|
138
138
|
@modelcontextprotocol/server-filesystem
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light" />
|
|
7
7
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* http://localhost:* ws://127.0.0.1:* ws://localhost:*; frame-src http://127.0.0.1:* http://localhost:*" />
|
|
8
8
|
<title>Flavor Code</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-BCJjMvbX.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-CPxt3vFY.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/evolve/store.d.ts
CHANGED
|
@@ -41,9 +41,17 @@ export interface EvolveReflection extends EvolveReflectionInput {
|
|
|
41
41
|
at: string;
|
|
42
42
|
perTool: Record<string, ToolTrend>;
|
|
43
43
|
}
|
|
44
|
+
export interface EvolveRule {
|
|
45
|
+
id: string;
|
|
46
|
+
text: string;
|
|
47
|
+
addedAt: string;
|
|
48
|
+
/** Signal id that motivated this rule, when it came from a suggestion. */
|
|
49
|
+
sourceId?: string;
|
|
50
|
+
}
|
|
44
51
|
export interface EvolveStoreOptions {
|
|
45
52
|
workspace: string;
|
|
46
53
|
maxSignals?: number;
|
|
54
|
+
maxRules?: number;
|
|
47
55
|
}
|
|
48
56
|
/** Collapse whitespace and quoted values so equivalent messages coalesce. */
|
|
49
57
|
export declare function normalizeError(message: unknown): string;
|
|
@@ -58,7 +66,9 @@ export declare class EvolveStore {
|
|
|
58
66
|
readonly reflectionsFile: string;
|
|
59
67
|
readonly doneFile: string;
|
|
60
68
|
readonly verifiedFile: string;
|
|
69
|
+
readonly rulesFile: string;
|
|
61
70
|
readonly maxSignals: number;
|
|
71
|
+
readonly maxRules: number;
|
|
62
72
|
constructor(options: EvolveStoreOptions);
|
|
63
73
|
/**
|
|
64
74
|
* Record one failed tool call. Dedupes by (tool, errorCode, normalized error):
|
|
@@ -88,4 +98,20 @@ export declare class EvolveStore {
|
|
|
88
98
|
verifiedIds(): Promise<string[]>;
|
|
89
99
|
/** Mark a suggestion as verified so it is no longer proposed. */
|
|
90
100
|
markSuggestionVerified(id: string): Promise<void>;
|
|
101
|
+
/** Learned guardrail rules, oldest first. */
|
|
102
|
+
listRules(): Promise<EvolveRule[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Add one guardrail rule. Dedupes by fingerprint of the normalized text and
|
|
105
|
+
* keeps at most maxRules entries (oldest dropped first).
|
|
106
|
+
*/
|
|
107
|
+
addRule(input: {
|
|
108
|
+
text: string;
|
|
109
|
+
sourceId?: string;
|
|
110
|
+
}): Promise<{
|
|
111
|
+
added: boolean;
|
|
112
|
+
rule: EvolveRule;
|
|
113
|
+
}>;
|
|
114
|
+
removeRule(id: string): Promise<{
|
|
115
|
+
removed: boolean;
|
|
116
|
+
}>;
|
|
91
117
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ModelRegistry } from "../models/registry.js";
|
|
3
|
+
export interface GitInsightOptions {
|
|
4
|
+
registry: ModelRegistry;
|
|
5
|
+
/** Cheap model id provider; evaluated lazily so /model switches apply. */
|
|
6
|
+
modelId(): string;
|
|
7
|
+
}
|
|
8
|
+
export declare function suggestCommitMessage(options: GitInsightOptions, input: {
|
|
9
|
+
stat: string;
|
|
10
|
+
diff: string;
|
|
11
|
+
hint?: string;
|
|
12
|
+
}, signal: AbortSignal): Promise<string>;
|
|
13
|
+
/** Strip fences/quotes and any trailing commentary the model may add. */
|
|
14
|
+
export declare function cleanCommitMessage(raw: string): string;
|
|
15
|
+
export declare const ReviewFindingSchema: z.ZodObject<{
|
|
16
|
+
severity: z.ZodEnum<{
|
|
17
|
+
critical: "critical";
|
|
18
|
+
nit: "nit";
|
|
19
|
+
warning: "warning";
|
|
20
|
+
}>;
|
|
21
|
+
file: z.ZodString;
|
|
22
|
+
line: z.ZodString;
|
|
23
|
+
issue: z.ZodString;
|
|
24
|
+
suggestion: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export declare const ReviewReportSchema: z.ZodObject<{
|
|
27
|
+
summary: z.ZodString;
|
|
28
|
+
verdict: z.ZodEnum<{
|
|
29
|
+
"needs-work": "needs-work";
|
|
30
|
+
ship: "ship";
|
|
31
|
+
"ship-with-fixes": "ship-with-fixes";
|
|
32
|
+
}>;
|
|
33
|
+
findings: z.ZodArray<z.ZodObject<{
|
|
34
|
+
severity: z.ZodEnum<{
|
|
35
|
+
critical: "critical";
|
|
36
|
+
nit: "nit";
|
|
37
|
+
warning: "warning";
|
|
38
|
+
}>;
|
|
39
|
+
file: z.ZodString;
|
|
40
|
+
line: z.ZodString;
|
|
41
|
+
issue: z.ZodString;
|
|
42
|
+
suggestion: z.ZodString;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
export type ReviewReport = z.infer<typeof ReviewReportSchema>;
|
|
46
|
+
export declare function reviewDiff(options: GitInsightOptions, input: {
|
|
47
|
+
stat: string;
|
|
48
|
+
diff: string;
|
|
49
|
+
untracked: readonly string[];
|
|
50
|
+
focus?: string;
|
|
51
|
+
}, signal: AbortSignal): Promise<ReviewReport>;
|
|
52
|
+
export declare function formatReviewReport(report: ReviewReport): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface GitResult {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
stdout: string;
|
|
4
|
+
stderr: string;
|
|
5
|
+
code: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function git(workspace: string, args: readonly string[], timeoutMs?: number): Promise<GitResult>;
|
|
8
|
+
export declare function isGitRepository(workspace: string): Promise<boolean>;
|
|
9
|
+
export interface GitChangeSummary {
|
|
10
|
+
branch: string;
|
|
11
|
+
head: string;
|
|
12
|
+
/** porcelain v1 lines, e.g. `M src/a.ts`. */
|
|
13
|
+
statusLines: readonly string[];
|
|
14
|
+
stagedFiles: readonly string[];
|
|
15
|
+
unstagedFiles: readonly string[];
|
|
16
|
+
untrackedFiles: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/** Snapshot of the working tree used to drive /commit decisions. */
|
|
19
|
+
export declare function changeSummary(workspace: string): Promise<GitChangeSummary>;
|
|
20
|
+
/** The staged diff (capped) plus a short stat summary for model prompts. */
|
|
21
|
+
export declare function stagedDiff(workspace: string, maxChars?: number): Promise<{
|
|
22
|
+
diff: string;
|
|
23
|
+
stat: string;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
/** All uncommitted changes (staged + unstaged + untracked names) for review. */
|
|
27
|
+
export declare function uncommittedDiff(workspace: string, maxChars?: number): Promise<{
|
|
28
|
+
diff: string;
|
|
29
|
+
stat: string;
|
|
30
|
+
untracked: readonly string[];
|
|
31
|
+
}>;
|
|
32
|
+
export declare function stageAll(workspace: string): Promise<void>;
|
|
33
|
+
export declare function commit(workspace: string, commitMessage: string): Promise<string>;
|
|
34
|
+
export interface GitHistoryEntry {
|
|
35
|
+
hash: string;
|
|
36
|
+
date: string;
|
|
37
|
+
author: string;
|
|
38
|
+
subject: string;
|
|
39
|
+
}
|
|
40
|
+
/** Commit history for the repository, or for one file when a path is given. */
|
|
41
|
+
export declare function fileHistory(workspace: string, path: string | undefined, limit: number): Promise<GitHistoryEntry[]>;
|
|
42
|
+
/** Short branch@sha marker used to tag session checkpoints with git state. */
|
|
43
|
+
export declare function gitMarker(workspace: string): Promise<string | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolDefinition } from "../tools/types.js";
|
|
3
|
+
declare const GitHistoryInput: z.ZodObject<{
|
|
4
|
+
path: z.ZodOptional<z.ZodString>;
|
|
5
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type GitHistoryInput = z.infer<typeof GitHistoryInput>;
|
|
8
|
+
export declare function createGitHistoryTool(workspace: string): ToolDefinition<GitHistoryInput, string>;
|
|
9
|
+
export {};
|
package/dist/sdk/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FlavorRpcServer,
|
|
5
5
|
TraceRecordSchema,
|
|
6
6
|
TraceRecorder
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BKARQJQZ.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentMessageQueue,
|
|
10
10
|
DockerExecutionEnvironment,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
WorkspaceCheckpointStore,
|
|
14
14
|
buildDockerInvocation,
|
|
15
15
|
createProductionRuntime
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-5TG3E2EJ.js";
|
|
17
17
|
import "../chunk-IG4Z23CL.js";
|
|
18
18
|
import "../chunk-RQTYHUMK.js";
|
|
19
19
|
import "../chunk-S32JRDZK.js";
|
package/dist/session/store.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare const SessionDocumentSchema: z.ZodObject<{
|
|
|
35
35
|
dependencies: z.ZodArray<z.ZodString>;
|
|
36
36
|
expectedOutputs: z.ZodArray<z.ZodString>;
|
|
37
37
|
verification: z.ZodArray<z.ZodString>;
|
|
38
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
39
|
}, z.core.$strict>>;
|
|
39
40
|
}, z.core.$strict>>;
|
|
40
41
|
states: z.ZodRecord<z.ZodString, z.ZodEnum<{
|
package/dist/ui/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "evolve", "mcp", "ide", "memory", "remember", "forget", "forget-cold", "checkpoint", "tree", "rewind", "unrevert", "fork", "pals", "chat", "co-work"];
|
|
1
|
+
export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "evolve", "mcp", "commit", "review", "ide", "memory", "remember", "forget", "forget-cold", "checkpoint", "tree", "rewind", "unrevert", "fork", "pals", "chat", "co-work"];
|
|
2
2
|
export declare const COMMAND_DESCRIPTIONS: Record<(typeof MVP_COMMANDS)[number], string>;
|
|
3
3
|
export type PermissionCommandMode = PermissionMode;
|
|
4
4
|
export type ModelRole = "main" | "subagent";
|
|
@@ -63,6 +63,12 @@ export type SlashCommand = {
|
|
|
63
63
|
} | {
|
|
64
64
|
name: "goal";
|
|
65
65
|
goal: string;
|
|
66
|
+
} | {
|
|
67
|
+
name: "commit";
|
|
68
|
+
hint?: string;
|
|
69
|
+
} | {
|
|
70
|
+
name: "review";
|
|
71
|
+
focus?: string;
|
|
66
72
|
} | {
|
|
67
73
|
name: "remember";
|
|
68
74
|
type: MemoryType;
|
|
@@ -81,7 +87,7 @@ export type SlashCommand = {
|
|
|
81
87
|
target: string;
|
|
82
88
|
goal: string;
|
|
83
89
|
} | CoWorkSlashCommand | {
|
|
84
|
-
name: Exclude<(typeof MVP_COMMANDS)[number], "model" | "permissions" | "audit" | "loop" | "goal" | "evolve" | "mcp" | "remember" | "forget" | "checkpoint" | "rewind" | "fork" | "pals" | "chat" | "co-work">;
|
|
90
|
+
name: Exclude<(typeof MVP_COMMANDS)[number], "model" | "permissions" | "audit" | "loop" | "goal" | "evolve" | "commit" | "review" | "mcp" | "remember" | "forget" | "checkpoint" | "rewind" | "fork" | "pals" | "chat" | "co-work">;
|
|
85
91
|
} | {
|
|
86
92
|
name: "audit";
|
|
87
93
|
toolFilter?: string | undefined;
|
package/dist/ui/session.d.ts
CHANGED
|
@@ -129,6 +129,8 @@ export interface SessionServices {
|
|
|
129
129
|
tasks(): unknown;
|
|
130
130
|
audit(toolFilter?: string): string | Promise<string>;
|
|
131
131
|
evolve(args: readonly string[]): string | Promise<string>;
|
|
132
|
+
gitCommit?(hint: string | undefined, signal: AbortSignal): Promise<string>;
|
|
133
|
+
gitReview?(focus: string | undefined, signal: AbortSignal): Promise<string>;
|
|
132
134
|
usage(): string | Promise<string>;
|
|
133
135
|
cancelActiveTask(): void | Promise<void>;
|
|
134
136
|
clearContext(): void | Promise<void>;
|